|
|
@@ -720,9 +720,30 @@ const { toggle, isFullscreen } = useFullscreen(targetArea)
|
|
|
const message = useMessage()
|
|
|
|
|
|
async function handleSave(item: Dimensions) {
|
|
|
+ const { minValue, maxValue } = item
|
|
|
+
|
|
|
+ // 1. 判断是否为空 (包括空字符串、null、undefined)
|
|
|
+ if (!minValue || !maxValue) {
|
|
|
+ return message.warning('最大值和最小值不能为空')
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 判断是否为有效的数字
|
|
|
+ // Number() 处理字符串数字,isNaN 排除非数字字符
|
|
|
+ const min = Number(minValue)
|
|
|
+ const max = Number(maxValue)
|
|
|
+
|
|
|
+ if (isNaN(min) || isNaN(max)) {
|
|
|
+ return message.warning('请输入有效的数字')
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. (附加逻辑) 比较大小
|
|
|
+ if (min > max) {
|
|
|
+ return message.warning('最小值不能大于最大值')
|
|
|
+ }
|
|
|
+
|
|
|
const body = {
|
|
|
- minValue: item.minValue,
|
|
|
- maxValue: item.maxValue,
|
|
|
+ minValue: min,
|
|
|
+ maxValue: max,
|
|
|
deviceId: query.id,
|
|
|
propertyCode: item.identifier,
|
|
|
alarmProperty: item.name,
|