|
@@ -415,16 +415,15 @@
|
|
|
<el-select
|
|
<el-select
|
|
|
clearable
|
|
clearable
|
|
|
v-model="scope.row.modelKey"
|
|
v-model="scope.row.modelKey"
|
|
|
- multiple
|
|
|
|
|
filterable
|
|
filterable
|
|
|
allow-create
|
|
allow-create
|
|
|
default-first-option
|
|
default-first-option
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
- v-for="item in modelList"
|
|
|
|
|
- :key="item.label"
|
|
|
|
|
- :value="item.label"
|
|
|
|
|
- :label="item.label"
|
|
|
|
|
|
|
+ v-for="item in scope.row.modelList"
|
|
|
|
|
+ :key="item"
|
|
|
|
|
+ :value="item"
|
|
|
|
|
+ :label="item"
|
|
|
>
|
|
>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
@@ -440,16 +439,15 @@
|
|
|
<el-select
|
|
<el-select
|
|
|
clearable
|
|
clearable
|
|
|
v-model="scope.row.colorKey"
|
|
v-model="scope.row.colorKey"
|
|
|
- multiple
|
|
|
|
|
filterable
|
|
filterable
|
|
|
allow-create
|
|
allow-create
|
|
|
default-first-option
|
|
default-first-option
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
- v-for="item in colorList"
|
|
|
|
|
- :key="item.label"
|
|
|
|
|
- :value="item.label"
|
|
|
|
|
- :label="item.label"
|
|
|
|
|
|
|
+ v-for="item in scope.row.colorList"
|
|
|
|
|
+ :key="item"
|
|
|
|
|
+ :value="item"
|
|
|
|
|
+ :label="item"
|
|
|
>
|
|
>
|
|
|
</el-option>
|
|
</el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
@@ -878,7 +876,8 @@
|
|
|
bomRoutingList,
|
|
bomRoutingList,
|
|
|
bomListByPlan,
|
|
bomListByPlan,
|
|
|
getFactoryList,
|
|
getFactoryList,
|
|
|
- getInventoryTotalAPI
|
|
|
|
|
|
|
+ getInventoryTotalAPI,
|
|
|
|
|
+ getColorModelInfoById
|
|
|
} from '@/api/saleOrder';
|
|
} from '@/api/saleOrder';
|
|
|
import {
|
|
import {
|
|
|
findBomCategoryByCategoryId,
|
|
findBomCategoryByCategoryId,
|
|
@@ -1019,7 +1018,7 @@
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.mandatoryField();
|
|
this.mandatoryField();
|
|
|
- this.getCodeData();
|
|
|
|
|
|
|
+ // this.getCodeData();
|
|
|
this.getplannedReleaseRequire('planned_release_require');
|
|
this.getplannedReleaseRequire('planned_release_require');
|
|
|
parameterGetByCode({ code: 'salesToProduction_batchNo' }).then((res) => {
|
|
parameterGetByCode({ code: 'salesToProduction_batchNo' }).then((res) => {
|
|
|
if (res) {
|
|
if (res) {
|
|
@@ -1070,6 +1069,51 @@
|
|
|
this.modelList = arr1;
|
|
this.modelList = arr1;
|
|
|
this.colorList = arr2;
|
|
this.colorList = arr2;
|
|
|
},
|
|
},
|
|
|
|
|
+ // 根据 categoryId 给每一行填充机型/颜色可选项
|
|
|
|
|
+ async fillColorModelInfo(item) {
|
|
|
|
|
+ let info = {};
|
|
|
|
|
+ try {
|
|
|
|
|
+ info = (await getColorModelInfoById(item.categoryId)) || {};
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ info = {};
|
|
|
|
|
+ }
|
|
|
|
|
+ const colorKey = info.colorKey || '';
|
|
|
|
|
+ const modelKey = info.modelKey || '';
|
|
|
|
|
+ const baseColorList = colorKey ? colorKey.split(',') : [];
|
|
|
|
|
+ const baseModelList = modelKey ? modelKey.split(',') : [];
|
|
|
|
|
+
|
|
|
|
|
+ let curColor = item.colorKey;
|
|
|
|
|
+ if (Array.isArray(curColor)) {
|
|
|
|
|
+ curColor = curColor[0] || '';
|
|
|
|
|
+ } else if (typeof curColor !== 'string') {
|
|
|
|
|
+ curColor = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!curColor && baseColorList.length) {
|
|
|
|
|
+ curColor = baseColorList[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ let curModel = item.modelKey;
|
|
|
|
|
+ if (Array.isArray(curModel)) {
|
|
|
|
|
+ curModel = curModel[0] || '';
|
|
|
|
|
+ } else if (typeof curModel !== 'string') {
|
|
|
|
|
+ curModel = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!curModel && baseModelList.length) {
|
|
|
|
|
+ curModel = baseModelList[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const mergedColorList = Array.from(
|
|
|
|
|
+ new Set([...baseColorList, curColor].filter((v) => v !== '' && v != null))
|
|
|
|
|
+ );
|
|
|
|
|
+ const mergedModelList = Array.from(
|
|
|
|
|
+ new Set([...baseModelList, curModel].filter((v) => v !== '' && v != null))
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ this.$set(item, 'colorList', mergedColorList);
|
|
|
|
|
+ this.$set(item, 'modelList', mergedModelList);
|
|
|
|
|
+ this.$set(item, 'colorKey', curColor);
|
|
|
|
|
+ this.$set(item, 'modelKey', curModel);
|
|
|
|
|
+ return item;
|
|
|
|
|
+ },
|
|
|
async getLevelCode(code) {
|
|
async getLevelCode(code) {
|
|
|
try {
|
|
try {
|
|
|
const res = await getByCode(code);
|
|
const res = await getByCode(code);
|
|
@@ -1109,6 +1153,7 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const producedList = JSON.parse(this.$route.query.producedList);
|
|
const producedList = JSON.parse(this.$route.query.producedList);
|
|
|
|
|
+ console.log(producedList, 'producedList');
|
|
|
this.producedList = producedList;
|
|
this.producedList = producedList;
|
|
|
},
|
|
},
|
|
|
// 初始化时间赋值
|
|
// 初始化时间赋值
|
|
@@ -1172,6 +1217,12 @@
|
|
|
}
|
|
}
|
|
|
if (data.salesOrders && data.salesOrders.length > 0) {
|
|
if (data.salesOrders && data.salesOrders.length > 0) {
|
|
|
this.form.factoriesId = data.salesOrders[0].factoriesId;
|
|
this.form.factoriesId = data.salesOrders[0].factoriesId;
|
|
|
|
|
+ await Promise.all(
|
|
|
|
|
+ this.form.salesOrders.map(async (item, index) => {
|
|
|
|
|
+ await this.fillColorModelInfo(item);
|
|
|
|
|
+ this.$set(this.form.salesOrders, index, item);
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
// this.form.factoriesId = data.salesOrders
|
|
// this.form.factoriesId = data.salesOrders
|
|
|
// ? data.salesOrders[0].factoriesId
|
|
// ? data.salesOrders[0].factoriesId
|
|
@@ -1322,7 +1373,24 @@
|
|
|
|
|
|
|
|
getSaleInfo() {
|
|
getSaleInfo() {
|
|
|
let params = JSON.parse(this.$route.query.selection);
|
|
let params = JSON.parse(this.$route.query.selection);
|
|
|
- productionToPlan(params).then((res) => {
|
|
|
|
|
|
|
+ productionToPlan(params).then(async (res) => {
|
|
|
|
|
+ // 先初始化每行的下拉可选列表,保证 el-select 初次渲染就能显示已选项
|
|
|
|
|
+ if (Array.isArray(res?.salesOrders)) {
|
|
|
|
|
+ res.salesOrders.forEach((item) => {
|
|
|
|
|
+ if (Array.isArray(item.colorKey)) {
|
|
|
|
|
+ item.colorKey = item.colorKey[0] || '';
|
|
|
|
|
+ } else if (typeof item.colorKey !== 'string') {
|
|
|
|
|
+ item.colorKey = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Array.isArray(item.modelKey)) {
|
|
|
|
|
+ item.modelKey = item.modelKey[0] || '';
|
|
|
|
|
+ } else if (typeof item.modelKey !== 'string') {
|
|
|
|
|
+ item.modelKey = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ item.colorList = item.colorKey ? [item.colorKey] : [];
|
|
|
|
|
+ item.modelList = item.modelKey ? [item.modelKey] : [];
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
this.form = deepClone(res);
|
|
this.form = deepClone(res);
|
|
|
console.log(222222222222222222222222, '===', res);
|
|
console.log(222222222222222222222222, '===', res);
|
|
|
this.initTime();
|
|
this.initTime();
|
|
@@ -1369,35 +1437,66 @@
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- this.form.salesOrders.map((item, index) => {
|
|
|
|
|
- if (this.clientEnvironmentId == '4') {
|
|
|
|
|
- this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
|
|
|
|
|
- } else {
|
|
|
|
|
- item.planProductNum = item.lackNum;
|
|
|
|
|
- item.requiredFormingNum = item.lackNum;
|
|
|
|
|
- }
|
|
|
|
|
- item.slottingType = item.slottingType && item.slottingType + '';
|
|
|
|
|
- item.priority = index + 1;
|
|
|
|
|
-
|
|
|
|
|
- item.reqMoldTime = item.deliveryTime;
|
|
|
|
|
- if (item.colorKey && typeof item.colorKey == 'string') {
|
|
|
|
|
- this.$set(
|
|
|
|
|
- this.form.salesOrders[index],
|
|
|
|
|
- 'colorKey',
|
|
|
|
|
- item.colorKey.split(',')
|
|
|
|
|
|
|
+ const updatedSalesOrders = await Promise.all(
|
|
|
|
|
+ this.form.salesOrders.map(async (item, index) => {
|
|
|
|
|
+ if (this.clientEnvironmentId == '4') {
|
|
|
|
|
+ this.tableHandleKeyUp(item, '', item.lackNum, 'sum');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ item.planProductNum = item.lackNum;
|
|
|
|
|
+ item.requiredFormingNum = item.lackNum;
|
|
|
|
|
+ }
|
|
|
|
|
+ item.slottingType = item.slottingType && item.slottingType + '';
|
|
|
|
|
+ item.priority = index + 1;
|
|
|
|
|
+ item.reqMoldTime = item.deliveryTime;
|
|
|
|
|
+
|
|
|
|
|
+ let info = {};
|
|
|
|
|
+ try {
|
|
|
|
|
+ info = (await getColorModelInfoById(item.categoryId)) || {};
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ info = {};
|
|
|
|
|
+ }
|
|
|
|
|
+ const colorKey = info.colorKey || '';
|
|
|
|
|
+ const modelKey = info.modelKey || '';
|
|
|
|
|
+ const baseColorList = colorKey ? colorKey.split(',') : [];
|
|
|
|
|
+ const baseModelList = modelKey ? modelKey.split(',') : [];
|
|
|
|
|
+
|
|
|
|
|
+ let curColor = item.colorKey;
|
|
|
|
|
+ if (Array.isArray(curColor)) {
|
|
|
|
|
+ curColor = curColor[0] || '';
|
|
|
|
|
+ } else if (typeof curColor !== 'string') {
|
|
|
|
|
+ curColor = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!curColor && baseColorList.length) {
|
|
|
|
|
+ curColor = baseColorList[0];
|
|
|
|
|
+ }
|
|
|
|
|
+ let curModel = item.modelKey;
|
|
|
|
|
+ if (Array.isArray(curModel)) {
|
|
|
|
|
+ curModel = curModel[0] || '';
|
|
|
|
|
+ } else if (typeof curModel !== 'string') {
|
|
|
|
|
+ curModel = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!curModel && baseModelList.length) {
|
|
|
|
|
+ curModel = baseModelList[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 把当前已选的值合并进可选列表,保证 el-select 能正确显示已选项
|
|
|
|
|
+ const mergedColorList = Array.from(
|
|
|
|
|
+ new Set([...baseColorList, curColor].filter((v) => v !== '' && v != null))
|
|
|
);
|
|
);
|
|
|
- }
|
|
|
|
|
- if (item.modelKey && typeof item.modelKey == 'string') {
|
|
|
|
|
- this.$set(
|
|
|
|
|
- this.form.salesOrders[index],
|
|
|
|
|
- 'modelKey',
|
|
|
|
|
- item.modelKey.split(',')
|
|
|
|
|
|
|
+ const mergedModelList = Array.from(
|
|
|
|
|
+ new Set([...baseModelList, curModel].filter((v) => v !== '' && v != null))
|
|
|
);
|
|
);
|
|
|
- }
|
|
|
|
|
- // dayjs(
|
|
|
|
|
- // new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
|
|
|
|
|
- // ).format('YYYY-MM-DD');
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ colorList: mergedColorList,
|
|
|
|
|
+ modelList: mergedModelList,
|
|
|
|
|
+ colorKey: curColor,
|
|
|
|
|
+ modelKey: curModel
|
|
|
|
|
+ };
|
|
|
|
|
+ })
|
|
|
|
|
+ );
|
|
|
|
|
+ this.$set(this.form, 'salesOrders', updatedSalesOrders);
|
|
|
if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
|
|
if (this.form.salesOrders.every((itm) => itm.orderType == 2)) {
|
|
|
this.form.planType = 2;
|
|
this.form.planType = 2;
|
|
|
} else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
|
|
} else if (this.form.salesOrders.every((itm) => itm.orderType == 1)) {
|
|
@@ -1778,19 +1877,22 @@
|
|
|
let priority =
|
|
let priority =
|
|
|
this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
|
|
this.form.salesOrders[this.form.salesOrders.length - 1]?.priority ||
|
|
|
0;
|
|
0;
|
|
|
- this.form.salesOrders = this.form.salesOrders.concat(
|
|
|
|
|
- result.map((item, index) => {
|
|
|
|
|
- item.priority = ++priority;
|
|
|
|
|
-
|
|
|
|
|
- item.planProductNum = item.lackNum;
|
|
|
|
|
- item.requiredFormingNum = item.lackNum;
|
|
|
|
|
- item.reqMoldTime = dayjs(
|
|
|
|
|
- new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
|
|
|
|
|
- ).format('YYYY-MM-DD');
|
|
|
|
|
- return item;
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const newItems = result.map((item, index) => {
|
|
|
|
|
+ item.priority = ++priority;
|
|
|
|
|
+
|
|
|
|
|
+ item.planProductNum = item.lackNum;
|
|
|
|
|
+ item.requiredFormingNum = item.lackNum;
|
|
|
|
|
+ item.reqMoldTime = dayjs(
|
|
|
|
|
+ new Date(item.deliveryTime).getTime() - 3600 * 1000 * 24 * 10
|
|
|
|
|
+ ).format('YYYY-MM-DD');
|
|
|
|
|
+ return item;
|
|
|
|
|
+ });
|
|
|
|
|
+ Promise.all(newItems.map((item) => this.fillColorModelInfo(item))).then(
|
|
|
|
|
+ () => {
|
|
|
|
|
+ this.form.salesOrders = this.form.salesOrders.concat(newItems);
|
|
|
|
|
+ this.changeData();
|
|
|
|
|
+ }
|
|
|
);
|
|
);
|
|
|
- this.changeData();
|
|
|
|
|
},
|
|
},
|
|
|
changeData() {
|
|
changeData() {
|
|
|
var planProductNum = 0;
|
|
var planProductNum = 0;
|
|
@@ -1815,8 +1917,8 @@
|
|
|
}
|
|
}
|
|
|
console.log(params, 'params');
|
|
console.log(params, 'params');
|
|
|
params.salesOrders.forEach((item) => {
|
|
params.salesOrders.forEach((item) => {
|
|
|
- item.colorKey = item.colorKey.toString();
|
|
|
|
|
- item.modelKey = item.modelKey.toString();
|
|
|
|
|
|
|
+ item.colorKey = item.colorKey == null ? '' : String(item.colorKey);
|
|
|
|
|
+ item.modelKey = item.modelKey == null ? '' : String(item.modelKey);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
if (type === 2) {
|
|
if (type === 2) {
|