|
@@ -61,8 +61,8 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
-<script lang="ts">
|
|
|
- import { computed, defineComponent, watch } from 'vue';
|
|
|
+<script lang="ts" setup name="FormItemProps">
|
|
|
+ import { computed, watch } from 'vue';
|
|
|
import {
|
|
|
baseFormItemControlAttrs,
|
|
|
baseFormItemProps,
|
|
@@ -70,76 +70,36 @@
|
|
|
advanceFormItemColProps,
|
|
|
} from '../../VFormDesign/config/formItemPropsConfig';
|
|
|
|
|
|
- import {
|
|
|
- Empty,
|
|
|
- Input,
|
|
|
- Form,
|
|
|
- FormItem,
|
|
|
- Switch,
|
|
|
- Checkbox,
|
|
|
- Select,
|
|
|
- Slider,
|
|
|
- Col,
|
|
|
- RadioGroup,
|
|
|
- } from 'ant-design-vue';
|
|
|
+ import { Empty, Input, Form, FormItem, Switch, Checkbox, Col } from 'ant-design-vue';
|
|
|
import RuleProps from './RuleProps.vue';
|
|
|
import { useFormDesignState } from '../../../hooks/useFormDesignState';
|
|
|
import { isArray } from 'lodash-es';
|
|
|
|
|
|
- export default defineComponent({
|
|
|
- name: 'FormItemProps',
|
|
|
- components: {
|
|
|
- RuleProps,
|
|
|
- Empty,
|
|
|
- Input,
|
|
|
- Form,
|
|
|
- FormItem,
|
|
|
- Switch,
|
|
|
- Checkbox,
|
|
|
- Select,
|
|
|
- Slider,
|
|
|
- Col,
|
|
|
- RadioGroup,
|
|
|
- },
|
|
|
- // props: {} as PropsOptions,
|
|
|
-
|
|
|
- setup() {
|
|
|
- const { formConfig } = useFormDesignState();
|
|
|
+ const { formConfig } = useFormDesignState();
|
|
|
|
|
|
- watch(
|
|
|
- () => formConfig.value,
|
|
|
- () => {
|
|
|
- if (formConfig.value.currentItem) {
|
|
|
- formConfig.value.currentItem.itemProps = formConfig.value.currentItem.itemProps || {};
|
|
|
- formConfig.value.currentItem.itemProps.labelCol =
|
|
|
- formConfig.value.currentItem.itemProps.labelCol || {};
|
|
|
- formConfig.value.currentItem.itemProps.wrapperCol =
|
|
|
- formConfig.value.currentItem.itemProps.wrapperCol || {};
|
|
|
- }
|
|
|
- },
|
|
|
- { deep: true, immediate: true },
|
|
|
- );
|
|
|
- const showProps = (exclude: string[] | undefined) => {
|
|
|
- if (!exclude) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return isArray(exclude) ? !exclude.includes(formConfig.value.currentItem!.component) : true;
|
|
|
- };
|
|
|
-
|
|
|
- const controlPropsList = computed(() => {
|
|
|
- return baseFormItemControlAttrs.filter((item) => {
|
|
|
- return showProps(item.exclude);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- return {
|
|
|
- baseFormItemProps,
|
|
|
- advanceFormItemProps,
|
|
|
- advanceFormItemColProps,
|
|
|
- formConfig,
|
|
|
- controlPropsList,
|
|
|
- showProps,
|
|
|
- };
|
|
|
+ watch(
|
|
|
+ () => formConfig.value,
|
|
|
+ () => {
|
|
|
+ if (formConfig.value.currentItem) {
|
|
|
+ formConfig.value.currentItem.itemProps = formConfig.value.currentItem.itemProps || {};
|
|
|
+ formConfig.value.currentItem.itemProps.labelCol =
|
|
|
+ formConfig.value.currentItem.itemProps.labelCol || {};
|
|
|
+ formConfig.value.currentItem.itemProps.wrapperCol =
|
|
|
+ formConfig.value.currentItem.itemProps.wrapperCol || {};
|
|
|
+ }
|
|
|
},
|
|
|
+ { deep: true, immediate: true },
|
|
|
+ );
|
|
|
+ const showProps = (exclude: string[] | undefined) => {
|
|
|
+ if (!exclude) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return isArray(exclude) ? !exclude.includes(formConfig.value.currentItem!.component) : true;
|
|
|
+ };
|
|
|
+
|
|
|
+ const controlPropsList = computed(() => {
|
|
|
+ return baseFormItemControlAttrs.filter((item) => {
|
|
|
+ return showProps(item.exclude);
|
|
|
+ });
|
|
|
});
|
|
|
</script>
|