|
|
|
@ -1,5 +1,5 @@ |
|
|
|
<script> |
|
|
|
import {generateSiteId, getSiteList, removeSite, saveSite, updateSite} from '../../../api/factory/site' |
|
|
|
import {generateSiteId, getSiteList, removeSite, saveSite, updateSite, exportSite} from '../../../api/factory/site' |
|
|
|
import dayjs from 'dayjs' |
|
|
|
import { |
|
|
|
getTableDefaultListGroupLanguage, |
|
|
|
@ -109,6 +109,24 @@ export default { |
|
|
|
fixed: '', |
|
|
|
columnWidth: 120 |
|
|
|
}, |
|
|
|
{ |
|
|
|
userId: this.$store.state.user.name, |
|
|
|
functionId: 998001, |
|
|
|
serialNumber: '998001TableSiteCode', |
|
|
|
tableId: "998001Table", |
|
|
|
tableName: "Site Info Table", |
|
|
|
columnProp: "siteCode", |
|
|
|
headerAlign: "center", |
|
|
|
align: "left", |
|
|
|
columnLabel: "Site Code", |
|
|
|
columnHidden: false, |
|
|
|
columnImage: false, |
|
|
|
columnSortable: false, |
|
|
|
sortLv: 20, |
|
|
|
status: true, |
|
|
|
fixed: '', |
|
|
|
columnWidth: 80 |
|
|
|
}, |
|
|
|
{ |
|
|
|
userId: this.$store.state.user.name, |
|
|
|
functionId: 998001, |
|
|
|
@ -254,6 +272,7 @@ export default { |
|
|
|
columnWidth: 120 |
|
|
|
}, |
|
|
|
], |
|
|
|
exportLoading:false, |
|
|
|
countryList:[], |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -520,11 +539,56 @@ export default { |
|
|
|
}).catch((error)=>{ |
|
|
|
this.$message.error(error) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
handleExport(){ |
|
|
|
if (this.siteList.length === 0){ |
|
|
|
this.$message.warning('Site data does not exist') |
|
|
|
return |
|
|
|
} |
|
|
|
this.exportLoading = true; |
|
|
|
exportSite(this.site).then(response => { |
|
|
|
const contentType = response.headers['content-type']; |
|
|
|
if (contentType && contentType.includes('application/json')) { |
|
|
|
// 处理错误响应 |
|
|
|
const reader = new FileReader(); |
|
|
|
reader.onload = () => { |
|
|
|
const result = JSON.parse(reader.result); |
|
|
|
this.$message.warning(result.msg); |
|
|
|
}; |
|
|
|
reader.readAsText(response.data); |
|
|
|
this.exportLoading = false; |
|
|
|
} else if (response.status === 200){ |
|
|
|
const blob = new Blob([response.data], { type: response.headers['content-type'] }); |
|
|
|
const url = window.URL.createObjectURL(blob); |
|
|
|
const a = document.createElement('a'); |
|
|
|
a.href = url; |
|
|
|
// 解析后端返回的文件名 |
|
|
|
//const contentDisposition = response.headers['content-disposition']; |
|
|
|
//const fileName = contentDisposition ? decodeURIComponent(contentDisposition.split('filename*=utf-8')[1]) : 'pallet_data.xlsx'; |
|
|
|
a.download = "Site.xlsx"; |
|
|
|
document.body.appendChild(a); |
|
|
|
a.click(); |
|
|
|
document.body.removeChild(a); |
|
|
|
URL.revokeObjectURL(url); |
|
|
|
this.exportLoading = false; |
|
|
|
} |
|
|
|
}).catch((error)=>{ |
|
|
|
this.exportLoading = false; |
|
|
|
this.$message.error(error); |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch:{ |
|
|
|
'siteForm.siteCode'(newVal, oldVal){ |
|
|
|
this.siteForm.siteCode = newVal.toUpperCase() |
|
|
|
}, |
|
|
|
exportLoading(newVal,oldVal){ |
|
|
|
if (newVal === true){ |
|
|
|
setTimeout(()=>{ |
|
|
|
this.exportLoading = false |
|
|
|
},30000) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
created () { |
|
|
|
@ -556,6 +620,7 @@ export default { |
|
|
|
<el-form-item label=" "> |
|
|
|
<el-button type="primary" v-if="!ofComponent" @click="handleSave">New</el-button> |
|
|
|
<el-button type="primary" @click="getSiteList">Query</el-button> |
|
|
|
<el-button type="primary" :loading="exportLoading" icon="el-icon-printer" @click="handleExport">Export</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-table |
|
|
|
|