Browse Source

feat(eam): 新增维保项目导入功能并优化导入体验

- 添加维保项目明细导入API接口和模板下载功能
- 实现导入对话框防止重复提交功能
- 优化导入结果显示,支持换行错误信息展示
- 新增导入维保项目和点检项目的独立操作入口
- 统一导入流程的状态管理和错误处理机制
- 优化导入对话框样式和用户体验
master
qiankanghui 2 days ago
parent
commit
96bc199be4
  1. 2
      src/api/eam/eam.js
  2. 33
      src/views/modules/eam/eamMaintenanceItem.vue
  3. 300
      src/views/modules/eam/eamMaintenanceModel.vue
  4. 44
      src/views/modules/eam/eamPropertiesItem.vue
  5. 74
      src/views/modules/eam/eamPropertiesModel.vue

2
src/api/eam/eam.js

@ -83,6 +83,8 @@ export const downloadEamPropertiesItemDetailTemplate = () => createAPI(`/pms/eam
//---------------维保项目------------------------ //---------------维保项目------------------------
export const uploadEamMaintenanceItemExcel = data => createAPI(`/pms/eam/uploadEamMaintenanceItemExcel`,'post',data) export const uploadEamMaintenanceItemExcel = data => createAPI(`/pms/eam/uploadEamMaintenanceItemExcel`,'post',data)
export const downloadEamMaintenanceItemTemplate = () => createAPI(`/pms/eam/downloadEamMaintenanceItemTemplate`,'get',{},'download') export const downloadEamMaintenanceItemTemplate = () => createAPI(`/pms/eam/downloadEamMaintenanceItemTemplate`,'get',{},'download')
export const uploadEamMaintenanceItemDetailExcel = data => createAPI(`/pms/eam/uploadEamMaintenanceItemDetailExcel`,'post',data)
export const downloadEamMaintenanceItemDetailTemplate = () => createAPI(`/pms/eam/downloadEamMaintenanceItemDetailTemplate`,'get',{},'download')
//---------------点检模板------------------- //---------------点检模板-------------------
export const eamPropertiesModelSearch = data => createAPI(`/pms/eam/eamPropertiesModelSearch`,'post',data) export const eamPropertiesModelSearch = data => createAPI(`/pms/eam/eamPropertiesModelSearch`,'post',data)

33
src/views/modules/eam/eamMaintenanceItem.vue

@ -276,8 +276,8 @@
<!-- 底部 --> <!-- 底部 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmUpload" size="medium">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium">关闭</el-button>
<el-button type="primary" @click="confirmUpload" size="medium" :disabled="uploadSubmitting">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium" :disabled="uploadSubmitting">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -712,6 +712,7 @@
uploadFileName: '', uploadFileName: '',
uploadFile: null, uploadFile: null,
uploadBu: '', // BU uploadBu: '', // BU
uploadSubmitting: false, //
} }
}, },
@ -1181,6 +1182,11 @@
// //
confirmUpload () { confirmUpload () {
//
if (this.uploadSubmitting) {
return
}
// BU // BU
if (!this.uploadBu || this.uploadBu === '') { if (!this.uploadBu || this.uploadBu === '') {
this.$message.warning('请先选择BU') this.$message.warning('请先选择BU')
@ -1198,6 +1204,9 @@
formData.append('site', this.uploadBu.split('_')[0]) // BUsite formData.append('site', this.uploadBu.split('_')[0]) // BUsite
formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo
//
this.uploadSubmitting = true
// //
uploadEamMaintenanceItemExcel(formData).then(({data}) => { uploadEamMaintenanceItemExcel(formData).then(({data}) => {
if (data.code === 0) { if (data.code === 0) {
@ -1216,8 +1225,23 @@
} }
}).catch((error) => { }).catch((error) => {
console.error('导入失败:', error) console.error('导入失败:', error)
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
this.$message.error('导入失败: ' + errorMsg)
const errorMsg =
(error.response && error.response.data && error.response.data.msg)
|| error.message
|| '未知错误'
this.$alert(
('导入失败: ' + errorMsg).replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}).finally(() => {
//
this.uploadSubmitting = false
}) })
}, },
@ -1278,6 +1302,7 @@
this.uploadFileName = '' this.uploadFileName = ''
this.uploadFile = null this.uploadFile = null
this.uploadBu = '' // BU this.uploadBu = '' // BU
this.uploadSubmitting = false //
if (this.$refs.uploadFile) { if (this.$refs.uploadFile) {
this.$refs.uploadFile.clearFiles() this.$refs.uploadFile.clearFiles()
} }

300
src/views/modules/eam/eamMaintenanceModel.vue

@ -41,7 +41,8 @@
<el-form-item label=" "> <el-form-item label=" ">
<el-button v-if="!authSearch" @click="getDataList()">查询</el-button> <el-button v-if="!authSearch" @click="getDataList()">查询</el-button>
<el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button> <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
<el-button type="primary" icon="el-icon-upload" @click="importExcel" style="margin-left: 2px">导入</el-button>
<el-button type="primary" icon="el-icon-upload" @click="importExcel" style="margin-left: 2px">导入模板</el-button>
<el-button type="primary" icon="el-icon-upload" @click="importItemExcel" style="margin-left: 2px">导入维保项目</el-button>
<el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button> <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
<el-button @click="exportDetailExcel()" type="primary" style="margin-left: 2px">{{'导出明细'}}</el-button> <el-button @click="exportDetailExcel()" type="primary" style="margin-left: 2px">{{'导出明细'}}</el-button>
<!-- <download-excel--> <!-- <download-excel-->
@ -428,8 +429,50 @@
<!-- 底部 --> <!-- 底部 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmUpload" size="medium">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium">关闭</el-button>
<el-button type="primary" @click="confirmUpload" size="medium" :disabled="uploadSubmitting">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium" :disabled="uploadSubmitting">关闭</el-button>
</span>
</el-dialog>
</template>
<!-- 导入维保项目对话框 -->
<template>
<el-dialog
title="维保项目清单导入"
:close-on-click-modal="false"
:visible.sync="uploadItemDialogVisible"
width="400px"
top="12vh"
class="simple-dialog"
@close="handleUploadItemDialogClose"
>
<div class="download-area">
<el-button type="primary" @click="downloadItemTemplate" size="medium" style="width: 40%;">
<i class="el-icon-download"></i> 下载文件模板
</el-button>
</div>
<!-- 文件上传 -->
<div>
<el-upload
class="upload-demo"
drag
action="javascript:void(0);"
ref="uploadItemFile"
:on-change="handleItemFileChange"
:auto-upload="false"
:limit="1"
accept=".xlsx,.xls"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
</el-upload>
</div>
<!-- 底部 -->
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmItemUpload" size="medium" :disabled="uploadItemSubmitting">保存</el-button>
<el-button @click="uploadItemDialogVisible = false" size="medium" :disabled="uploadItemSubmitting">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -455,6 +498,8 @@
goDownItemEam, goDownItemEam,
uploadEamMaintenanceModelExcel, // Excel uploadEamMaintenanceModelExcel, // Excel
downloadEamMaintenanceModelTemplate, // downloadEamMaintenanceModelTemplate, //
uploadEamMaintenanceItemDetailExcel, // Excel
downloadEamMaintenanceItemDetailTemplate //
} from "@/api/eam/eam.js" } from "@/api/eam/eam.js"
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
import Chooselist from '@/views/modules/common/Chooselist_eam' import Chooselist from '@/views/modules/common/Chooselist_eam'
@ -1252,6 +1297,12 @@
uploadFileName: '', uploadFileName: '',
uploadFile: null, uploadFile: null,
uploadBu: '', // BU uploadBu: '', // BU
uploadSubmitting: false, //
//
uploadItemDialogVisible: false,
uploadItemFileName: '',
uploadItemFile: null,
uploadItemSubmitting: false, //
} }
}, },
@ -1881,6 +1932,11 @@
// //
confirmUpload () { confirmUpload () {
//
if (this.uploadSubmitting) {
return
}
// BU // BU
if (!this.uploadBu || this.uploadBu === '') { if (!this.uploadBu || this.uploadBu === '') {
this.$message.warning('请先选择BU') this.$message.warning('请先选择BU')
@ -1898,6 +1954,9 @@
formData.append('site', this.uploadBu.split('_')[0]) // BUsite formData.append('site', this.uploadBu.split('_')[0]) // BUsite
formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo
//
this.uploadSubmitting = true
// //
uploadEamMaintenanceModelExcel(formData).then(({data}) => { uploadEamMaintenanceModelExcel(formData).then(({data}) => {
if (data.code === 0) { if (data.code === 0) {
@ -1912,12 +1971,104 @@
} }
this.getDataList() this.getDataList()
} else { } else {
this.$message.error(data.msg || '导入失败')
}
this.$alert(
(data.msg || '导入失败').replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}
}).catch((error) => { }).catch((error) => {
console.error('导入失败:', error) console.error('导入失败:', error)
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误' const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
this.$message.error('导入失败: ' + errorMsg)
this.$alert(
('导入失败: ' + errorMsg).replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}).finally(() => {
//
this.uploadSubmitting = false
})
},
//
importItemExcel () {
this.uploadItemDialogVisible = true
this.uploadItemFileName = ''
this.uploadItemFile = null
// el-upload
if (this.$refs.uploadItemFile) {
this.$refs.uploadItemFile.clearFiles()
}
},
//
handleItemFileChange (file) {
this.uploadItemFile = file.raw
this.uploadItemFileName = file.name
},
//
confirmItemUpload () {
//
if (this.uploadItemSubmitting) {
return
}
if (!this.uploadItemFile) {
this.$message.warning('请先选择文件')
return
}
const formData = new FormData()
formData.append('file', this.uploadItemFile)
formData.append('userId', this.$store.state.user.name)
//
this.uploadItemSubmitting = true
//
uploadEamMaintenanceItemDetailExcel(formData).then(({data}) => {
if (data.code === 0) {
this.$message.success(data.msg || '导入成功')
this.uploadItemDialogVisible = false
//
this.uploadItemFileName = ''
this.uploadItemFile = null
if (this.$refs.uploadItemFile) {
this.$refs.uploadItemFile.clearFiles()
}
this.getDataList()
} else {
this.$alert(
(data.msg || '导入失败').replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}
}).catch((error) => {
console.error('导入失败:', error)
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
this.$alert(
('导入失败: ' + errorMsg).replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}).finally(() => {
//
this.uploadItemSubmitting = false
}) })
}, },
@ -1990,10 +2141,85 @@
this.uploadFileName = '' this.uploadFileName = ''
this.uploadFile = null this.uploadFile = null
this.uploadBu = '' // BU this.uploadBu = '' // BU
this.uploadSubmitting = false //
if (this.$refs.uploadFile) { if (this.$refs.uploadFile) {
this.$refs.uploadFile.clearFiles() this.$refs.uploadFile.clearFiles()
} }
}, },
//
handleUploadItemDialogClose () {
this.uploadItemFileName = ''
this.uploadItemFile = null
this.uploadItemSubmitting = false //
if (this.$refs.uploadItemFile) {
this.$refs.uploadItemFile.clearFiles()
}
},
//
downloadItemTemplate () {
const loading = this.$loading({
lock: true,
text: '正在下载模板...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
// 使XMLHttpRequest,axios
const xhr = new XMLHttpRequest()
xhr.open('GET', this.$http.adornUrl('/pms/eam/downloadEamMaintenanceItemDetailTemplate'), true)
xhr.responseType = 'blob'
// token
const token = this.$cookie.get('token')
if (token) {
xhr.setRequestHeader('token', token)
}
xhr.onload = () => {
loading.close()
if (xhr.status === 200) {
const blob = xhr.response
// Blob
if (blob.size === 0) {
this.$message.error('模板文件为空,请联系管理员')
return
}
//
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '维保项目清单导入模板.xlsx'
link.style.display = 'none'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
// URL
setTimeout(() => {
window.URL.revokeObjectURL(url)
}, 100)
this.$message.success('模板下载成功')
} else {
console.error('模板下载失败,状态码:', xhr.status)
this.$message.error('模板下载失败:服务器错误')
}
}
xhr.onerror = () => {
loading.close()
console.error('网络错误')
this.$message.error('模板下载失败:网络错误')
}
xhr.send()
},
} }
} }
</script> </script>
@ -2003,37 +2229,69 @@
line-height: 1.5; line-height: 1.5;
} }
.simple-dialog >>> .el-dialog { .simple-dialog >>> .el-dialog {
margin-top: 12vh !important;
max-height: 70vh;
border-radius: 8px; border-radius: 8px;
} }
/* body顶格 */
.simple-dialog >>> .el-dialog__body { .simple-dialog >>> .el-dialog__body {
padding: 10px 20px;
max-height: calc(70vh - 120px);
overflow-y: auto;
padding: 0px 20px 10px 20px !important;
} }
/* 导入对话框内部元素靠左对齐 */
/* 内容不要额外缩进 */
.simple-dialog >>> .el-dialog__body > div { .simple-dialog >>> .el-dialog__body > div {
text-align: left;
margin-left: 0 !important;
}
/* 下载区域 */
.download-area {
margin-top: 0;
margin-bottom: 0;
}
/* 下载按钮 */
.download-btn {
width: 40%;
}
/* BU区域 */
.bu-area {
margin-top: 0;
margin-bottom: 5px;
} }
/* BU label */
.simple-dialog >>> .el-form-item__label { .simple-dialog >>> .el-form-item__label {
text-align: left !important;
padding-bottom: 0;
line-height: 22px;
} }
/* 上传拖拽区域大小调整 */
/* 去掉form自带间距 */
.simple-dialog >>> .el-form-item {
margin-bottom: 0;
}
/* 上传区域 */
.upload-demo {
margin-top: 0;
}
/* 上传框 */
.upload-demo .el-upload-dragger { .upload-demo .el-upload-dragger {
width: 100%; width: 100%;
height: 150px; height: 150px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
} }
.upload-demo .el-upload-dragger .el-icon-upload {
margin-bottom: 10px;
.simple-dialog >>> .el-dialog__body {
padding-left: 10px !important;
padding-right: 0 !important;
} }
</style> </style>

44
src/views/modules/eam/eamPropertiesItem.vue

@ -279,8 +279,8 @@
<!-- 底部 --> <!-- 底部 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmUpload" size="medium">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium">关闭</el-button>
<el-button type="primary" @click="confirmUpload" size="medium" :disabled="uploadSubmitting">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium" :disabled="uploadSubmitting">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -736,6 +736,7 @@
uploadFileName: '', uploadFileName: '',
uploadFile: null, uploadFile: null,
uploadBu: '', // BU uploadBu: '', // BU
uploadSubmitting: false, //
} }
}, },
@ -1215,6 +1216,11 @@
// //
confirmUpload () { confirmUpload () {
//
if (this.uploadSubmitting) {
return
}
// BU // BU
if (!this.uploadBu || this.uploadBu === '') { if (!this.uploadBu || this.uploadBu === '') {
this.$message.warning('请先选择BU') this.$message.warning('请先选择BU')
@ -1232,6 +1238,9 @@
formData.append('site', this.uploadBu.split('_')[0]) // BUsite formData.append('site', this.uploadBu.split('_')[0]) // BUsite
formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo
//
this.uploadSubmitting = true
// //
uploadEamPropertiesItemExcel(formData).then(({data}) => { uploadEamPropertiesItemExcel(formData).then(({data}) => {
if (data.code === 0) { if (data.code === 0) {
@ -1250,8 +1259,34 @@
} }
}).catch((error) => { }).catch((error) => {
console.error('导入失败:', error) console.error('导入失败:', error)
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
this.$message.error('导入失败: ' + errorMsg)
let errorMsg = ''
if (error.response && error.response.data) {
errorMsg = error.response.data.msg || error.response.data.message || ''
}
if (!errorMsg) {
errorMsg = error.message || '未知错误'
}
//
errorMsg = errorMsg
.replace(/\\n/g, '\n') //
.replace(/\n/g, '<br>') // html
this.$alert(
'导入失败:<br>' + errorMsg,
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true,
customClass: 'import-error-dialog'
}
)
}).finally(() => {
//
this.uploadSubmitting = false
}) })
}, },
@ -1312,6 +1347,7 @@
this.uploadFileName = '' this.uploadFileName = ''
this.uploadFile = null this.uploadFile = null
this.uploadBu = '' // BU this.uploadBu = '' // BU
this.uploadSubmitting = false //
if (this.$refs.uploadFile) { if (this.$refs.uploadFile) {
this.$refs.uploadFile.clearFiles() this.$refs.uploadFile.clearFiles()
} }

74
src/views/modules/eam/eamPropertiesModel.vue

@ -41,7 +41,7 @@
<el-form-item label=" "> <el-form-item label=" ">
<el-button v-if="!authSearch" @click="getDataList()">查询</el-button> <el-button v-if="!authSearch" @click="getDataList()">查询</el-button>
<el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button> <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
<el-button type="primary" icon="el-icon-upload" @click="importExcel" style="margin-left: 2px">导入</el-button>
<el-button type="primary" icon="el-icon-upload" @click="importExcel" style="margin-left: 2px">导入模板</el-button>
<el-button type="primary" icon="el-icon-upload" @click="importItemExcel" style="margin-left: 2px">导入点检项目</el-button> <el-button type="primary" icon="el-icon-upload" @click="importItemExcel" style="margin-left: 2px">导入点检项目</el-button>
<el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button> <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
<el-button @click="exportDetailExcel()" type="primary" style="margin-left: 2px">{{'导出明细'}}</el-button> <el-button @click="exportDetailExcel()" type="primary" style="margin-left: 2px">{{'导出明细'}}</el-button>
@ -406,8 +406,8 @@
<!-- 底部 --> <!-- 底部 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmUpload" size="medium">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium">关闭</el-button>
<el-button type="primary" @click="confirmUpload" size="medium" :disabled="uploadSubmitting">保存</el-button>
<el-button @click="uploadDialogVisible = false" size="medium" :disabled="uploadSubmitting">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -448,8 +448,8 @@
<!-- 底部 --> <!-- 底部 -->
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmItemUpload" size="medium">保存</el-button>
<el-button @click="uploadItemDialogVisible = false" size="medium">关闭</el-button>
<el-button type="primary" @click="confirmItemUpload" size="medium" :disabled="uploadItemSubmitting">保存</el-button>
<el-button @click="uploadItemDialogVisible = false" size="medium" :disabled="uploadItemSubmitting">关闭</el-button>
</span> </span>
</el-dialog> </el-dialog>
</template> </template>
@ -1273,11 +1273,13 @@
uploadFileName: '', uploadFileName: '',
uploadFile: null, uploadFile: null,
uploadBu: '', // BU uploadBu: '', // BU
uploadSubmitting: false, //
// //
uploadItemDialogVisible: false, uploadItemDialogVisible: false,
uploadItemFileName: '', uploadItemFileName: '',
uploadItemFile: null, uploadItemFile: null,
uploadItemBu: '', // BU uploadItemBu: '', // BU
uploadItemSubmitting: false, //
} }
}, },
@ -1871,6 +1873,11 @@
// //
confirmUpload () { confirmUpload () {
//
if (this.uploadSubmitting) {
return
}
// BU // BU
if (!this.uploadBu || this.uploadBu === '') { if (!this.uploadBu || this.uploadBu === '') {
this.$message.warning('请先选择BU') this.$message.warning('请先选择BU')
@ -1888,6 +1895,9 @@
formData.append('site', this.uploadBu.split('_')[0]) // BUsite formData.append('site', this.uploadBu.split('_')[0]) // BUsite
formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo formData.append('buNo', this.uploadBu.split('_')[1]) // BUbuNo
//
this.uploadSubmitting = true
// //
uploadEamPropertiesModelExcel(formData).then(({data}) => { uploadEamPropertiesModelExcel(formData).then(({data}) => {
if (data.code === 0) { if (data.code === 0) {
@ -1902,12 +1912,29 @@
} }
this.getDataList() this.getDataList()
} else { } else {
this.$message.error(data.msg || '导入失败')
}
this.$alert(
(data.msg || '导入失败').replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}
}).catch((error) => { }).catch((error) => {
console.error('导入失败:', error) console.error('导入失败:', error)
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误' const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
this.$message.error('导入失败: ' + errorMsg)
this.$alert(
('导入失败: ' + errorMsg).replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}).finally(() => {
//
this.uploadSubmitting = false
}) })
}, },
@ -1930,6 +1957,11 @@
// //
confirmItemUpload () { confirmItemUpload () {
//
if (this.uploadItemSubmitting) {
return
}
if (!this.uploadItemFile) { if (!this.uploadItemFile) {
this.$message.warning('请先选择文件') this.$message.warning('请先选择文件')
return return
@ -1939,6 +1971,9 @@
formData.append('file', this.uploadItemFile) formData.append('file', this.uploadItemFile)
formData.append('userId', this.$store.state.user.name) formData.append('userId', this.$store.state.user.name)
//
this.uploadItemSubmitting = true
// //
uploadEamPropertiesItemDetailExcel(formData).then(({data}) => { uploadEamPropertiesItemDetailExcel(formData).then(({data}) => {
if (data.code === 0) { if (data.code === 0) {
@ -1952,12 +1987,29 @@
} }
this.getDataList() this.getDataList()
} else { } else {
this.$message.error(data.msg || '导入失败')
this.$alert(
(data.msg || '导入失败').replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
} }
}).catch((error) => { }).catch((error) => {
console.error('导入失败:', error) console.error('导入失败:', error)
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误' const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误'
this.$message.error('导入失败: ' + errorMsg)
this.$alert(
('导入失败: ' + errorMsg).replace(/\n/g, '<br>'),
'导入结果',
{
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
}
)
}).finally(() => {
//
this.uploadItemSubmitting = false
}) })
}, },
@ -2094,6 +2146,7 @@
this.uploadFileName = '' this.uploadFileName = ''
this.uploadFile = null this.uploadFile = null
this.uploadBu = '' // BU this.uploadBu = '' // BU
this.uploadSubmitting = false //
if (this.$refs.uploadFile) { if (this.$refs.uploadFile) {
this.$refs.uploadFile.clearFiles() this.$refs.uploadFile.clearFiles()
} }
@ -2103,6 +2156,7 @@
handleUploadItemDialogClose () { handleUploadItemDialogClose () {
this.uploadItemFileName = '' this.uploadItemFileName = ''
this.uploadItemFile = null this.uploadItemFile = null
this.uploadItemSubmitting = false //
if (this.$refs.uploadItemFile) { if (this.$refs.uploadItemFile) {
this.$refs.uploadItemFile.clearFiles() this.$refs.uploadItemFile.clearFiles()
} }

Loading…
Cancel
Save