|
|
@ -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]) // 从BU中提取site |
|
|
formData.append('site', this.uploadBu.split('_')[0]) // 从BU中提取site |
|
|
formData.append('buNo', this.uploadBu.split('_')[1]) // 从BU中提取buNo |
|
|
formData.append('buNo', this.uploadBu.split('_')[1]) // 从BU中提取buNo |
|
|
|
|
|
|
|
|
|
|
|
// 设置提交状态 |
|
|
|
|
|
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> |