Commit 2c36edc05c7429af88c77ecf6570eb4a1a2237fa

Authored by ww
1 parent 04de33d9

fix: 修复产品详情物模型管理结构体类型能无限嵌套,修复后只能嵌套一层

... ... @@ -20,9 +20,11 @@
20 20 defineProps<{
21 21 value: ModelOfMatterParams[];
22 22 disabled: boolean;
  23 + hasStructForm?: boolean;
23 24 }>(),
24 25 {
25 26 value: () => [],
  27 + hasStructForm: false,
26 28 }
27 29 );
28 30
... ... @@ -106,6 +108,7 @@
106 108 </div>
107 109 </div>
108 110 <StructFormModel
  111 + :has-struct-form="$props.hasStructForm!"
109 112 :disabled="$props.disabled"
110 113 @register="registerModal"
111 114 @submit="handleSaveStruct"
... ...
... ... @@ -18,13 +18,13 @@
18 18 mode: OpenModalMode.CREATE,
19 19 });
20 20
21   - const props = defineProps<{ disabled: boolean }>();
  21 + const props = defineProps<{ disabled: boolean; hasStructForm: boolean }>();
22 22
23 23 const emit = defineEmits(['register', 'submit']);
24 24
25 25 const [register, { validate, setFieldsValue, setProps }] = useForm({
26 26 labelWidth: 100,
27   - schemas: formSchemas,
  27 + schemas: formSchemas(props.hasStructForm),
28 28 actionColOptions: {
29 29 span: 14,
30 30 },
... ...
... ... @@ -27,272 +27,288 @@ export const validateJSON = (_rule, value: ModelOfMatterParams[], _callback) =>
27 27 return Promise.reject('JSON对象不能为空');
28 28 };
29 29
30   -export const formSchemas: FormSchema[] = [
31   - {
32   - field: FormField.FUNCTION_NAME,
33   - label: '功能名称',
34   - required: true,
35   - component: 'Input',
36   - colProps: {
37   - span: 18,
38   - },
39   - componentProps: {
40   - maxLength: 255,
41   - placeholder: '请输入功能名称',
42   - },
43   - },
44   - {
45   - field: FormField.IDENTIFIER,
46   - label: '标识符',
47   - required: true,
48   - component: 'Input',
49   - colProps: {
50   - span: 18,
51   - },
52   - componentProps: {
53   - maxLength: 255,
54   - placeholder: '请输入标识符',
55   - },
56   - },
57   - {
58   - field: FormField.TYPE,
59   - label: '数据类型',
60   - required: true,
61   - component: 'ApiSelect',
62   - colProps: {
63   - span: 9,
64   - },
65   - defaultValue: 'INT',
66   - componentProps: {
67   - placeholder: '请选择数据类型',
68   - api: async (params: Recordable) => {
69   - try {
70   - const record = await findDictItemByCode(params);
71   - return record.filter((item) => item.itemValue !== 'STRUCT');
72   - } catch (error) {
73   - console.log(error);
74   - return [];
75   - }
  30 +export const formSchemas = (hasStructForm: boolean): FormSchema[] => {
  31 + return [
  32 + {
  33 + field: FormField.FUNCTION_NAME,
  34 + label: '功能名称',
  35 + required: true,
  36 + component: 'Input',
  37 + colProps: {
  38 + span: 18,
76 39 },
77   - params: {
78   - dictCode: 'data_type',
  40 + componentProps: {
  41 + maxLength: 255,
  42 + placeholder: '请输入功能名称',
79 43 },
80   - labelField: 'itemText',
81   - valueField: 'itemValue',
82   - getPopupContainer: () => document.body,
83   - },
84   - },
85   - {
86   - field: FormField.VALUE_RANGE,
87   - label: '取值范围',
88   - component: 'CustomMinMaxInput',
89   - valueField: 'value',
90   - changeEvent: 'update:value',
91   - colProps: {
92   - span: 18,
93 44 },
94   - ifShow: ({ values }) =>
95   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
96   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
97   - rules: [{ validator: validateValueRange }],
98   - },
99   - {
100   - field: FormField.STEP,
101   - label: '步长',
102   - component: 'InputNumber',
103   - colProps: {
104   - span: 18,
105   - },
106   - componentProps: {
107   - maxLength: 255,
108   - placeholder: '请输入步长',
109   - min: 1,
110   - formatter: (value: number | string) => {
111   - return value ? Math.floor(Number(value)) : value;
  45 + {
  46 + field: FormField.IDENTIFIER,
  47 + label: '标识符',
  48 + required: true,
  49 + component: 'Input',
  50 + colProps: {
  51 + span: 18,
  52 + },
  53 + componentProps: {
  54 + maxLength: 255,
  55 + placeholder: '请输入标识符',
112 56 },
113 57 },
114   - ifShow: ({ values }) =>
115   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
116   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
117   - dynamicRules: ({ model }) => {
118   - const valueRange = model[FormField.VALUE_RANGE] || {};
119   - const { min = 0, max = 0 } = valueRange;
120   - const step = model[FormField.STEP];
121   - return [
122   - {
123   - validator: () => {
124   - if (step > max - min) {
125   - return Promise.reject('步长不能大于取值范围的差值');
  58 + {
  59 + field: FormField.TYPE,
  60 + label: '数据类型',
  61 + required: true,
  62 + component: 'ApiSelect',
  63 + colProps: {
  64 + span: 9,
  65 + },
  66 + defaultValue: 'INT',
  67 + componentProps: ({ formActionType }) => {
  68 + const { updateSchema } = formActionType;
  69 + return {
  70 + placeholder: '请选择数据类型',
  71 + api: async (params: Recordable) => {
  72 + try {
  73 + const record = await findDictItemByCode(params);
  74 + return hasStructForm
  75 + ? record.filter((item) => item.itemValue !== DataTypeEnum.IS_STRUCT)
  76 + : record;
  77 + } catch (error) {
  78 + console.log(error);
  79 + return [];
126 80 }
127   - return Promise.resolve();
128 81 },
129   - },
130   - ];
131   - },
132   - },
133   - {
134   - field: FormField.UNIT_NAME,
135   - label: '单位名称',
136   - component: 'Input',
137   - show: false,
138   - },
139   - {
140   - field: FormField.UNIT,
141   - label: '单位',
142   - component: 'ApiSelect',
143   - colProps: {
144   - span: 9,
145   - },
146   - componentProps: ({ formActionType }) => {
147   - const { setFieldsValue } = formActionType;
148   - return {
149   - placeholder: '请选择单位',
150   - api: async (params) => {
151   - const list = await findDictItemByCode(params);
152   - list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`));
153   - return list;
154   - },
155   - params: {
156   - dictCode: 'attribute_unit',
157   - },
158   - labelInValue: true,
159   - labelField: 'itemText',
160   - valueField: 'itemValue',
161   - onChange(_, record: Record<'label' | 'value', string>) {
162   - if (record) {
163   - const { label } = record;
164   - setFieldsValue({ [FormField.UNIT_NAME]: label });
165   - }
166   - },
167   - getPopupContainer: () => document.body,
168   - showSearch: true,
169   - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => {
170   - let { label, value } = option;
171   - label = label.toLowerCase();
172   - value = value.toLowerCase();
173   - inputValue = inputValue.toLowerCase();
174   - return label.includes(inputValue) || value.includes(inputValue);
175   - },
176   - };
177   - },
178   - ifShow: ({ values }) =>
179   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
180   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
181   - },
182   - {
183   - field: FormField.BOOL_CLOSE,
184   - component: 'Input',
185   - required: true,
186   - label: '0 -',
187   - colProps: {
188   - span: 18,
  82 + params: {
  83 + dictCode: 'data_type',
  84 + },
  85 + labelField: 'itemText',
  86 + valueField: 'itemValue',
  87 + getPopupContainer: () => document.body,
  88 + onChange: (value: string) => {
  89 + value === DataTypeEnum.IS_STRUCT &&
  90 + updateSchema({
  91 + field: FormField.SPECS_LIST,
  92 + componentProps: {
  93 + hasStructForm: true,
  94 + },
  95 + });
  96 + },
  97 + };
  98 + },
189 99 },
190   - componentProps: {
191   - placeholder: '如:关',
  100 + {
  101 + field: FormField.VALUE_RANGE,
  102 + label: '取值范围',
  103 + component: 'CustomMinMaxInput',
  104 + valueField: 'value',
  105 + changeEvent: 'update:value',
  106 + colProps: {
  107 + span: 18,
  108 + },
  109 + ifShow: ({ values }) =>
  110 + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
  111 + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
  112 + rules: [{ validator: validateValueRange }],
192 113 },
193   - defaultValue: '关',
194   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
195   - dynamicRules: ({ model }) => {
196   - const close = model[FormField.BOOL_CLOSE];
197   - const open = model[FormField.BOOL_OPEN];
198   - return [
199   - {
200   - required: true,
  114 + {
  115 + field: FormField.STEP,
  116 + label: '步长',
  117 + component: 'InputNumber',
  118 + colProps: {
  119 + span: 18,
  120 + },
  121 + componentProps: {
  122 + maxLength: 255,
  123 + placeholder: '请输入步长',
  124 + min: 1,
  125 + formatter: (value: number | string) => {
  126 + return value ? Math.floor(Number(value)) : value;
201 127 },
202   - {
203   - validator() {
204   - if (open === close) return Promise.reject('布尔值不能相同');
205   - return Promise.resolve();
  128 + },
  129 + ifShow: ({ values }) =>
  130 + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
  131 + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
  132 + dynamicRules: ({ model }) => {
  133 + const valueRange = model[FormField.VALUE_RANGE] || {};
  134 + const { min = 0, max = 0 } = valueRange;
  135 + const step = model[FormField.STEP];
  136 + return [
  137 + {
  138 + validator: () => {
  139 + if (step > max - min) {
  140 + return Promise.reject('步长不能大于取值范围的差值');
  141 + }
  142 + return Promise.resolve();
  143 + },
206 144 },
207   - },
208   - ];
  145 + ];
  146 + },
209 147 },
210   - },
211   - {
212   - field: FormField.BOOL_OPEN,
213   - component: 'Input',
214   - required: true,
215   - label: '1 -',
216   - colProps: {
217   - span: 18,
  148 + {
  149 + field: FormField.UNIT_NAME,
  150 + label: '单位名称',
  151 + component: 'Input',
  152 + show: false,
218 153 },
219   - componentProps: {
220   - placeholder: '如:开',
  154 + {
  155 + field: FormField.UNIT,
  156 + label: '单位',
  157 + component: 'ApiSelect',
  158 + colProps: {
  159 + span: 9,
  160 + },
  161 + componentProps: ({ formActionType }) => {
  162 + const { setFieldsValue } = formActionType;
  163 + return {
  164 + placeholder: '请选择单位',
  165 + api: async (params) => {
  166 + const list = await findDictItemByCode(params);
  167 + list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`));
  168 + return list;
  169 + },
  170 + params: {
  171 + dictCode: 'attribute_unit',
  172 + },
  173 + labelInValue: true,
  174 + labelField: 'itemText',
  175 + valueField: 'itemValue',
  176 + onChange(_, record: Record<'label' | 'value', string>) {
  177 + if (record) {
  178 + const { label } = record;
  179 + setFieldsValue({ [FormField.UNIT_NAME]: label });
  180 + }
  181 + },
  182 + getPopupContainer: () => document.body,
  183 + showSearch: true,
  184 + filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => {
  185 + let { label, value } = option;
  186 + label = label.toLowerCase();
  187 + value = value.toLowerCase();
  188 + inputValue = inputValue.toLowerCase();
  189 + return label.includes(inputValue) || value.includes(inputValue);
  190 + },
  191 + };
  192 + },
  193 + ifShow: ({ values }) =>
  194 + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
  195 + values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
221 196 },
222   - defaultValue: '开',
223   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
224   - dynamicRules: ({ model }) => {
225   - const close = model[FormField.BOOL_CLOSE];
226   - const open = model[FormField.BOOL_OPEN];
227   - return [
228   - {
229   - required: true,
230   - },
231   - {
232   - validator() {
233   - if (open === close) return Promise.reject('布尔值不能相同');
234   - return Promise.resolve();
  197 + {
  198 + field: FormField.BOOL_CLOSE,
  199 + component: 'Input',
  200 + required: true,
  201 + label: '0 -',
  202 + colProps: {
  203 + span: 18,
  204 + },
  205 + componentProps: {
  206 + placeholder: '如:关',
  207 + },
  208 + defaultValue: '关',
  209 + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
  210 + dynamicRules: ({ model }) => {
  211 + const close = model[FormField.BOOL_CLOSE];
  212 + const open = model[FormField.BOOL_OPEN];
  213 + return [
  214 + {
  215 + required: true,
235 216 },
236   - },
237   - ];
  217 + {
  218 + validator() {
  219 + if (open === close) return Promise.reject('布尔值不能相同');
  220 + return Promise.resolve();
  221 + },
  222 + },
  223 + ];
  224 + },
238 225 },
239   - },
240   - {
241   - field: FormField.LENGTH,
242   - component: 'Input',
243   - required: true,
244   - label: '数据长度',
245   - defaultValue: '10240',
246   - colProps: {
247   - span: 8,
  226 + {
  227 + field: FormField.BOOL_OPEN,
  228 + component: 'Input',
  229 + required: true,
  230 + label: '1 -',
  231 + colProps: {
  232 + span: 18,
  233 + },
  234 + componentProps: {
  235 + placeholder: '如:开',
  236 + },
  237 + defaultValue: '开',
  238 + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
  239 + dynamicRules: ({ model }) => {
  240 + const close = model[FormField.BOOL_CLOSE];
  241 + const open = model[FormField.BOOL_OPEN];
  242 + return [
  243 + {
  244 + required: true,
  245 + },
  246 + {
  247 + validator() {
  248 + if (open === close) return Promise.reject('布尔值不能相同');
  249 + return Promise.resolve();
  250 + },
  251 + },
  252 + ];
  253 + },
248 254 },
249   - componentProps: {
250   - placeholder: '请输入数据长度',
  255 + {
  256 + field: FormField.LENGTH,
  257 + component: 'Input',
  258 + required: true,
  259 + label: '数据长度',
  260 + defaultValue: '10240',
  261 + colProps: {
  262 + span: 8,
  263 + },
  264 + componentProps: {
  265 + placeholder: '请输入数据长度',
  266 + },
  267 + renderComponentContent: () => {
  268 + return {
  269 + suffix: () => '字节',
  270 + };
  271 + },
  272 + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRING,
251 273 },
252   - renderComponentContent: () => {
253   - return {
254   - suffix: () => '字节',
255   - };
  274 + {
  275 + field: FormField.ACCESS_MODE,
  276 + component: 'ApiRadioGroup',
  277 + label: '读写类型',
  278 + required: true,
  279 + colProps: {
  280 + span: 24,
  281 + },
  282 + defaultValue: 'r',
  283 + componentProps: {
  284 + placeholder: '请选择读写类型',
  285 + api: findDictItemByCode,
  286 + params: {
  287 + dictCode: 'read_write_type',
  288 + },
  289 + labelField: 'itemText',
  290 + valueField: 'itemValue',
  291 + },
256 292 },
257   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRING,
258   - },
259   - {
260   - field: FormField.ACCESS_MODE,
261   - component: 'ApiRadioGroup',
262   - label: '读写类型',
263   - required: true,
264   - colProps: {
265   - span: 24,
  293 + {
  294 + field: FormField.SPECS_LIST,
  295 + label: 'JSON对象',
  296 + component: 'StructForm',
  297 + valueField: 'value',
  298 + changeEvent: 'update:value',
  299 + colProps: { span: 24 },
  300 + ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRUCT,
  301 + rules: [{ required: true, validator: validateJSON }],
266 302 },
267   - defaultValue: 'r',
268   - componentProps: {
269   - placeholder: '请选择读写类型',
270   - api: findDictItemByCode,
271   - params: {
272   - dictCode: 'read_write_type',
  303 + {
  304 + field: FormField.REFARK,
  305 + label: '备注',
  306 + component: 'InputTextArea',
  307 + componentProps: {
  308 + rows: 4,
  309 + maxLength: 100,
  310 + placeholder: '请输入描述',
273 311 },
274   - labelField: 'itemText',
275   - valueField: 'itemValue',
276   - },
277   - },
278   - {
279   - field: FormField.SPECS_LIST,
280   - label: 'JSON对象',
281   - component: 'StructForm',
282   - valueField: 'value',
283   - changeEvent: 'update:value',
284   - colProps: { span: 24 },
285   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRUCT,
286   - rules: [{ required: true, validator: validateJSON }],
287   - },
288   - {
289   - field: FormField.REFARK,
290   - label: '备注',
291   - component: 'InputTextArea',
292   - componentProps: {
293   - rows: 4,
294   - maxLength: 100,
295   - placeholder: '请输入描述',
296 312 },
297   - },
298   -];
  313 + ];
  314 +};
... ...
... ... @@ -9,15 +9,16 @@
9 9 transfromToStructJSON,
10 10 excludeIdInStructJSON,
11 11 } from '/@/components/Form/src/externalCompns/components/StructForm/util';
12   - import { FunctionType, attributeSchema } from './config';
  12 + import { FunctionType } from './config';
13 13 import { isArray } from 'lodash';
14 14 import { OpenModelMode } from '../types';
  15 + import { formSchemas } from '/@/components/Form/src/externalCompns/components/StructForm/config';
15 16
16 17 defineProps<{ openModalMode: OpenModelMode }>();
17 18
18 19 const [register, { validate, resetFields, setFieldsValue, setProps }] = useForm({
19 20 labelWidth: 100,
20   - schemas: attributeSchema,
  21 + schemas: formSchemas(false),
21 22 actionColOptions: {
22 23 span: 14,
23 24 },
... ...
1 1 import { FormSchema } from '/@/components/Table';
2 2 import { findDictItemByCode } from '/@/api/system/dict';
3   -import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
4   -
5   -export const validateValueRange = (_rule, value: Record<'min' | 'max', number>, _callback) => {
6   - value = value || {};
7   - const { min, max } = value;
8   - if (min >= max) {
9   - return Promise.reject('最大值小于最小值');
10   - }
11   - return Promise.resolve();
12   -};
13   -
14   -export const validateJSON = (_rule, value: ModelOfMatterParams[], _callback) => {
15   - if (value.length) {
16   - return Promise.resolve();
17   - }
18   - return Promise.reject('JSON对象不能为空');
19   -};
20 3
21 4 export enum FormField {
22 5 FUNCTION_NAME = 'functionName',
... ... @@ -375,265 +358,3 @@ export const addParamsSchemas: FormSchema[] = [
375 358 ifShow: ({ values }) => isNumber(values[FormField.TYPE]),
376 359 },
377 360 ];
378   -
379   -export const attributeSchema: FormSchema[] = [
380   - {
381   - field: FormField.FUNCTION_NAME,
382   - label: '功能名称',
383   - required: true,
384   - component: 'Input',
385   - colProps: {
386   - span: 18,
387   - },
388   - componentProps: {
389   - maxLength: 255,
390   - placeholder: '请输入功能名称',
391   - },
392   - },
393   - {
394   - field: FormField.IDENTIFIER,
395   - label: '标识符',
396   - required: true,
397   - component: 'Input',
398   - colProps: {
399   - span: 18,
400   - },
401   - componentProps: {
402   - maxLength: 255,
403   - placeholder: '请输入标识符',
404   - },
405   - },
406   - {
407   - field: FormField.TYPE,
408   - label: '数据类型',
409   - required: true,
410   - component: 'ApiSelect',
411   - colProps: {
412   - span: 9,
413   - },
414   - defaultValue: 'INT',
415   - componentProps: {
416   - placeholder: '请选择数据类型',
417   - api: findDictItemByCode,
418   - params: {
419   - dictCode: 'data_type',
420   - },
421   - labelField: 'itemText',
422   - valueField: 'itemValue',
423   - getPopupContainer: () => document.body,
424   - },
425   - },
426   - {
427   - field: FormField.VALUE_RANGE,
428   - label: '取值范围',
429   - component: 'CustomMinMaxInput',
430   - valueField: 'value',
431   - changeEvent: 'update:value',
432   - colProps: {
433   - span: 18,
434   - },
435   - ifShow: ({ values }) =>
436   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
437   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
438   - rules: [{ validator: validateValueRange }],
439   - },
440   - {
441   - field: FormField.STEP,
442   - label: '步长',
443   - component: 'InputNumber',
444   - colProps: {
445   - span: 18,
446   - },
447   - componentProps: {
448   - maxLength: 255,
449   - placeholder: '请输入步长',
450   - min: 1,
451   - formatter: (value: number | string) => {
452   - return value ? Math.floor(Number(value)) : value;
453   - },
454   - },
455   - ifShow: ({ values }) =>
456   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
457   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
458   - dynamicRules: ({ model }) => {
459   - const valueRange = model[FormField.VALUE_RANGE] || {};
460   - const { min = 0, max = 0 } = valueRange;
461   - const step = model[FormField.STEP];
462   - return [
463   - {
464   - validator: () => {
465   - if (step > max - min) {
466   - return Promise.reject('步长不能大于取值范围的差值');
467   - }
468   - return Promise.resolve();
469   - },
470   - },
471   - ];
472   - },
473   - },
474   - {
475   - field: FormField.UNIT_NAME,
476   - label: '单位名称',
477   - component: 'Input',
478   - show: false,
479   - },
480   - {
481   - field: FormField.UNIT,
482   - label: '单位',
483   - component: 'ApiSelect',
484   - colProps: {
485   - span: 9,
486   - },
487   - componentProps: ({ formActionType }) => {
488   - const { setFieldsValue } = formActionType;
489   - return {
490   - placeholder: '请选择单位',
491   - api: async (params) => {
492   - const list = await findDictItemByCode(params);
493   - list.map((item) => (item.itemText = `${item.itemText} / ${item.itemValue}`));
494   - return list;
495   - },
496   - params: {
497   - dictCode: 'attribute_unit',
498   - },
499   - labelInValue: true,
500   - labelField: 'itemText',
501   - valueField: 'itemValue',
502   - onChange(_, record: Record<'label' | 'value', string>) {
503   - if (record) {
504   - const { label } = record;
505   - setFieldsValue({ [FormField.UNIT_NAME]: label });
506   - }
507   - },
508   - getPopupContainer: () => document.body,
509   - showSearch: true,
510   - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => {
511   - let { label, value } = option;
512   - label = label.toLowerCase();
513   - value = value.toLowerCase();
514   - inputValue = inputValue.toLowerCase();
515   - return label.includes(inputValue) || value.includes(inputValue);
516   - },
517   - };
518   - },
519   - ifShow: ({ values }) =>
520   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_INT ||
521   - values[FormField.TYPE] === DataTypeEnum.IS_NUMBER_DOUBLE,
522   - },
523   - {
524   - field: FormField.BOOL_CLOSE,
525   - component: 'Input',
526   - required: true,
527   - label: '0 -',
528   - colProps: {
529   - span: 18,
530   - },
531   - componentProps: {
532   - placeholder: '如:关',
533   - },
534   - defaultValue: '关',
535   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
536   - dynamicRules: ({ model }) => {
537   - const close = model[FormField.BOOL_CLOSE];
538   - const open = model[FormField.BOOL_OPEN];
539   - return [
540   - {
541   - required: true,
542   - },
543   - {
544   - validator() {
545   - if (open === close) return Promise.reject('布尔值不能相同');
546   - return Promise.resolve();
547   - },
548   - },
549   - ];
550   - },
551   - },
552   - {
553   - field: FormField.BOOL_OPEN,
554   - component: 'Input',
555   - required: true,
556   - label: '1 -',
557   - colProps: {
558   - span: 18,
559   - },
560   - componentProps: {
561   - placeholder: '如:开',
562   - },
563   - defaultValue: '开',
564   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
565   - dynamicRules: ({ model }) => {
566   - const close = model[FormField.BOOL_CLOSE];
567   - const open = model[FormField.BOOL_OPEN];
568   - return [
569   - {
570   - required: true,
571   - },
572   - {
573   - validator() {
574   - if (open === close) return Promise.reject('布尔值不能相同');
575   - return Promise.resolve();
576   - },
577   - },
578   - ];
579   - },
580   - },
581   - {
582   - field: FormField.LENGTH,
583   - component: 'Input',
584   - required: true,
585   - label: '数据长度',
586   - defaultValue: '10240',
587   - colProps: {
588   - span: 8,
589   - },
590   - componentProps: {
591   - placeholder: '请输入数据长度',
592   - },
593   - renderComponentContent: () => {
594   - return {
595   - suffix: () => '字节',
596   - };
597   - },
598   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRING,
599   - },
600   - {
601   - field: FormField.ACCESS_MODE,
602   - component: 'ApiRadioGroup',
603   - label: '读写类型',
604   - required: true,
605   - colProps: {
606   - span: 24,
607   - },
608   - defaultValue: 'r',
609   - componentProps: {
610   - placeholder: '请选择读写类型',
611   - api: findDictItemByCode,
612   - params: {
613   - dictCode: 'read_write_type',
614   - },
615   - labelField: 'itemText',
616   - valueField: 'itemValue',
617   - },
618   - },
619   - {
620   - field: FormField.SPECS_LIST,
621   - label: 'JSON对象',
622   - component: 'StructForm',
623   - valueField: 'value',
624   - changeEvent: 'update:value',
625   - colProps: { span: 24 },
626   - ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_STRUCT,
627   - rules: [{ required: true, validator: validateJSON }],
628   - },
629   - {
630   - field: FormField.REFARK,
631   - label: '备注',
632   - component: 'InputTextArea',
633   - componentProps: {
634   - rows: 4,
635   - maxLength: 100,
636   - placeholder: '请输入描述',
637   - },
638   - },
639   -];
... ...