|
@ -82,7 +82,7 @@ |
|
|
<Icon icon="ep:download" /> |
|
|
<Icon icon="ep:download" /> |
|
|
{{ t('ts.下载模板') }} |
|
|
{{ t('ts.下载模板') }} |
|
|
</el-button> |
|
|
</el-button> |
|
|
<el-button type="primary" plain @click="importTemplate" v-if="active == 1"> |
|
|
<el-button type="primary" plain @click="downloadDifferenceData" v-if="active == 1"> |
|
|
<Icon icon="ep:download" /> |
|
|
<Icon icon="ep:download" /> |
|
|
{{ t('ts.下载差异数据') }} |
|
|
{{ t('ts.下载差异数据') }} |
|
|
</el-button> |
|
|
</el-button> |
|
@ -101,6 +101,7 @@ import download from '@/utils/download' |
|
|
import { getBaseUrl } from '@/utils/systemParam' |
|
|
import { getBaseUrl } from '@/utils/systemParam' |
|
|
import { UploadFilled, List, CircleCheckFilled,WarningFilled } from '@element-plus/icons-vue' |
|
|
import { UploadFilled, List, CircleCheckFilled,WarningFilled } from '@element-plus/icons-vue' |
|
|
import { waitForDebugger } from 'node:inspector/promises' |
|
|
import { waitForDebugger } from 'node:inspector/promises' |
|
|
|
|
|
import * as XLSX from 'xlsx'; |
|
|
|
|
|
|
|
|
defineOptions({ name: 'ImportForm' }) |
|
|
defineOptions({ name: 'ImportForm' }) |
|
|
|
|
|
|
|
@ -432,6 +433,37 @@ const importTemplate = () => { |
|
|
const res = importTemplateData.value.templateUrl |
|
|
const res = importTemplateData.value.templateUrl |
|
|
download.excel(res, importTemplateData.value.templateTitle) |
|
|
download.excel(res, importTemplateData.value.templateTitle) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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`); |
|
|
|
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
<style scoped lang="scss"> |
|
|