diff --git a/src/views/modules/qc/qcPartAttribute.vue b/src/views/modules/qc/qcPartAttribute.vue index 8e9a699..e731be7 100644 --- a/src/views/modules/qc/qcPartAttribute.vue +++ b/src/views/modules/qc/qcPartAttribute.vue @@ -2277,6 +2277,7 @@ flag: 'partAttribute', createBy: this.$store.state.user.name, site: this.$store.state.user.site, + buNo: this.userBuList[0].buNo.split('_')[1], } //打开组件 去做新增业务 this.$nextTick(() => { diff --git a/src/views/modules/qc/qc_upload.vue b/src/views/modules/qc/qc_upload.vue index 74a35ee..fea19f2 100644 --- a/src/views/modules/qc/qc_upload.vue +++ b/src/views/modules/qc/qc_upload.vue @@ -14,7 +14,7 @@ - 保存 + 保存 关闭 @@ -38,10 +38,12 @@ export default { titleCon: '文件导入', visible: false, fileList: [], + uploadLoading: false, pageData: { flag: '', createBy: '', - site: '' + site: '', + buNo: '', }, } }, @@ -68,6 +70,7 @@ export default { /*关闭modal*/ closeDialog () { this.fileList = [] + this.$refs.uploadFile.clearFiles() // 刷新报工的页面 this.$emit('refreshPageTables') // 关闭当前的页面 @@ -75,64 +78,47 @@ export default { }, /*保修当前的数据*/ saveUploadFile () { + this.uploadLoading = true /*判断文件是否上传*/ if (null == this.fileList || 0 == this.fileList.length) { this.$message.error("请先上传文件!") + this.uploadLoading = false return false } const formData = new FormData() formData.append("file", this.fileList[0].raw) formData.append("createBy", this.pageData.createBy) formData.append("site", this.pageData.site) + formData.append("buNo", this.pageData.buNo) + + // 根据 flag 发不同的接口 + let promise if (this.pageData.flag === 'item') { - uploadExcel(formData).then(({data}) => { - if (data.code === 0) { - this.$message.success(data.msg) - // 清空文件上传记录 - this.$refs.uploadFile.clearFiles() - // 关闭窗口并刷新页面 - this.closeDialog() - } else { - this.$message.warning(data.msg) - } - }) + promise = uploadExcel(formData) } else if (this.pageData.flag === 'template') { - uploadTemplateExcel(formData).then(({data}) => { - if (data.code === 0) { - this.$message.success(data.msg) - // 清空文件上传记录 - this.$refs.uploadFile.clearFiles() - // 关闭窗口并刷新页面 - this.closeDialog() - } else { - this.$message.warning(data.msg) - } - }) + promise = uploadTemplateExcel(formData) } else if (this.pageData.flag === 'partAttribute') { - uploadPartAttributeExcel(formData).then(({data}) => { - if (data.code === 0) { - this.$message.success(data.msg) - // 清空文件上传记录 - this.$refs.uploadFile.clearFiles() - // 关闭窗口并刷新页面 - this.closeDialog() - }else { - this.$message.warning(data.msg) - } - }) + promise = uploadPartAttributeExcel(formData) } else if (this.pageData.flag === 'familyAttribute') { - uploadFamilyAttributeExcel(formData).then(({data}) => { + promise = uploadFamilyAttributeExcel(formData) + } + promise + .then(({ data }) => { if (data.code === 0) { this.$message.success(data.msg) - // 清空文件上传记录 this.$refs.uploadFile.clearFiles() - // 关闭窗口并刷新页面 this.closeDialog() } else { this.$message.warning(data.msg) } }) - } + .catch(err => { + this.$message.error("上传失败,请稍后重试") + console.error(err) + }) + .finally(() => { + this.uploadLoading = false // 请求结束时再关 loading + }) }, // 下载 async downloadFile () {