| | |
| | | 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++) { |