From fcda0fd663b49460cec95b30459e83515ff4886c Mon Sep 17 00:00:00 2001 From: han2015 <1019850453@qq.com> Date: Fri, 25 Jul 2025 11:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtable=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DesignForm/app/index.vue | 10 ++++++---- src/components/DesignForm/exportPanel.vue | 16 +++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/components/DesignForm/app/index.vue b/src/components/DesignForm/app/index.vue index 35a4b74..aa038be 100644 --- a/src/components/DesignForm/app/index.vue +++ b/src/components/DesignForm/app/index.vue @@ -993,7 +993,7 @@ const getPageData = () => { //表单导入 function doImportTableData(){ dynamicVNode.value=h(importPanel,{ - fields:props.fieldsDetailList, + fields:props.fieldsDetailList.filter(val=>val.type!=="table"), formId:props.versionid, commitFunc:()=>{ getPageData() //刷新table页面 @@ -1033,7 +1033,8 @@ function doExportTableData(){ let maxline=0; //写主表列 for (let val of fields){ - line.push((item[val.field] as string).replaceAll(",",",")) + if(typeof(val)==="string") line.push((item[val.field] as string).replaceAll(",",",")) + else line.push(item[val.field]) } //写子表列 @@ -1080,7 +1081,7 @@ function doExportTableData(){ }) //去掉标题行的统计 - if((array.length-1)!==datas.total) alert(`实际数据总量:${datas.total}, 导出数据总量:${array.length}`) + if((array.length-1)!==datas.total) alert(`导出记录数:${datas.total}, 共计:${array.length-1} 行`) const filename= props.pickAppMenu.label+".csv" const csvString = array.join('\n'); @@ -1100,7 +1101,8 @@ function doExportTableData(){ } dynamicVNode.value=h(exportPanel,{ - fields:columnsFilter.value, + fields:columnsFilter.value.filter((item)=>item.pattern!=="table"), + subtabs:columnsFilter.value.filter((item)=>item.pattern==="table"), subFields:subTableFieldsFilter.value.fields, commitFunc:exportFunc, closeFunc:()=>dynamicVNode.value=null diff --git a/src/components/DesignForm/exportPanel.vue b/src/components/DesignForm/exportPanel.vue index a6930ba..39ecf48 100644 --- a/src/components/DesignForm/exportPanel.vue +++ b/src/components/DesignForm/exportPanel.vue @@ -4,6 +4,7 @@ import { ElDialog } from 'element-plus'; const props = withDefaults(defineProps<{ fields:any[], + subtabs:any[], subFields:any[], commitFunc:(fields:{field:string,label:string}[],subs:{table:string,field:string,label:string}[])=>void, closeFunc:()=>void, //父级只需销毁组件 @@ -14,15 +15,19 @@ const checkList=ref([]) //子表字段 const subCheckList=ref([]) +//优化:用来按子表显示子表自动 +const subTables=ref([]) + onMounted(()=>{ props.fields.forEach((val)=>{ - if (val.attribute===''){ + if (val.attribute==='' && val.type!=""){ checkList.value.push(val.field) } }) + //初始化子表的字段 props.subFields.forEach((val)=>{ - subCheckList.value.push(val.field) + subCheckList.value.push(val.field) }) }) @@ -37,6 +42,7 @@ function handleData(){ //收集子表需要导出的字段 props.subFields.forEach((val)=>{ + if(subCheckList.value.includes(val.field)){ sub.push(val) } @@ -55,10 +61,10 @@ function handleData(){ -
-

请选择子表导出的字段

+
+

{{ tab.label }} : 表导出的字段

- +