|
|
@ -150,24 +150,14 @@ |
|
|
@click="freezeStatus"> |
|
|
@click="freezeStatus"> |
|
|
冻结 |
|
|
冻结 |
|
|
</el-button> |
|
|
</el-button> |
|
|
<download-excel |
|
|
|
|
|
:fields="exportFields()" |
|
|
|
|
|
:data="exportData" |
|
|
|
|
|
type="xls" |
|
|
|
|
|
:name="exportName" |
|
|
|
|
|
:header="exportHeader" |
|
|
|
|
|
:footer="exportFooter" |
|
|
|
|
|
:fetch="createExportData" |
|
|
|
|
|
:before-generate="startDownload" |
|
|
|
|
|
:before-finish="finishDownload" |
|
|
|
|
|
worksheet="实时库存数据" |
|
|
|
|
|
class="export-btn"> |
|
|
|
|
|
<el-button |
|
|
<el-button |
|
|
|
|
|
class="export-btn" |
|
|
type="success" |
|
|
type="success" |
|
|
icon="el-icon-download"> |
|
|
|
|
|
|
|
|
icon="el-icon-download" |
|
|
|
|
|
:loading="exportLoading" |
|
|
|
|
|
@click="exportInventoryData"> |
|
|
导出 |
|
|
导出 |
|
|
</el-button> |
|
|
</el-button> |
|
|
</download-excel> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</el-col> |
|
|
</el-col> |
|
|
@ -525,6 +515,7 @@ import {rollPrint} from '@/api/finishedProductWarehouse/rollPrint.js' |
|
|
import { |
|
|
import { |
|
|
getInboundQcResultData, |
|
|
getInboundQcResultData, |
|
|
getKuCunLabelData, |
|
|
getKuCunLabelData, |
|
|
|
|
|
exportKuCunLabelData, |
|
|
updateInventoryStockAttribute, |
|
|
updateInventoryStockAttribute, |
|
|
getWarehouseList, |
|
|
getWarehouseList, |
|
|
freezeStatusInventoryStock, |
|
|
freezeStatusInventoryStock, |
|
|
@ -992,10 +983,7 @@ export default { |
|
|
printLoading: false, |
|
|
printLoading: false, |
|
|
multiPartNoTip: '', |
|
|
multiPartNoTip: '', |
|
|
// 导出相关 |
|
|
// 导出相关 |
|
|
exportData: [], |
|
|
|
|
|
exportName: "实时库存数据", |
|
|
exportName: "实时库存数据", |
|
|
exportHeader: ["实时库存数据"], |
|
|
|
|
|
exportFooter: [], |
|
|
|
|
|
exportLoading: false |
|
|
exportLoading: false |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -1518,31 +1506,47 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 导出相关方法 |
|
|
// 导出相关方法 |
|
|
exportFields() { |
|
|
|
|
|
let json = {} |
|
|
|
|
|
this.columnList.forEach((item) => { |
|
|
|
|
|
json[item.columnLabel] = item.columnProp |
|
|
|
|
|
}) |
|
|
|
|
|
return json |
|
|
|
|
|
}, |
|
|
|
|
|
async createExportData() { |
|
|
|
|
|
// 构建查询参数,获取所有数据(不分页) |
|
|
|
|
|
|
|
|
async exportInventoryData() { |
|
|
|
|
|
this.startDownload() |
|
|
const params = { |
|
|
const params = { |
|
|
...this.searchData, |
|
|
|
|
|
page: 1, |
|
|
|
|
|
limit: 999999 // 获取所有数据 |
|
|
|
|
|
|
|
|
...this.searchData |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
const {data} = await getKuCunLabelData(params) |
|
|
|
|
|
if (data.code === 0) { |
|
|
|
|
|
return data.page.list || [] |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$message.error('获取导出数据失败') |
|
|
|
|
|
return [] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const response = await exportKuCunLabelData(params) |
|
|
|
|
|
const fileBlob = response && response.data ? response.data : null |
|
|
|
|
|
if (!fileBlob || fileBlob.size === 0) { |
|
|
|
|
|
throw new Error('导出文件为空') |
|
|
|
|
|
} |
|
|
|
|
|
const contentType = fileBlob.type || '' |
|
|
|
|
|
if (contentType.indexOf('application/json') > -1) { |
|
|
|
|
|
const text = await fileBlob.text() |
|
|
|
|
|
let errMsg = '导出失败' |
|
|
|
|
|
try { |
|
|
|
|
|
const json = JSON.parse(text) |
|
|
|
|
|
errMsg = json.msg || json.message || errMsg |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
errMsg = text || errMsg |
|
|
|
|
|
} |
|
|
|
|
|
throw new Error(errMsg) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const disposition = response.headers && response.headers['content-disposition'] |
|
|
|
|
|
const defaultFileName = `${this.exportName}.xlsx` |
|
|
|
|
|
const fileName = this.parseDownloadFileName(disposition) || defaultFileName |
|
|
|
|
|
const linkNode = document.createElement('a') |
|
|
|
|
|
const url = URL.createObjectURL(fileBlob) |
|
|
|
|
|
linkNode.href = url |
|
|
|
|
|
linkNode.download = fileName |
|
|
|
|
|
linkNode.style.display = 'none' |
|
|
|
|
|
document.body.appendChild(linkNode) |
|
|
|
|
|
linkNode.click() |
|
|
|
|
|
document.body.removeChild(linkNode) |
|
|
|
|
|
URL.revokeObjectURL(url) |
|
|
|
|
|
this.$message.success('导出成功') |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
this.$message.error('获取导出数据失败:' + error.message) |
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
this.$message.error('导出失败:' + (error.message || '请稍后重试')) |
|
|
|
|
|
} finally { |
|
|
|
|
|
this.finishDownload() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
startDownload() { |
|
|
startDownload() { |
|
|
@ -1561,6 +1565,28 @@ export default { |
|
|
this._exportLoadingInstance.close() |
|
|
this._exportLoadingInstance.close() |
|
|
this._exportLoadingInstance = null |
|
|
this._exportLoadingInstance = null |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
parseDownloadFileName(disposition) { |
|
|
|
|
|
if (!disposition) { |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
let fileName = '' |
|
|
|
|
|
const utf8Match = disposition.match(/filename\*=UTF-8''([^;]+)/i) |
|
|
|
|
|
if (utf8Match && utf8Match[1]) { |
|
|
|
|
|
fileName = utf8Match[1] |
|
|
|
|
|
} else { |
|
|
|
|
|
const normalMatch = disposition.match(/filename="?([^"]+)"?/i) |
|
|
|
|
|
fileName = normalMatch && normalMatch[1] ? normalMatch[1] : '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!fileName) { |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
return decodeURIComponent(fileName) |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
return fileName |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
|