From ac67dcc5849a1e5a3940c01662d4b596b9c234a9 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 2 Apr 2025 16:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/views/flow/components/FieldExport.vue | 81 ++++++++++++++----- src/views/flow/list.vue | 94 +++++++++++++++++++++-- 3 files changed, 150 insertions(+), 27 deletions(-) diff --git a/src/App.vue b/src/App.vue index 9fb69fa..156cbe5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,7 +2,7 @@
- +
diff --git a/src/views/flow/components/FieldExport.vue b/src/views/flow/components/FieldExport.vue index 4ceb6cb..9a13d07 100644 --- a/src/views/flow/components/FieldExport.vue +++ b/src/views/flow/components/FieldExport.vue @@ -4,7 +4,7 @@ :z-index="zIndex" :value="isShow" show-footer - title="特殊日期" + title="导出" show-confirm-button :width="defaultModalSize.width" :height="defaultModalSize.height" @@ -26,9 +26,18 @@ {{ field.label }} - @@ -62,15 +71,20 @@ export default { config: { fields: [] }, + sub2ModelFields:[], fileName: `导出_${this.$moment().valueOf()}`, selectedFields: [], checkAll: false, isIndeterminate: false, + //子表单 + selectedFields2: [], + checkAll2: false, + isIndeterminate2: false, } }, computed: { mainFields() { - return this.config?.fields?.filter(i => i.type !== 'relation') + return this.config?.fields?.filter(i => i.type !== 'relation' && i.type !== 'file') }, relationsFields() { return this.config?.fields?.filter(i => i.type === 'relation') @@ -79,19 +93,29 @@ export default { methods: { handleCheckedFieldsChange(value) { let checkedCount = value.length; - this.checkAll = checkedCount === this.config?.fields?.length; + this.checkAll = checkedCount === this.mainFields?.length; this.isIndeterminate = checkedCount > 0 && checkedCount < this.config?.fields?.length; }, handleCheckAllChange(val) { - this.selectedFields = val ? this.config.fields?.map(i => i.name) : []; + this.selectedFields = val ? this.mainFields?.map(i => i.name) : []; this.isIndeterminate = false; }, + + handleCheckedFieldsChange2(value) { + let checkedCount = value.length; + this.checkAll2 = checkedCount === this.sub2ModelFields.length; + this.isIndeterminate2 = checkedCount > 0 && checkedCount < this.sub2ModelFields.length; + }, + handleCheckAllChange2(val) { + this.selectedFields2 = val ? this.sub2ModelFields?.map(i => i.name) : []; + this.isIndeterminate2 = false; + }, async getFields(id) { try { const { customModel } = await fieldConfig(id) this.config = customModel this.config.fields.forEach(i => { - i.name = 'data.' + i.name + i.name = i.name }) this.fileName = `${customModel.name}_${this.$moment().valueOf()}` } catch (err) { @@ -140,18 +164,33 @@ export default { return parts.join('&'); }; try { - let export_fields = {} - this.selectedFields?.forEach(field => { - let key = field - export_fields[key] = this.config?.fields?.find(j => j.name === key)?.label - }) - await download('/api/oa/flow/list-groups', 'get', { - ...this.select, - type: this.$route.params.type, - is_export: 1, - export_name: this.fileName, - export_fields - }, this.fileName+'.xlsx', paramsSerializer) + let export_fields = { + 'no':'编号' + } + if((this.selectedFields && this.selectedFields.length>0) || (this.selectedFields2 && this.selectedFields2.length>0)){ + this.selectedFields?.forEach(field => { + let key = field + export_fields[key] = this.config?.fields?.find(j => j.name === key)?.label + }) + if(this.selectedFields2 && this.selectedFields2.length>0){ + this.selectedFields2?.forEach(field => { + let key = field + export_fields[key] = this.sub2ModelFields?.find(j => j.name === key)?.label + }) + } + + await download(`/api/oa/flow/list/${this.$route.params.type}`, 'get', { + ...this.select, + type: this.$route.params.type, + is_export: 1, + export_name: this.fileName, + export_fields + }, this.fileName+'.xlsx', paramsSerializer) + }else{ + // this.$Message.warning("请选择需要导出的字段") + return + } + } catch (err) { console.error(err) } @@ -164,7 +203,7 @@ export default { } }, "select.custom_model_id"(newVal) { - this.getFields(newVal) + // this.getFields(newVal) } }, } diff --git a/src/views/flow/list.vue b/src/views/flow/list.vue index 701c599..c2643f2 100644 --- a/src/views/flow/list.vue +++ b/src/views/flow/list.vue @@ -25,6 +25,7 @@ filterable clearable size="small" + @change="changeModelId" v-model="select.custom_model_id" > + + + + + + + + + + 导出 @@ -131,7 +168,7 @@ :key="model.custom_model_id" :effect="select.custom_model_id === model.custom_model_id ? 'dark' : 'plain'" :type="['success', 'info', 'warning', 'danger'][index%4]" - @click="select.custom_model_id = model.custom_model_id,getList()"> + @click="select.custom_model_id = model.custom_model_id,getFields(model.custom_model_id),getList()"> {{ model.custom_model ? model.custom_model.name : '' }}{{ model.total }} @@ -504,12 +541,12 @@ - +