From 50e9a40ac746c7d46bd0b9f74e98d4d478cf5e64 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期三, 10 九月 2025 15:43:22 +0800 Subject: [PATCH] 优化二保批量导入,改为返回文件让用户自己查询对应设备型号 --- src/views/eam/base/EamMaintenanceStandardList.vue | 73 ++++++++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) diff --git a/src/views/eam/base/EamMaintenanceStandardList.vue b/src/views/eam/base/EamMaintenanceStandardList.vue index 52406b7..e669c1e 100644 --- a/src/views/eam/base/EamMaintenanceStandardList.vue +++ b/src/views/eam/base/EamMaintenanceStandardList.vue @@ -421,6 +421,79 @@ this.loadData(); }, + /* 瀵煎叆 */ + handleImportExcel(info) { + this.loading = true; + + if (info.file.status === 'done') { + this.loading = false; + + // 妫�鏌ュ搷搴斿唴瀹规槸鍚︿负CSV鏍煎紡锛堝寘鍚湭鎵惧埌鐨勮澶囩紪鐮侊級 + if (info.file.response && typeof info.file.response === 'string' && + info.file.response.includes('鏈壘鍒扮殑璁惧缂栫爜')) { + + // 鍒涘缓CSV鏂囦欢骞朵笅杞� + const blob = new Blob([info.file.response], { type: 'text/csv;charset=utf-8' }); + const downloadUrl = window.URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = downloadUrl; + link.setAttribute('download', '鏈壘鍒扮殑璁惧缂栫爜.csv'); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + window.URL.revokeObjectURL(downloadUrl); + + // 鏄剧ず鎻愮ず淇℃伅 + this.$notification.warning({ + message: '瀵煎叆瀹屾垚', + description: '瀵煎叆鎴愬姛浣嗗瓨鍦ㄦ湭鎵惧埌鐨勮澶囩紪鐮侊紝宸蹭笅杞芥湭鎵惧埌鐨勮澶囩紪鐮佸垪琛�' + }); + + this.loadData(); + return; + } + + // 澶勭悊甯歌JSON鍝嶅簲 + if (info.file.response && info.file.response.success) { + this.$notification.success({ + message: '瀵煎叆鎴愬姛', + description: info.file.response.message || `${info.file.name} 鏂囦欢涓婁紶鎴愬姛` + }); + this.loadData(); + } else { + const fileName = info.file.name || '鏈煡鏂囦欢'; + const errorMessage = info.file.response && info.file.response.message + ? info.file.response.message + : '瀵煎叆澶辫触锛屾湭鐭ラ敊璇�'; + + this.$notification.error({ + message: '瀵煎叆澶辫触', + description: `${fileName} ${errorMessage}` + }); + } + } else if (info.file.status === 'error') { + this.loading = false; + + const fileName = info.file.name || '鏈煡鏂囦欢'; + let errorMessage = '涓婁紶澶辫触锛屾湭鐭ラ敊璇�'; + + if (info.file.response) { + if (info.file.response.message) { + errorMessage = info.file.response.message; + } else if (info.file.response.error) { + errorMessage = info.file.response.error; + } + } else if (info.file.error) { + errorMessage = info.file.error.message || info.file.error; + } + + this.$notification.error({ + message: '涓婁紶澶辫触', + description: `${fileName} ${errorMessage}` + }); + } + }, + batchDel() { var ids = '' for (var a = 0; a < this.selectedRowKeys.length; a++) { -- Gitblit v1.9.3