|
|
@@ -72,7 +72,7 @@
|
|
|
</el-row>
|
|
|
|
|
|
<el-row :gutter="24">
|
|
|
- <!-- <el-col :span="6">
|
|
|
+ <el-col :span="6" v-if="isSaleOrder">
|
|
|
<el-form-item label="销售订单号:" prop="saleOrder">
|
|
|
<div class="sale-order-select">
|
|
|
<el-input
|
|
|
@@ -92,7 +92,7 @@
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
- </el-col> -->
|
|
|
+ </el-col>
|
|
|
|
|
|
<el-col :span="6">
|
|
|
<el-form-item
|
|
|
@@ -511,7 +511,7 @@
|
|
|
<script>
|
|
|
import { findBomCategoryByCategoryId } from '@/api/productionPlan/index';
|
|
|
import EquipmentDialog from '@/views/saleOrder/components/EquipmentDialog';
|
|
|
- import saleOrderPop from '@/views/materialPlan/components/saleOrderPop.vue';
|
|
|
+ import saleOrderPop from './components/saleOrderPop.vue';
|
|
|
import { getCode } from '@/api/codeManagement';
|
|
|
import ProcessRoute from '@/components/selectionDialog/processRoute.vue';
|
|
|
import { parameterGetByCode } from '@/api/mainData/index';
|
|
|
@@ -899,7 +899,8 @@
|
|
|
],
|
|
|
selectIndex: 0, // 选择工艺路线的当前数据下标
|
|
|
processingRequired: 0, // 生产类型跟BOM 版本是否必填 1:是 0:否
|
|
|
- isReview: false
|
|
|
+ isReview: false,
|
|
|
+ isSaleOrder: false
|
|
|
// selectionRowShow: false // 工艺路线输入框展示 状态
|
|
|
};
|
|
|
},
|
|
|
@@ -909,18 +910,7 @@
|
|
|
// return this.$store.state.user.info.clientEnvironmentId;
|
|
|
// }
|
|
|
// },
|
|
|
- mounted() {
|
|
|
- this.getCodeData();
|
|
|
- // 生产类型跟BOM版本字段是否必填
|
|
|
- parameterGetByCode({
|
|
|
- code: 'production_plan_code'
|
|
|
- }).then((res) => {
|
|
|
- console.log(res, 'res 1');
|
|
|
- if (res) {
|
|
|
- this.processingRequired = res.value;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ mounted() {},
|
|
|
methods: {
|
|
|
// 获取
|
|
|
async getCodeData() {
|
|
|
@@ -983,138 +973,110 @@
|
|
|
this.factoryList = await getFactoryList();
|
|
|
},
|
|
|
async open(val) {
|
|
|
- await this.getFactoryList();
|
|
|
- await this.getPlannedReleaseRequire('planned_release_require');
|
|
|
+ const [processingRes, saleOrderRes] = await Promise.all([
|
|
|
+ parameterGetByCode({ code: 'production_plan_code' }),
|
|
|
+ parameterGetByCode({ code: 'create_plan_binding_sale_order' }),
|
|
|
+ this.getCodeData(),
|
|
|
+ this.getFactoryList(),
|
|
|
+ this.getPlannedReleaseRequire('planned_release_require')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if (processingRes) {
|
|
|
+ this.processingRequired = processingRes.value;
|
|
|
+ }
|
|
|
+ this.isSaleOrder = saleOrderRes?.value === '1';
|
|
|
this.clientEnvironmentId =
|
|
|
this.$store.state.user.info.clientEnvironmentId;
|
|
|
this.factoriesId = this.$store.state.user.info.factoryId;
|
|
|
|
|
|
- if (val) {
|
|
|
- if (val.planType == null || val.planType == 'null') {
|
|
|
- val.planType = '';
|
|
|
- }
|
|
|
- this.title = !val.id ? '新增临时生产计划' : '编辑临时生产计划';
|
|
|
- val.planType = String(val.planType);
|
|
|
- this.form = await getUpdateInfoByCode(val.code);
|
|
|
- // 修改
|
|
|
- if (val.id) {
|
|
|
- if (
|
|
|
- Array.isArray(val.productInfoList) &&
|
|
|
- val.productInfoList.length
|
|
|
- ) {
|
|
|
- this.form.productInfoList.map(async (v, index) => {
|
|
|
- if (!v.bomCategoryId) {
|
|
|
- v.productType = '';
|
|
|
- v.selectionRowShow = true;
|
|
|
- } else {
|
|
|
- v.selectionRowShow = false;
|
|
|
- }
|
|
|
- if (v.productType) {
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'bomVersionList',
|
|
|
- await this.bomListVersionFn(v.productType, v.categoryId)
|
|
|
- );
|
|
|
- }
|
|
|
- if (v.bomCategoryId) {
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'routingList',
|
|
|
- await this.changeBomIdFn(
|
|
|
- v.bomCategoryId,
|
|
|
- this.form.productInfoList[index]
|
|
|
- )
|
|
|
- );
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // let categoryId = this.form.productInfoList[0].categoryId;
|
|
|
- // const res = await findBomCategoryByCategoryId(categoryId);
|
|
|
- let promiseAll = [];
|
|
|
- this.form.productInfoList.forEach(async (item) => {
|
|
|
- let categoryId = item.categoryId;
|
|
|
- promiseAll.push(findBomCategoryByCategoryId(categoryId));
|
|
|
- });
|
|
|
- const resAll = await Promise.all(promiseAll);
|
|
|
- console.log(this.form.productInfoList);
|
|
|
+ if (!val) {
|
|
|
+ this.title = '新增临时生产计划';
|
|
|
+ this.visible = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- this.form.productInfoList.forEach((item, index) => {
|
|
|
- if (item.colorKey && typeof item.colorKey == 'string') {
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'colorKey',
|
|
|
- item.colorKey.split(',')
|
|
|
- );
|
|
|
+ if (val.planType == null || val.planType === 'null') {
|
|
|
+ val.planType = '';
|
|
|
+ }
|
|
|
+ this.title = val.id ? '编辑临时生产计划' : '新增临时生产计划';
|
|
|
+ val.planType = String(val.planType);
|
|
|
+ this.form = await getUpdateInfoByCode(val.code);
|
|
|
+
|
|
|
+ if (this.isSaleOrder) {
|
|
|
+ const salesCode = this.form.salesCode;
|
|
|
+ this.$set(
|
|
|
+ this.form,
|
|
|
+ 'saleOrder',
|
|
|
+ Array.isArray(salesCode) ? salesCode.join(',') : salesCode || ''
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if (val.id) {
|
|
|
+ await this.initEditProductList(val);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$forceUpdate();
|
|
|
+ this.visible = true;
|
|
|
+ },
|
|
|
+
|
|
|
+ async initEditProductList(val) {
|
|
|
+ const productList = this.form.productInfoList;
|
|
|
+
|
|
|
+ if (Array.isArray(val.productInfoList) && val.productInfoList.length) {
|
|
|
+ await Promise.all(
|
|
|
+ productList.map(async (v, index) => {
|
|
|
+ v.selectionRowShow = !v.bomCategoryId;
|
|
|
+ if (!v.bomCategoryId) {
|
|
|
+ v.productType = '';
|
|
|
}
|
|
|
- if (item.modelKey && typeof item.modelKey == 'string') {
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'modelKey',
|
|
|
- item.modelKey.split(',')
|
|
|
+ if (v.productType) {
|
|
|
+ this.$set(productList[index], 'bomVersionList',
|
|
|
+ await this.bomListVersionFn(v.productType, v.categoryId)
|
|
|
);
|
|
|
}
|
|
|
- if (resAll[index]) {
|
|
|
- let list = [];
|
|
|
- let listMap = {};
|
|
|
-
|
|
|
- resAll[index].map((el) => {
|
|
|
- if (el.bomType == '2' || el.bomType == '3') {
|
|
|
- console.log(listMap, 'listMap');
|
|
|
- if (listMap[el.bomType]) {
|
|
|
- listMap[el.bomType].push(el);
|
|
|
- } else {
|
|
|
- listMap[el.bomType] = [el];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- if (listMap[2]) {
|
|
|
- list.push({ code: 2, name: 'MBOM' });
|
|
|
- }
|
|
|
- if (listMap[3]) {
|
|
|
- list.push({ code: 3, name: 'ABOM' });
|
|
|
- }
|
|
|
-
|
|
|
- if (!item.factoriesId) {
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'factoriesId',
|
|
|
- this.factoriesId
|
|
|
- );
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'factoriesName',
|
|
|
- this.factoryList?.find(
|
|
|
- (factoryData) => factoryData.id === this.factoriesId
|
|
|
- )?.name
|
|
|
- );
|
|
|
- }
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'producedList',
|
|
|
- list
|
|
|
+ if (v.bomCategoryId) {
|
|
|
+ this.$set(productList[index], 'routingList',
|
|
|
+ await this.changeBomIdFn(v.bomCategoryId, productList[index])
|
|
|
);
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
- this.$forceUpdate();
|
|
|
- } else {
|
|
|
- this.title = '新增临时生产计划';
|
|
|
+ })
|
|
|
+ );
|
|
|
}
|
|
|
- this.visible = true;
|
|
|
|
|
|
- // this.$nextTick(async () => {
|
|
|
- // console.log(val.productInfoList);
|
|
|
- // this.$set(this.form, 'productInfoList', val.productInfoList);
|
|
|
- // this.$set(this.form, 'routingList', val.routingList);
|
|
|
+ const resAll = await Promise.all(
|
|
|
+ productList.map((item) => findBomCategoryByCategoryId(item.categoryId))
|
|
|
+ );
|
|
|
+
|
|
|
+ productList.forEach((item, index) => {
|
|
|
+ if (typeof item.colorKey === 'string' && item.colorKey) {
|
|
|
+ this.$set(productList[index], 'colorKey', item.colorKey.split(','));
|
|
|
+ }
|
|
|
+ if (typeof item.modelKey === 'string' && item.modelKey) {
|
|
|
+ this.$set(productList[index], 'modelKey', item.modelKey.split(','));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!resAll[index]) return;
|
|
|
|
|
|
- // });
|
|
|
+ const listMap = {};
|
|
|
+ resAll[index].forEach((el) => {
|
|
|
+ if (el.bomType === '2' || el.bomType === '3') {
|
|
|
+ if (!listMap[el.bomType]) listMap[el.bomType] = [];
|
|
|
+ listMap[el.bomType].push(el);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- //this.clientEnvironmentId 环境判断 宝悦环境
|
|
|
- // if (this.clientEnvironmentId == 4) {
|
|
|
- // this.getPlanRoutingNew();
|
|
|
- // }
|
|
|
+ const list = [];
|
|
|
+ if (listMap[2]) list.push({ code: 2, name: 'MBOM' });
|
|
|
+ if (listMap[3]) list.push({ code: 3, name: 'ABOM' });
|
|
|
|
|
|
- // this.getPlanRoutingNew();
|
|
|
+ if (!item.factoriesId) {
|
|
|
+ this.$set(productList[index], 'factoriesId', this.factoriesId);
|
|
|
+ this.$set(productList[index], 'factoriesName',
|
|
|
+ this.factoryList?.find((f) => f.id === this.factoriesId)?.name
|
|
|
+ );
|
|
|
+ }
|
|
|
+ this.$set(productList[index], 'producedList', list);
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
addEquipment() {
|
|
|
@@ -1380,7 +1342,7 @@
|
|
|
},
|
|
|
chooseSaleOrder(list) {
|
|
|
const currentRow = list[0] || {};
|
|
|
- this.$set(this.form, 'saleOrder', currentRow.code || '');
|
|
|
+ this.$set(this.form, 'saleOrder', currentRow.orderNo || '');
|
|
|
},
|
|
|
// 清空BOM 跟工艺路线
|
|
|
wipeData(index) {
|
|
|
@@ -1476,75 +1438,113 @@
|
|
|
});
|
|
|
return flag;
|
|
|
},
|
|
|
+
|
|
|
save(type) {
|
|
|
this.$refs.form.validate(async (valid) => {
|
|
|
- if (!valid) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- let flag = this.parameterVerification();
|
|
|
- // 必填参数校验
|
|
|
- if (!flag) return;
|
|
|
-
|
|
|
- this.form.productInfoList.forEach((item, index) => {
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'colorKey',
|
|
|
- item.colorKey.toString()
|
|
|
- );
|
|
|
- this.$set(
|
|
|
- this.form.productInfoList[index],
|
|
|
- 'modelKey',
|
|
|
- item.modelKey.toString()
|
|
|
- );
|
|
|
- });
|
|
|
+ if (!valid) return;
|
|
|
+ if (!this.parameterVerification()) return;
|
|
|
|
|
|
- // this.
|
|
|
- if (!this.form.id) {
|
|
|
- if (this.form.productInfoList.length) {
|
|
|
- this.form.productInfoList.map((item, index) => {
|
|
|
- delete item.selectionRowShow;
|
|
|
- // if (item.bomVersionList && item.bomVersionList.length) {
|
|
|
- // item.bomCategoryName = item.bomVersionList[0].name;
|
|
|
- // item.bomCategoryVersions = item.bomVersionList[0].versions;
|
|
|
- // item.produceRoutingName = item.routingList[0].name;
|
|
|
- // }
|
|
|
- });
|
|
|
- }
|
|
|
+ const isAdd = !this.form.id;
|
|
|
+
|
|
|
+ this.form.productInfoList.forEach((item) => {
|
|
|
+ item.colorKey = item.colorKey.toString();
|
|
|
+ item.modelKey = item.modelKey.toString();
|
|
|
+ if (isAdd) delete item.selectionRowShow;
|
|
|
+ });
|
|
|
|
|
|
+ if (isAdd) {
|
|
|
this.form.timeDimensionPlanType = this.type;
|
|
|
- // await this.getPlanCode();
|
|
|
- this.loading = true;
|
|
|
-
|
|
|
- let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
|
|
|
- api(this.form)
|
|
|
- .then((res) => {
|
|
|
- this.$message.success('新增成功!');
|
|
|
- this.visible = false;
|
|
|
- this.initForm();
|
|
|
- this.$emit('close', true);
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- this.loading = false;
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.loading = true;
|
|
|
- let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
|
|
|
-
|
|
|
- console.log(type, this.isReview, this.form, '请求数据');
|
|
|
-
|
|
|
- api(this.form)
|
|
|
- .then((res) => {
|
|
|
- this.$message.success('修改成功!');
|
|
|
- this.visible = false;
|
|
|
- this.initForm();
|
|
|
- this.$emit('close', true);
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- this.loading = false;
|
|
|
- });
|
|
|
}
|
|
|
+ if (this.isSaleOrder) {
|
|
|
+ this.form.salesCode = this.form.saleOrder.split(',');
|
|
|
+ }
|
|
|
+
|
|
|
+ this.loading = true;
|
|
|
+ const api = type === 'sub' ? saveAndRelease : temporaryPlanSave;
|
|
|
+ api(this.form)
|
|
|
+ .then(() => {
|
|
|
+ this.$message.success(isAdd ? '新增成功!' : '修改成功!');
|
|
|
+ this.visible = false;
|
|
|
+ this.initForm();
|
|
|
+ this.$emit('close', true);
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
+ // save(type) {
|
|
|
+ // this.$refs.form.validate(async (valid) => {
|
|
|
+ // if (!valid) {
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // let flag = this.parameterVerification();
|
|
|
+ // // 必填参数校验
|
|
|
+ // if (!flag) return;
|
|
|
+
|
|
|
+ // this.form.productInfoList.forEach((item, index) => {
|
|
|
+ // this.$set(
|
|
|
+ // this.form.productInfoList[index],
|
|
|
+ // 'colorKey',
|
|
|
+ // item.colorKey.toString()
|
|
|
+ // );
|
|
|
+ // this.$set(
|
|
|
+ // this.form.productInfoList[index],
|
|
|
+ // 'modelKey',
|
|
|
+ // item.modelKey.toString()
|
|
|
+ // );
|
|
|
+ // });
|
|
|
+
|
|
|
+ // // this.
|
|
|
+ // if (!this.form.id) {
|
|
|
+ // if (this.form.productInfoList.length) {
|
|
|
+ // this.form.productInfoList.map((item, index) => {
|
|
|
+ // delete item.selectionRowShow;
|
|
|
+ // // if (item.bomVersionList && item.bomVersionList.length) {
|
|
|
+ // // item.bomCategoryName = item.bomVersionList[0].name;
|
|
|
+ // // item.bomCategoryVersions = item.bomVersionList[0].versions;
|
|
|
+ // // item.produceRoutingName = item.routingList[0].name;
|
|
|
+ // // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // this.form.timeDimensionPlanType = this.type;
|
|
|
+ // if (this.isSaleOrder) {
|
|
|
+ // this.form.saleOrder = this.form.saleOrder.split(',');
|
|
|
+ // }
|
|
|
+ // this.loading = true;
|
|
|
+
|
|
|
+ // let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
|
|
|
+ // api(this.form)
|
|
|
+ // .then((res) => {
|
|
|
+ // this.$message.success('新增成功!');
|
|
|
+ // this.visible = false;
|
|
|
+ // this.initForm();
|
|
|
+ // this.$emit('close', true);
|
|
|
+ // })
|
|
|
+ // .finally(() => {
|
|
|
+ // this.loading = false;
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // this.loading = true;
|
|
|
+ // let api = type == 'sub' ? saveAndRelease : temporaryPlanSave;
|
|
|
+ // if (this.isSaleOrder) {
|
|
|
+ // this.form.saleOrder = this.form.saleOrder.split(',');
|
|
|
+ // }
|
|
|
+
|
|
|
+ // api(this.form)
|
|
|
+ // .then((res) => {
|
|
|
+ // this.$message.success('修改成功!');
|
|
|
+ // this.visible = false;
|
|
|
+ // this.initForm();
|
|
|
+ // this.$emit('close', true);
|
|
|
+ // })
|
|
|
+ // .finally(() => {
|
|
|
+ // this.loading = false;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
bomListVersionFn(produceType, categoryId) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
let param = {
|