Commit 77342a41b94be80759071d82608c5ccd4cea8b6b
Merge branch 'ft-dev' into 'main'
fix:修复设备配置无法点击第三步问题,feat:站内通知表单字段限制 See merge request huang/yun-teng-iot-front!68
Showing
9 changed files
with
260 additions
and
34 deletions
... | ... | @@ -60,3 +60,182 @@ export const EmailRegexp = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a |
60 | 60 | |
61 | 61 | // 手机号正则 |
62 | 62 | export const PhoneRegexp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; |
63 | + | |
64 | +//站内通知 | |
65 | +export const NotificationTitleMaxLength: Rule[] = [ | |
66 | + { | |
67 | + required: true, | |
68 | + validator: (_, value: string) => { | |
69 | + if (String(value).length > 50) { | |
70 | + return Promise.reject('标题长度不超过200字'); | |
71 | + } | |
72 | + }, | |
73 | + validateTrigger: 'blur', | |
74 | + }, | |
75 | +]; | |
76 | + | |
77 | +export const NotificationContentMaxLength: Rule[] = [ | |
78 | + { | |
79 | + required: true, | |
80 | + validator: (_, value: string) => { | |
81 | + if (String(value).length > 50) { | |
82 | + return Promise.reject('内容长度不超过50字'); | |
83 | + } | |
84 | + return Promise.resolve(); | |
85 | + }, | |
86 | + validateTrigger: 'blur', | |
87 | + }, | |
88 | +]; | |
89 | +export const NotificationTypeMaxLength: Rule[] = [ | |
90 | + { | |
91 | + required: true, | |
92 | + validator: (_, value: string) => { | |
93 | + if (!value) { | |
94 | + return Promise.reject('请选择类型'); | |
95 | + } | |
96 | + return Promise.resolve(); | |
97 | + }, | |
98 | + validateTrigger: 'blur', | |
99 | + }, | |
100 | +]; | |
101 | + | |
102 | +export const DeviceNameMaxLength: Rule[] = [ | |
103 | + { | |
104 | + required: true, | |
105 | + validator: (_, value: string) => { | |
106 | + if (String(value).length > 30) { | |
107 | + return Promise.reject('设备名称长度不超过30字'); | |
108 | + } | |
109 | + return Promise.resolve(); | |
110 | + }, | |
111 | + validateTrigger: 'blur', | |
112 | + }, | |
113 | +]; | |
114 | + | |
115 | +export const DeviceProfileIdMaxLength: Rule[] = [ | |
116 | + { | |
117 | + required: true, | |
118 | + validator: (_, value: string) => { | |
119 | + if (String(value).length > 36) { | |
120 | + return Promise.reject('设备配置长度不超过36字'); | |
121 | + } | |
122 | + return Promise.resolve(); | |
123 | + }, | |
124 | + validateTrigger: 'blur', | |
125 | + }, | |
126 | +]; | |
127 | + | |
128 | +export const DeviceOrgIdMaxLength: Rule[] = [ | |
129 | + { | |
130 | + required: true, | |
131 | + validator: (_, value: string) => { | |
132 | + if (String(value).length > 36) { | |
133 | + return Promise.reject('组织长度不超过36字'); | |
134 | + } | |
135 | + return Promise.resolve(); | |
136 | + }, | |
137 | + validateTrigger: 'blur', | |
138 | + }, | |
139 | +]; | |
140 | + | |
141 | +export const DeviceLabelMaxLength: Rule[] = [ | |
142 | + { | |
143 | + required: true, | |
144 | + validator: (_, value: string) => { | |
145 | + if (String(value).length > 255) { | |
146 | + return Promise.reject('设备标签不超过255字'); | |
147 | + } | |
148 | + return Promise.resolve(); | |
149 | + }, | |
150 | + validateTrigger: 'blur', | |
151 | + }, | |
152 | +]; | |
153 | +export const DeviceDescriptionlMaxLength: Rule[] = [ | |
154 | + { | |
155 | + required: true, | |
156 | + validator: (_, value: string) => { | |
157 | + if (String(value).length > 500) { | |
158 | + return Promise.reject('备注不超过500字'); | |
159 | + } | |
160 | + return Promise.resolve(); | |
161 | + }, | |
162 | + validateTrigger: 'blur', | |
163 | + }, | |
164 | +]; | |
165 | +export const DeviceIdMaxLength: Rule[] = [ | |
166 | + { | |
167 | + required: true, | |
168 | + validator: (_, value: string) => { | |
169 | + if (String(value).length > 36) { | |
170 | + return Promise.reject('id不超过36字'); | |
171 | + } | |
172 | + return Promise.resolve(); | |
173 | + }, | |
174 | + validateTrigger: 'blur', | |
175 | + }, | |
176 | +]; | |
177 | + | |
178 | +export const DeviceTenantIdMaxLength: Rule[] = [ | |
179 | + { | |
180 | + required: true, | |
181 | + validator: (_, value: string) => { | |
182 | + if (String(value).length > 36) { | |
183 | + return Promise.reject('租户Code不超过36字'); | |
184 | + } | |
185 | + return Promise.resolve(); | |
186 | + }, | |
187 | + validateTrigger: 'blur', | |
188 | + }, | |
189 | +]; | |
190 | + | |
191 | +export const DeviceTbDeviceIdMaxLength: Rule[] = [ | |
192 | + { | |
193 | + required: true, | |
194 | + validator: (_, value: string) => { | |
195 | + if (String(value).length > 36) { | |
196 | + return Promise.reject('tbDeviceId不超过36字'); | |
197 | + } | |
198 | + return Promise.resolve(); | |
199 | + }, | |
200 | + validateTrigger: 'blur', | |
201 | + }, | |
202 | +]; | |
203 | + | |
204 | +export const DeviceUserNameMaxLength: Rule[] = [ | |
205 | + { | |
206 | + required: true, | |
207 | + validator: (_, value: string) => { | |
208 | + if (String(value).length > 50) { | |
209 | + return Promise.reject('用户名长度不超过50字'); | |
210 | + } | |
211 | + return Promise.resolve(); | |
212 | + }, | |
213 | + validateTrigger: 'blur', | |
214 | + }, | |
215 | +]; | |
216 | + | |
217 | +export const DeviceQueryUserNameMaxLength: Rule[] = [ | |
218 | + { | |
219 | + required: true, | |
220 | + validator: (_, value: string) => { | |
221 | + if (String(value).length > 50) { | |
222 | + return Promise.reject('设备名称长度不超过50字'); | |
223 | + } | |
224 | + return Promise.resolve(); | |
225 | + }, | |
226 | + validateTrigger: 'blur', | |
227 | + }, | |
228 | +]; | |
229 | + | |
230 | +export const DeviceProfileQueryUserNameMaxLength: Rule[] = [ | |
231 | + { | |
232 | + required: true, | |
233 | + validator: (_, value: string) => { | |
234 | + if (String(value).length > 50) { | |
235 | + return Promise.reject('配置名称长度不超过50字'); | |
236 | + } | |
237 | + return Promise.resolve(); | |
238 | + }, | |
239 | + validateTrigger: 'blur', | |
240 | + }, | |
241 | +]; | ... | ... |
... | ... | @@ -3,6 +3,18 @@ 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 | + DeviceUserNameMaxLength, | |
9 | + DeviceProfileIdMaxLength, | |
10 | + DeviceOrgIdMaxLength, | |
11 | + DeviceLabelMaxLength, | |
12 | + DeviceDescriptionlMaxLength, | |
13 | + DeviceIdMaxLength, | |
14 | + DeviceTenantIdMaxLength, | |
15 | + DeviceTbDeviceIdMaxLength, | |
16 | +} from '/@/utils/rules'; | |
17 | + | |
6 | 18 | // 第一步的表单 |
7 | 19 | export const step1Schemas: FormSchema[] = [ |
8 | 20 | { |
... | ... | @@ -17,8 +29,9 @@ export const step1Schemas: FormSchema[] = [ |
17 | 29 | required: true, |
18 | 30 | component: 'Input', |
19 | 31 | componentProps: { |
20 | - maxLength: 30, | |
32 | + placeholder: '设备名称', | |
21 | 33 | }, |
34 | + rules: DeviceNameMaxLength, | |
22 | 35 | }, |
23 | 36 | { |
24 | 37 | field: 'deviceType', |
... | ... | @@ -26,6 +39,7 @@ export const step1Schemas: FormSchema[] = [ |
26 | 39 | required: true, |
27 | 40 | component: 'ApiSelect', |
28 | 41 | componentProps: { |
42 | + placeholder: '设备类型', | |
29 | 43 | api: findDictItemByCode, |
30 | 44 | params: { |
31 | 45 | dictCode: 'device_type', |
... | ... | @@ -44,6 +58,7 @@ export const step1Schemas: FormSchema[] = [ |
44 | 58 | labelField: 'name', |
45 | 59 | valueField: 'id', |
46 | 60 | }, |
61 | + rules: DeviceProfileIdMaxLength, | |
47 | 62 | }, |
48 | 63 | { |
49 | 64 | field: 'organizationId', |
... | ... | @@ -57,6 +72,7 @@ export const step1Schemas: FormSchema[] = [ |
57 | 72 | return data; |
58 | 73 | }, |
59 | 74 | }, |
75 | + rules: DeviceOrgIdMaxLength, | |
60 | 76 | }, |
61 | 77 | { |
62 | 78 | field: 'label', |
... | ... | @@ -65,6 +81,7 @@ export const step1Schemas: FormSchema[] = [ |
65 | 81 | componentProps: { |
66 | 82 | maxLength: 255, |
67 | 83 | }, |
84 | + rules: DeviceLabelMaxLength, | |
68 | 85 | }, |
69 | 86 | { |
70 | 87 | field: 'deviceAddress', |
... | ... | @@ -76,24 +93,28 @@ export const step1Schemas: FormSchema[] = [ |
76 | 93 | field: 'description', |
77 | 94 | label: '备注', |
78 | 95 | component: 'InputTextArea', |
96 | + rules: DeviceDescriptionlMaxLength, | |
79 | 97 | }, |
80 | 98 | { |
81 | 99 | field: 'id', |
82 | 100 | label: 'id', |
83 | 101 | component: 'Input', |
84 | 102 | show: false, |
103 | + rules: DeviceIdMaxLength, | |
85 | 104 | }, |
86 | 105 | { |
87 | 106 | field: 'tenantId', |
88 | 107 | label: '租户Code', |
89 | 108 | component: 'Input', |
90 | 109 | show: false, |
110 | + rules: DeviceTenantIdMaxLength, | |
91 | 111 | }, |
92 | 112 | { |
93 | 113 | field: 'tbDeviceId', |
94 | 114 | label: 'tbDeviceId', |
95 | 115 | component: 'Input', |
96 | 116 | show: false, |
117 | + rules: DeviceTbDeviceIdMaxLength, | |
97 | 118 | }, |
98 | 119 | ]; |
99 | 120 | |
... | ... | @@ -264,6 +285,7 @@ export const step2Schemas: FormSchema[] = [ |
264 | 285 | component: 'Input', |
265 | 286 | field: 'username', |
266 | 287 | required: true, |
288 | + rules: DeviceUserNameMaxLength, | |
267 | 289 | ifShow: false, |
268 | 290 | }, |
269 | 291 | { |
... | ... | @@ -430,6 +452,7 @@ export const TokenSchemas: FormSchema[] = [ |
430 | 452 | field: 'username', |
431 | 453 | required: true, |
432 | 454 | ifShow: false, |
455 | + rules: DeviceUserNameMaxLength, | |
433 | 456 | }, |
434 | 457 | { |
435 | 458 | label: '密码', | ... | ... |
... | ... | @@ -2,6 +2,8 @@ import { formatToDate } from '/@/utils/dateUtil'; |
2 | 2 | import { BasicColumn } from '/@/components/Table'; |
3 | 3 | import { FormSchema } from '/@/components/Table'; |
4 | 4 | import { DeviceTypeEnum, DeviceState } from '/@/api/device/model/deviceModel'; |
5 | +import { DeviceQueryUserNameMaxLength } from '/@/utils/rules'; | |
6 | + | |
5 | 7 | // 表格列数据 |
6 | 8 | export const columns: BasicColumn[] = [ |
7 | 9 | { |
... | ... | @@ -84,6 +86,7 @@ export const searchFormSchema: FormSchema[] = [ |
84 | 86 | field: 'name', |
85 | 87 | label: '设备名称', |
86 | 88 | component: 'Input', |
87 | - colProps: { span: 6 }, | |
89 | + colProps: { span: 7 }, | |
90 | + rules: DeviceQueryUserNameMaxLength, | |
88 | 91 | }, |
89 | 92 | ]; | ... | ... |
... | ... | @@ -34,10 +34,9 @@ |
34 | 34 | @next="handleStep3Next" |
35 | 35 | @redo="handleRedo" |
36 | 36 | /></div> |
37 | - | |
38 | 37 | <div v-show="current === 3"> |
39 | - <DeviceProfileStep4 ref="DeviceProfileStep4Ref" @prev="handleStepPrev" | |
40 | - /></div> | |
38 | + <DeviceProfileStep4 ref="DeviceProfileStep4Ref" @prev="handleStepPrev" /> | |
39 | + </div> | |
41 | 40 | </div> |
42 | 41 | </BasicModal> |
43 | 42 | </template> |
... | ... | @@ -95,6 +94,8 @@ |
95 | 94 | current.value = 0; |
96 | 95 | proxy.$refs.DeviceProfileStep3Ref.clearProfileDataFunc(); |
97 | 96 | proxy.$refs.DeviceProfileStep3Ref.addAlarmRule(); |
97 | + // proxy.$refs.DeviceProfileStep4Ref.customResetAndFunc(); | |
98 | + | |
98 | 99 | switch (current.value) { |
99 | 100 | case 0: |
100 | 101 | proxy.$refs.DeviceProfileStep1Ref.customResetFunc(); |
... | ... | @@ -142,6 +143,7 @@ |
142 | 143 | } |
143 | 144 | function handleStep2Next(v) { |
144 | 145 | current.value++; |
146 | + | |
145 | 147 | getStepTwoData.value = v; |
146 | 148 | if (unref(isUpdate)) { |
147 | 149 | proxy.$refs.DeviceProfileStep3Ref.retryRegisterFormFunc({ |
... | ... | @@ -234,13 +236,22 @@ |
234 | 236 | function handleStep3Next(v) { |
235 | 237 | current.value++; |
236 | 238 | getStepThreeData.value = v; |
237 | - if (unref(isUpdate)) { | |
238 | - proxy.$refs.DeviceProfileStep4Ref.resetFieldsFunc({ | |
239 | - alarmContactId: editEchoData.value.alarmProfile.alarmContactId, | |
240 | - messageMode: editEchoData.value.alarmProfile.messageMode, | |
241 | - }); | |
242 | - } else { | |
243 | - proxy.$refs.DeviceProfileStep4Ref.customResetAndFunc(); | |
239 | + try { | |
240 | + if (unref(isUpdate)) { | |
241 | + setTimeout(() => { | |
242 | + proxy.$refs.DeviceProfileStep4Ref.resetFieldsFunc({ | |
243 | + alarmContactId: editEchoData.value.alarmProfile.alarmContactId, | |
244 | + messageMode: editEchoData.value.alarmProfile.messageMode, | |
245 | + }); | |
246 | + }, 1000); | |
247 | + } | |
248 | + // if (!unref(isUpdate)) { | |
249 | + // setTimeout(() => { | |
250 | + // proxy.$refs.DeviceProfileStep4Ref.customResetAndFunc(); | |
251 | + // }, 1000); | |
252 | + // } | |
253 | + } catch (e) { | |
254 | + return e; | |
244 | 255 | } |
245 | 256 | } |
246 | 257 | function handleRedo() { | ... | ... |
... | ... | @@ -2,8 +2,9 @@ import { BasicColumn } from '/@/components/Table'; |
2 | 2 | import { FormSchema } from '/@/components/Table'; |
3 | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
4 | 4 | import { MessageEnum } from '/@/enums/messageEnum'; |
5 | -import { getOrganizationList } from '/@/api/system/system'; | |
6 | -import { copyTransFun } from '/@/utils/fnUtils'; | |
5 | +// import { getOrganizationList } from '/@/api/system/system'; | |
6 | +// import { copyTransFun } from '/@/utils/fnUtils'; | |
7 | +import { DeviceProfileQueryUserNameMaxLength } from '/@/utils/rules'; | |
7 | 8 | |
8 | 9 | export const columns: BasicColumn[] = [ |
9 | 10 | { |
... | ... | @@ -30,23 +31,13 @@ export const columns: BasicColumn[] = [ |
30 | 31 | |
31 | 32 | export const searchFormSchema: FormSchema[] = [ |
32 | 33 | { |
33 | - field: 'organizationId', | |
34 | - label: '请选择组织', | |
35 | - component: 'ApiTreeSelect', | |
36 | - colProps: { span: 6 }, | |
37 | - componentProps: { | |
38 | - api: async () => { | |
39 | - const data = await getOrganizationList(); | |
40 | - copyTransFun(data as any as any[]); | |
41 | - return data; | |
42 | - }, | |
43 | - }, | |
44 | - }, | |
45 | - { | |
46 | 34 | field: 'name', |
47 | 35 | label: '配置名称', |
48 | 36 | component: 'Input', |
49 | 37 | colProps: { span: 8 }, |
38 | + componentProps: { | |
39 | + placeholder: '请输入配置名称', | |
40 | + }, | |
50 | 41 | }, |
51 | 42 | ]; |
52 | 43 | |
... | ... | @@ -63,6 +54,10 @@ export const formSchema: FormSchema[] = [ |
63 | 54 | label: '配置名称', |
64 | 55 | required: true, |
65 | 56 | component: 'Input', |
57 | + componentProps: { | |
58 | + placeholder: '请输入配置名称', | |
59 | + }, | |
60 | + rules: DeviceProfileQueryUserNameMaxLength, | |
66 | 61 | }, |
67 | 62 | { |
68 | 63 | field: 'messageType', | ... | ... |
... | ... | @@ -223,7 +223,8 @@ |
223 | 223 | const [register] = useModalInner(async (data) => { |
224 | 224 | activeKey.value = '1'; |
225 | 225 | isUpdate.value = !!data?.isUpdate; |
226 | - descInfo.value = await deviceConfigGetDetail(data.record.id); | |
226 | + const getV = await deviceConfigGetDetail(data.record.id); | |
227 | + descInfo.value = getV; | |
227 | 228 | try { |
228 | 229 | resetFields(); |
229 | 230 | await setRegisterDetail({ ...descInfo.value }); |
... | ... | @@ -312,10 +313,12 @@ |
312 | 313 | }); |
313 | 314 | }, 1000); |
314 | 315 | case '4': |
315 | - setRegisterContact({ | |
316 | - alarmContactId: descInfo.value.alarmProfile.alarmContactId, | |
317 | - messageMode: descInfo.value.alarmProfile.messageMode, | |
318 | - }); | |
316 | + setTimeout(() => { | |
317 | + setRegisterContact({ | |
318 | + alarmContactId: descInfo.value.alarmProfile.alarmContactId, | |
319 | + messageMode: descInfo.value.alarmProfile.messageMode, | |
320 | + }); | |
321 | + }, 1000); | |
319 | 322 | break; |
320 | 323 | } |
321 | 324 | } catch (e) { | ... | ... |
... | ... | @@ -949,7 +949,11 @@ |
949 | 949 | isRuleAlarmRuleConditions.value = 4; |
950 | 950 | setTimeout(() => { |
951 | 951 | openModal4(true); |
952 | - proxy.$refs.getChildData1.resetDataFunc(); | |
952 | + try { | |
953 | + proxy.$refs.getChildData1.resetDataFunc(); | |
954 | + } catch (e) { | |
955 | + return e; | |
956 | + } | |
953 | 957 | }, 50); |
954 | 958 | }; |
955 | 959 | const handleOpenClearEnableRule = () => { | ... | ... |
... | ... | @@ -5,6 +5,7 @@ import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi'; |
5 | 5 | import { ref } from 'vue'; |
6 | 6 | import { findDictItemByCode } from '/@/api/system/dict'; |
7 | 7 | import { alarmContactGetPage } from '/@/api/device/deviceConfigApi'; |
8 | +import { DeviceProfileQueryUserNameMaxLength } from '/@/utils/rules'; | |
8 | 9 | |
9 | 10 | export const step1Schemas: FormSchema[] = [ |
10 | 11 | { |
... | ... | @@ -13,8 +14,9 @@ export const step1Schemas: FormSchema[] = [ |
13 | 14 | required: true, |
14 | 15 | component: 'Input', |
15 | 16 | componentProps: { |
16 | - maxLength: 30, | |
17 | + placeholder: '请输入配置名称', | |
17 | 18 | }, |
19 | + rules: DeviceProfileQueryUserNameMaxLength, | |
18 | 20 | }, |
19 | 21 | //规则链(string) |
20 | 22 | { |
... | ... | @@ -216,7 +218,9 @@ export const alertContactsSchemas: FormSchema[] = [ |
216 | 218 | field: 'alarmContactId', |
217 | 219 | label: '告警通知联系人', |
218 | 220 | component: 'ApiSelect', |
221 | + required: true, | |
219 | 222 | componentProps: { |
223 | + placeholder: '请选择告警通知联系人', | |
220 | 224 | api: alarmContactGetPage, |
221 | 225 | labelField: 'username', |
222 | 226 | valueField: 'id', |
... | ... | @@ -229,6 +233,7 @@ export const alertContactsSchemas: FormSchema[] = [ |
229 | 233 | required: true, |
230 | 234 | component: 'ApiSelect', |
231 | 235 | componentProps: { |
236 | + placeholder: '请选择告警通知方式', | |
232 | 237 | api: findDictItemByCode, |
233 | 238 | params: { |
234 | 239 | dictCode: 'message_type', | ... | ... |
... | ... | @@ -5,6 +5,7 @@ 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, NotificationTypeMaxLength } from '/@/utils/rules'; | |
8 | 9 | |
9 | 10 | export enum IsOrgEnum { |
10 | 11 | IS_ORG_ENUM = '1', |
... | ... | @@ -86,6 +87,7 @@ export const formSchema: FormSchema[] = [ |
86 | 87 | }, |
87 | 88 | ], |
88 | 89 | }, |
90 | + rules: NotificationTypeMaxLength, | |
89 | 91 | }, |
90 | 92 | { |
91 | 93 | field: 'title', |
... | ... | @@ -96,6 +98,7 @@ export const formSchema: FormSchema[] = [ |
96 | 98 | componentProps: { |
97 | 99 | placeholder: '请输入标题', |
98 | 100 | }, |
101 | + rules: NotificationTitleMaxLength, | |
99 | 102 | }, |
100 | 103 | { |
101 | 104 | field: 'content', | ... | ... |