|
|
@@ -613,6 +613,7 @@
|
|
|
datasourceList: [], // 表格物料数据
|
|
|
bomListV: [], // BOM版本
|
|
|
bomListType: [], // BOM 类型
|
|
|
+ bomRequestSeq: 0,
|
|
|
form: {
|
|
|
homogeneityInspect: []
|
|
|
},
|
|
|
@@ -783,15 +784,19 @@
|
|
|
},
|
|
|
|
|
|
async handleNodeClick(data) {
|
|
|
+ const requestSeq = ++this.bomRequestSeq;
|
|
|
this.orderInfo = data;
|
|
|
+ this.clearBomData();
|
|
|
+ this.kitComInfo = {};
|
|
|
try {
|
|
|
- await this.getKitting();
|
|
|
- await this.getBomData(data);
|
|
|
+ await this.getKitting(requestSeq);
|
|
|
+ if (!this.isActiveRequest(requestSeq)) return;
|
|
|
+ await this.getBomData(data, requestSeq);
|
|
|
} catch (e) {
|
|
|
console.log(e, 'eeeeeeeeeeeeeeeeeee');
|
|
|
}
|
|
|
},
|
|
|
- async getKitting() {
|
|
|
+ async getKitting(requestSeq = this.bomRequestSeq) {
|
|
|
let { startTime, endTime } = this.getTimeData();
|
|
|
let params = {
|
|
|
categoryId: this.orderInfo.categoryId,
|
|
|
@@ -799,21 +804,24 @@
|
|
|
endTime
|
|
|
};
|
|
|
const res = await getProductKitting(params);
|
|
|
- if (res) {
|
|
|
- this.kitComInfo = res;
|
|
|
- }
|
|
|
+ if (!this.isActiveRequest(requestSeq)) return;
|
|
|
+ this.kitComInfo = res || {};
|
|
|
},
|
|
|
selectCalculate(val) {
|
|
|
this.attributeChange(this.formInline.attributeType);
|
|
|
},
|
|
|
|
|
|
// 获取bom 数据
|
|
|
- async getBomData(data) {
|
|
|
+ async getBomData(data, requestSeq = this.bomRequestSeq) {
|
|
|
try {
|
|
|
this.salesOrderId = data.id;
|
|
|
let params = { categoryId: data.categoryId };
|
|
|
const res = await listBomType(params);
|
|
|
- if (!res || res.length === 0) return;
|
|
|
+ if (!this.isActiveRequest(requestSeq)) return;
|
|
|
+ if (!res || res.length === 0) {
|
|
|
+ this.clearBomData();
|
|
|
+ return;
|
|
|
+ }
|
|
|
let bomMap = {
|
|
|
1: 'PBOM',
|
|
|
2: 'MBOM',
|
|
|
@@ -831,14 +839,14 @@
|
|
|
let bomType = bom ? bom.bomType : list[0].bomType;
|
|
|
this.bomListType = list;
|
|
|
this.formInline.bomType = bomType;
|
|
|
- this.bomTypeChange(bomType, 'init');
|
|
|
+ await this.bomTypeChange(bomType, 'init', requestSeq);
|
|
|
} catch (e) {
|
|
|
- this.$message.error(err.message);
|
|
|
+ this.$message.error(e.message);
|
|
|
this.loading = false;
|
|
|
}
|
|
|
},
|
|
|
// 选择BOM类型
|
|
|
- async bomTypeChange(e, type) {
|
|
|
+ async bomTypeChange(e, type, requestSeq = this.bomRequestSeq) {
|
|
|
this.formInline.bomType = e;
|
|
|
const params = {
|
|
|
categoryId: this.orderInfo.categoryId,
|
|
|
@@ -846,8 +854,11 @@
|
|
|
isTemp: 0
|
|
|
};
|
|
|
const res = await bomVersionList(params);
|
|
|
+ if (!this.isActiveRequest(requestSeq)) return;
|
|
|
if (!res || res.length == 0) {
|
|
|
this.bomListV = [];
|
|
|
+ this.formInline.bomId = '';
|
|
|
+ this.clearMaterialData();
|
|
|
return;
|
|
|
}
|
|
|
let list = [];
|
|
|
@@ -861,26 +872,35 @@
|
|
|
list.push(obj);
|
|
|
});
|
|
|
this.bomListV = list;
|
|
|
+ if (!list.length) {
|
|
|
+ this.formInline.bomId = '';
|
|
|
+ this.clearMaterialData();
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (type == 'init') {
|
|
|
let obj = list.find((el) => el.bomId == this.orderInfo.bomCategoryId);
|
|
|
let id = obj ? obj.bomId : list[0].bomId;
|
|
|
this.formInline.bomId = id;
|
|
|
- this.bomVChange(id);
|
|
|
+ await this.bomVChange(id, requestSeq);
|
|
|
} else {
|
|
|
let id = list[0].bomId;
|
|
|
this.formInline.bomId = id;
|
|
|
- this.bomVChange(id);
|
|
|
+ await this.bomVChange(id, requestSeq);
|
|
|
}
|
|
|
},
|
|
|
// 选择BOM版本
|
|
|
- async bomVChange(e) {
|
|
|
- this.datasourceList = [];
|
|
|
- this.datasourceAllList = [];
|
|
|
- await this.getMaterialData({ bomId: e }, this.formInline.attributeType);
|
|
|
+ async bomVChange(e, requestSeq = this.bomRequestSeq) {
|
|
|
+ this.clearMaterialData();
|
|
|
+ if (!e) return;
|
|
|
+ await this.getMaterialData(
|
|
|
+ { bomId: e },
|
|
|
+ this.formInline.attributeType,
|
|
|
+ requestSeq
|
|
|
+ );
|
|
|
},
|
|
|
|
|
|
// 查询采购价跟外协件两个类型数据
|
|
|
- async dataMerging() {
|
|
|
+ async dataMerging(requestSeq = this.bomRequestSeq) {
|
|
|
if (!this.formInline.bomId) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -909,6 +929,7 @@
|
|
|
let p2 = findMaterialInfoSalesorder(params2);
|
|
|
// 使用Promise.all并行执行多个Promise
|
|
|
let results = await Promise.all([p1, p2]);
|
|
|
+ if (!this.isActiveRequest(requestSeq)) return;
|
|
|
this.loading = false;
|
|
|
// 这里可以继续对results做后续处理,比如解构等
|
|
|
const [result1, result2] = results;
|
|
|
@@ -916,7 +937,9 @@
|
|
|
const mergeData = this.handleMergedData(result1, result2);
|
|
|
this.resultProcess(mergeData);
|
|
|
} catch (error) {
|
|
|
- this.loading = false;
|
|
|
+ if (this.isActiveRequest(requestSeq)) {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
console.error('接口请求出错:', error);
|
|
|
}
|
|
|
},
|
|
|
@@ -925,25 +948,31 @@
|
|
|
return [...result1, ...result2];
|
|
|
},
|
|
|
// 切换属性
|
|
|
- async attributeChange(e) {
|
|
|
+ async attributeChange(e, requestSeq = this.bomRequestSeq) {
|
|
|
if (e == 'all') {
|
|
|
- this.dataMerging();
|
|
|
+ this.dataMerging(requestSeq);
|
|
|
return;
|
|
|
}
|
|
|
let data = this.bomListV.find(
|
|
|
(el) => el.bomId === this.formInline.bomId
|
|
|
);
|
|
|
if (!data) return;
|
|
|
- await this.getMaterialData(data, e);
|
|
|
+ await this.getMaterialData(data, e, requestSeq);
|
|
|
},
|
|
|
// 获取物料数据信息
|
|
|
- async getMaterialData(data, attributeType) {
|
|
|
+ async getMaterialData(
|
|
|
+ data,
|
|
|
+ attributeType,
|
|
|
+ requestSeq = this.bomRequestSeq
|
|
|
+ ) {
|
|
|
if (attributeType == 'all') {
|
|
|
- this.dataMerging();
|
|
|
+ this.dataMerging(requestSeq);
|
|
|
return;
|
|
|
}
|
|
|
let params = {};
|
|
|
let api = null;
|
|
|
+ let kitting = this.quota_calculation == 1 ? false : true;
|
|
|
+ let { startTime, endTime } = this.getTimeData();
|
|
|
if (this.source == 'list') {
|
|
|
let produceType =
|
|
|
this.produceType == 1
|
|
|
@@ -953,8 +982,6 @@
|
|
|
: attributeType == 2
|
|
|
? 2
|
|
|
: 3;
|
|
|
- let kitting = this.quota_calculation == 1 ? false : true;
|
|
|
- let { startTime, endTime } = this.getTimeData();
|
|
|
params = {
|
|
|
salesOrderId: this.salesOrderId,
|
|
|
bomVersionId: data.bomId,
|
|
|
@@ -978,11 +1005,14 @@
|
|
|
this.loading = true;
|
|
|
try {
|
|
|
const result = await api(params);
|
|
|
+ if (!this.isActiveRequest(requestSeq)) return;
|
|
|
// 结果数据处理
|
|
|
this.resultProcess(result);
|
|
|
this.loading = false;
|
|
|
} catch (err) {
|
|
|
- this.loading = false;
|
|
|
+ if (this.isActiveRequest(requestSeq)) {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
getTimeData() {
|
|
|
@@ -1103,18 +1133,32 @@
|
|
|
return null; // 没有匹配到符合格式的数据
|
|
|
},
|
|
|
clearData() {
|
|
|
+ this.bomRequestSeq += 1;
|
|
|
+ this.loading = false;
|
|
|
this.formInline = {
|
|
|
finalState: 0,
|
|
|
attributeType: 2
|
|
|
};
|
|
|
- this.baseCount = '';
|
|
|
- this.baseUnit = '';
|
|
|
+ this.clearBomData();
|
|
|
+ this.orderInfo = {};
|
|
|
+ this.kitComInfo = {};
|
|
|
+ },
|
|
|
+ clearBomData() {
|
|
|
this.bomListV = [];
|
|
|
this.bomListType = [];
|
|
|
+ this.formInline.bomType = '';
|
|
|
+ this.formInline.bomId = '';
|
|
|
+ this.clearMaterialData();
|
|
|
+ },
|
|
|
+ clearMaterialData() {
|
|
|
+ this.baseCount = '';
|
|
|
+ this.baseUnit = '';
|
|
|
this.datasourceList = [];
|
|
|
this.datasourceAllList = [];
|
|
|
- this.orderInfo = {};
|
|
|
- this.kitComInfo = {};
|
|
|
+ this.selection = [];
|
|
|
+ },
|
|
|
+ isActiveRequest(requestSeq) {
|
|
|
+ return requestSeq === this.bomRequestSeq;
|
|
|
},
|
|
|
|
|
|
onSubmit() {
|