|
|
@ -43,6 +43,7 @@ |
|
|
<el-button type="primary" @click="queryHeader">查询</el-button> |
|
|
<el-button type="primary" @click="queryHeader">查询</el-button> |
|
|
<el-button type="primary" @click="resetQuery">重置</el-button> |
|
|
<el-button type="primary" @click="resetQuery">重置</el-button> |
|
|
<el-button type="primary" @click="openAddDialog">新增</el-button> |
|
|
<el-button type="primary" @click="openAddDialog">新增</el-button> |
|
|
|
|
|
<el-button type="primary" :loading="exportLoading" @click="exportFile">{{ exportLoading ? '导出中...' : '导出' }}</el-button> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
|
|
|
|
|
|
@ -257,6 +258,7 @@ import { getSiteAndBuByUserName } from '@/api/qc/qc.js' |
|
|
import { |
|
|
import { |
|
|
getHeaderList, |
|
|
getHeaderList, |
|
|
getDetailList, |
|
|
getDetailList, |
|
|
|
|
|
exportQcSubPart, |
|
|
queryAddMainList, |
|
|
queryAddMainList, |
|
|
queryAddDetailList, |
|
|
queryAddDetailList, |
|
|
saveAddRecord, |
|
|
saveAddRecord, |
|
|
@ -276,6 +278,7 @@ export default { |
|
|
headerLoading: false, |
|
|
headerLoading: false, |
|
|
detailLoading: false, |
|
|
detailLoading: false, |
|
|
addMainLoading: false, |
|
|
addMainLoading: false, |
|
|
|
|
|
exportLoading: false, |
|
|
headerList: [], |
|
|
headerList: [], |
|
|
detailList: [], |
|
|
detailList: [], |
|
|
currentHeader: null, |
|
|
currentHeader: null, |
|
|
@ -401,6 +404,52 @@ export default { |
|
|
this.headerLoading = false |
|
|
this.headerLoading = false |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
exportFile () { |
|
|
|
|
|
const payload = { |
|
|
|
|
|
...this.queryForm, |
|
|
|
|
|
site: this.extractSiteFromBuKey(this.queryForm.citemCode), |
|
|
|
|
|
searchFlag: 'Y' |
|
|
|
|
|
} |
|
|
|
|
|
this.exportLoading = true |
|
|
|
|
|
exportQcSubPart(payload).then((response) => { |
|
|
|
|
|
const blobData = response.data |
|
|
|
|
|
const contentType = String((response.headers && response.headers['content-type']) || blobData.type || '').toLowerCase() |
|
|
|
|
|
if (!blobData || blobData.size === 0) { |
|
|
|
|
|
this.$message.warning('无可导出数据') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (contentType.includes('application/json')) { |
|
|
|
|
|
const reader = new FileReader() |
|
|
|
|
|
reader.onload = () => { |
|
|
|
|
|
let msg = '无可导出数据' |
|
|
|
|
|
try { |
|
|
|
|
|
const json = JSON.parse(reader.result) |
|
|
|
|
|
if (json && json.msg) { |
|
|
|
|
|
msg = json.msg |
|
|
|
|
|
} |
|
|
|
|
|
} catch (e) {} |
|
|
|
|
|
this.$message.warning(msg) |
|
|
|
|
|
} |
|
|
|
|
|
reader.readAsText(blobData, 'utf-8') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
const blob = new Blob([blobData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) |
|
|
|
|
|
const fileName = `QC子件报表_${this.formatExportTimestamp(new Date())}.xlsx` |
|
|
|
|
|
const linkNode = document.createElement('a') |
|
|
|
|
|
linkNode.download = fileName |
|
|
|
|
|
linkNode.style.display = 'none' |
|
|
|
|
|
linkNode.href = URL.createObjectURL(blob) |
|
|
|
|
|
document.body.appendChild(linkNode) |
|
|
|
|
|
linkNode.click() |
|
|
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
|
|
document.body.removeChild(linkNode) |
|
|
|
|
|
this.$message.success('导出完成') |
|
|
|
|
|
}).catch(() => { |
|
|
|
|
|
this.$message.error('导出失败') |
|
|
|
|
|
}).finally(() => { |
|
|
|
|
|
this.exportLoading = false |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
onHeaderCurrentChange (row) { |
|
|
onHeaderCurrentChange (row) { |
|
|
this.currentHeader = row |
|
|
this.currentHeader = row |
|
|
if (!row) { |
|
|
if (!row) { |
|
|
@ -667,6 +716,15 @@ export default { |
|
|
const mm = '00' |
|
|
const mm = '00' |
|
|
return `${y}-${m}-${d} ${hh}:${mm}` |
|
|
return `${y}-${m}-${d} ${hh}:${mm}` |
|
|
}, |
|
|
}, |
|
|
|
|
|
formatExportTimestamp (date) { |
|
|
|
|
|
const y = date.getFullYear() |
|
|
|
|
|
const m = (`0${date.getMonth() + 1}`).slice(-2) |
|
|
|
|
|
const d = (`0${date.getDate()}`).slice(-2) |
|
|
|
|
|
const hh = (`0${date.getHours()}`).slice(-2) |
|
|
|
|
|
const mm = (`0${date.getMinutes()}`).slice(-2) |
|
|
|
|
|
const ss = (`0${date.getSeconds()}`).slice(-2) |
|
|
|
|
|
return `${y}${m}${d}${hh}${mm}${ss}` |
|
|
|
|
|
}, |
|
|
extractSiteFromBuKey (buKey) { |
|
|
extractSiteFromBuKey (buKey) { |
|
|
if (!buKey || buKey.indexOf('_') < 0) { |
|
|
if (!buKey || buKey.indexOf('_') < 0) { |
|
|
return this.$store.state.user.site |
|
|
return this.$store.state.user.site |
|
|
|