Commit 77028fb77564f63a38b306eb46ef12d65b5f8ad9

Authored by ww
1 parent 0637688d

wip: implement colorPicker

@@ -31,6 +31,7 @@ import ApiRadioGroup from './components/ApiRadioGroup.vue'; @@ -31,6 +31,7 @@ import ApiRadioGroup from './components/ApiRadioGroup.vue';
31 //自定义组件 31 //自定义组件
32 import JAddInput from './externalCompns/components/JAddInput.vue'; 32 import JAddInput from './externalCompns/components/JAddInput.vue';
33 import { JEasyCron } from './externalCompns/components/JEasyCron'; 33 import { JEasyCron } from './externalCompns/components/JEasyCron';
  34 +import ColorPicker from './components/ColorPicker.vue';
34 35
35 const componentMap = new Map<ComponentType, Component>(); 36 const componentMap = new Map<ComponentType, Component>();
36 37
@@ -69,6 +70,7 @@ componentMap.set('Upload', BasicUpload); @@ -69,6 +70,7 @@ componentMap.set('Upload', BasicUpload);
69 //注册自定义组件 70 //注册自定义组件
70 componentMap.set('JAddInput', JAddInput); 71 componentMap.set('JAddInput', JAddInput);
71 componentMap.set('JEasyCron', JEasyCron); 72 componentMap.set('JEasyCron', JEasyCron);
  73 +componentMap.set('ColorPicker', ColorPicker);
72 74
73 export function add(compName: ComponentType, component: Component) { 75 export function add(compName: ComponentType, component: Component) {
74 componentMap.set(compName, component); 76 componentMap.set(compName, component);
src/components/Form/src/components/ColorPicker.vue renamed from src/views/data/board/components/ColorPicker.vue
@@ -112,4 +112,5 @@ export type ComponentType = @@ -112,4 +112,5 @@ export type ComponentType =
112 | 'Render' 112 | 'Render'
113 | 'Slider' 113 | 'Slider'
114 | 'JAddInput' 114 | 'JAddInput'
115 - | 'Rate'; 115 + | 'Rate'
  116 + | 'ColorPicker';
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 - import { BasicModal } from '/@/components/Modal'; 2 + import { modeOne } from '../config/visualOptions';
  3 + import { useForm, BasicForm } from '/@/components/Form';
  4 + import { BasicModal, useModalInner } from '/@/components/Modal';
  5 + const [registerForm, method] = useForm({
  6 + schemas: modeOne,
  7 + showActionButtonGroup: false,
  8 + labelWidth: 120,
  9 + baseColProps: {
  10 + span: 12,
  11 + },
  12 + });
  13 +
  14 + const [registerModal, { closeModal }] = useModalInner();
  15 +
  16 + const handleGetValue = () => {
  17 + const value = method.getFieldsValue();
  18 + console.log(value);
  19 + };
3 </script> 20 </script>
4 21
5 <template> 22 <template>
6 - <BasicModal v-bind="$attrs" title="" width="60%">  
7 - <section> content </section> 23 + <BasicModal v-bind="$attrs" @register="registerModal" title="" width="60%">
  24 + <BasicForm @register="registerForm" />
  25 + <button @click="handleGetValue">啊按钮</button>
8 </BasicModal> 26 </BasicModal>
9 </template> 27 </template>
@@ -3,10 +3,130 @@ export enum defaultOptions { @@ -3,10 +3,130 @@ export enum defaultOptions {
3 fontColor = '#rer', 3 fontColor = '#rer',
4 } 4 }
5 5
6 -export const mode: FormSchema[] = [ 6 +export enum visualOptionField {
  7 + FONT_COLOR = 'fontColor',
  8 + UNIT = 'unit',
  9 + ICON_COLOR = 'iconColor',
  10 + ICON = 'icon',
  11 + FIRST_PHASE_COLOR = 'firstPhaseColor',
  12 + SECOND_PHASE_COLOR = 'secondPhaseColor',
  13 + THIRD_PHASE_COLOR = 'thirdPhaseColor',
  14 + FOURTH_PHASE_COLOR = 'fourthPhaseColor',
  15 + FIRST_PHASE_VALUE = 'firstPhaseValue',
  16 + SECOND_PHASE_VALUE = 'secondPhaseValue',
  17 + THIRD_PHASE_VALUE = 'thirdPhaseValue',
  18 + FOURTH_PHASE_VALUE = 'fourthPhaseValue',
  19 +}
  20 +
  21 +export const modeOne: FormSchema[] = [
  22 + {
  23 + field: visualOptionField.FONT_COLOR,
  24 + label: '数值字体颜色',
  25 + component: 'ColorPicker',
  26 + changeEvent: 'update:value',
  27 + },
  28 +];
  29 +
  30 +export const modeTwo: FormSchema[] = [
  31 + {
  32 + field: visualOptionField.UNIT,
  33 + label: '数值字体颜色',
  34 + component: 'ColorPicker',
  35 + changeEvent: 'update:value',
  36 + },
  37 + {
  38 + field: visualOptionField.UNIT,
  39 + label: '数值单位',
  40 + component: 'Input',
  41 + componentProps: {
  42 + placeholder: '请输入数值单位',
  43 + },
  44 + },
  45 + {
  46 + field: visualOptionField.ICON_COLOR,
  47 + label: '图标颜色',
  48 + component: 'ColorPicker',
  49 + changeEvent: 'update:value',
  50 + },
  51 + {
  52 + field: visualOptionField.ICON,
  53 + label: '图标',
  54 + component: 'Input',
  55 + },
  56 +];
  57 +
  58 +export const modeThree: FormSchema[] = [
  59 + {
  60 + field: visualOptionField.FONT_COLOR,
  61 + label: '数值字体颜色',
  62 + component: 'ColorPicker',
  63 + changeEvent: 'update:value',
  64 + },
  65 + {
  66 + field: visualOptionField.UNIT,
  67 + label: '数值单位',
  68 + component: 'Input',
  69 + componentProps: {
  70 + placeholder: '请输入数值单位',
  71 + },
  72 + },
  73 + {
  74 + field: visualOptionField.FIRST_PHASE_COLOR,
  75 + label: '一阶段颜色',
  76 + component: 'ColorPicker',
  77 + changeEvent: 'update:value',
  78 + },
  79 + {
  80 + field: visualOptionField.FIRST_PHASE_VALUE,
  81 + label: '一阶段阀值',
  82 + component: 'Input',
  83 + componentProps: {
  84 + placeholder: '请输入一阶段阀值',
  85 + },
  86 + },
  87 + {
  88 + field: visualOptionField.SECOND_PHASE_COLOR,
  89 + label: '二阶段颜色',
  90 + component: 'ColorPicker',
  91 + changeEvent: 'update:value',
  92 + },
7 { 93 {
8 - field: 'fontColor', 94 + field: visualOptionField.SECOND_PHASE_VALUE,
  95 + label: '二阶段阀值',
  96 + component: 'Input',
  97 + componentProps: {
  98 + placeholder: '请输入二阶段阀值',
  99 + },
  100 + },
  101 + {
  102 + field: visualOptionField.THIRD_PHASE_COLOR,
  103 + label: '三阶段颜色',
  104 + component: 'ColorPicker',
  105 + changeEvent: 'update:value',
  106 + },
  107 + {
  108 + field: visualOptionField.THIRD_PHASE_VALUE,
  109 + label: '三阶段阀值',
  110 + component: 'Input',
  111 + componentProps: {
  112 + placeholder: '请输入三阶段阀值',
  113 + },
  114 + },
  115 +];
  116 +
  117 +export const modeFour: FormSchema[] = [
  118 + {
  119 + field: visualOptionField.FONT_COLOR,
9 label: '数值字体颜色', 120 label: '数值字体颜色',
10 component: 'ColorPicker', 121 component: 'ColorPicker',
  122 + changeEvent: 'update:value',
  123 + },
  124 + {
  125 + field: visualOptionField.UNIT,
  126 + label: '数值单位',
  127 + component: 'Input',
  128 + componentProps: {
  129 + placeholder: '请输入数值单位',
  130 + },
11 }, 131 },
12 ]; 132 ];