|
|
|
@ -12,6 +12,7 @@
|
|
|
|
|
<slot name="formHeader"></slot>
|
|
|
|
|
<template v-for="schema in getSchema" :key="schema.field">
|
|
|
|
|
<FormItem
|
|
|
|
|
v-if="!getProps.readonly"
|
|
|
|
|
:is-advanced="fieldsIsAdvancedMap[schema.field]"
|
|
|
|
|
:table-action="tableAction"
|
|
|
|
|
:form-action-type="formActionType"
|
|
|
|
@ -25,8 +26,16 @@
|
|
|
|
|
<slot :name="item" v-bind="data || {}"></slot>
|
|
|
|
|
</template>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItemOnlyread
|
|
|
|
|
v-else
|
|
|
|
|
:table-action="tableAction"
|
|
|
|
|
:form-action-type="formActionType"
|
|
|
|
|
:schema="schema"
|
|
|
|
|
:form-props="getProps"
|
|
|
|
|
:form-model="formModel"
|
|
|
|
|
>
|
|
|
|
|
</FormItemOnlyread>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<FormAction
|
|
|
|
|
v-bind="getFormActionBindProps"
|
|
|
|
|
@toggle-advanced="handleToggleAdvanced"
|
|
|
|
@ -51,6 +60,7 @@
|
|
|
|
|
import { defineComponent, reactive, ref, computed, unref, onMounted, watch, nextTick } from 'vue'
|
|
|
|
|
import { Form, Row } from 'ant-design-vue'
|
|
|
|
|
import FormItem from './components/FormItem.vue'
|
|
|
|
|
import FormItemOnlyread from './components/FormItemOnlyread.vue'
|
|
|
|
|
import FormAction from './components/FormAction.vue'
|
|
|
|
|
|
|
|
|
|
import { dateItemType } from './helper'
|
|
|
|
@ -74,7 +84,7 @@
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: 'BasicForm',
|
|
|
|
|
components: { FormItem, Form, Row, FormAction },
|
|
|
|
|
components: { FormItem, Form, Row, FormAction, FormItemOnlyread },
|
|
|
|
|
props: basicProps,
|
|
|
|
|
emits: ['advanced-change', 'reset', 'submit', 'register', 'field-value-change'],
|
|
|
|
|
setup(props, { emit, attrs }) {
|
|
|
|
@ -125,7 +135,10 @@
|
|
|
|
|
|
|
|
|
|
const getSchema = computed((): FormSchema[] => {
|
|
|
|
|
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any)
|
|
|
|
|
const isReadonly = unref(propsRef).readonly
|
|
|
|
|
for (const schema of schemas) {
|
|
|
|
|
// 如果表单包含只读属性。处理每个item增加是否可编辑
|
|
|
|
|
if (isReadonly) schema['isEdit'] = 1
|
|
|
|
|
const { defaultValue, component, isHandleDateDefaultValue = true } = schema
|
|
|
|
|
// handle date type
|
|
|
|
|
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) {
|
|
|
|
|