From 15c8f6c98429d9d5e441c8d4f72eeb1f10d1fee3 Mon Sep 17 00:00:00 2001 From: chenhc <2369838784@qq.com> Date: Tue, 1 Apr 2025 13:12:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E4=BC=98=E5=8C=96loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/inoutDrug/DialogCreateDrugOrder.vue | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/views/inoutDrug/DialogCreateDrugOrder.vue b/src/views/inoutDrug/DialogCreateDrugOrder.vue index 7fb718bb..78f4a30a 100644 --- a/src/views/inoutDrug/DialogCreateDrugOrder.vue +++ b/src/views/inoutDrug/DialogCreateDrugOrder.vue @@ -394,7 +394,7 @@ - 导入阳采追溯码 @@ -848,14 +848,26 @@ export default { this.$refs.fileInput.click(); }, triggerFileUpload2() { + this.$refs.fileInput2.click(); }, handleFileUpload(event) { + + // 显示加载状态 + const loading = this.$loading({ + lock: true, + text: '数据提交中,请稍候', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }); + const file = event.target.files[0]; const billNo = this.orderFormData.billNo; const uploadUrl = process.env.VUE_APP_BASE_API + '/udiwms/inout/order/yc/fileUpload'; if (this.$isBlank(this.orderFormData.billNo)) { + // 关闭加载状态 + loading.close(); this.$message.error("单据编号不可以为空!"); return; } @@ -876,12 +888,16 @@ export default { }) .then(response => { if (!response.ok) { + // 关闭加载状态 + loading.close(); throw new Error(`HTTP error! Status: ${response.status}`); } return response.json(); }) .then(data => { if (data.code === 20000) { + // 关闭加载状态 + loading.close(); // 更新单据号 if (data.data && data.data.billNo) { this.orderFormData.billNo = data.data.billNo; @@ -895,6 +911,8 @@ export default { } }) .catch(error => { + // 关闭加载状态 + loading.close(); console.error('File upload failed:', error); this.$message.error('文件上传失败:' + error.message); }); @@ -902,8 +920,19 @@ export default { // 清空文件输入框的值 event.target.value = ''; + // 关闭加载状态 + loading.close(); }, handleFileUpload2(event) { + + // 显示加载状态 + const loading = this.$loading({ + lock: true, + text: '数据提交中,请稍候', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }); + const file = event.target.files[0]; const uploadUrl = process.env.VUE_APP_BASE_API + '/udiwms/inout/order/yc/orderFileUpload'; @@ -925,12 +954,16 @@ export default { }) .then(response => { if (!response.ok) { + // 关闭加载状态 + loading.close(); throw new Error(`HTTP error! Status: ${response.status}`); } return response.json(); }) .then(data => { if (data.code === 20000) { + // 关闭加载状态 + loading.close(); // 更新单据号 if (data.data && data.data.billNo) { this.orderFormData.billNo = data.data.billNo; @@ -954,15 +987,21 @@ export default { } }) .catch(error => { + // 关闭加载状态 + loading.close(); console.error('File upload failed:', error); this.$message.error('文件上传失败:' + error.message); }); } else { + // 关闭加载状态 + loading.close(); this.$message.warning('请选择要上传的文件'); } // 清空文件输入框的值 event.target.value = ''; + // 关闭加载状态 + loading.close(); }, //获取用户仓库列表 findInvListByUser() { @@ -2034,6 +2073,7 @@ export default {