|
|
@ -83,9 +83,11 @@ |
|
|
|
<Icon icon="ep:download" /> |
|
|
|
{{ t('ts.下载模板') }} |
|
|
|
</el-button> |
|
|
|
<el-button type="primary" plain @click="downloadDifferenceData" v-if="active == 1 && error"> |
|
|
|
<Icon icon="ep:download" /> |
|
|
|
{{ t('ts.差异数据') }} |
|
|
|
<el-button type="primary" plain @click="downloadDifferenceData" v-if="active == 1 && error"> |
|
|
|
{{ t('ts.下载差异数据') }} |
|
|
|
</el-button> |
|
|
|
<el-button type="primary" plain @click="differentialAdjustment" v-if="active == 1 && error"> |
|
|
|
{{ t('ts.差异调整') }} |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
<el-button :disabled="formLoading || isShowLoading" type="primary" @click="submitForm" v-if="active == 0 || (active == 1 && !error)">{{ t('ts.下一步') }}</el-button> |
|
|
@ -690,36 +692,43 @@ const importTemplate = () => { |
|
|
|
const searchTableSuccess = (formField, searchField, val, type, row) => { |
|
|
|
emits('searchTableSuccess', formField, searchField, val, formRef.value, type, row) |
|
|
|
} |
|
|
|
|
|
|
|
const downloadDifferenceData = () => { |
|
|
|
// 下载差异数据 |
|
|
|
const downloadDifferenceData = () => { |
|
|
|
if (props.tableObject.tableList.length === 0) { |
|
|
|
message.warning('没有可下载的差异数据'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// // 获取当前使用的列定义 |
|
|
|
// const columns = currentColumns.value; |
|
|
|
|
|
|
|
// // 创建工作簿和工作表,使用原始数据 |
|
|
|
// const wb = XLSX.utils.book_new(); |
|
|
|
// const ws = XLSX.utils.json_to_sheet(props.tableObject.tableList); |
|
|
|
|
|
|
|
// // 替换表头为中文; |
|
|
|
// columns.forEach((col, index) => { |
|
|
|
// const cellAddress = XLSX.utils.encode_cell({ r: 0, c: index }); |
|
|
|
// if (ws[cellAddress]) { |
|
|
|
// ws[cellAddress].v = col.label; |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
// // 设置列宽(可选) |
|
|
|
// const colWidth = columns.map(() => ({ wch: 20 })); |
|
|
|
// ws['!cols'] = colWidth; |
|
|
|
|
|
|
|
// // 添加工作表到工作簿并下载 |
|
|
|
// XLSX.utils.book_append_sheet(wb, ws, "差异数据"); |
|
|
|
// const timestamp = new Date().getTime(); |
|
|
|
// XLSX.writeFile(wb, `差异数据_${timestamp}.xlsx`); |
|
|
|
// 获取当前使用的列定义 |
|
|
|
const columns = currentColumns.value; |
|
|
|
|
|
|
|
// 创建工作簿和工作表,使用原始数据 |
|
|
|
const wb = XLSX.utils.book_new(); |
|
|
|
const ws = XLSX.utils.json_to_sheet(props.tableObject.tableList); |
|
|
|
|
|
|
|
// 替换表头为中文; |
|
|
|
columns.forEach((col, index) => { |
|
|
|
const cellAddress = XLSX.utils.encode_cell({ r: 0, c: index }); |
|
|
|
if (ws[cellAddress]) { |
|
|
|
ws[cellAddress].v = col.label; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 设置列宽(可选) |
|
|
|
const colWidth = columns.map(() => ({ wch: 20 })); |
|
|
|
ws['!cols'] = colWidth; |
|
|
|
|
|
|
|
// 添加工作表到工作簿并下载 |
|
|
|
XLSX.utils.book_append_sheet(wb, ws, "差异数据"); |
|
|
|
const timestamp = new Date().getTime(); |
|
|
|
XLSX.writeFile(wb, `差异数据_${timestamp}.xlsx`); |
|
|
|
} |
|
|
|
// 差异调整 |
|
|
|
const differentialAdjustment = () => { |
|
|
|
if (props.tableObject.tableList.length === 0) { |
|
|
|
message.warning('没有差异数据'); |
|
|
|
return; |
|
|
|
} |
|
|
|
const list = props.tableObject.tableList.map(item => { |
|
|
|
return { |
|
|
|
materialCode: item.materialCode, |
|
|
|