diff --git a/src/views/demo/onlineform/formCall/index.vue b/src/views/demo/onlineform/formCall/index.vue index 94e02562..435e43d8 100644 --- a/src/views/demo/onlineform/formCall/index.vue +++ b/src/views/demo/onlineform/formCall/index.vue @@ -97,6 +97,7 @@ // import MapboxMap from '@/components/MapboxMaps/MapComponent.vue' import ShowFormModal from './ShowFormModal/index.vue'; import { v4 as uuidv4 } from 'uuid'; + import { cardNestStructure } from '@/views/demo/onlineform/util.ts' const MapboxMap = defineAsyncComponent(() => import('@/components/MapboxMaps/MapComponent.vue')); @@ -566,6 +567,8 @@ let columnObj = JSON.parse(res.entity.scheme); let formObj = JSON.parse(res.formScheme.scheme); console.log('formObj', formObj); + // 将card嵌套起来 + formObj.formInfo.tabList = cardNestStructure(formObj.formInfo.tabList) if (formObj.formInfo.tabList && formObj.formInfo.tabList.length > 1) { const arr: any = []; formObj.formInfo.tabList.forEach((item, index) => { diff --git a/src/views/demo/onlineform/util.ts b/src/views/demo/onlineform/util.ts new file mode 100644 index 00000000..d95dc73f --- /dev/null +++ b/src/views/demo/onlineform/util.ts @@ -0,0 +1,28 @@ +export const cardNestStructure = (data) => { + let childList = {} + let result = [] + data.forEach(item => { + if(item.schemas){ + item.schemas = cardNestStructure(item.schemas) + result.push(item) + }else if(item.ptype){ + let pushItem = {} + Object.keys(item).forEach(key => { + if(key !== 'ptype' && key !== 'pfield'){ + pushItem[key] = item[key] + } + }) + if(childList[item.pfield]){ + childList[item.pfield].push(pushItem) + }else{ + childList[item.pfield] = [pushItem] + } + }else if(item.component === 'Card'){ + item.columns[0].children = childList[item.field] + result.push(item) + }else{ + result.push(item) + } + }) + return result +} \ No newline at end of file