fix: iot
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
<!-- dataType:number 数组类型 -->
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getStrDictOptions } from '@vben/constants';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
import type { DataSpecsNumberData } from '#/api/iot/thingmodel';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { useVModel } from '@vueuse/core';
|
||||
|
||||
import { DataSpecsNumberData } from '#/api/iot/thingmodel';
|
||||
|
||||
/** 数值型的 dataSpecs 配置组件 */
|
||||
defineOptions({ name: 'ThingModelNumberDataSpecs' });
|
||||
|
||||
@@ -28,11 +31,11 @@ const unitChange = (UnitSpecs: string) => {
|
||||
const validateMin = (_: any, __: any, callback: any) => {
|
||||
const min = Number(dataSpecs.value.min);
|
||||
const max = Number(dataSpecs.value.max);
|
||||
if (isNaN(min)) {
|
||||
if (Number.isNaN(min)) {
|
||||
callback(new Error('请输入有效的数值'));
|
||||
return;
|
||||
}
|
||||
if (max !== undefined && !isNaN(max) && min >= max) {
|
||||
if (max !== undefined && !Number.isNaN(max) && min >= max) {
|
||||
callback(new Error('最小值必须小于最大值'));
|
||||
return;
|
||||
}
|
||||
@@ -44,11 +47,11 @@ const validateMin = (_: any, __: any, callback: any) => {
|
||||
const validateMax = (_: any, __: any, callback: any) => {
|
||||
const min = Number(dataSpecs.value.min);
|
||||
const max = Number(dataSpecs.value.max);
|
||||
if (isNaN(max)) {
|
||||
if (Number.isNaN(max)) {
|
||||
callback(new Error('请输入有效的数值'));
|
||||
return;
|
||||
}
|
||||
if (min !== undefined && !isNaN(min) && max <= min) {
|
||||
if (min !== undefined && !Number.isNaN(min) && max <= min) {
|
||||
callback(new Error('最大值必须大于最小值'));
|
||||
return;
|
||||
}
|
||||
@@ -59,7 +62,7 @@ const validateMax = (_: any, __: any, callback: any) => {
|
||||
/** 校验步长 */
|
||||
const validateStep = (_: any, __: any, callback: any) => {
|
||||
const step = Number(dataSpecs.value.step);
|
||||
if (isNaN(step)) {
|
||||
if (Number.isNaN(step)) {
|
||||
callback(new Error('请输入有效的数值'));
|
||||
return;
|
||||
}
|
||||
@@ -69,7 +72,7 @@ const validateStep = (_: any, __: any, callback: any) => {
|
||||
}
|
||||
const min = Number(dataSpecs.value.min);
|
||||
const max = Number(dataSpecs.value.max);
|
||||
if (!isNaN(min) && !isNaN(max) && step > max - min) {
|
||||
if (!Number.isNaN(min) && !Number.isNaN(max) && step > max - min) {
|
||||
callback(new Error('步长不能大于最大值和最小值的差值'));
|
||||
return;
|
||||
}
|
||||
@@ -129,8 +132,9 @@ const validateStep = (_: any, __: any, callback: any) => {
|
||||
@change="unitChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in getStrDictOptions(
|
||||
v-for="(item, index) in getDictOptions(
|
||||
DICT_TYPE.IOT_THING_MODEL_UNIT,
|
||||
'string',
|
||||
)"
|
||||
:key="index"
|
||||
:label="`${item.label}-${item.value}`"
|
||||
|
||||
Reference in New Issue
Block a user