|
|
|
@ -123,7 +123,7 @@ |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="' '"> |
|
|
|
<el-button type="primary" @click="searchClick()">查询</el-button> |
|
|
|
<el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button> |
|
|
|
<el-button @click="exportExcel()" :loading="exportLoading" type="primary" style="margin-left: 2px">{{'导出'}}</el-button> |
|
|
|
<!-- <download-excel--> |
|
|
|
<!-- :fields="fields()"--> |
|
|
|
<!-- :data="exportData"--> |
|
|
|
@ -211,12 +211,12 @@ |
|
|
|
import { |
|
|
|
eamDefectRecordSearch, |
|
|
|
searchFileUrl, |
|
|
|
getSiteAndBuByUserName |
|
|
|
getSiteAndBuByUserName, |
|
|
|
eamDefectRecordExportExcel |
|
|
|
} from "@/api/eam/eam.js" |
|
|
|
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js" |
|
|
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|
|
|
import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js' |
|
|
|
import excel from "@/utils/excel-util.js"; |
|
|
|
export default { |
|
|
|
components: { |
|
|
|
Chooselist |
|
|
|
@ -235,13 +235,8 @@ export default { |
|
|
|
return { |
|
|
|
// 是否收藏 |
|
|
|
favorite: false, |
|
|
|
// 导出 start |
|
|
|
exportData: [], |
|
|
|
exportName: "设备维修记录" + this.dayjs().format('YYYYMMDDHHmmss'), |
|
|
|
exportHeader: ["设备维修记录"], |
|
|
|
exportFooter: [], |
|
|
|
exportList: [], |
|
|
|
// 导出 end |
|
|
|
// 导出加载 |
|
|
|
exportLoading: false, |
|
|
|
tagNo:'', |
|
|
|
searchData: { |
|
|
|
site: this.$store.state.user.site, |
|
|
|
@ -999,18 +994,43 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
async exportExcel() { |
|
|
|
this.searchData.limit = -1 |
|
|
|
this.searchData.page = 1 |
|
|
|
excel.exportTable({ |
|
|
|
url: "/pms/eam/eamDefectRecordSearch", |
|
|
|
columnMapping: this.columnList,//可以直接用table,不需要的列就剔除 |
|
|
|
mergeSetting: [],//需要合并的列 |
|
|
|
params: this.searchData, |
|
|
|
fileName: this.exportName+".xlsx", |
|
|
|
rowFetcher: res => res.data, |
|
|
|
columnFormatter: [], |
|
|
|
dropColumns: [],//需要剔除的列,例如dropColumns: ["netWeight"],即剔除净重列 |
|
|
|
}); |
|
|
|
if (this.exportLoading) return |
|
|
|
|
|
|
|
try { |
|
|
|
this.exportLoading = true |
|
|
|
|
|
|
|
const params = { |
|
|
|
...this.searchData, |
|
|
|
limit: -1, |
|
|
|
page: 1 |
|
|
|
} |
|
|
|
const response = await eamDefectRecordExportExcel(params) |
|
|
|
|
|
|
|
const now = new Date() |
|
|
|
const pad = n => n.toString().padStart(2, '0') |
|
|
|
const timeStr = |
|
|
|
now.getFullYear() + |
|
|
|
pad(now.getMonth() + 1) + |
|
|
|
pad(now.getDate()) + |
|
|
|
pad(now.getHours()) + |
|
|
|
pad(now.getMinutes()) + |
|
|
|
pad(now.getSeconds()) |
|
|
|
|
|
|
|
const fileName = `设备维修记录_${timeStr}.xlsx` |
|
|
|
const url = window.URL.createObjectURL(new Blob([response.data])) |
|
|
|
const link = document.createElement('a') |
|
|
|
link.href = url |
|
|
|
link.setAttribute('download', fileName) |
|
|
|
document.body.appendChild(link) |
|
|
|
link.click() |
|
|
|
link.remove() |
|
|
|
window.URL.revokeObjectURL(url) |
|
|
|
} catch (error) { |
|
|
|
console.error('导出失败:', error) |
|
|
|
this.$message.error('导出失败') |
|
|
|
} finally { |
|
|
|
this.exportLoading = false |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//导出excel |
|
|
|
|