fix: 处理表单设计器右侧属性配置面板表单不展示问题
parent
5c89365c44
commit
c5811b82b8
|
@ -14,6 +14,7 @@ import {
|
||||||
import { formItemsForEach, remove } from '../../../utils'
|
import { formItemsForEach, remove } from '../../../utils'
|
||||||
import type { IBaseFormAttrs } from '../config/formItemPropsConfig'
|
import type { IBaseFormAttrs } from '../config/formItemPropsConfig'
|
||||||
import FormOptions from './FormOptions.vue'
|
import FormOptions from './FormOptions.vue'
|
||||||
|
import { componentMap } from '../../../../../Form/src/componentMap.ts'
|
||||||
|
|
||||||
const { formConfig } = useFormDesignState()
|
const { formConfig } = useFormDesignState()
|
||||||
// 让compuated属性自动更新
|
// 让compuated属性自动更新
|
||||||
|
@ -106,6 +107,10 @@ const inputOptions = computed(() => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const Com = computed(() => {
|
||||||
|
return com => componentMap.get(com) as ReturnType<typeof defineComponent>
|
||||||
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => formConfig.value.currentItem!.componentProps,
|
() => formConfig.value.currentItem!.componentProps,
|
||||||
() => {
|
() => {
|
||||||
|
@ -133,7 +138,7 @@ const linkOptions = computed(() => {
|
||||||
<div v-if="formConfig.currentItem" class="properties-body">
|
<div v-if="formConfig.currentItem" class="properties-body">
|
||||||
<Empty v-if="!formConfig.currentItem.key" class="hint-box" description="未选择组件" />
|
<Empty v-if="!formConfig.currentItem.key" class="hint-box" description="未选择组件" />
|
||||||
|
|
||||||
<Form label-align="left" layout="vertical">
|
<aForm label-align="left" layout="vertical">
|
||||||
<!-- 循环遍历渲染组件属性 -->
|
<!-- 循环遍历渲染组件属性 -->
|
||||||
|
|
||||||
<div v-if="formConfig.currentItem && formConfig.currentItem.componentProps">
|
<div v-if="formConfig.currentItem && formConfig.currentItem.componentProps">
|
||||||
|
@ -144,7 +149,7 @@ const linkOptions = computed(() => {
|
||||||
<template v-for="(child, index) of item.children" :key="index">
|
<template v-for="(child, index) of item.children" :key="index">
|
||||||
<component
|
<component
|
||||||
v-bind="child.componentProps"
|
v-bind="child.componentProps"
|
||||||
:is="child.component"
|
:is="Com(child.component)"
|
||||||
v-if="child.component"
|
v-if="child.component"
|
||||||
v-model:value="formConfig.currentItem.componentProps[item.name][index]"
|
v-model:value="formConfig.currentItem.componentProps[item.name][index]"
|
||||||
/>
|
/>
|
||||||
|
@ -152,7 +157,7 @@ const linkOptions = computed(() => {
|
||||||
</div>
|
</div>
|
||||||
<!-- 如果不是数组,则正常处理属性值 -->
|
<!-- 如果不是数组,则正常处理属性值 -->
|
||||||
<component
|
<component
|
||||||
v-bind="item.componentProps" :is="item.component" v-else-if="item.component"
|
v-bind="item.componentProps" :is="Com(item.component)" v-else-if="item.component"
|
||||||
v-model:value="formConfig.currentItem.componentProps[item.name]" class="component-prop"
|
v-model:value="formConfig.currentItem.componentProps[item.name]" class="component-prop"
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
@ -188,7 +193,7 @@ const linkOptions = computed(() => {
|
||||||
<FormItem v-if="['Grid'].includes(formConfig.currentItem.component)" label="栅格">
|
<FormItem v-if="['Grid'].includes(formConfig.currentItem.component)" label="栅格">
|
||||||
<FormOptions />
|
<FormOptions />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</aForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
* @Description: 表单项属性
|
* @Description: 表单项属性
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Empty, Form, FormItem } from 'ant-design-vue'
|
import {computed, defineComponent} from 'vue'
|
||||||
|
import { Empty, Form, FormItem, } from 'ant-design-vue'
|
||||||
import { isArray } from 'lodash-es'
|
import { isArray } from 'lodash-es'
|
||||||
import { baseItemColumnProps } from '../config/formItemPropsConfig'
|
import { baseItemColumnProps } from '../config/formItemPropsConfig'
|
||||||
|
|
||||||
import { useFormDesignState } from '../../../hooks/useFormDesignState'
|
import { useFormDesignState } from '../../../hooks/useFormDesignState'
|
||||||
|
import { componentMap } from '../../../../../Form/src/componentMap.ts'
|
||||||
|
|
||||||
const { formConfig } = useFormDesignState()
|
const { formConfig } = useFormDesignState()
|
||||||
function showProps(exclude: string[] | undefined) {
|
function showProps(exclude: string[] | undefined) {
|
||||||
|
@ -15,22 +17,28 @@ function showProps(exclude: string[] | undefined) {
|
||||||
|
|
||||||
return isArray(exclude) ? !exclude.includes(formConfig.value.currentItem!.component) : true
|
return isArray(exclude) ? !exclude.includes(formConfig.value.currentItem!.component) : true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Com = computed(() => {
|
||||||
|
return com => componentMap.get(com) as ReturnType<typeof defineComponent>
|
||||||
|
})
|
||||||
|
console.log(baseItemColumnProps);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="properties-content">
|
<div class="properties-content">
|
||||||
<div v-if="formConfig.currentItem" class="properties-body">
|
<div v-if="formConfig.currentItem" class="properties-body">
|
||||||
<Empty v-if="!formConfig.currentItem.key" class="hint-box" description="未选择控件" />
|
<Empty v-if="!formConfig.currentItem.key" class="hint-box" description="未选择控件" />
|
||||||
<Form v-else label-align="left" layout="vertical">
|
<aForm v-else label-align="left" layout="vertical">
|
||||||
<div v-for="item of baseItemColumnProps" :key="item.name">
|
<div v-for="item of baseItemColumnProps" :key="item.name">
|
||||||
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
||||||
<component
|
<component
|
||||||
v-bind="item.componentProps" :is="item.component" v-if="formConfig.currentItem.colProps && item.component"
|
v-bind="item.componentProps" :is="Com(item.component)" v-if="formConfig.currentItem.colProps && item.component"
|
||||||
v-model:value="formConfig.currentItem.colProps[item.name]" class="component-props"
|
v-model:value="formConfig.currentItem.colProps[item.name]" class="component-props"
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</aForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Description: 表单项属性,控件属性面板
|
* @Description: 表单项属性,控件属性面板
|
||||||
-->
|
-->
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, watch } from 'vue'
|
import { computed, watch, defineComponent } from 'vue'
|
||||||
import { Checkbox, Col, Empty, Form, FormItem, Input, Switch } from 'ant-design-vue'
|
import { Checkbox, Col, Empty, Form, FormItem, Input, Switch } from 'ant-design-vue'
|
||||||
import { isArray } from 'lodash-es'
|
import { isArray } from 'lodash-es'
|
||||||
import {
|
import {
|
||||||
|
@ -11,7 +11,7 @@ import {
|
||||||
baseFormItemControlAttrs,
|
baseFormItemControlAttrs,
|
||||||
baseFormItemProps,
|
baseFormItemProps,
|
||||||
} from '../../VFormDesign/config/formItemPropsConfig'
|
} from '../../VFormDesign/config/formItemPropsConfig'
|
||||||
|
import { componentMap } from '../../../../../Form/src/componentMap.ts'
|
||||||
import { useFormDesignState } from '../../../hooks/useFormDesignState'
|
import { useFormDesignState } from '../../../hooks/useFormDesignState'
|
||||||
import RuleProps from './RuleProps.vue'
|
import RuleProps from './RuleProps.vue'
|
||||||
|
|
||||||
|
@ -44,18 +44,22 @@ const controlPropsList = computed(() => {
|
||||||
return showProps(item.exclude)
|
return showProps(item.exclude)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const Com = computed(() => {
|
||||||
|
return com => componentMap.get(com) as ReturnType<typeof defineComponent>
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="properties-content">
|
<div class="properties-content">
|
||||||
<div v-if="formConfig.currentItem?.itemProps" class="properties-body">
|
<div v-if="formConfig.currentItem?.itemProps" class="properties-body">
|
||||||
<Empty v-if="!formConfig.currentItem.key" class="hint-box" description="未选择控件" />
|
<Empty v-if="!formConfig.currentItem.key" class="hint-box" description="未选择控件" />
|
||||||
<Form v-else label-align="left" layout="vertical">
|
<aForm v-else label-align="left" layout="vertical">
|
||||||
<div v-for="item of baseFormItemProps" :key="item.name">
|
<div v-for="item of baseFormItemProps" :key="item.name">
|
||||||
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
||||||
<component
|
<component
|
||||||
v-bind="item.componentProps"
|
v-bind="item.componentProps"
|
||||||
:is="item.component"
|
:is="Com(item.component)"
|
||||||
v-if="item.component"
|
v-if="item.component"
|
||||||
v-model:value="formConfig.currentItem[item.name]"
|
v-model:value="formConfig.currentItem[item.name]"
|
||||||
class="component-props"
|
class="component-props"
|
||||||
|
@ -66,7 +70,7 @@ const controlPropsList = computed(() => {
|
||||||
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
||||||
<component
|
<component
|
||||||
v-bind="item.componentProps"
|
v-bind="item.componentProps"
|
||||||
:is="item.component"
|
:is="Com(item.component)"
|
||||||
v-if="item.component"
|
v-if="item.component"
|
||||||
v-model:value="formConfig.currentItem.itemProps[item.name]"
|
v-model:value="formConfig.currentItem.itemProps[item.name]"
|
||||||
class="component-props"
|
class="component-props"
|
||||||
|
@ -76,7 +80,7 @@ const controlPropsList = computed(() => {
|
||||||
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
<FormItem v-if="showProps(item.exclude)" :label="item.label">
|
||||||
<component
|
<component
|
||||||
v-bind="item.componentProps"
|
v-bind="item.componentProps"
|
||||||
:is="item.component"
|
:is="Com(item.component)"
|
||||||
v-if="item.component"
|
v-if="item.component"
|
||||||
v-model:value="formConfig.currentItem.itemProps[item.name].span"
|
v-model:value="formConfig.currentItem.itemProps[item.name].span"
|
||||||
class="component-props"
|
class="component-props"
|
||||||
|
@ -105,7 +109,7 @@ const controlPropsList = computed(() => {
|
||||||
>
|
>
|
||||||
<RuleProps />
|
<RuleProps />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</aForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -11,6 +11,8 @@ import {
|
||||||
FormItem,
|
FormItem,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
Slider,
|
Slider,
|
||||||
|
RadioGroup,
|
||||||
|
RadioButton
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
import { useFormDesignState } from '../../../hooks/useFormDesignState'
|
import { useFormDesignState } from '../../../hooks/useFormDesignState'
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ const sliderSpan = computed(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="properties-content">
|
<div class="properties-content">
|
||||||
<Form class="properties-body" label-align="left" layout="vertical">
|
<aForm class="properties-body" label-align="left" layout="vertical">
|
||||||
<!-- <e-upload v-model="fileList"></e-upload> -->
|
<!-- <e-upload v-model="fileList"></e-upload> -->
|
||||||
|
|
||||||
<FormItem label="表单布局">
|
<FormItem label="表单布局">
|
||||||
|
@ -129,6 +131,6 @@ const sliderSpan = computed(() => {
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</Col>
|
</Col>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</aForm>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue