From bcfab27f9ed2a0cc8503041665a2b66d1ae2e1c3 Mon Sep 17 00:00:00 2001 From: danshihao Date: Wed, 3 Jan 2024 16:20:52 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=81=E6=A0=87=E7=A8=BD=E6=9F=A5?= =?UTF-8?q?=E8=AE=A1=E5=88=92-=E4=B8=9A=E5=8A=A1=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=89=8D=E7=AB=AF=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/InspectionPlanTable.vue | 112 +++++++++++++++++- 1 file changed, 106 insertions(+), 6 deletions(-) diff --git a/src/views/workCenter/enterpriseStandardInspectionPlan/modules/InspectionPlanTable.vue b/src/views/workCenter/enterpriseStandardInspectionPlan/modules/InspectionPlanTable.vue index 0c84835f..07806787 100644 --- a/src/views/workCenter/enterpriseStandardInspectionPlan/modules/InspectionPlanTable.vue +++ b/src/views/workCenter/enterpriseStandardInspectionPlan/modules/InspectionPlanTable.vue @@ -18,7 +18,7 @@ :columns="columns" :dataSource="dataSource" :can-drag="true" - rowKey="id" + :rowKey="(row, index) => row.id || index" :loading="loading" :pagination="false" :row-selection="hasTableOperator ? { selectedRowKeys: selectedRowKeys, onChange: onSelectChange, getCheckboxProps } : null" @@ -63,7 +63,7 @@ - + @@ -74,7 +74,10 @@ import InspectionPlanDrawer from '@views/workCenter/enterpriseStandardInspection import WriteOpinionModal from '@views/workCenter/enterpriseStandardInspectionPlan/modules/WriteOpinionModal' import ShowOpinionModal from '@views/workCenter/enterpriseStandardInspectionPlan/modules/ShowOpinionModal' import { EsInspectionPlan } from '@/enums/commonEnums' - +import Vue from 'vue' +import { ACCESS_TOKEN } from '@/store/mutation-types' +import store from '@/store' +let importModalLoading export default { name: 'InspectionPlanTable', components: { ShowOpinionModal, WriteOpinionModal, InspectionPlanDrawer, JTable }, @@ -98,9 +101,13 @@ export default { url: { list: '/process/processEsInspectPlan/list', delete: '/process/processEsInspectPlan/delete', - importExcelUrl: '/process/processEsInspectPlan/importExcel', deleteBatch: '/process/processEsInspectPlan/deleteBatch', - downTemplateUrl: '/process/processEsInspectPlan/templateDownload' + // 默认是发起节点的导入和 下载模板,如果是节点2就用没有 征求意见对象 的模板和导入接口 + importExcelUrl: '/process/processEsInspectPlan/importExcelByStart', + downTemplateUrl: '/process/processEsInspectPlan/templateDownloadByStart', + // 节点2 的导入和下载模板 + nodeTwoImportUrl: '/process/processEsInspectPlan/importExcelByOpinionFill', + nodeTwoDownTemplateUrl: '/process/processEsInspectPlan/templateDownloadByStartByOpinionFill' }, model: {}, dataSource: [], @@ -238,6 +245,17 @@ export default { } this.loadData() } + }, + // 监听当前节点变化 + currentNode: { + immediate: true, + handler () { + // 节点2填写意见,用没有“征求意见对象”的模板和导入接口 + if (this.currentNode === EsInspectionPlan.fillInComments.value) { + this.url.importExcelUrl = this.url.nodeTwoImportUrl + this.url.downTemplateUrl = this.url.nodeTwoDownTemplateUrl + } + } } }, computed: { @@ -245,7 +263,7 @@ export default { currentUserName () { return this.$store.getters.userInfo.username }, - // 是否显示表格操作按钮 + // 是否前两个节点:显示表格操作按钮 hasTableOperator () { const arr = [ EsInspectionPlan.initiate.value, @@ -345,6 +363,88 @@ export default { // 查看所属部门意见 showDepartOpinion (record) { this.$refs.showOpinionModal.show(record) + }, + /* 导入 */ + handleImportExcel (info) { + // 限制导入大于500MB + if (info.file.size > 1024 * 1024 * 500) { + this.$message.error('导入文件最大500MB!') + info.fileList.pop() + return + } + // 加一个大的提示 + if (!this.loading) { + importModalLoading = this.$info({ + title: '提示', + content: 正在导入,请稍候 , + keyboard: false + }) + } + this.loading = true + // 把知道了这个按钮去掉 + this.$nextTick(() => { + document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none' + }) + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList) + } + if (info.file.status === 'done') { + // 销毁这个提示 + importModalLoading && importModalLoading.destroy() + this.loading = false + if (info.file.response.success) { + // this.$message.success(`${info.file.name} 文件上传成功`); + if (info.file.response.code === 201) { + const { message, result: { msg, fileUrl, fileName } } = info.file.response + const href = window._CONFIG.domianURL + fileUrl + this.$warning({ + title: message, + content: (
+ {msg}
+ 具体详情请 点击下载 +
+ ) + }) + } else { + this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) + } + // 前端存储 + const data = info.file.response.result || [] + this.dataSource.push(...data) + } else { + if (Array.isArray(info.file.response.result) && info.file.response.result.length > 0) { + this.messageLineFeed(this.$t('fileImportError'), info.file.response.result) + } else if (/
|<\/br>|/.test(info.file.response.message)) { + this.messageLineFeedByBr(this.$t('fileImportError'), info.file.response.message) + } else { + this.$message.warning(`${info.file.name} ${info.file.response.message}`) + } + } + } else if (info.file.status === 'error') { + // 销毁这个提示 + importModalLoading && importModalLoading.destroy() + this.loading = false + if (info.file.response.status === 500) { + const data = info.file.response + const token = Vue.ls.get(ACCESS_TOKEN) + if (token && data.message.includes('Token失效')) { + this.error({ + title: '登录已过期', + content: '很抱歉,登录已过期,请重新登录', + okText: '重新登录', + mask: false, + onOk: () => { + store.dispatch('Logout').then(() => { + Vue.ls.remove(ACCESS_TOKEN) + window.location.reload() + }) + } + }) + } + } else { + this.$message.warning(`文件上传失败: ${info.file.msg} `) + } + } } } }