Commit 2e80187a8c538beb49f8b9581d496cbb0d0420b0

Authored by ww
1 parent 0f9a309a

perf: 优化组件目录结构调整

Showing 44 changed files with 23 additions and 292 deletions
... ... @@ -12,17 +12,17 @@ export { default as ApiTreeSelect } from './src/components/ApiTreeSelect.vue';
12 12 export { default as ApiRadioGroup } from './src/components/ApiRadioGroup.vue';
13 13 export { default as ApiUpload } from './src/components/ApiUpload.vue';
14 14
15   -export { default as StructForm } from './src/externalCompns/components/StructForm/StructForm.vue';
  15 +export { default as StructForm } from './src/components/StructForm/StructForm.vue';
16 16 export { default as JavaScriptFunctionEditor } from './src/components/JavaScriptFunctionEditor.vue';
17 17
18   -export { ThingsModelForm } from './src/externalCompns/components/ThingsModelForm';
  18 +export { ThingsModelForm } from './src/components/ThingsModelForm';
19 19
20 20 //注册自定义组件
21 21 export {
22 22 JEasyCron,
23 23 JEasyCronInner,
24 24 JEasyCronModal,
25   -} from '/@/components/Form/src/externalCompns/components/JEasyCron';
  25 +} from '/@/components/Form/src/components/JEasyCron';
26 26 // Jeecg自定义校验
27   -export { JCronValidator } from '/@/components/Form/src/externalCompns/components/JEasyCron';
  27 +export { JCronValidator } from '/@/components/Form/src/components/JEasyCron';
28 28 // export { BasicForm };
... ...
... ... @@ -29,20 +29,20 @@ import { IconPicker } from '/@/components/Icon';
29 29 import { CountdownInput } from '/@/components/CountDown';
30 30 import ApiRadioGroup from './components/ApiRadioGroup.vue';
31 31 //自定义组件
32   -import JAddInput from './externalCompns/components/JAddInput.vue';
33   -import { JEasyCron } from './externalCompns/components/JEasyCron';
  32 +import JAddInput from './components/JAddInput.vue';
  33 +import { JEasyCron } from './components/JEasyCron';
34 34 import ColorPicker from './components/ColorPicker.vue';
35 35 import IconDrawer from './components/IconDrawer.vue';
36 36 import ApiUpload from './components/ApiUpload.vue';
37 37 import ApiSearchSelect from './components/ApiSearchSelect.vue';
38   -import CustomMinMaxInput from './externalCompns/components/CustomMinMaxInput.vue';
39   -import StructForm from './externalCompns/components/StructForm/StructForm.vue';
  38 +import CustomMinMaxInput from './components/CustomMinMaxInput.vue';
  39 +import StructForm from './components/StructForm/StructForm.vue';
40 40 import ApiSelectScrollLoad from './components/ApiSelectScrollLoad.vue';
41 41 import InputGroup from './components/InputGroup.vue';
42 42 import RegisterAddressInput from '/@/views/task/center/components/PollCommandInput/RegisterAddressInput.vue';
43   -import ExtendDesc from '/@/components/Form/src/externalCompns/components/ExtendDesc/index.vue';
44   -import DeviceProfileForm from '/@/components/Form/src/externalCompns/components/DeviceProfileForm/index.vue';
45   -import EnumList from './externalCompns/components/StructForm/EnumList.vue';
  43 +import ExtendDesc from '/@/components/Form/src/components/ExtendDesc/index.vue';
  44 +import DeviceProfileForm from '/@/components/Form/src/components/DeviceProfileForm/index.vue';
  45 +import EnumList from './components/StructForm/EnumList.vue';
46 46
47 47 const componentMap = new Map<ComponentType, Component>();
48 48
... ...
src/components/Form/src/components/CustomMinMaxInput.vue renamed from src/components/Form/src/externalCompns/components/CustomMinMaxInput.vue
src/components/Form/src/components/DeviceProfileForm/index.vue renamed from src/components/Form/src/externalCompns/components/DeviceProfileForm/index.vue
src/components/Form/src/components/ExtendDesc/config.ts renamed from src/components/Form/src/externalCompns/components/ExtendDesc/config.ts
src/components/Form/src/components/ExtendDesc/index.vue renamed from src/components/Form/src/externalCompns/components/ExtendDesc/index.vue
src/components/Form/src/components/JAddInput.vue renamed from src/components/Form/src/externalCompns/components/JAddInput.vue
src/components/Form/src/components/JEasyCron/EasyCronInner.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/EasyCronInner.vue
src/components/Form/src/components/JEasyCron/EasyCronInput.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/EasyCronInput.vue
src/components/Form/src/components/JEasyCron/EasyCronModal.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/EasyCronModal.vue
src/components/Form/src/components/JEasyCron/LICENSE renamed from src/components/Form/src/externalCompns/components/JEasyCron/LICENSE
src/components/Form/src/components/JEasyCron/easy.cron.data.ts renamed from src/components/Form/src/externalCompns/components/JEasyCron/easy.cron.data.ts
src/components/Form/src/components/JEasyCron/easy.cron.inner.less renamed from src/components/Form/src/externalCompns/components/JEasyCron/easy.cron.inner.less
src/components/Form/src/components/JEasyCron/easy.cron.input.less renamed from src/components/Form/src/externalCompns/components/JEasyCron/easy.cron.input.less
src/components/Form/src/components/JEasyCron/index.ts renamed from src/components/Form/src/externalCompns/components/JEasyCron/index.ts
src/components/Form/src/components/JEasyCron/tabs/DayUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/DayUI.vue
src/components/Form/src/components/JEasyCron/tabs/HourUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/HourUI.vue
src/components/Form/src/components/JEasyCron/tabs/MinuteUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/MinuteUI.vue
src/components/Form/src/components/JEasyCron/tabs/MonthUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/MonthUI.vue
src/components/Form/src/components/JEasyCron/tabs/SecondUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/SecondUI.vue
src/components/Form/src/components/JEasyCron/tabs/WeekUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/WeekUI.vue
src/components/Form/src/components/JEasyCron/tabs/YearUI.vue renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/YearUI.vue
src/components/Form/src/components/JEasyCron/tabs/useTabMixin.ts renamed from src/components/Form/src/externalCompns/components/JEasyCron/tabs/useTabMixin.ts
src/components/Form/src/components/JEasyCron/validator.ts renamed from src/components/Form/src/externalCompns/components/JEasyCron/validator.ts
src/components/Form/src/components/StructForm/EnumList.config.ts renamed from src/components/Form/src/externalCompns/components/StructForm/EnumList.config.ts
src/components/Form/src/components/StructForm/EnumList.vue renamed from src/components/Form/src/externalCompns/components/StructForm/EnumList.vue
src/components/Form/src/components/StructForm/StructForm.vue renamed from src/components/Form/src/externalCompns/components/StructForm/StructForm.vue
src/components/Form/src/components/StructForm/StructFormModel.vue renamed from src/components/Form/src/externalCompns/components/StructForm/StructFormModel.vue
src/components/Form/src/components/StructForm/config.ts renamed from src/components/Form/src/externalCompns/components/StructForm/config.ts
src/components/Form/src/components/StructForm/type.ts renamed from src/components/Form/src/externalCompns/components/StructForm/type.ts
src/components/Form/src/components/StructForm/util.ts renamed from src/components/Form/src/externalCompns/components/StructForm/util.ts
src/components/Form/src/components/ThingsModelForm/StructPreview.vue renamed from src/components/Form/src/externalCompns/components/ThingsModelForm/StructPreview.vue
src/components/Form/src/components/ThingsModelForm/config.ts renamed from src/components/Form/src/externalCompns/components/ThingsModelForm/config.ts
src/components/Form/src/components/ThingsModelForm/index.ts renamed from src/components/Form/src/externalCompns/components/ThingsModelForm/index.ts
src/components/Form/src/components/ThingsModelForm/index.vue renamed from src/components/Form/src/externalCompns/components/ThingsModelForm/index.vue
... ... @@ -5,7 +5,7 @@
5 5 import { ThingsModelForm } from '.';
6 6 import { DefineComponentsBasicExpose } from '/#/utils';
7 7 import { StructJSON } from '/@/api/device/model/modelOfMatterModel';
8   - import { useForm } from '../../../hooks/useForm';
  8 + import { useForm } from '../../hooks/useForm';
9 9 import { DataTypeEnum } from '/@/enums/objectModelEnum';
10 10 import { BasicForm } from '/@/components/Form';
11 11
... ...
1   -<script lang="ts" setup>
2   - import { Card } from 'ant-design-vue';
3   - import { computed, nextTick, onMounted, onUpdated, unref, watch } from 'vue';
4   - import { BasicCreateFormParams } from './type';
5   - import { DynamicProps } from '/#/utils';
6   - import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel';
7   - import { BasicForm, FormProps, FormSchema, useForm } from '/@/components/Form';
8   - import { DataTypeEnum } from '/@/enums/objectModelEnum';
9   - import { ReadAndWriteEnum } from '/@/enums/toolEnum';
10   -
11   - const props = withDefaults(
12   - defineProps<{
13   - inputData?: StructJSON[];
14   - formProps?: FormProps;
15   - value?: Recordable;
16   - required?: boolean;
17   - }>(),
18   - {
19   - inputData: () => [] as StructJSON[],
20   - formProps: () => ({}),
21   - value: () => ({}),
22   - }
23   - );
24   -
25   - const emit = defineEmits(['update:value']);
26   -
27   - const getCurrentKeys = computed(() => {
28   - const { inputData } = props;
29   - return (inputData || []).map((item) => item.identifier);
30   - });
31   -
32   - const [register, { setProps, getFieldsValue, setFieldsValue }] = useForm({
33   - schemas: [],
34   - showActionButtonGroup: false,
35   - layout: 'inline',
36   - labelWidth: 80,
37   - wrapperCol: { span: 12 },
38   - ...(props.formProps || ({} as unknown as Partial<DynamicProps<FormProps>>)),
39   - });
40   -
41   - const syncValue = (key: string, value: any) => {
42   - let record = getFieldsValue();
43   - record = { ...record, [key]: value };
44   - const setValues = {};
45   - Object.keys(record).forEach((key) => {
46   - const hasKey = unref(getCurrentKeys).includes(key);
47   - if (hasKey) {
48   - setValues[key] = record[key];
49   - }
50   - });
51   - emit('update:value', setValues);
52   - };
53   -
54   - const createInputNumber = ({
55   - identifier,
56   - functionName,
57   - specs,
58   - }: BasicCreateFormParams): FormSchema => {
59   - const { valueRange } = specs! as Partial<Specs>;
60   - const { max = 2147483647, min = -2147483648 } = valueRange || {};
61   - return {
62   - field: identifier,
63   - label: functionName,
64   - component: 'InputNumber',
65   - rules: [
66   - {
67   - required: props.required,
68   - message: `${functionName}是必填项`,
69   - },
70   - {
71   - type: 'number',
72   - trigger: 'change',
73   - validator: (_rule, value) => {
74   - const reg = /^[0-9]*$/;
75   - if (!reg.test(value)) return Promise.reject(`${functionName}不是一个有效的数字`);
76   - if (value < min || value > max) {
77   - return Promise.reject(`${functionName}取值范围在${min}~${max}之间`);
78   - }
79   - return Promise.resolve(value);
80   - },
81   - },
82   - ],
83   - componentProps: {
84   - max,
85   - min,
86   - // step: step,
87   - // formatter: (value: string) => value,
88   - // parser: (string: string) => {
89   - // if (dataType === DataTypeEnum.NUMBER_INT) {
90   - // return Number(Number(string).toFixed());
91   - // }
92   - // return Number(string);
93   - // },
94   - onChange: (value: string) => {
95   - syncValue(identifier, value);
96   - },
97   - },
98   - } as FormSchema;
99   - };
100   -
101   - const createInput = ({ identifier, functionName, specs }: BasicCreateFormParams): FormSchema => {
102   - const { length = 10240 } = specs! as Partial<Specs>;
103   - return {
104   - field: identifier,
105   - label: functionName,
106   - component: 'Input',
107   - rules: [
108   - {
109   - required: props.required,
110   - message: `${functionName}是必填项`,
111   - },
112   - {
113   - type: 'string',
114   - trigger: 'change',
115   - validator: (_rule, value) => {
116   - if (value.length > length) {
117   - return Promise.reject(`${functionName}数据长度应该小于${length}`);
118   - }
119   - return Promise.resolve(value);
120   - },
121   - },
122   - ],
123   - componentProps: {
124   - maxLength: length,
125   - onChange: (value: InputEvent) => {
126   - syncValue(identifier, (value.target as HTMLInputElement).value);
127   - },
128   - },
129   - } as FormSchema;
130   - };
131   -
132   - const createSelect = ({ identifier, functionName, specs }: BasicCreateFormParams): FormSchema => {
133   - const { boolClose, boolOpen } = specs! as Partial<Specs>;
134   - return {
135   - field: identifier,
136   - label: functionName,
137   - component: 'Select',
138   - rules: [
139   - {
140   - required: props.required,
141   - message: `${functionName}是必填项`,
142   - type: 'number',
143   - },
144   - ],
145   - componentProps: {
146   - options: [
147   - { label: `${boolClose}-0`, value: 0 },
148   - { label: `${boolOpen}-1`, value: 1 },
149   - ],
150   - onChange: (value: string) => {
151   - syncValue(identifier, value);
152   - },
153   - },
154   - };
155   - };
156   -
157   - const createInputJson = ({ identifier, functionName }: BasicCreateFormParams): FormSchema => {
158   - return {
159   - field: identifier,
160   - label: functionName,
161   - component: 'InputTextArea',
162   - rules: [
163   - {
164   - required: props.required,
165   - message: `${functionName}是必填项`,
166   - },
167   - ],
168   - componentProps: {
169   - onChange: (value: InputEvent) => {
170   - syncValue(identifier, (value.target as HTMLInputElement).value);
171   - },
172   - },
173   - };
174   - };
175   -
176   - const transformToFormSchema = (inputData: StructJSON[]) => {
177   - const schemas: FormSchema[] = [];
178   - for (const item of inputData) {
179   - const { dataType, identifier, functionName, accessMode } = item;
180   - if (accessMode === ReadAndWriteEnum.READ) {
181   - continue;
182   - }
183   - const { type, specs } = dataType! || {};
184   -
185   - const params: BasicCreateFormParams = {
186   - identifier: identifier!,
187   - functionName: functionName!,
188   - dataType: dataType! as unknown as DataTypeEnum,
189   - specs: specs as Partial<Specs>,
190   - };
191   - if (type === DataTypeEnum.NUMBER_INT || type === DataTypeEnum.NUMBER_DOUBLE) {
192   - schemas.push(createInputNumber(params));
193   - }
194   -
195   - if (type === DataTypeEnum.BOOL) {
196   - schemas.push(createSelect(params));
197   - }
198   -
199   - if (type === DataTypeEnum.STRING) {
200   - schemas.push(createInput(params));
201   - }
202   -
203   - if (type === DataTypeEnum.STRUCT) {
204   - schemas.push(createInputJson(params));
205   - }
206   - }
207   -
208   - return schemas;
209   - };
210   -
211   - const generateSchemas = (value: StructJSON[]) => {
212   - if (value && value.length) {
213   - const schemas = transformToFormSchema(value);
214   - setProps({ schemas });
215   - }
216   - };
217   -
218   - onMounted(() => {
219   - generateSchemas(props.inputData);
220   - });
221   -
222   - onUpdated(async () => {
223   - if (props.inputData && props.inputData.length) {
224   - await nextTick();
225   - setFieldsValue(props.value || {});
226   - }
227   - });
228   -
229   - watch(
230   - () => props.inputData,
231   - (value) => {
232   - generateSchemas(value);
233   - }
234   - );
235   -
236   - watch(
237   - () => props.formProps,
238   - (value) => {
239   - setProps(value);
240   - }
241   - );
242   -</script>
243   -
244   -<template>
245   - <Card bordered class="!border-dashed !rounded-lg !border-2px">
246   - <!-- <Alert class="!mb-4 w-32" message="服务参数配置" type="info" /> -->
247   - <BasicForm class="object-model-validate-form" @register="register" />
248   - </Card>
249   -</template>
250   -
251   -<style lang="less">
252   - .object-model-validate-form {
253   - .ant-input-number {
254   - width: 100% !important;
255   - }
256   - }
257   -</style>
1   -import { Specs } from '/@/api/device/model/modelOfMatterModel';
2   -import { DataTypeEnum } from '/@/enums/objectModelEnum';
3   -
4   -export interface BasicCreateFormParams {
5   - identifier: string;
6   - functionName: string;
7   - dataType: DataTypeEnum;
8   - specs: Partial<Specs>;
9   -}
... ... @@ -122,7 +122,6 @@ export type ComponentType =
122 122 | 'ApiSelectScrollLoad'
123 123 | 'TransferModal'
124 124 | 'TransferTableModal'
125   - | 'ObjectModelValidateForm'
126 125 | 'ThingsModelForm'
127 126 | 'DevicePicker'
128 127 | 'ProductPicker'
... ...
... ... @@ -7,7 +7,6 @@ import { DeviceRecord, DeviceTypeEnum } from '/@/api/device/model/deviceModel';
7 7 import { getModelServices } from '/@/api/device/modelOfMatter';
8 8 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
9 9 import { h, toRaw, unref } from 'vue';
10   -import ObjectModelValidateForm from '/@/components/Form/src/externalCompns/components/ObjectModelValidateForm/ObjectModelValidateForm.vue';
11 10 import { CommandDeliveryWayEnum, ServiceCallTypeEnum } from '/@/enums/toolEnum';
12 11 import { TaskTypeEnum } from '/@/views/task/center/config';
13 12 import { AddressTypeEnum } from '/@/views/task/center/components/PollCommandInput';
... ... @@ -19,7 +18,6 @@ import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect';
19 18 import { TransportTypeEnum } from '/@/enums/deviceEnum';
20 19
21 20 useComponentRegister('JSONEditor', JSONEditor);
22   -useComponentRegister('ObjectModelValidateForm', ObjectModelValidateForm);
23 21 useComponentRegister('LockControlGroup', LockControlGroup);
24 22 useComponentRegister('OrgTreeSelect', OrgTreeSelect);
25 23
... ... @@ -1105,7 +1103,7 @@ export const CommandSchemas = (
1105 1103 },
1106 1104 {
1107 1105 field: CommandFieldsEnum.MODEL_INPUT,
1108   - component: 'ObjectModelValidateForm',
  1106 + component: 'ThingsModelForm',
1109 1107 label: '输入参数',
1110 1108 changeEvent: 'update:value',
1111 1109 valueField: 'value',
... ...
1 1 import { StructJSON } from '/@/api/device/model/modelOfMatterModel';
2 2 import { FormSchema } from '/@/components/Form';
3   -import { validateTCPCustomCommand } from '/@/components/Form/src/externalCompns/components/ThingsModelForm';
  3 +import { validateTCPCustomCommand } from '/@/components/Form/src/components/ThingsModelForm';
4 4 import { DataTypeEnum } from '/@/enums/objectModelEnum';
5 5
6 6 const InsertString = (t, c, n) => {
... ...
1 1 <script lang="ts" setup>
2 2 import { BasicForm, useForm } from '/@/components/Form';
3 3 import { DataType, ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
4   - import { StructFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/type';
  4 + import { StructFormValue } from '/@/components/Form/src/components/StructForm/type';
5 5 import {
6 6 transfromToStructJSON,
7 7 excludeIdInStructJSON,
8   - } from '/@/components/Form/src/externalCompns/components/StructForm/util';
  8 + } from '/@/components/Form/src/components/StructForm/util';
9 9 import { FunctionType } from './config';
10 10 import { isArray } from 'lodash';
11 11 import { OpenModelMode } from '../types';
12   - import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config';
  12 + import { formSchemas } from '/@/components/Form/src/components/StructForm/config';
13 13 import { DataTypeEnum } from '/@/enums/objectModelEnum';
14 14 import { ref, unref } from 'vue';
15   - import EnumList from '/@/components/Form/src/externalCompns/components/StructForm/EnumList.vue';
  15 + import EnumList from '/@/components/Form/src/components/StructForm/EnumList.vue';
16 16 import { TransportTypeEnum } from '/@/enums/deviceEnum';
17 17
18 18 const props = defineProps<{ openModalMode: OpenModelMode; transportType?: string | undefined }>();
... ...
... ... @@ -5,8 +5,8 @@
5 5 import { BasicForm, useForm } from '/@/components/Form';
6 6 import { eventSchemas, FunctionType } from './config';
7 7 import { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel';
8   - import { StructFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/type';
9   - import { excludeIdInStructJSON } from '/@/components/Form/src/externalCompns/components/StructForm/util';
  8 + import { StructFormValue } from '/@/components/Form/src/components/StructForm/type';
  9 + import { excludeIdInStructJSON } from '/@/components/Form/src/components/StructForm/util';
10 10 import { OpenModelMode } from '../types';
11 11
12 12 defineProps<{ openModalMode: OpenModelMode }>();
... ...
... ... @@ -5,10 +5,10 @@
5 5 import { BasicForm, useForm } from '/@/components/Form';
6 6 import { FormField, serviceSchemas } from './config';
7 7 import { FunctionType } from './config';
8   - import { StructFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/type';
  8 + import { StructFormValue } from '/@/components/Form/src/components/StructForm/type';
9 9 import { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatterModel';
10 10 import { DeviceRecord } from '/@/api/device/model/deviceModel';
11   - import { excludeIdInStructJSON } from '/@/components/Form/src/externalCompns/components/StructForm/util';
  11 + import { excludeIdInStructJSON } from '/@/components/Form/src/components/StructForm/util';
12 12 import { OpenModelMode } from '../types';
13 13 import { isArray } from '/@/utils/is';
14 14 import { DataTypeEnum } from '/@/enums/objectModelEnum';
... ...
... ... @@ -28,7 +28,7 @@ import { ModelOfMatterParams, StructJSON } from '/@/api/device/model/modelOfMatt
28 28 import { DeviceProfileModel } from '/@/api/device/model/deviceModel';
29 29 import { JSONEditor } from '/@/components/CodeEditor';
30 30 import { useJsonParse } from '/@/hooks/business/useJsonParse';
31   -import { validateTCPCustomCommand } from '/@/components/Form/src/externalCompns/components/ThingsModelForm';
  31 +import { validateTCPCustomCommand } from '/@/components/Form/src/components/ThingsModelForm';
32 32 import { TransportTypeEnum } from '/@/enums/deviceEnum';
33 33
34 34 export enum FormFieldsEnum {
... ...