|
|
@ -42,6 +42,7 @@ |
|
|
<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--> |
|
|
@ -411,6 +412,48 @@ |
|
|
</el-dialog> |
|
|
</el-dialog> |
|
|
</template> |
|
|
</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">保存</el-button> |
|
|
|
|
|
<el-button @click="uploadItemDialogVisible = false" size="medium">关闭</el-button> |
|
|
|
|
|
</span> |
|
|
|
|
|
</el-dialog> |
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
@ -433,7 +476,9 @@ |
|
|
goDownItemEam, |
|
|
goDownItemEam, |
|
|
uploadEamPropertiesModelExcel, // 导入点检模板Excel |
|
|
uploadEamPropertiesModelExcel, // 导入点检模板Excel |
|
|
downloadEamPropertiesModelTemplate, // 下载点检模板导入模板 |
|
|
downloadEamPropertiesModelTemplate, // 下载点检模板导入模板 |
|
|
} from "@/api/eam/eam.js" |
|
|
|
|
|
|
|
|
uploadEamPropertiesItemDetailExcel, // 导入点检项目清单Excel |
|
|
|
|
|
downloadEamPropertiesItemDetailTemplate // 下载点检项目清单导入模板 |
|
|
|
|
|
} from '@/api/eam/eam.js' |
|
|
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" |
|
|
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" |
|
|
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js' |
|
|
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js' |
|
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|
|
@ -1228,6 +1273,11 @@ |
|
|
uploadFileName: '', |
|
|
uploadFileName: '', |
|
|
uploadFile: null, |
|
|
uploadFile: null, |
|
|
uploadBu: '', // 上传时选择的BU |
|
|
uploadBu: '', // 上传时选择的BU |
|
|
|
|
|
// 导入点检项目相关 |
|
|
|
|
|
uploadItemDialogVisible: false, |
|
|
|
|
|
uploadItemFileName: '', |
|
|
|
|
|
uploadItemFile: null, |
|
|
|
|
|
uploadItemBu: '', // 导入点检项目时选择的BU |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -1861,6 +1911,56 @@ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 导入点检项目 |
|
|
|
|
|
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.uploadItemFile) { |
|
|
|
|
|
this.$message.warning('请先选择文件') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const formData = new FormData() |
|
|
|
|
|
formData.append('file', this.uploadItemFile) |
|
|
|
|
|
formData.append('userId', this.$store.state.user.name) |
|
|
|
|
|
|
|
|
|
|
|
// 调用后端导入接口 |
|
|
|
|
|
uploadEamPropertiesItemDetailExcel(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.$message.error(data.msg || '导入失败') |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((error) => { |
|
|
|
|
|
console.error('导入失败:', error) |
|
|
|
|
|
const errorMsg = (error.response && error.response.data && error.response.data.msg) || error.message || '未知错误' |
|
|
|
|
|
this.$message.error('导入失败: ' + errorMsg) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
// 下载模板 |
|
|
// 下载模板 |
|
|
downloadTemplate () { |
|
|
downloadTemplate () { |
|
|
const loading = this.$loading({ |
|
|
const loading = this.$loading({ |
|
|
@ -1874,54 +1974,118 @@ |
|
|
const xhr = new XMLHttpRequest() |
|
|
const xhr = new XMLHttpRequest() |
|
|
xhr.open('GET', this.$http.adornUrl('/pms/eam/downloadEamPropertiesModelTemplate'), true) |
|
|
xhr.open('GET', this.$http.adornUrl('/pms/eam/downloadEamPropertiesModelTemplate'), true) |
|
|
xhr.responseType = 'blob' |
|
|
xhr.responseType = 'blob' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加token |
|
|
// 添加token |
|
|
const token = this.$cookie.get('token') |
|
|
const token = this.$cookie.get('token') |
|
|
if (token) { |
|
|
if (token) { |
|
|
xhr.setRequestHeader('token', token) |
|
|
xhr.setRequestHeader('token', token) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onload = () => { |
|
|
xhr.onload = () => { |
|
|
loading.close() |
|
|
loading.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (xhr.status === 200) { |
|
|
if (xhr.status === 200) { |
|
|
const blob = xhr.response |
|
|
const blob = xhr.response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 验证Blob大小 |
|
|
// 验证Blob大小 |
|
|
if (blob.size === 0) { |
|
|
if (blob.size === 0) { |
|
|
this.$message.error('模板文件为空,请联系管理员') |
|
|
this.$message.error('模板文件为空,请联系管理员') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建下载链接 |
|
|
// 创建下载链接 |
|
|
const url = window.URL.createObjectURL(blob) |
|
|
const url = window.URL.createObjectURL(blob) |
|
|
const link = document.createElement('a') |
|
|
const link = document.createElement('a') |
|
|
link.href = url |
|
|
link.href = url |
|
|
link.download = '点检模板导入模板.xlsx' |
|
|
link.download = '点检模板导入模板.xlsx' |
|
|
link.style.display = 'none' |
|
|
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() |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 下载点检项目模板 |
|
|
|
|
|
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/downloadEamPropertiesItemDetailTemplate'), 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) |
|
|
document.body.appendChild(link) |
|
|
link.click() |
|
|
link.click() |
|
|
document.body.removeChild(link) |
|
|
document.body.removeChild(link) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 释放URL对象 |
|
|
// 释放URL对象 |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
window.URL.revokeObjectURL(url) |
|
|
window.URL.revokeObjectURL(url) |
|
|
}, 100) |
|
|
}, 100) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$message.success('模板下载成功') |
|
|
this.$message.success('模板下载成功') |
|
|
} else { |
|
|
} else { |
|
|
console.error('模板下载失败,状态码:', xhr.status) |
|
|
console.error('模板下载失败,状态码:', xhr.status) |
|
|
this.$message.error('模板下载失败:服务器错误') |
|
|
this.$message.error('模板下载失败:服务器错误') |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.onerror = () => { |
|
|
xhr.onerror = () => { |
|
|
loading.close() |
|
|
loading.close() |
|
|
console.error('网络错误') |
|
|
console.error('网络错误') |
|
|
this.$message.error('模板下载失败:网络错误') |
|
|
this.$message.error('模板下载失败:网络错误') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xhr.send() |
|
|
xhr.send() |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -1934,6 +2098,15 @@ |
|
|
this.$refs.uploadFile.clearFiles() |
|
|
this.$refs.uploadFile.clearFiles() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 关闭点检项目上传对话框时清空文件 |
|
|
|
|
|
handleUploadItemDialogClose () { |
|
|
|
|
|
this.uploadItemFileName = '' |
|
|
|
|
|
this.uploadItemFile = null |
|
|
|
|
|
if (this.$refs.uploadItemFile) { |
|
|
|
|
|
this.$refs.uploadItemFile.clearFiles() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|