Skip to content

Commit

Permalink
fix(useWriteDataCheckNParse.ts): fix that always displaying validate …
Browse files Browse the repository at this point in the history
…error message
  • Loading branch information
oucb authored and ysfscream committed Dec 12, 2023
1 parent 205f3bb commit c3ee5b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/composables/data/useWriteDataCheckNParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ STRING 15 string

import { TagType } from '@/types/enums'
import { HEXADECIMAL_PREFIX } from '@/utils/constants'
import { BYTES_REGEX, FLOAT_REGEX, BIT_REGEX, INT_REGEX } from '@/utils/regexps'
import { HEXADECIMAL_REGEX, BYTES_REGEX, FLOAT_REGEX, BIT_REGEX, INT_REGEX } from '@/utils/regexps'
import {
transFloatNumberToHex,
transNegativeNumberToHex,
Expand Down Expand Up @@ -190,7 +190,7 @@ export default (isWriteValue = true) => {
value.slice(0, HEXADECIMAL_PREFIX.length).toLowerCase() === HEXADECIMAL_PREFIX
? value
: HEXADECIMAL_PREFIX + value
return checkByte(str)
return HEXADECIMAL_REGEX.test(str)
}
const transToDecimal = async (tagData: TagDataInTable) => {
const { value, type } = tagData
Expand All @@ -199,7 +199,7 @@ export default (isWriteValue = true) => {
? value
: HEXADECIMAL_PREFIX + value
try {
await checkByte(str)
await HEXADECIMAL_REGEX.test(str)
const hexStr = str.slice(HEXADECIMAL_PREFIX.length)
if (type === TagType.FLOAT || type === TagType.DOUBLE) {
return transFloatHexToDecimalNum(hexStr, type)
Expand Down
5 changes: 4 additions & 1 deletion src/views/monitoring/components/WriteDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
</template>
<emqx-input
v-if="tag.type !== TagType.BOOL"
v-if="tag?.type !== TagType.BOOL"
v-model="inputValue"
:type="isBYTESType ? 'textarea' : 'text'"
:placeholder="isBYTESType ? '[0,0,0,0]' : ''"
Expand Down Expand Up @@ -99,6 +99,9 @@ watch(showDialog, (val) => {
isUseHexadecimal.value = false
}
})
watch(inputValue, () => {
inputErrorMsg.value = ''
})
const submitData = async () => {
await submit()
emit('updated')
Expand Down

0 comments on commit c3ee5b5

Please sign in to comment.