|
@@ -1,33 +1,7 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<el-card class="box-card" v-loading="loading">
|
|
|
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
|
|
|
- <template #basicInformation>
|
|
|
- <div style="width: 100%">
|
|
|
- <el-row>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="事业部" prop="departmentId" style="width: 100%; margin-bottom: 18px">
|
|
|
- <el-select v-model="formData.data.departmentId" placeholder="请选择事业部" clearable style="width: 100%" @change="changeDepartment">
|
|
|
- <el-option v-for="item in departmentList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="出库类型" prop="detailType" style="width: 100%; margin-bottom: 18px">
|
|
|
- <el-select v-model="formData.data.detailType" placeholder="请选择出库类型" clearable style="width: 100%">
|
|
|
- <el-option v-for="item in useUserStore().allDict['come_stock_type']" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="申请人" prop="applicant" style="width: 100%; margin-bottom: 18px">
|
|
|
- <el-input v-model="formData.data.applicant" placeholder="请输入申请人" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="备注" prop="remark" style="width: 100%; margin-bottom: 18px">
|
|
|
- <el-input v-model="formData.data.remark" :rows="4" type="textarea" placeholder="请输入备注" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
+ <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" ref="submit">
|
|
|
<template #inOutStorageBomList>
|
|
|
<div style="width: 100%; padding: 0 20px">
|
|
|
<el-table :data="formData.data.inOutStorageBomList" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
|
|
@@ -53,35 +27,11 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="品号" prop="code" width="180" />
|
|
|
- <el-table-column label="品名" prop="name" min-width="220" />
|
|
|
- <el-table-column label="仓库" width="160">
|
|
|
- <template #default="{ row, $index }">
|
|
|
- <el-form-item :prop="'inOutStorageBomList.' + $index + '.warehouseId'" :rules="rules.warehouseId" :inline-message="true" style="width: 100%">
|
|
|
- <el-select
|
|
|
- v-model="row.warehouseId"
|
|
|
- placeholder="请选择仓库"
|
|
|
- clearable
|
|
|
- style="width: 100%"
|
|
|
- @change="
|
|
|
- (val) => {
|
|
|
- return changeWarehouse(val, row, $index);
|
|
|
- }
|
|
|
- ">
|
|
|
- <el-option v-for="item in warehouseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="剩余库存" prop="surplusStock" width="120" />
|
|
|
+ <el-table-column label="品号" prop="bomSpecCode" width="180" />
|
|
|
+ <el-table-column label="品名" prop="bomSpecName" min-width="220" />
|
|
|
<el-table-column label="出库数量" width="140">
|
|
|
<template #default="{ row }">
|
|
|
- <span :style="row.surplusStock && row.surplusStock > row.quantity ? '' : 'color: red'">{{ row.quantity }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="操作" align="center" fixed="right" width="80">
|
|
|
- <template #default="{ $index }">
|
|
|
- <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
|
|
|
+ <span>{{ row.quantity }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -105,7 +55,6 @@ const departmentList = ref([{ dictKey: "0", dictValue: "胜德体育" }]);
|
|
|
const props = defineProps({
|
|
|
selectData: Array,
|
|
|
});
|
|
|
-const warehouseList = ref([]);
|
|
|
const submit = ref(null);
|
|
|
const formOption = reactive({
|
|
|
inline: true,
|
|
@@ -116,9 +65,6 @@ const formOption = reactive({
|
|
|
});
|
|
|
const formData = reactive({
|
|
|
data: {
|
|
|
- departmentId: "0",
|
|
|
- type: 0,
|
|
|
- applicant: proxy.useUserStore().user.nickName,
|
|
|
inOutStorageBomList: [],
|
|
|
},
|
|
|
});
|
|
@@ -126,16 +72,6 @@ const formConfig = computed(() => {
|
|
|
return [
|
|
|
{
|
|
|
type: "title",
|
|
|
- title: "出库信息",
|
|
|
- label: "",
|
|
|
- },
|
|
|
- {
|
|
|
- type: "slot",
|
|
|
- slotName: "basicInformation",
|
|
|
- label: "",
|
|
|
- },
|
|
|
- {
|
|
|
- type: "title",
|
|
|
title: "物料信息",
|
|
|
label: "",
|
|
|
},
|
|
@@ -146,13 +82,6 @@ const formConfig = computed(() => {
|
|
|
},
|
|
|
];
|
|
|
});
|
|
|
-const rules = ref({
|
|
|
- departmentId: [{ required: true, message: "请选择事业部", trigger: "change" }],
|
|
|
- warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
|
|
|
- detailType: [{ required: true, message: "请选择出库类型", trigger: "change" }],
|
|
|
- applicant: [{ required: true, message: "请输入申请人", trigger: "blur" }],
|
|
|
- quantity: [{ required: true, message: "请输入出库数量", trigger: "blur" }],
|
|
|
-});
|
|
|
const getDemandData = () => {
|
|
|
proxy.post("/department/page", { pageNum: 1, pageSize: 999 }).then((res) => {
|
|
|
if (res.rows && res.rows.length > 0) {
|
|
@@ -168,38 +97,32 @@ const getDemandData = () => {
|
|
|
});
|
|
|
};
|
|
|
getDemandData();
|
|
|
-const clickDelete = (index) => {
|
|
|
- formData.data.inOutStorageBomList.splice(index, 1);
|
|
|
-};
|
|
|
const emit = defineEmits(["clickCancel"]);
|
|
|
const duplicateRemoval = (arr) => {
|
|
|
let list = [];
|
|
|
return arr.filter((item) => !list.includes(item) && list.push(item));
|
|
|
};
|
|
|
-const loading = ref(false)
|
|
|
+const loading = ref(false);
|
|
|
const submitForm = () => {
|
|
|
- submit.value.handleSubmit(async () => {
|
|
|
+ submit.value.handleSubmit(() => {
|
|
|
if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
|
|
|
- for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
|
|
|
- if (Number(formData.data.inOutStorageBomList[i].surplusStock) < Number(formData.data.inOutStorageBomList[i].quantity)) {
|
|
|
- return ElMessage("出库数量大于剩余库存数量");
|
|
|
+ loading.value = true;
|
|
|
+ let orderList = [];
|
|
|
+ for (let j = 0; j < formData.data.inOutStorageBomList.length; j++) {
|
|
|
+ if (formData.data.inOutStorageBomList[j].orderList && formData.data.inOutStorageBomList[j].orderList.length > 0) {
|
|
|
+ orderList = orderList.concat(formData.data.inOutStorageBomList[j].orderList.map((itemOrder) => itemOrder.orderSkuId));
|
|
|
}
|
|
|
}
|
|
|
- loading.value = true
|
|
|
- for (let i = 0; i < warehouseList.value.length; i++) {
|
|
|
- let data = proxy.deepClone(formData.data);
|
|
|
- data.inOutStorageBomList = data.inOutStorageBomList.filter((item) => item.warehouseId === warehouseList.value[i].dictKey);
|
|
|
- if (data.inOutStorageBomList && data.inOutStorageBomList.length > 0) {
|
|
|
- let orderList = [];
|
|
|
- for (let j = 0; j < data.inOutStorageBomList.length; j++) {
|
|
|
- orderList = orderList.concat(data.inOutStorageBomList[j].orderList.map((itemOrder) => itemOrder.orderSkuId));
|
|
|
- }
|
|
|
- const resTwo = await proxy.post("/stockPreparation/submit", duplicateRemoval(orderList));
|
|
|
+ proxy.post("/stockPreparation/submit", duplicateRemoval(orderList)).then(
|
|
|
+ () => {
|
|
|
+ ElMessage({ message: "提交完成", type: "success" });
|
|
|
+ emit("clickCancel", true);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log(err);
|
|
|
+ loading.value = false;
|
|
|
}
|
|
|
- }
|
|
|
- ElMessage({ message: "提交完成", type: "success" });
|
|
|
- loading.value = false
|
|
|
- emit("clickCancel", true);
|
|
|
+ );
|
|
|
} else {
|
|
|
return ElMessage("请添加BOM");
|
|
|
}
|
|
@@ -222,136 +145,59 @@ const delSomeObjValue = (arr, keyName, valueName) => {
|
|
|
}
|
|
|
return resultArr;
|
|
|
};
|
|
|
-const getWarehouse = () => {
|
|
|
- return proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
|
|
|
- if (res.rows && res.rows.length > 0) {
|
|
|
- warehouseList.value = res.rows
|
|
|
- .filter((item) => ["2", "3"].includes(item.type))
|
|
|
- .map((item) => {
|
|
|
- return {
|
|
|
- dictKey: item.id,
|
|
|
- dictValue: item.name,
|
|
|
- };
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
-};
|
|
|
onMounted(() => {
|
|
|
- Promise.all([getWarehouse()]).then(() => {
|
|
|
- if (props.selectData && props.selectData.length > 0) {
|
|
|
- formData.data.inOutStorageBomList = delSomeObjValue(
|
|
|
- props.selectData.map((item) => {
|
|
|
- let num = 0;
|
|
|
- if (item.quantity) {
|
|
|
- num = Number(item.quantity);
|
|
|
- }
|
|
|
- return {
|
|
|
- bomSpecId: item.bomSpecId,
|
|
|
- quantity: num,
|
|
|
- name: item.bomSpecName,
|
|
|
- code: item.bomSpecCode,
|
|
|
- warehouseId: "",
|
|
|
- surplusStock: 0,
|
|
|
- };
|
|
|
- }),
|
|
|
- "bomSpecId",
|
|
|
- "quantity"
|
|
|
- ).map((item) => {
|
|
|
+ if (props.selectData && props.selectData.length > 0) {
|
|
|
+ formData.data.inOutStorageBomList = delSomeObjValue(
|
|
|
+ props.selectData.map((item) => {
|
|
|
+ let num = 0;
|
|
|
+ if (item.quantity) {
|
|
|
+ num = Number(item.quantity);
|
|
|
+ }
|
|
|
return {
|
|
|
- ...item,
|
|
|
- orderList: props.selectData
|
|
|
- .map((item) => {
|
|
|
- let num = 0;
|
|
|
- if (item.quantity) {
|
|
|
- num = Number(item.quantity);
|
|
|
- }
|
|
|
- return {
|
|
|
- bomSpecId: item.bomSpecId,
|
|
|
- quantity: num,
|
|
|
- orderSkuId: item.orderSkuId,
|
|
|
- orderCode: item.orderCode,
|
|
|
- orderWlnCode: item.orderWlnCode,
|
|
|
- skuSpecCode: item.skuSpecCode,
|
|
|
- skuSpecName: item.skuSpecName,
|
|
|
- };
|
|
|
- })
|
|
|
- .filter((itemSelect) => itemSelect.bomSpecId === item.bomSpecId),
|
|
|
+ bomSpecId: item.bomSpecId,
|
|
|
+ quantity: num,
|
|
|
+ bomSpecName: item.bomSpecName,
|
|
|
+ bomSpecCode: item.bomSpecCode,
|
|
|
+ warehouseId: "",
|
|
|
+ surplusStock: 0,
|
|
|
};
|
|
|
- });
|
|
|
- if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
|
|
|
- let bomSpecIdList = [];
|
|
|
- bomSpecIdList = formData.data.inOutStorageBomList.map((item) => item.bomSpecId);
|
|
|
- proxy
|
|
|
- .post("/inventory/getQuantity", {
|
|
|
- departmentId: formData.data.departmentId,
|
|
|
- warehouseId: warehouseList.value[0].dictKey,
|
|
|
- bomSpecIdList: bomSpecIdList,
|
|
|
- })
|
|
|
- .then((resInventory) => {
|
|
|
- let bomSpecIdTwoList = [];
|
|
|
- for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
|
|
|
- if (resInventory[formData.data.inOutStorageBomList[i].bomSpecId]) {
|
|
|
- formData.data.inOutStorageBomList[i].warehouseId = warehouseList.value[0].dictKey;
|
|
|
- formData.data.inOutStorageBomList[i].surplusStock = resInventory[formData.data.inOutStorageBomList[i].bomSpecId];
|
|
|
- } else {
|
|
|
- bomSpecIdTwoList.push(formData.data.inOutStorageBomList[i].bomSpecId);
|
|
|
- }
|
|
|
- }
|
|
|
- if (bomSpecIdTwoList && bomSpecIdTwoList.length > 0) {
|
|
|
- proxy
|
|
|
- .post("/inventory/getQuantity", {
|
|
|
- departmentId: formData.data.departmentId,
|
|
|
- warehouseId: warehouseList.value[1].dictKey,
|
|
|
- bomSpecIdList: bomSpecIdTwoList,
|
|
|
- })
|
|
|
- .then((inventoryTwo) => {
|
|
|
- for (let i = 0; i < formData.data.inOutStorageBomList.length; i++) {
|
|
|
- if (inventoryTwo[formData.data.inOutStorageBomList[i].bomSpecId]) {
|
|
|
- formData.data.inOutStorageBomList[i].warehouseId = warehouseList.value[0].dictKey;
|
|
|
- formData.data.inOutStorageBomList[i].surplusStock = inventoryTwo[formData.data.inOutStorageBomList[i].bomSpecId];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-});
|
|
|
-const changeWarehouse = (val, item, index) => {
|
|
|
- if (val) {
|
|
|
- if (formData.data.departmentId) {
|
|
|
- proxy
|
|
|
- .post("/inventory/getQuantity", {
|
|
|
- departmentId: formData.data.departmentId,
|
|
|
- warehouseId: val,
|
|
|
- bomSpecIdList: [item.bomSpecId],
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- if (res[item.bomSpecId]) {
|
|
|
- formData.data.inOutStorageBomList[index].surplusStock = res[item.bomSpecId];
|
|
|
- } else {
|
|
|
- formData.data.inOutStorageBomList[index].surplusStock = 0;
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- return ElMessage("请先选择事业部");
|
|
|
- }
|
|
|
- } else {
|
|
|
- formData.data.inOutStorageBomList[index].surplusStock = 0;
|
|
|
- }
|
|
|
-};
|
|
|
-const changeDepartment = () => {
|
|
|
- if (formData.data.inOutStorageBomList && formData.data.inOutStorageBomList.length > 0) {
|
|
|
- formData.data.inOutStorageBomList = formData.data.inOutStorageBomList.map((item) => {
|
|
|
+ }),
|
|
|
+ "bomSpecId",
|
|
|
+ "quantity"
|
|
|
+ ).map((item) => {
|
|
|
return {
|
|
|
...item,
|
|
|
- warehouseId: "",
|
|
|
- surplusStock: 0,
|
|
|
+ orderList: props.selectData
|
|
|
+ .map((item) => {
|
|
|
+ let num = 0;
|
|
|
+ if (item.quantity) {
|
|
|
+ num = Number(item.quantity);
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ bomSpecId: item.bomSpecId,
|
|
|
+ quantity: num,
|
|
|
+ orderSkuId: item.orderSkuId,
|
|
|
+ orderCode: item.orderCode,
|
|
|
+ orderWlnCode: item.orderWlnCode,
|
|
|
+ skuSpecCode: item.skuSpecCode,
|
|
|
+ skuSpecName: item.skuSpecName,
|
|
|
+ };
|
|
|
+ })
|
|
|
+ .filter((itemSelect) => itemSelect.bomSpecId === item.bomSpecId),
|
|
|
};
|
|
|
});
|
|
|
+ let orderList = [];
|
|
|
+ for (let j = 0; j < formData.data.inOutStorageBomList.length; j++) {
|
|
|
+ if (formData.data.inOutStorageBomList[j].orderList && formData.data.inOutStorageBomList[j].orderList.length > 0) {
|
|
|
+ orderList = orderList.concat(formData.data.inOutStorageBomList[j].orderList.map((itemOrder) => itemOrder.orderSkuId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ proxy.post("/stockPreparation/getPackageBomList", orderList).then((res) => {
|
|
|
+ console.log(res, "1111111111111111");
|
|
|
+ formData.data.inOutStorageBomList = formData.data.inOutStorageBomList.concat(res);
|
|
|
+ });
|
|
|
}
|
|
|
-};
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|