From 9b3978ac1de6cd1b9fa05d9bf75147acb966f716 Mon Sep 17 00:00:00 2001
From: Zhufu <1176354795@qq.com>
Date: Tue, 11 Jun 2024 11:24:16 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=A1=A8=E5=8D=95=E5=8F=91=E5=B8=83?=
=?UTF-8?q?=E5=90=8E=E3=80=91=E8=A7=A3=E6=9E=90=E5=8D=A1=E7=89=87=E7=BB=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../demo/onlineform/formCall/CallModal.vue | 57 +++++++++++++++++++
src/views/demo/onlineform/formCall/index.vue | 12 ++--
2 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/src/views/demo/onlineform/formCall/CallModal.vue b/src/views/demo/onlineform/formCall/CallModal.vue
index 4f73780d..1497e85c 100644
--- a/src/views/demo/onlineform/formCall/CallModal.vue
+++ b/src/views/demo/onlineform/formCall/CallModal.vue
@@ -20,6 +20,12 @@
@click="codeClickFunction('beforeSetData', beforeSetData)"
@change="codeClickFunction('changeDataEvent', changeDataEvent)"
/>
+
@@ -51,6 +57,14 @@
+
+
+
@@ -107,6 +121,10 @@
import { v4 as uuidv4 } from 'uuid';
import FormItem from './ShowFormModal/FormItem/index.vue';
import CallModalFormItem from './CallModalFormItem/index.vue';
+ import { CardGourp } from '@/components/FormViewer/index.ts'
+ import { subTableStore } from '@/store/modules/subTable';
+
+ const subTableDataStore = subTableStore();
// import FormRender from '@/views/demo/form-design/components/VFormCreate/components/FormRender.vue';
@@ -127,6 +145,9 @@
userId: userInfo.id,
title: '',
});
+ const cardGroupData = ref([]);
+ const cardGourpFormData = ref({});
+ const cardGroupValues = ref({})
const subTableId = ref(null);
const subTableColumns: any = ref([]);
const subTableData = ref([]);
@@ -153,8 +174,22 @@
}
});
};
+ const getCardGroupLayoutKey = (dataList) => {
+ console.log('dataList',dataList)
+ dataList.children.forEach((item?) => {
+ if (['CardGroup'].includes(item.component)) {
+ cardGroupValues.value[item.field] = ""
+ item.componentProps.options.forEach(childItem => {
+ getCardGroupLayoutKey(childItem);
+ })
+ }else{
+ cardGroupValues.value[item.field] = "";
+ }
+ })
+ }
const [registerModal, { setModalProps, closeModal }] = useModalInner((data: any) => {
cardLayout.value = [];
+ subTableDataStore.clearGoupData();
console.log('daaaaa', data);
// 脚本
beforeSetData.value = data?.beforeSetData;
@@ -181,6 +216,12 @@
if (opt.component === 'Card') {
cardLayout.value.push(opt);
}
+ if (opt.component === 'CardGroup') {
+ if(cardGroupData.value.length !== index){
+ cardGroupData.value.push(null)
+ }
+ cardGroupData.value.push(opt);
+ }
if (opt.component === 'Button') {
buttonLayout.value.push(opt);
}
@@ -279,6 +320,13 @@
if (item.component === 'Card') {
cardLayout.value.push(item);
}
+ if (item.component === 'CardGroup') {
+ cardGroupValues.value[item.field] = "";
+ item.componentProps.options.forEach(childItem => {
+ getCardGroupLayoutKey(childItem)
+ })
+ cardGroupData.value.push(item);
+ }
if (item.component === 'Button') {
buttonLayout.value.push(item);
}
@@ -350,6 +398,10 @@
});
});
}
+ Object.keys(cardGroupValues.value).forEach(item => {
+ cardGroupValues.value[item] = data.infoUseMainTableData[item]
+ })
+ subTableDataStore.setGroupData(cardGroupValues.value)
}
if (!unref(isUpdate) && unref(isDetail)) {
getTitle.value = '详情';
@@ -369,6 +421,10 @@
});
});
}
+ Object.keys(cardGroupValues.value).forEach(item => {
+ cardGroupValues.value[item] = data.infoUseMainTableData[item]
+ })
+ subTableDataStore.setGroupData(cardGroupValues.value)
}
formModalVisible.value = true;
primaryQuery.value = data.query;
@@ -504,6 +560,7 @@
}
});
}
+ query = {...query, ...subTableDataStore.getGroupData}
params.data = JSON.stringify(query);
console.log('query222', query);
console.log('params222', params);
diff --git a/src/views/demo/onlineform/formCall/index.vue b/src/views/demo/onlineform/formCall/index.vue
index 02c4905e..d5400d60 100644
--- a/src/views/demo/onlineform/formCall/index.vue
+++ b/src/views/demo/onlineform/formCall/index.vue
@@ -573,7 +573,7 @@
let formObj = JSON.parse(res.formScheme.scheme);
console.log('formObj', formObj);
// 将card嵌套起来
- if (formObj.formInfo.tabList && formObj.formInfo.tabList.length > 1) {
+ if (formObj.formInfo.tabList && formObj.formInfo.tabList.length > 0) {
formObj.formInfo.tabList = cardNestStructure(formObj.formInfo.tabList);
const arr: any = [];
formObj.formInfo.tabList.forEach((item, index) => {
@@ -730,24 +730,24 @@
};
getFormData(params)
.then((res) => {
- let childTableName = designData.value.db.find((item) => item.type === 'chlid').name;
+ let childTableName = designData.value.db.find((item) => item.type === 'chlid')?.name;
let mainTableName = designData.value.db.find((item) => item.type === 'main').name;
- let subTableData = res[childTableName].map((item) => {
+ let subTableData = res[childTableName]? res[childTableName].map((item) => {
return {
...item,
key: uuidv4(),
MapGeom: item.mapgeom,
};
- });
+ }): [];
formData.value = [...subTableData];
- infoUseSubTableData.value = res[childTableName].map((item) => {
+ infoUseSubTableData.value = res[childTableName]? res[childTableName].map((item) => {
return {
...item,
key: uuidv4(),
};
- });
+ }): [];
res[mainTableName].forEach((item) => {
infoUseMainTableData.value = { ...infoUseMainTableData.value, ...item };