Commit 406ddf248c625db39fe56af9b507ae2b5538b5a9

Authored by fengtao
1 parent 6e5e5a83

feat:物模型页面新增结构体验证

@@ -21,18 +21,18 @@ @@ -21,18 +21,18 @@
21 <template #outputParamSlot> 21 <template #outputParamSlot>
22 <div> 22 <div>
23 <template v-for="(item, index) in outputParamData" :key="item"> 23 <template v-for="(item, index) in outputParamData" :key="item">
24 - <span style="display: none">{{ item }}</span> 24 + <span style="display: none">{{ item + index }}</span>
25 <InputParamItem 25 <InputParamItem
26 :title="item.name" 26 :title="item.name"
27 :item="item" 27 :item="item"
28 class="mt-4" 28 class="mt-4"
29 - :index="index" 29 + :index="item.id"
30 :ref="dynamicBindRef.outputParamItemRef" 30 :ref="dynamicBindRef.outputParamItemRef"
31 @delete="deleteOutParItem" 31 @delete="deleteOutParItem"
32 @edit="editOutParItem" 32 @edit="editOutParItem"
33 /> 33 />
34 </template> 34 </template>
35 - <div style="display: flex" class="mt-2"> 35 + <div style="display: flex" :class="{ 'mt-2': outputParamData.length > 0 }">
36 <span style="color: #0170cc; cursor: pointer">+</span> 36 <span style="color: #0170cc; cursor: pointer">+</span>
37 <span style="color: #0170cc; cursor: pointer" @click="handleAddOutParam">增加参数</span> 37 <span style="color: #0170cc; cursor: pointer" @click="handleAddOutParam">增加参数</span>
38 </div> 38 </div>
@@ -50,7 +50,11 @@ @@ -50,7 +50,11 @@
50 import InputParamItem from './components/InputParamItem.vue'; 50 import InputParamItem from './components/InputParamItem.vue';
51 import AddParamsModal from './components/AddParamsModal.vue'; 51 import AddParamsModal from './components/AddParamsModal.vue';
52 import { Input } from 'ant-design-vue'; 52 import { Input } from 'ant-design-vue';
53 - import { validateValueRangeAndStep, validateValueBool } from '../hook/useValidateParital'; 53 + import {
  54 + validateValueRangeAndStep,
  55 + validateValueBool,
  56 + validateValueStruct,
  57 + } from '../hook/useValidateParital';
54 import { buildUUID } from '/@/utils/uuid'; 58 import { buildUUID } from '/@/utils/uuid';
55 59
56 const outputParamData: any = ref([]); 60 const outputParamData: any = ref([]);
@@ -138,6 +142,9 @@ @@ -138,6 +142,9 @@
138 const values = await validate(); 142 const values = await validate();
139 if (!values) return; 143 if (!values) return;
140 const dataSpecsList = getStructList(); 144 const dataSpecsList = getStructList();
  145 + if (values.dataType === 'STRUCT') {
  146 + validateValueStruct(dataSpecsList as any);
  147 + }
141 validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max)); 148 validateValueRangeAndStep(Number(minMaxObj.min), Number(values.step), Number(minMaxObj.max));
142 validateValueBool(Number(values.boolClose), Number(values.boolOpen)); 149 validateValueBool(Number(values.boolClose), Number(values.boolOpen));
143 const dataSpecs = { 150 const dataSpecs = {
@@ -237,6 +237,7 @@ @@ -237,6 +237,7 @@
237 }; 237 };
238 const resetFormData = () => { 238 const resetFormData = () => {
239 resetFields(); 239 resetFields();
  240 + outputParamData.value = [];
240 minMaxObj.min = ''; 241 minMaxObj.min = '';
241 minMaxObj.max = ''; 242 minMaxObj.max = '';
242 }; 243 };
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 import { ref, computed, reactive } from 'vue'; 17 import { ref, computed, reactive } from 'vue';
18 import { BasicModal, useModalInner } from '/@/components/Modal'; 18 import { BasicModal, useModalInner } from '/@/components/Modal';
19 import AddParamForm from './AddParamForm.vue'; 19 import AddParamForm from './AddParamForm.vue';
  20 + import { validateValueStruct } from '../../hook/useValidateParital';
20 21
21 const emits = defineEmits(['register', 'data']); 22 const emits = defineEmits(['register', 'data']);
22 const setEditData: any = reactive({ 23 const setEditData: any = reactive({
@@ -53,6 +54,9 @@ @@ -53,6 +54,9 @@
53 const handleSubmit = async () => { 54 const handleSubmit = async () => {
54 const value = await AddParamFormRef.value?.getFormData(); 55 const value = await AddParamFormRef.value?.getFormData();
55 if (!value) return; 56 if (!value) return;
  57 + if (value.dataType === 'STRUCT') {
  58 + validateValueStruct(value.dataSpecsList as any);
  59 + }
56 emits( 60 emits(
57 'data', 61 'data',
58 { 62 {
@@ -21,3 +21,10 @@ export const validateValueBool = (boolClose, boolOpen) => { @@ -21,3 +21,10 @@ export const validateValueBool = (boolClose, boolOpen) => {
21 throw '布尔值不能相同'; 21 throw '布尔值不能相同';
22 } 22 }
23 }; 23 };
  24 +
  25 +export const validateValueStruct = (data: []) => {
  26 + if (data.length === 0) {
  27 + createMessage.error('struct不能为空');
  28 + throw 'struct不能为空';
  29 + }
  30 +};
@@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; @@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
3 import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; 3 import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
4 import { scheduleOptions } from './formatData'; 4 import { scheduleOptions } from './formatData';
5 import { copyTransFun } from '/@/utils/fnUtils'; 5 import { copyTransFun } from '/@/utils/fnUtils';
6 -import { numberAndNonegativeRule, numberAndEngLishRule } from '/@/utils/rules'; 6 +import { numberAndNonegativeRule } from '/@/utils/rules';
7 7
8 /** 8 /**
9 * 所使用的枚举值 9 * 所使用的枚举值
@@ -265,7 +265,7 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -265,7 +265,7 @@ export const trigger_condition_schema: FormSchema[] = [
265 }, 265 },
266 ifShow: ({ values }) => isDevice(values.triggerType), 266 ifShow: ({ values }) => isDevice(values.triggerType),
267 colProps: { span: 6 }, 267 colProps: { span: 6 },
268 - rules: numberAndEngLishRule, 268 + // rules: numberAndEngLishRule,
269 }, 269 },
270 { 270 {
271 field: 'operationType', 271 field: 'operationType',