Commit 8484ee22e2f0f72b1bcc5db464775b204b394428

Authored by 1400859700@qq.com
1 parent 0e1f79ab

fix:所有的字段验证

... ... @@ -41,6 +41,7 @@ export const formSchema: FormSchema[] = [
41 41 label: '',
42 42 component: 'Input',
43 43 componentProps: {
  44 + maxLength: 255,
44 45 placeholder: '请输入设备名称',
45 46 },
46 47 },
... ...
... ... @@ -56,6 +56,7 @@ export const searchFormSchema: FormSchema[] = [
56 56 component: 'Input',
57 57 colProps: { span: 6 },
58 58 componentProps: {
  59 + maxLength: 36,
59 60 placeholder: '请输入联系人姓名',
60 61 },
61 62 },
... ...
... ... @@ -3,11 +3,6 @@ import { findDictItemByCode } from '/@/api/system/dict';
3 3 import { deviceProfile } from '/@/api/device/deviceManager';
4 4 import { getOrganizationList } from '/@/api/system/system';
5 5 import { copyTransFun } from '/@/utils/fnUtils';
6   -import {
7   - DeviceNameMaxLength,
8   - DeviceProfileIdMaxLength,
9   - DeviceOrgIdMaxLength,
10   -} from '/@/utils/rules';
11 6
12 7 // 第一步的表单
13 8 export const step1Schemas: FormSchema[] = [
... ... @@ -26,7 +21,6 @@ export const step1Schemas: FormSchema[] = [
26 21 placeholder: '设备名称',
27 22 maxLength: 30,
28 23 },
29   - rules: DeviceNameMaxLength,
30 24 },
31 25 {
32 26 field: 'deviceType',
... ... @@ -53,7 +47,6 @@ export const step1Schemas: FormSchema[] = [
53 47 labelField: 'name',
54 48 valueField: 'id',
55 49 },
56   - rules: DeviceProfileIdMaxLength,
57 50 },
58 51 {
59 52 field: 'organizationId',
... ... @@ -67,7 +60,6 @@ export const step1Schemas: FormSchema[] = [
67 60 return data;
68 61 },
69 62 },
70   - rules: DeviceOrgIdMaxLength,
71 63 },
72 64 {
73 65 field: 'label',
... ... @@ -341,19 +333,6 @@ export const step2Schemas: FormSchema[] = [
341 333 maxLength: 36,
342 334 placeholder: '请输入访问令牌',
343 335 },
344   - dynamicRules: () => {
345   - return [
346   - {
347   - required: true,
348   - validator: (_, value) => {
349   - if (String(value).length > 36) {
350   - return Promise.reject('字数不超过36个字');
351   - }
352   - return Promise.resolve();
353   - },
354   - },
355   - ];
356   - },
357 336 },
358 337 {
359 338 label: 'RSA公钥',
... ... @@ -365,19 +344,6 @@ export const step2Schemas: FormSchema[] = [
365 344 maxLength: 36,
366 345 placeholder: '请输入RSA公钥',
367 346 },
368   - dynamicRules: () => {
369   - return [
370   - {
371   - required: true,
372   - validator: (_, value) => {
373   - if (String(value).length > 36) {
374   - return Promise.reject('字数不超过36个字');
375   - }
376   - return Promise.resolve();
377   - },
378   - },
379   - ];
380   - },
381 347 },
382 348 {
383 349 label: '客户端ID',
... ... @@ -389,19 +355,6 @@ export const step2Schemas: FormSchema[] = [
389 355 maxLength: 36,
390 356 placeholder: '请输入客户端ID',
391 357 },
392   - dynamicRules: () => {
393   - return [
394   - {
395   - required: true,
396   - validator: (_, value) => {
397   - if (String(value).length > 36) {
398   - return Promise.reject('字数不超过36个字');
399   - }
400   - return Promise.resolve();
401   - },
402   - },
403   - ];
404   - },
405 358 },
406 359 {
407 360 label: '用户名',
... ... @@ -413,19 +366,6 @@ export const step2Schemas: FormSchema[] = [
413 366 maxLength: 255,
414 367 placeholder: '请输入用户名',
415 368 },
416   - dynamicRules: () => {
417   - return [
418   - {
419   - required: true,
420   - validator: (_, value) => {
421   - if (String(value).length > 255) {
422   - return Promise.reject('字数不超过255个字');
423   - }
424   - return Promise.resolve();
425   - },
426   - },
427   - ];
428   - },
429 369 },
430 370 {
431 371 label: '密码',
... ... @@ -591,19 +531,6 @@ export const TokenSchemas: FormSchema[] = [
591 531 maxLength: 36,
592 532 placeholder: '请输入访问令牌',
593 533 },
594   - dynamicRules: () => {
595   - return [
596   - {
597   - required: false,
598   - validator: (_, value) => {
599   - if (String(value).length > 36) {
600   - return Promise.reject('字数不超过36个字');
601   - }
602   - return Promise.resolve();
603   - },
604   - },
605   - ];
606   - },
607 534 },
608 535 {
609 536 label: 'RSA公钥',
... ... @@ -615,19 +542,6 @@ export const TokenSchemas: FormSchema[] = [
615 542 maxLength: 36,
616 543 placeholder: '请输入RSA公钥',
617 544 },
618   - dynamicRules: () => {
619   - return [
620   - {
621   - required: true,
622   - validator: (_, value) => {
623   - if (String(value).length > 36) {
624   - return Promise.reject('字数不超过36个字');
625   - }
626   - return Promise.resolve();
627   - },
628   - },
629   - ];
630   - },
631 545 },
632 546 {
633 547 label: '客户端ID',
... ... @@ -639,19 +553,6 @@ export const TokenSchemas: FormSchema[] = [
639 553 maxLength: 36,
640 554 placeholder: '请输入客户端ID',
641 555 },
642   - dynamicRules: () => {
643   - return [
644   - {
645   - required: true,
646   - validator: (_, value) => {
647   - if (String(value).length > 36) {
648   - return Promise.reject('字数不超过36个字');
649   - }
650   - return Promise.resolve();
651   - },
652   - },
653   - ];
654   - },
655 556 },
656 557 {
657 558 label: '用户名',
... ... @@ -663,19 +564,6 @@ export const TokenSchemas: FormSchema[] = [
663 564 maxLength: 255,
664 565 placeholder: '请输入用户名',
665 566 },
666   - dynamicRules: () => {
667   - return [
668   - {
669   - required: true,
670   - validator: (_, value) => {
671   - if (String(value).length > 255) {
672   - return Promise.reject('字数不超过255个字');
673   - }
674   - return Promise.resolve();
675   - },
676   - },
677   - ];
678   - },
679 567 },
680 568 {
681 569 label: '密码',
... ...
... ... @@ -90,6 +90,9 @@ export const alarmSearchSchemas: FormSchema[] = [
90 90 label: '告警类型',
91 91 component: 'Input',
92 92 colProps: { span: 6 },
  93 + componentProps: {
  94 + maxLength: 36,
  95 + },
93 96 },
94 97 {
95 98 field: 'endTime',
... ...
... ... @@ -72,19 +72,6 @@ export const formSchema: FormSchema[] = [
72 72 maxLength: 255,
73 73 placeholder: '请输入配置名称',
74 74 },
75   - dynamicRules: () => {
76   - return [
77   - {
78   - required: true,
79   - validator: (_, value) => {
80   - if (String(value).length > 255) {
81   - return Promise.reject('字数不超过255个字');
82   - }
83   - return Promise.resolve();
84   - },
85   - },
86   - ];
87   - },
88 75 },
89 76 {
90 77 field: 'messageType',
... ... @@ -124,19 +111,7 @@ export const formSchema: FormSchema[] = [
124 111 maxLength: 36,
125 112 placeholder: '请输入accessKeyId',
126 113 },
127   - dynamicRules: () => {
128   - return [
129   - {
130   - required: true,
131   - validator: (_, value) => {
132   - if (String(value).length > 36) {
133   - return Promise.reject('字数不超过36个字');
134   - }
135   - return Promise.resolve();
136   - },
137   - },
138   - ];
139   - },
  114 +
140 115 ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
141 116 },
142 117 {
... ... @@ -148,19 +123,7 @@ export const formSchema: FormSchema[] = [
148 123 maxLength: 36,
149 124 placeholder: '请输入accessKeySecret',
150 125 },
151   - dynamicRules: () => {
152   - return [
153   - {
154   - required: true,
155   - validator: (_, value) => {
156   - if (String(value).length > 36) {
157   - return Promise.reject('字数不超过36个字');
158   - }
159   - return Promise.resolve();
160   - },
161   - },
162   - ];
163   - },
  126 +
164 127 ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
165 128 },
166 129 {
... ... @@ -173,19 +136,7 @@ export const formSchema: FormSchema[] = [
173 136 maxLength: 36,
174 137 placeholder: '请输入accessKeySecret',
175 138 },
176   - dynamicRules: () => {
177   - return [
178   - {
179   - required: true,
180   - validator: (_, value) => {
181   - if (String(value).length > 36) {
182   - return Promise.reject('字数不超过36个字');
183   - }
184   - return Promise.resolve();
185   - },
186   - },
187   - ];
188   - },
  139 +
189 140 ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
190 141 },
191 142 {
... ... @@ -211,19 +162,6 @@ export const formSchema: FormSchema[] = [
211 162 maxLength: 255,
212 163 placeholder: '请输入用户名',
213 164 },
214   - dynamicRules: () => {
215   - return [
216   - {
217   - required: true,
218   - validator: (_, value) => {
219   - if (String(value).length > 255) {
220   - return Promise.reject('字数不超过255个字');
221   - }
222   - return Promise.resolve();
223   - },
224   - },
225   - ];
226   - },
227 165
228 166 ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
229 167 },
... ...
... ... @@ -11,18 +11,5 @@ export const formSchema: FormSchema[] = [
11 11 maxLength: 255,
12 12 placeholder: '请输入报警详细信息',
13 13 },
14   - dynamicRules: () => {
15   - return [
16   - {
17   - required: true,
18   - validator: (_, value) => {
19   - if (String(value).length > 255) {
20   - return Promise.reject('字数不超过255个字');
21   - }
22   - return Promise.resolve();
23   - },
24   - },
25   - ];
26   - },
27 14 },
28 15 ];
... ...
... ... @@ -16,19 +16,6 @@ export const step1Schemas: FormSchema[] = [
16 16 maxLength: 255,
17 17 placeholder: '请输入配置名称',
18 18 },
19   - dynamicRules: () => {
20   - return [
21   - {
22   - required: true,
23   - validator: (_, value) => {
24   - if (String(value).length > 255) {
25   - return Promise.reject('字数不超过255个字');
26   - }
27   - return Promise.resolve();
28   - },
29   - },
30   - ];
31   - },
32 19 },
33 20 //规则链(string)
34 21 {
... ...
... ... @@ -118,19 +118,6 @@ export const formSchema: FormSchema[] = [
118 118 maxLength: 30,
119 119 placeholder: '请输入配置名称',
120 120 },
121   - dynamicRules: () => {
122   - return [
123   - {
124   - required: true,
125   - validator: (_, value) => {
126   - if (String(value).length > 30) {
127   - return Promise.reject('字数不超过30个字');
128   - }
129   - return Promise.resolve();
130   - },
131   - },
132   - ];
133   - },
134 121 },
135 122 {
136 123 field: 'messageType',
... ... @@ -170,19 +157,7 @@ export const formSchema: FormSchema[] = [
170 157 maxLength: 36,
171 158 placeholder: '请输入accessKeyId',
172 159 },
173   - dynamicRules: () => {
174   - return [
175   - {
176   - required: true,
177   - validator: (_, value) => {
178   - if (String(value).length > 36) {
179   - return Promise.reject('字数不超过36个字');
180   - }
181   - return Promise.resolve();
182   - },
183   - },
184   - ];
185   - },
  160 +
186 161 ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
187 162 },
188 163 {
... ... @@ -193,19 +168,7 @@ export const formSchema: FormSchema[] = [
193 168 maxLength: 36,
194 169 placeholder: '请输入accessKeySecret',
195 170 },
196   - dynamicRules: () => {
197   - return [
198   - {
199   - required: true,
200   - validator: (_, value) => {
201   - if (String(value).length > 36) {
202   - return Promise.reject('字数不超过36个字');
203   - }
204   - return Promise.resolve();
205   - },
206   - },
207   - ];
208   - },
  171 +
209 172 component: 'Input',
210 173 ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
211 174 },
... ... @@ -219,19 +182,7 @@ export const formSchema: FormSchema[] = [
219 182 maxLength: 36,
220 183 placeholder: '请输入服务器地址',
221 184 },
222   - dynamicRules: () => {
223   - return [
224   - {
225   - required: true,
226   - validator: (_, value) => {
227   - if (String(value).length > 36) {
228   - return Promise.reject('字数不超过36个字');
229   - }
230   - return Promise.resolve();
231   - },
232   - },
233   - ];
234   - },
  185 +
235 186 ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
236 187 },
237 188 {
... ... @@ -243,19 +194,7 @@ export const formSchema: FormSchema[] = [
243 194 maxLength: 36,
244 195 placeholder: '请输入端口',
245 196 },
246   - dynamicRules: () => {
247   - return [
248   - {
249   - required: true,
250   - validator: (_, value) => {
251   - if (String(value).length > 36) {
252   - return Promise.reject('字数不超过36个字');
253   - }
254   - return Promise.resolve();
255   - },
256   - },
257   - ];
258   - },
  197 +
259 198 component: 'InputNumber',
260 199 ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
261 200 },
... ... @@ -267,19 +206,6 @@ export const formSchema: FormSchema[] = [
267 206 maxLength: 255,
268 207 placeholder: '请输入用户名',
269 208 },
270   - dynamicRules: () => {
271   - return [
272   - {
273   - required: false,
274   - validator: (_, value) => {
275   - if (String(value).length > 255) {
276   - return Promise.reject('字数不超过255个字');
277   - }
278   - return Promise.resolve();
279   - },
280   - },
281   - ];
282   - },
283 209
284 210 component: 'Input',
285 211 ifShow: ({ values }) => isEmail(Reflect.get(values, 'messageType')),
... ...
... ... @@ -52,6 +52,9 @@ export const searchFormSchema: FormSchema[] = [
52 52 label: '发送手机',
53 53 component: 'Input',
54 54 colProps: { span: 6 },
  55 + componentProps: {
  56 + maxLength: 36,
  57 + },
55 58 },
56 59 {
57 60 field: 'sendTime',
... ...
... ... @@ -200,19 +200,6 @@ export const formSchema: FormSchema[] = [
200 200 maxLength: 32,
201 201 placeholder: '请输入模板名称',
202 202 },
203   - dynamicRules: () => {
204   - return [
205   - {
206   - required: false,
207   - validator: (_, value) => {
208   - if (String(value).length > 32) {
209   - return Promise.reject('字数不超过32个字');
210   - }
211   - return Promise.resolve();
212   - },
213   - },
214   - ];
215   - },
216 203 },
217 204 {
218 205 field: 'templateCode',
... ... @@ -223,19 +210,7 @@ export const formSchema: FormSchema[] = [
223 210 maxLength: 20,
224 211 placeholder: '请输入模板编号',
225 212 },
226   - dynamicRules: () => {
227   - return [
228   - {
229   - required: false,
230   - validator: (_, value) => {
231   - if (String(value).length > 20) {
232   - return Promise.reject('字数不超过20个字');
233   - }
234   - return Promise.resolve();
235   - },
236   - },
237   - ];
238   - },
  213 +
239 214 ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
240 215 },
241 216 {
... ... @@ -247,19 +222,6 @@ export const formSchema: FormSchema[] = [
247 222 maxLength: 32,
248 223 placeholder: '请输入签名',
249 224 },
250   - dynamicRules: () => {
251   - return [
252   - {
253   - required: false,
254   - validator: (_, value) => {
255   - if (String(value).length > 32) {
256   - return Promise.reject('字数不超过32个字');
257   - }
258   - return Promise.resolve();
259   - },
260   - },
261   - ];
262   - },
263 225
264 226 ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')),
265 227 },
... ...
... ... @@ -150,19 +150,6 @@ export const formSchema: FormSchema[] = [
150 150 maxLength: 36,
151 151 placeholder: '请输入场景联动名称',
152 152 },
153   - dynamicRules: () => {
154   - return [
155   - {
156   - required: true,
157   - validator: (_, value) => {
158   - if (String(value).length > 36) {
159   - return Promise.reject('字数不超过36个字');
160   - }
161   - return Promise.resolve();
162   - },
163   - },
164   - ];
165   - },
166 153 },
167 154 {
168 155 required: true,
... ...
... ... @@ -5,7 +5,6 @@ import { Tinymce } from '/@/components/Tinymce/index';
5 5 import { getOrganizationList } from '/@/api/system/system';
6 6 import { copyTransFun } from '/@/utils/fnUtils';
7 7 import { Tag } from 'ant-design-vue';
8   -import { NotificationTitleMaxLength } from '/@/utils/rules';
9 8
10 9 export enum IsOrgEnum {
11 10 IS_ORG_ENUM = '1',
... ... @@ -98,7 +97,6 @@ export const formSchema: FormSchema[] = [
98 97 placeholder: '请输入标题',
99 98 maxLength: 200,
100 99 },
101   - rules: NotificationTitleMaxLength,
102 100 },
103 101 {
104 102 field: 'content',
... ...
... ... @@ -159,19 +159,6 @@ export const accountFormSchema: FormSchema[] = [
159 159 componentProps: {
160 160 maxLength: 255,
161 161 },
162   - dynamicRules: () => {
163   - return [
164   - {
165   - required: true,
166   - validator: (_, value) => {
167   - if (String(value).length > 255) {
168   - return Promise.reject('字数不超过255个字');
169   - }
170   - return Promise.resolve();
171   - },
172   - },
173   - ];
174   - },
175 162 },
176 163 {
177 164 label: '角色',
... ...
... ... @@ -85,19 +85,6 @@ export const formSchema: FormSchema[] = [
85 85 componentProps: {
86 86 maxLength: 32,
87 87 },
88   - dynamicRules: () => {
89   - return [
90   - {
91   - required: true,
92   - validator: (_, value) => {
93   - if (String(value).length > 32) {
94   - return Promise.reject('字数不超过32个字');
95   - }
96   - return Promise.resolve();
97   - },
98   - },
99   - ];
100   - },
101 88 },
102 89 {
103 90 field: 'dictCode',
... ... @@ -107,19 +94,6 @@ export const formSchema: FormSchema[] = [
107 94 componentProps: {
108 95 maxLength: 32,
109 96 },
110   - dynamicRules: () => {
111   - return [
112   - {
113   - required: true,
114   - validator: (_, value) => {
115   - if (String(value).length > 32) {
116   - return Promise.reject('字数不超过32个字');
117   - }
118   - return Promise.resolve();
119   - },
120   - },
121   - ];
122   - },
123 97 },
124 98 {
125 99 label: '备注',
... ...
... ... @@ -141,19 +141,7 @@ export const formSchema: FormSchema[] = [
141 141 required: true,
142 142 componentProps: {
143 143 maxLength: 255,
144   - },
145   - dynamicRules: () => {
146   - return [
147   - {
148   - required: true,
149   - validator: (_, value) => {
150   - if (String(value).length > 255) {
151   - return Promise.reject('字数不超过255个字');
152   - }
153   - return Promise.resolve();
154   - },
155   - },
156   - ];
  144 + placeholder: '请输入title',
157 145 },
158 146 },
159 147
... ... @@ -179,19 +167,6 @@ export const formSchema: FormSchema[] = [
179 167 componentProps: {
180 168 maxLength: 32,
181 169 },
182   - dynamicRules: () => {
183   - return [
184   - {
185   - required: true,
186   - validator: (_, value) => {
187   - if (String(value).length > 32) {
188   - return Promise.reject('字数不超过32个字');
189   - }
190   - return Promise.resolve();
191   - },
192   - },
193   - ];
194   - },
195 170 },
196 171 {
197 172 field: 'icon',
... ... @@ -209,19 +184,7 @@ export const formSchema: FormSchema[] = [
209 184 ifShow: ({ values }) => !isButton(Reflect.get(values, 'menuType')),
210 185 componentProps: {
211 186 maxLength: 255,
212   - },
213   - dynamicRules: () => {
214   - return [
215   - {
216   - required: false,
217   - validator: (_, value) => {
218   - if (String(value).length > 255) {
219   - return Promise.reject('字数不超过255个字');
220   - }
221   - return Promise.resolve();
222   - },
223   - },
224   - ];
  187 + palceholder: '请输入path',
225 188 },
226 189 },
227 190 {
... ...
... ... @@ -47,19 +47,7 @@ export const formSchema: FormSchema[] = [
47 47 required: true,
48 48 componentProps: {
49 49 maxLength: 255,
50   - },
51   - dynamicRules: () => {
52   - return [
53   - {
54   - required: true,
55   - validator: (_, value) => {
56   - if (String(value).length > 255) {
57   - return Promise.reject('字数不超过255个字');
58   - }
59   - return Promise.resolve();
60   - },
61   - },
62   - ];
  50 + placeholder: '请输入name',
63 51 },
64 52 },
65 53 {
... ... @@ -70,19 +58,6 @@ export const formSchema: FormSchema[] = [
70 58 componentProps: {
71 59 maxLength: 32,
72 60 },
73   - dynamicRules: () => {
74   - return [
75   - {
76   - required: true,
77   - validator: (_, value) => {
78   - if (String(value).length > 32) {
79   - return Promise.reject('字数不超过32个字');
80   - }
81   - return Promise.resolve();
82   - },
83   - },
84   - ];
85   - },
86 61 },
87 62 {
88 63 label: t('routes.common.common.remark'), //备注
... ...
... ... @@ -107,19 +107,6 @@ export const formSchema: FormSchema[] = [
107 107 componentProps: {
108 108 maxLength: 255,
109 109 },
110   - dynamicRules: () => {
111   - return [
112   - {
113   - required: true,
114   - validator: (_, value) => {
115   - if (String(value).length > 255) {
116   - return Promise.reject('字数不超过255个字');
117   - }
118   - return Promise.resolve();
119   - },
120   - },
121   - ];
122   - },
123 110 },
124 111 {
125 112 field: 'status',
... ...
... ... @@ -115,19 +115,7 @@ export const tenantFormSchema: FormSchema[] = [
115 115 component: 'Input',
116 116 componentProps: {
117 117 maxLength: 255,
118   - },
119   - dynamicRules: () => {
120   - return [
121   - {
122   - required: false,
123   - validator: (_, value) => {
124   - if (String(value).length > 255) {
125   - return Promise.reject('字数不超过255个字');
126   - }
127   - return Promise.resolve();
128   - },
129   - },
130   - ];
  118 + placeholder: '请输入租户名称',
131 119 },
132 120 },
133 121 {
... ...
... ... @@ -133,19 +133,6 @@ export const formSchema: FormSchema[] = [
133 133 maxLength: 255,
134 134 placeholder: '请输入角色名称',
135 135 },
136   - dynamicRules: () => {
137   - return [
138   - {
139   - required: true,
140   - validator: (_, value) => {
141   - if (String(value).length > 255) {
142   - return Promise.reject('字数不超过255个字');
143   - }
144   - return Promise.resolve();
145   - },
146   - },
147   - ];
148   - },
149 136 },
150 137 {
151 138 field: 'status',
... ...
... ... @@ -66,19 +66,6 @@ export const formSchema: FormSchema[] = [
66 66 maxLength: 255,
67 67 placeholder: '请输入名称',
68 68 },
69   - dynamicRules: () => {
70   - return [
71   - {
72   - required: true,
73   - validator: (_, value) => {
74   - if (String(value).length > 255) {
75   - return Promise.reject('字数不超过255个字');
76   - }
77   - return Promise.resolve();
78   - },
79   - },
80   - ];
81   - },
82 69 },
83 70 {
84 71 field: 'isolatedTbRuleEngine',
... ...