| | |
| | | </CollapseContainer> |
| | | </PageWrapper> |
| | | </template> |
| | | <script lang="ts"> |
| | | import { defineComponent } from 'vue'; |
| | | import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; |
| | | import { CollapseContainer } from '/@/components/Container/index'; |
| | | import { PageWrapper } from '/@/components/Page'; |
| | | <script lang="ts" setup> |
| | | import { BasicForm, FormSchema, useForm } from '@/components/Form'; |
| | | import { CollapseContainer } from '@/components/Container'; |
| | | import { PageWrapper } from '@/components/Page'; |
| | | |
| | | const schemas: FormSchema[] = [ |
| | | { |
| | |
| | | componentProps: ({ formModel }) => { |
| | | return { |
| | | placeholder: '同步f2的值为f1', |
| | | onChange: (e: ChangeEvent) => { |
| | | onChange: (e) => { |
| | | formModel.f2 = e.target.value; |
| | | }, |
| | | }; |
| | |
| | | }, |
| | | ]; |
| | | |
| | | export default defineComponent({ |
| | | components: { BasicForm, CollapseContainer, PageWrapper }, |
| | | setup() { |
| | | const [register, { setProps, updateSchema, appendSchemaByField, removeSchemaByField }] = |
| | | useForm({ |
| | | labelWidth: 120, |
| | | schemas, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | }); |
| | | const [register1] = useForm({ |
| | | labelWidth: 120, |
| | | schemas: schemas1, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | }); |
| | | function changeLabel3() { |
| | | updateSchema({ |
| | | field: 'field3', |
| | | label: '字段3 New', |
| | | }); |
| | | } |
| | | function changeLabel34() { |
| | | updateSchema([ |
| | | { |
| | | field: 'field3', |
| | | label: '字段3 New++', |
| | | }, |
| | | { |
| | | field: 'field4', |
| | | label: '字段4 New++', |
| | | }, |
| | | ]); |
| | | } |
| | | |
| | | function appendField() { |
| | | appendSchemaByField( |
| | | { |
| | | field: 'field10', |
| | | label: '字段10', |
| | | component: 'Input', |
| | | colProps: { |
| | | span: 8, |
| | | }, |
| | | }, |
| | | 'field3', |
| | | ); |
| | | } |
| | | function deleteField() { |
| | | removeSchemaByField('field11'); |
| | | } |
| | | return { |
| | | register, |
| | | register1, |
| | | schemas, |
| | | setProps, |
| | | changeLabel3, |
| | | changeLabel34, |
| | | appendField, |
| | | deleteField, |
| | | }; |
| | | const [register, { updateSchema, appendSchemaByField, removeSchemaByField }] = useForm({ |
| | | labelWidth: 120, |
| | | schemas, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | }); |
| | | const [register1] = useForm({ |
| | | labelWidth: 120, |
| | | schemas: schemas1, |
| | | actionColOptions: { |
| | | span: 24, |
| | | }, |
| | | }); |
| | | function changeLabel3() { |
| | | updateSchema({ |
| | | field: 'field3', |
| | | label: '字段3 New', |
| | | }); |
| | | } |
| | | function changeLabel34() { |
| | | updateSchema([ |
| | | { |
| | | field: 'field3', |
| | | label: '字段3 New++', |
| | | }, |
| | | { |
| | | field: 'field4', |
| | | label: '字段4 New++', |
| | | }, |
| | | ]); |
| | | } |
| | | |
| | | function appendField() { |
| | | appendSchemaByField( |
| | | { |
| | | field: 'field10', |
| | | label: '字段10', |
| | | component: 'Input', |
| | | colProps: { |
| | | span: 8, |
| | | }, |
| | | }, |
| | | 'field3', |
| | | ); |
| | | } |
| | | function deleteField() { |
| | | removeSchemaByField('field11'); |
| | | } |
| | | </script> |