PropsPanel.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!--
  2. * @Description: 右侧属性配置面板
  3. -->
  4. <template>
  5. <div>
  6. <Tabs v-model:activeKey="formConfig.activeKey" :tabBarStyle="{ margin: 0 }">
  7. <TabPane :key="1" tab="表单">
  8. <FormProps />
  9. </TabPane>
  10. <TabPane :key="2" tab="控件">
  11. <FormItemProps />
  12. </TabPane>
  13. <TabPane :key="3" tab="栅格">
  14. <ComponentColumnProps />
  15. </TabPane>
  16. <TabPane :key="4" tab="组件">
  17. <slot v-if="slotProps" :name="slotProps.component + 'Props'"></slot>
  18. <ComponentProps v-else />
  19. </TabPane>
  20. </Tabs>
  21. </div>
  22. </template>
  23. <script lang="ts">
  24. import { computed, defineComponent } from 'vue';
  25. import FormProps from '../components/FormProps.vue';
  26. import FormItemProps from '../components/FormItemProps.vue';
  27. import ComponentProps from '../components/ComponentProps.vue';
  28. import ComponentColumnProps from '../components/FormItemColumnProps.vue';
  29. import { useFormDesignState } from '../../../hooks/useFormDesignState';
  30. import { customComponents } from '../../../core/formItemConfig';
  31. import { TabPane, Tabs } from 'ant-design-vue';
  32. type ChangeTabKey = 1 | 2;
  33. export interface IPropsPanel {
  34. changeTab: (key: ChangeTabKey) => void;
  35. }
  36. export default defineComponent({
  37. name: 'PropsPanel',
  38. components: {
  39. FormProps,
  40. FormItemProps,
  41. ComponentProps,
  42. ComponentColumnProps,
  43. Tabs,
  44. TabPane,
  45. },
  46. setup() {
  47. const { formConfig } = useFormDesignState();
  48. const slotProps = computed(() => {
  49. return customComponents.find(
  50. (item) => item.component === formConfig.value.currentItem?.component,
  51. );
  52. });
  53. return { formConfig, customComponents, slotProps };
  54. },
  55. });
  56. </script>
  57. <style lang="less" scoped>
  58. @import url('../styles/variable.less');
  59. :deep(.ant-tabs) {
  60. box-sizing: border-box;
  61. form {
  62. width: 100%;
  63. height: 85vh;
  64. margin-right: 10px;
  65. overflow-x: hidden;
  66. overflow-y: auto;
  67. }
  68. .hint-box {
  69. margin-top: 200px;
  70. }
  71. .ant-form-item,
  72. .ant-slider-with-marks {
  73. margin-right: 20px;
  74. margin-bottom: 0;
  75. margin-left: 10px;
  76. }
  77. .ant-form-item {
  78. // width: 100%;
  79. margin-bottom: 0;
  80. .ant-form-item-label {
  81. line-height: 2;
  82. vertical-align: text-top;
  83. }
  84. }
  85. .ant-input-number {
  86. width: 100%;
  87. }
  88. }
  89. </style>