【卡片布局】发布后获取数据后将card组件嵌套
parent
5548c1293b
commit
109d7fbdf3
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue