index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <script lang="ts" setup>
  2. import type { Ref } from 'vue';
  3. import type { IFormConfig, IFormDesignMethods, IVFormComponent } from './types';
  4. import { onMounted, provide, ref } from 'vue';
  5. import { Card, Tabs } from 'ant-design-vue';
  6. import ControlConfig from './components/control-config.vue';
  7. import FormConfig from './components/form-config.vue';
  8. import FormEdit from './components/form/index.vue';
  9. import Widget from './components/widget/index.vue';
  10. defineOptions({
  11. name: 'FormDesign',
  12. });
  13. const formConfig = ref<IFormConfig>({
  14. config: {
  15. wrapperClass: 'grid-cols-1',
  16. showDefaultActions: false,
  17. commonConfig: {
  18. labelWidth: 100,
  19. },
  20. },
  21. schemas: [],
  22. selectSchema: { component: '' } as IVFormComponent,
  23. });
  24. const setSelectSchema = (schema: IVFormComponent) => {
  25. formConfig.value.selectSchema = schema as any;
  26. };
  27. provide<Ref<IFormConfig>>('formConfig', formConfig as any);
  28. provide<IFormDesignMethods>('formDesignMethods', {
  29. setSelectSchema,
  30. });
  31. onMounted(async () => {});
  32. </script>
  33. <template>
  34. <div class="flex h-full w-full">
  35. <div class="w-[300px]">
  36. <Widget />
  37. </div>
  38. <div class="h-full flex-1 pl-2 pr-2">
  39. <Card title="设计区域" class="h-full w-full">
  40. <FormEdit />
  41. </Card>
  42. </div>
  43. <div class="w-[300px]">
  44. <Tabs>
  45. <Tabs.TabPane key="1" tab="组件属性">
  46. <ControlConfig />
  47. </Tabs.TabPane>
  48. <Tabs.TabPane key="2" tab="表单属性">
  49. <FormConfig v-model:config="formConfig.config" />
  50. </Tabs.TabPane>
  51. </Tabs>
  52. </div>
  53. </div>
  54. </template>