diff --git a/pages/produceManagement/paintMaterial/paint_call.vue b/pages/produceManagement/paintMaterial/paint_call.vue index 4ad0fac..6c20cc5 100644 --- a/pages/produceManagement/paintMaterial/paint_call.vue +++ b/pages/produceManagement/paintMaterial/paint_call.vue @@ -105,20 +105,22 @@ export default { methods: { // 获取线体数据 getLineOptions() { - getLineOptions().then(res => { - if (res.code === 200 && res.data) { - // 格式化线体数据为uni-data-select需要的格式 - this.lineOptions = res.data.map(item => ({ - text: item.groupName, // 显示名称 - value: item.groupCode // 实际值 - })); - } else { + getLineOptions() + .then(res => { + if (res.code === 200 && res.data) { + // 格式化线体数据为uni-data-select需要的格式 + this.lineOptions = res.data.map(item => ({ + text: item.groupName, // 显示名称 + value: item.groupCode // 实际值 + })); + } else { + this.$modal.showToast('获取线体数据失败'); + } + }) + .catch(err => { + console.error('获取线体数据失败', err); this.$modal.showToast('获取线体数据失败'); - } - }).catch(err => { - console.error('获取线体数据失败', err); - this.$modal.showToast('获取线体数据失败'); - }); + }); }, // 获取MRP叫料清单 @@ -142,21 +144,24 @@ export default { }); // 调用API获取MRP清单 - queryCallMaterialMRPList(params).then(res => { - uni.hideLoading(); - if (res.code === 200 && res.data) { - this.mrpList = res.data.result; - console.log('MRP数据:', res.data.result); - } else { + queryCallMaterialMRPList(params) + .then(res => { + if (res.code === 200 && res.data) { + this.mrpList = res.data.result; + //console.log('MRP数据:', res.data.result); + } else { + this.mrpList = []; + this.$modal.showToast(res.message || '获取MRP数据失败'); + } + }) + .catch(err => { + console.error('获取MRP数据失败', err); this.mrpList = []; - this.$modal.showToast(res.message || '获取MRP数据失败'); - } - }).catch(err => { - uni.hideLoading(); - console.error('获取MRP数据失败', err); - this.mrpList = []; - this.$modal.showToast('获取MRP数据失败'); - }); + this.$modal.showToast('获取MRP数据失败'); + }) + .finally(() => { + uni.hideLoading(); + }); }, @@ -195,26 +200,29 @@ export default { }); // 调用叫料API - doLineCallMaterial(params).then(res => { - uni.hideLoading(); - if (res.code === 200) { - this.$modal.showToast(`成功叫料 ${quantity} 个 ${this.currentMaterial.materialName}`); - // 更新物料数量 - this.currentMaterial.quantity -= quantity; - // 如果数量为0,从列表中移除 - if (this.currentMaterial.quantity <= 0) { - this.mrpList = this.mrpList.filter(m => m.id !== this.currentMaterial.id); + doLineCallMaterial(params) + .then(res => { + if (res.code === 200) { + this.$modal.showToast(`成功叫料 ${quantity} 个 ${this.currentMaterial.materialName}`); + // 更新物料数量 + this.currentMaterial.quantity -= quantity; + // 如果数量为0,从列表中移除 + if (this.currentMaterial.quantity <= 0) { + this.mrpList = this.mrpList.filter(m => m.id !== this.currentMaterial.id); + } + // 关闭弹窗 + this.$refs.popup.close(); + } else { + this.$modal.showToast(res.message || '叫料失败'); } - // 关闭弹窗 - this.$refs.popup.close(); - } else { - this.$modal.showToast(res.message || '叫料失败'); - } - }).catch(err => { - uni.hideLoading(); - console.error('叫料失败', err); - this.$modal.showToast('叫料失败'); - }); + }) + .catch(err => { + console.error('叫料失败', err); + this.$modal.showToast('叫料失败'); + }) + .finally(() => { + uni.hideLoading(); + }); }, // 取消叫料 diff --git a/pages/produceManagement/paintMaterial/paint_receive.vue b/pages/produceManagement/paintMaterial/paint_receive.vue index bc55385..56307b9 100644 --- a/pages/produceManagement/paintMaterial/paint_receive.vue +++ b/pages/produceManagement/paintMaterial/paint_receive.vue @@ -75,20 +75,22 @@ export default { methods: { // 获取线体数据 getLineOptions() { - getLineOptions().then(res => { - if (res.code === 200 && res.data) { - // 格式化线体数据为uni-data-select需要的格式 - this.lineOptions = res.data.map(item => ({ - text: item.groupName, // 显示名称 - value: item.groupCode // 实际值 - })); - } else { + getLineOptions() + .then(res => { + if (res.code === 200 && res.data) { + // 格式化线体数据为uni-data-select需要的格式 + this.lineOptions = res.data.map(item => ({ + text: item.groupName, // 显示名称 + value: item.groupCode // 实际值 + })); + } else { + this.$modal.showToast('获取线体数据失败'); + } + }) + .catch(err => { + console.error('获取线体数据失败', err); this.$modal.showToast('获取线体数据失败'); - } - }).catch(err => { - console.error('获取线体数据失败', err); - this.$modal.showToast('获取线体数据失败'); - }); + }); }, // 获取收料清单 @@ -112,21 +114,24 @@ export default { }); // 调用API获取收料清单 - queryCallReceiveList(params).then(res => { - uni.hideLoading(); - if (res.code === 200 && res.data) { - this.receiveList = res.data.result; - console.log('收料数据:', res.data.result); - } else { + queryCallReceiveList(params) + .then(res => { + if (res.code === 200 && res.data) { + this.receiveList = res.data.result; + //console.log('收料数据:', res.data.result); + } else { + this.receiveList = []; + this.$modal.showToast(res.message || '获取收料数据失败'); + } + }) + .catch(err => { + console.error('获取收料数据失败', err); this.receiveList = []; - this.$modal.showToast(res.message || '获取收料数据失败'); - } - }).catch(err => { - uni.hideLoading(); - console.error('获取收料数据失败', err); - this.receiveList = []; - this.$modal.showToast('获取收料数据失败'); - }); + this.$modal.showToast('获取收料数据失败'); + }) + .finally(() => { + uni.hideLoading(); + }); }, // 收料操作 @@ -155,20 +160,23 @@ export default { }); // 调用收料API - doLineReceiveMaterial(params).then(res => { - uni.hideLoading(); - if (res.code === 200) { - this.$modal.showToast(`成功收料 ${item.waitingQuantity} 个 ${item.materialName}`); - // 刷新收料清单 - this.getReceiveList(); - } else { - this.$modal.showToast(res.message || '收料失败'); - } - }).catch(err => { - uni.hideLoading(); - console.error('收料失败', err); - this.$modal.showToast('收料失败'); - }); + doLineReceiveMaterial(params) + .then(res => { + if (res.code === 200) { + this.$modal.showToast(`成功收料 ${item.quantity} 个 ${item.materialName}`); + // 刷新收料清单 + this.getReceiveList(); + } else { + this.$modal.showToast(res.message || '收料失败'); + } + }) + .catch(err => { + console.error('收料失败', err); + this.$modal.showToast('收料失败'); + }) + .finally(() => { + uni.hideLoading(); + }); } } }); @@ -200,20 +208,23 @@ export default { }); // 调用退料API - doLineReturnBackMaterial(params).then(res => { - uni.hideLoading(); - if (res.code === 200) { - this.$modal.showToast(`成功退料 ${item.waitingQuantity} 个 ${item.materialName}`); - // 刷新收料清单 - this.getReceiveList(); - } else { - this.$modal.showToast(res.message || '退料失败'); - } - }).catch(err => { - uni.hideLoading(); - console.error('退料失败', err); - this.$modal.showToast('退料失败'); - }); + doLineReturnBackMaterial(params) + .then(res => { + if (res.code === 200) { + this.$modal.showToast(`成功退料 ${item.quantity} 个 ${item.materialName}`); + // 刷新收料清单 + this.getReceiveList(); + } else { + this.$modal.showToast(res.message || '退料失败'); + } + }) + .catch(err => { + console.error('退料失败', err); + this.$modal.showToast('退料失败'); + }) + .finally(() => { + uni.hideLoading(); + }); } } });