From 2505410b5abed744201146f261994bf529ca3127 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 18 Dec 2024 20:50:48 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E3=80=91IoT=EF=BC=9A=E7=89=A9=E6=A8=A1=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/thinkmodel/index.ts | 1 + src/views/iot/thinkmodel/ThinkModelDataSpecs.vue | 4 +--- .../dataSpecs/ThinkModelArrayTypeDataSpecs.vue | 2 ++ .../dataSpecs/ThinkModelEnumTypeDataSpecs.vue | 3 --- .../dataSpecs/ThinkModelNumberTypeDataSpecs.vue | 11 ++--------- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/api/iot/thinkmodel/index.ts b/src/api/iot/thinkmodel/index.ts index f900ce6a..e1887048 100644 --- a/src/api/iot/thinkmodel/index.ts +++ b/src/api/iot/thinkmodel/index.ts @@ -54,6 +54,7 @@ export enum ProductFunctionAccessModeEnum { // IoT 产品物模型 API export const ThinkModelApi = { // 查询产品物模型分页 + // TODO @puhui999:product 前缀,是不是去掉哈。 getThinkModelPage: async (params: any) => { return await request.get({ url: `/iot/product-think-model/page`, params }) }, diff --git a/src/views/iot/thinkmodel/ThinkModelDataSpecs.vue b/src/views/iot/thinkmodel/ThinkModelDataSpecs.vue index f38e965e..2683242f 100644 --- a/src/views/iot/thinkmodel/ThinkModelDataSpecs.vue +++ b/src/views/iot/thinkmodel/ThinkModelDataSpecs.vue @@ -144,25 +144,23 @@ const handleChange = (dataType: any) => { } } +// TODO @puhui999:一些校验的规则,是不是写到 utils 里。 /** 校验布尔值名称 */ const validateBoolName = (_: any, value: string, callback: any) => { if (isEmpty(value)) { callback(new Error('布尔值名称不能为空')) return } - // 检查开头字符 if (!/^[\u4e00-\u9fa5a-zA-Z0-9]/.test(value)) { callback(new Error('布尔值名称必须以中文、英文字母或数字开头')) return } - // 检查整体格式 if (!/^[\u4e00-\u9fa5a-zA-Z0-9][a-zA-Z0-9\u4e00-\u9fa5_-]*$/.test(value)) { callback(new Error('布尔值名称只能包含中文、英文字母、数字、下划线和短划线')) return } - // 检查长度(一个中文算一个字符) if (value.length > 20) { callback(new Error('布尔值名称长度不能超过20个字符')) diff --git a/src/views/iot/thinkmodel/dataSpecs/ThinkModelArrayTypeDataSpecs.vue b/src/views/iot/thinkmodel/dataSpecs/ThinkModelArrayTypeDataSpecs.vue index fa2581ba..5362ceef 100644 --- a/src/views/iot/thinkmodel/dataSpecs/ThinkModelArrayTypeDataSpecs.vue +++ b/src/views/iot/thinkmodel/dataSpecs/ThinkModelArrayTypeDataSpecs.vue @@ -36,6 +36,8 @@ import { useVModel } from '@vueuse/core' import { DataSpecsDataType, dataTypeOptions } from '../config' import { isEmpty } from '@/utils/is' +// TODO @puhui999:参数校验,是不是还是定义一个变量,统一管,好阅读点哈? + /** 数组型的 dataSpecs 配置组件 */ defineOptions({ name: 'ThinkModelArrayTypeDataSpecs' }) diff --git a/src/views/iot/thinkmodel/dataSpecs/ThinkModelEnumTypeDataSpecs.vue b/src/views/iot/thinkmodel/dataSpecs/ThinkModelEnumTypeDataSpecs.vue index b8411e55..6db4bed7 100644 --- a/src/views/iot/thinkmodel/dataSpecs/ThinkModelEnumTypeDataSpecs.vue +++ b/src/views/iot/thinkmodel/dataSpecs/ThinkModelEnumTypeDataSpecs.vue @@ -98,19 +98,16 @@ const validateEnumName = (_: any, value: string, callback: any) => { callback(new Error('枚举描述不能为空')) return } - // 检查开头字符 if (!/^[\u4e00-\u9fa5a-zA-Z0-9]/.test(value)) { callback(new Error('枚举描述必须以中文、英文字母或数字开头')) return } - // 检查整体格式 if (!/^[\u4e00-\u9fa5a-zA-Z0-9][a-zA-Z0-9\u4e00-\u9fa5_-]*$/.test(value)) { callback(new Error('枚举描述只能包含中文、英文字母、数字、下划线和短划线')) return } - // 检查长度(一个中文算一个字符) if (value.length > 20) { callback(new Error('枚举描述长度不能超过20个字符')) diff --git a/src/views/iot/thinkmodel/dataSpecs/ThinkModelNumberTypeDataSpecs.vue b/src/views/iot/thinkmodel/dataSpecs/ThinkModelNumberTypeDataSpecs.vue index d3fe26b4..9b61eef6 100644 --- a/src/views/iot/thinkmodel/dataSpecs/ThinkModelNumberTypeDataSpecs.vue +++ b/src/views/iot/thinkmodel/dataSpecs/ThinkModelNumberTypeDataSpecs.vue @@ -79,12 +79,10 @@ 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)) { callback(new Error('请输入有效的数值')) return } - if (max !== undefined && !isNaN(max) && min >= max) { callback(new Error('最小值必须小于最大值')) return @@ -97,12 +95,10 @@ 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)) { callback(new Error('请输入有效的数值')) return } - if (min !== undefined && !isNaN(min) && max <= min) { callback(new Error('最大值必须大于最小值')) return @@ -114,19 +110,16 @@ const validateMax = (_: any, __: any, callback: any) => { /** 校验步长 */ const validateStep = (_: any, __: any, callback: any) => { const step = Number(dataSpecs.value.step) - const min = Number(dataSpecs.value.min) - const max = Number(dataSpecs.value.max) - if (isNaN(step)) { callback(new Error('请输入有效的数值')) return } - if (step <= 0) { callback(new Error('步长必须大于0')) return } - + const min = Number(dataSpecs.value.min) + const max = Number(dataSpecs.value.max) if (!isNaN(min) && !isNaN(max) && step > max - min) { callback(new Error('步长不能大于最大值和最小值的差值')) return