| | |
| | | import { useRefHistory, UseRefHistoryReturn } from '@vueuse/core'; |
| | | import { globalConfigState } from './config/formItemPropsConfig'; |
| | | import { IFormDesignMethods, IPropsPanel, IToolbarMethods } from '../../typings/form-type'; |
| | | import { useDesign } from '/@/hooks/web/useDesign'; |
| | | import { useDesign } from '@/hooks/web/useDesign'; |
| | | |
| | | import { CollapseContainer } from '/@/components/Container/index'; |
| | | import { CollapseContainer } from '@/components/Container'; |
| | | |
| | | defineProps({ |
| | | title: { |
| | | type: String, |
| | |
| | | item.componentProps = item.componentProps || {}; |
| | | item.itemProps = item.itemProps || {}; |
| | | }); |
| | | formConfig.value = config; |
| | | formConfig.value = config as any; |
| | | }; |
| | | // 获取历史记录,用于撤销和重构 |
| | | const historyReturn = useRefHistory(formConfig, { |
| | | const historyReturn = useRefHistory(formConfig as any, { |
| | | deep: true, |
| | | capacity: 20, |
| | | parse: (val: IFormConfig) => { |
| | |
| | | * @param schema 当前选中的表单项 |
| | | */ |
| | | const handleSetSelectItem = (schema: IVFormComponent) => { |
| | | formConfig.value.currentItem = schema; |
| | | formConfig.value.currentItem = schema as any; |
| | | handleChangePropsTabs( |
| | | schema.key ? (formConfig.value.activeKey! === 1 ? 2 : formConfig.value.activeKey!) : 1, |
| | | ); |
| | |
| | | generateKey(formItem); |
| | | if (!formConfig.value.currentItem?.key) { |
| | | handleSetSelectItem(formItem); |
| | | formConfig.value.schemas && formConfig.value.schemas.push(formItem); |
| | | formConfig.value.schemas && formConfig.value.schemas.push(formItem as any); |
| | | |
| | | return; |
| | | } |
| | |
| | | }); |
| | | }; |
| | | if (formConfig.value.schemas) { |
| | | traverse(formConfig.value.schemas); |
| | | traverse(formConfig.value.schemas as any); |
| | | } |
| | | }; |
| | | |
| | |
| | | // provide('currentItem', formConfig.value.currentItem) |
| | | |
| | | // 把表单配置项注入到子组件中,子组件可通过inject获取,获取到的数据为响应式 |
| | | provide<Ref<IFormConfig>>('formConfig', formConfig); |
| | | provide<Ref<IFormConfig>>('formConfig', formConfig as any); |
| | | |
| | | // 注入历史记录 |
| | | provide<UseRefHistoryReturn<any, any>>('historyReturn', historyReturn); |
| | |
| | | @prefix-cls: ~'@{namespace}-form-design'; |
| | | |
| | | [data-theme='dark'] { |
| | | .@{prefix-cls}-sider{ |
| | | background-color: #1f1f1f; |
| | | }} |
| | | .@{prefix-cls}-sider { |
| | | background-color: #1f1f1f; |
| | | } |
| | | } |
| | | |
| | | [data-theme='light'] { |
| | | .@{prefix-cls}-sider{ |
| | | background-color: #fff; |
| | | } |
| | | .@{prefix-cls}-sider { |
| | | background-color: #fff; |
| | | } |
| | | } |
| | | </style> |