Commit c6f35eabd632b6dd3757eefacf7547965efee434

Authored by xp.Huang
2 parents 25066245 0b45382a

Merge branch 'cherry-pick-14ac14d6' into 'main'

fix: 修改创建产品数据携带hex长度的为偶数的问题

See merge request yunteng/thingskit-front!1533
@@ -28,7 +28,7 @@ export default { @@ -28,7 +28,7 @@ export default {
28 telemetryDataSubjectFilterText: 'Telemetry data subject filter', 28 telemetryDataSubjectFilterText: 'Telemetry data subject filter',
29 attributeTopicFilterText: 'Attribute topic filter', 29 attributeTopicFilterText: 'Attribute topic filter',
30 testScriptText: 'Test script', 30 testScriptText: 'Test script',
31 - hexLengthText: 'Hex length', 31 + hexLengthText: 'Min Hex length',
32 splicePositionText: 'Intercept start and stop position', 32 splicePositionText: 'Intercept start and stop position',
33 splicePositionHelpMessageText: 33 splicePositionHelpMessageText:
34 'Example of interception: "ABCD".substring(0,2) The value after interception is "AB"', 34 'Example of interception: "ABCD".substring(0,2) The value after interception is "AB"',
@@ -36,6 +36,9 @@ export default { @@ -36,6 +36,9 @@ export default {
36 splicePositionValidText: 36 splicePositionValidText:
37 'The intercept start position is large and the intercept end position is large', 37 'The intercept start position is large and the intercept end position is large',
38 spliceLengthValidText: 'Intercept start and stop position large with HEX length', 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 inputStartPositionText: 'Please enter the starting position', 42 inputStartPositionText: 'Please enter the starting position',
40 inputEndPositionText: 'Please enter cut-off location', 43 inputEndPositionText: 'Please enter cut-off location',
41 filterPrefixText: 'Matching prefix', 44 filterPrefixText: 'Matching prefix',
@@ -28,12 +28,15 @@ export default { @@ -28,12 +28,15 @@ export default {
28 telemetryDataSubjectFilterText: '遥测数据主题筛选器 ', 28 telemetryDataSubjectFilterText: '遥测数据主题筛选器 ',
29 attributeTopicFilterText: '属性主题过滤器', 29 attributeTopicFilterText: '属性主题过滤器',
30 testScriptText: '测试脚本', 30 testScriptText: '测试脚本',
31 - hexLengthText: 'HEX长度', 31 + hexLengthText: '最小HEX长度',
32 splicePositionText: '截取起止位置', 32 splicePositionText: '截取起止位置',
33 splicePositionHelpMessageText: '截取示例:"ABCD".substring(0,2) 截取后的值为"AB"', 33 splicePositionHelpMessageText: '截取示例:"ABCD".substring(0,2) 截取后的值为"AB"',
34 inputSpliceStartPositionText: '请输入截取起止位置', 34 inputSpliceStartPositionText: '请输入截取起止位置',
35 splicePositionValidText: '截取起始位置大于截取结束位置', 35 splicePositionValidText: '截取起始位置大于截取结束位置',
36 - spliceLengthValidText: '截取起止位置大与HEX长度', 36 + spliceLengthValidText: '截取起止位置大于HEX长度',
  37 + spliceLengthEndValidText: '截取结束位置要小于HEX长度',
  38 + spliceLengthNotSame: '截取起止位置不能相同',
  39 + spliceRemingLength: '截取剩余长度位置不能是奇数',
37 inputStartPositionText: '请输入起始位置', 40 inputStartPositionText: '请输入起始位置',
38 inputEndPositionText: '请输入截止位置', 41 inputEndPositionText: '请输入截止位置',
39 filterPrefixText: '匹配前缀', 42 filterPrefixText: '匹配前缀',
@@ -123,6 +123,24 @@ export const formSchemas = (deviceTypeStr: string): FormSchema[] => { @@ -123,6 +123,24 @@ export const formSchemas = (deviceTypeStr: string): FormSchema[] => {
123 required: true, 123 required: true,
124 ifShow: ({ values }) => 124 ifShow: ({ values }) =>
125 values[FormFieldsEnum.AuthType] === TCPProtocolAccessAuthTypeEnum.DataCombination, 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 componentProps: { 144 componentProps: {
127 precision: 0, 145 precision: 0,
128 min: 1, 146 min: 1,
@@ -162,6 +180,15 @@ export const formSchemas = (deviceTypeStr: string): FormSchema[] => { @@ -162,6 +180,15 @@ export const formSchemas = (deviceTypeStr: string): FormSchema[] => {
162 ) { 180 ) {
163 return Promise.reject(t('deviceManagement.product.spliceLengthValidText')); 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 return Promise.resolve(); 193 return Promise.resolve();
167 }, 194 },