feat: (草稿)快速表单支持去掉部分只读字段的灰底

This commit is contained in:
gaoyunqi
2024-02-05 15:25:01 +08:00
parent ec11057a12
commit fd9f4569d2
2 changed files with 33 additions and 8 deletions

View File

@ -0,0 +1,19 @@
<template>
<div class="field-readonly">{{ fieldValue }}</div>
</template>
<script setup>
import { ref, watch } from 'vue';
const props = defineProps({
value: String,
schema: Object,
});
const fieldValue = ref(props.value);
watch(
() => props.value,
(newValue) => {
fieldValue.value = newValue;
},
);
</script>

View File

@ -246,14 +246,19 @@
:rules="rules"
:validateTrigger="['blur', 'change']"
>
<component
:is="defaultComponent(schema)"
:key="refreshFieldObj[schema.field]"
:disabled="getDisable"
:size="formProps?.size"
v-bind="getComponentsProps"
v-model:value="formModel![schema.field]"
/>
<template v-if="getDisable && /Input/.test(schema.component)">
<readonly :schema="schema" :value="formModel![schema.field]" />
</template>
<template v-else>
<component
:is="defaultComponent(schema)"
:key="refreshFieldObj[schema.field]"
v-model:value="formModel![schema.field]"
:disabled="getDisable"
:size="formProps?.size"
v-bind="getComponentsProps"
/>
</template>
</FormItem>
</template>
</div>
@ -274,6 +279,7 @@
import { useMessage } from '/@/hooks/web/useMessage';
import TableLayoutPreview from '/@/components/Form/src/components/TableLayoutPreview.vue';
import { camelCaseString } from '/@/utils/event/design';
import Readonly from '/@/components/Form/src/components/Readonly.vue';
const FormItem = Form.Item;