Commit 0b45382aec024f04142fe7f900322a4a736605f2
Committed by
xp.Huang
1 parent
25066245
fix: 修改创建产品数据携带hex长度的为偶数的问题
(cherry picked from commit 14ac14d64fcae613eb76c8acd069160a9515f771)
Showing
3 changed files
with
36 additions
and
3 deletions
... | ... | @@ -28,7 +28,7 @@ export default { |
28 | 28 | telemetryDataSubjectFilterText: 'Telemetry data subject filter', |
29 | 29 | attributeTopicFilterText: 'Attribute topic filter', |
30 | 30 | testScriptText: 'Test script', |
31 | - hexLengthText: 'Hex length', | |
31 | + hexLengthText: 'Min Hex length', | |
32 | 32 | splicePositionText: 'Intercept start and stop position', |
33 | 33 | splicePositionHelpMessageText: |
34 | 34 | 'Example of interception: "ABCD".substring(0,2) The value after interception is "AB"', |
... | ... | @@ -36,6 +36,9 @@ export default { |
36 | 36 | splicePositionValidText: |
37 | 37 | 'The intercept start position is large and the intercept end position is large', |
38 | 38 | spliceLengthValidText: 'Intercept start and stop position large with HEX length', |
39 | + spliceLengthEndValidText: 'Cut end position is less than HEX length', | |
40 | + spliceRemingLength: 'The remaining length position cannot be odd', | |
41 | + spliceLengthNotSame: 'The starting and ending positions of the interception cannot be the same', | |
39 | 42 | inputStartPositionText: 'Please enter the starting position', |
40 | 43 | inputEndPositionText: 'Please enter cut-off location', |
41 | 44 | filterPrefixText: 'Matching prefix', | ... | ... |
... | ... | @@ -28,12 +28,15 @@ export default { |
28 | 28 | telemetryDataSubjectFilterText: '遥测数据主题筛选器 ', |
29 | 29 | attributeTopicFilterText: '属性主题过滤器', |
30 | 30 | testScriptText: '测试脚本', |
31 | - hexLengthText: 'HEX长度', | |
31 | + hexLengthText: '最小HEX长度', | |
32 | 32 | splicePositionText: '截取起止位置', |
33 | 33 | splicePositionHelpMessageText: '截取示例:"ABCD".substring(0,2) 截取后的值为"AB"', |
34 | 34 | inputSpliceStartPositionText: '请输入截取起止位置', |
35 | 35 | splicePositionValidText: '截取起始位置大于截取结束位置', |
36 | - spliceLengthValidText: '截取起止位置大与HEX长度', | |
36 | + spliceLengthValidText: '截取起止位置大于HEX长度', | |
37 | + spliceLengthEndValidText: '截取结束位置要小于HEX长度', | |
38 | + spliceLengthNotSame: '截取起止位置不能相同', | |
39 | + spliceRemingLength: '截取剩余长度位置不能是奇数', | |
37 | 40 | inputStartPositionText: '请输入起始位置', |
38 | 41 | inputEndPositionText: '请输入截止位置', |
39 | 42 | filterPrefixText: '匹配前缀', | ... | ... |
... | ... | @@ -123,6 +123,24 @@ export const formSchemas = (deviceTypeStr: string): FormSchema[] => { |
123 | 123 | required: true, |
124 | 124 | ifShow: ({ values }) => |
125 | 125 | values[FormFieldsEnum.AuthType] === TCPProtocolAccessAuthTypeEnum.DataCombination, |
126 | + rules: [ | |
127 | + { | |
128 | + required: true, | |
129 | + validator(_rule, value) { | |
130 | + const number = parseInt(value, 10); | |
131 | + const isEven = number % 2 === 0; | |
132 | + if (!value) { | |
133 | + return Promise.reject( | |
134 | + t('common.inputText') + t('deviceManagement.product.hexLengthText') | |
135 | + ); | |
136 | + } | |
137 | + if (!isEven) { | |
138 | + return Promise.reject(t('validator.hexLength')); | |
139 | + } | |
140 | + return Promise.resolve(); | |
141 | + }, | |
142 | + }, | |
143 | + ], | |
126 | 144 | componentProps: { |
127 | 145 | precision: 0, |
128 | 146 | min: 1, |
... | ... | @@ -162,6 +180,15 @@ export const formSchemas = (deviceTypeStr: string): FormSchema[] => { |
162 | 180 | ) { |
163 | 181 | return Promise.reject(t('deviceManagement.product.spliceLengthValidText')); |
164 | 182 | } |
183 | + if (value[FormFieldsEnum.SubEndIndex] >= hexLength) { | |
184 | + return Promise.reject(t('deviceManagement.product.spliceLengthEndValidText')); | |
185 | + } | |
186 | + if ((hexLength - value[FormFieldsEnum.SubEndIndex]) % 2 !== 0) { | |
187 | + return Promise.reject(t('deviceManagement.product.spliceRemingLength')); | |
188 | + } | |
189 | + if (value[FormFieldsEnum.SubBeginIndex] == value[FormFieldsEnum.SubEndIndex]) { | |
190 | + return Promise.reject(t('deviceManagement.product.spliceLengthNotSame')); | |
191 | + } | |
165 | 192 | |
166 | 193 | return Promise.resolve(); |
167 | 194 | }, | ... | ... |