Commit b9dc346d897f6ca27907a8074bec76e2074874e0
1 parent
21acff67
fix: DEFECT-1407 设备名称前端限制一下不能超过255
Showing
1 changed file
with
11 additions
and
0 deletions
| ... | ... | @@ -109,6 +109,15 @@ |
| 109 | 109 | unref(DeviceStep1Ref)?.resetFields(); |
| 110 | 110 | unref(DeviceStep2Ref)?.resetFieldsValueAndStatus(); |
| 111 | 111 | } |
| 112 | + //验证设备名称不能超过255长度 | |
| 113 | + const MAX_NAME_LENGTH = 255; | |
| 114 | + const validateNameLength = (name: string) => { | |
| 115 | + if (String(name).length > MAX_NAME_LENGTH) { | |
| 116 | + const errorText = `设备名称长度不能超过${MAX_NAME_LENGTH}`; | |
| 117 | + createMessage.error(errorText); | |
| 118 | + throw Error(errorText); | |
| 119 | + } | |
| 120 | + }; | |
| 112 | 121 | // 提交 |
| 113 | 122 | const msg = computed(() => (unref(isUpdate) ? '更新设备成功' : '新增设备成功')); |
| 114 | 123 | async function handleOk() { |
| ... | ... | @@ -150,6 +159,7 @@ |
| 150 | 159 | ...DeviceStep1Ref.value?.positionState, |
| 151 | 160 | }, |
| 152 | 161 | }; |
| 162 | + validateNameLength(stepRecord.name); | |
| 153 | 163 | await createOrEditDevice(editData); |
| 154 | 164 | } else { |
| 155 | 165 | const stepRecord = unref(stepState); |
| ... | ... | @@ -178,6 +188,7 @@ |
| 178 | 188 | : null, |
| 179 | 189 | }, |
| 180 | 190 | }; |
| 191 | + validateNameLength(stepRecord.name); | |
| 181 | 192 | await createOrEditDevice(createData); |
| 182 | 193 | } |
| 183 | 194 | createMessage.success(unref(msg)); | ... | ... |