Commit dd853e5ba6a4bc5f6c7b426969efaa71028c0de1

Authored by ww
2 parents 40d46207 5860e087

merge: merge ww branch code to main

@@ -14,7 +14,7 @@ VITE_PUBLIC_PATH = / @@ -14,7 +14,7 @@ VITE_PUBLIC_PATH = /
14 # VITE_PROXY = [["/api","http://101.133.234.90:8080/api"]] 14 # VITE_PROXY = [["/api","http://101.133.234.90:8080/api"]]
15 # 线上测试环境 15 # 线上测试环境
16 # VITE_PROXY = [["/api","http://localhost:8080/api"],["/thingskit-drawio","http://localhost:3000/"]] 16 # VITE_PROXY = [["/api","http://localhost:8080/api"],["/thingskit-drawio","http://localhost:3000/"]]
17 -VITE_PROXY = [["/api","https://dev.thingskit.com/api"],["/thingskit-drawio","http://localhost:3000/"]] 17 +VITE_PROXY = [["/api","http://222.180.200.114:48080/api"],["/thingskit-drawio","http://localhost:3000/"]]
18 # VITE_PROXY = [["/api","http://121.37.251.8:8080/api"],["/thingskit-drawio","http://localhost:3000/"]] 18 # VITE_PROXY = [["/api","http://121.37.251.8:8080/api"],["/thingskit-drawio","http://localhost:3000/"]]
19 # VITE_PROXY = [["/api","http://192.168.10.136:8080/api"],["/thingskit-drawio","http://192.168.10.136:8080/api"]] 19 # VITE_PROXY = [["/api","http://192.168.10.136:8080/api"],["/thingskit-drawio","http://192.168.10.136:8080/api"]]
20 20
@@ -186,7 +186,7 @@ export const getGATEWAYdevice = async (params: { organization: string }) => { @@ -186,7 +186,7 @@ export const getGATEWAYdevice = async (params: { organization: string }) => {
186 params, 186 params,
187 }); 187 });
188 return Promise.resolve<{ label: string; value: string }[]>( 188 return Promise.resolve<{ label: string; value: string }[]>(
189 - res.map((item) => ({ label: item.name, value: item.id })) 189 + res.map((item) => ({ label: item.name, value: item.tbDeviceId }))
190 ); 190 );
191 }; 191 };
192 192
@@ -118,8 +118,10 @@ const transform: AxiosTransform = { @@ -118,8 +118,10 @@ const transform: AxiosTransform = {
118 errorLogStore.addAjaxErrorInfo(error); 118 errorLogStore.addAjaxErrorInfo(error);
119 const { response, code, message, config } = error || {}; 119 const { response, code, message, config } = error || {};
120 const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'; 120 const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none';
121 - // const msg: string = response?.data?.msg ?? '';  
122 - const msg: string = response?.data?.message || response?.data?.msg; 121 + const errorMsgIsObj = typeof response.data === 'object';
  122 + const msg: string = errorMsgIsObj
  123 + ? response?.data?.message || response?.data?.msg
  124 + : response.data;
123 const err: string = error?.toString?.() ?? ''; 125 const err: string = error?.toString?.() ?? '';
124 let errMessage = ''; 126 let errMessage = '';
125 try { 127 try {
@@ -22,12 +22,20 @@ export const step1Schemas: FormSchema[] = [ @@ -22,12 +22,20 @@ export const step1Schemas: FormSchema[] = [
22 label: '设备名称', 22 label: '设备名称',
23 required: true, 23 required: true,
24 component: 'Input', 24 component: 'Input',
  25 + colProps: { span: 14 },
25 componentProps: { 26 componentProps: {
26 placeholder: '设备名称', 27 placeholder: '设备名称',
27 maxLength: 30, 28 maxLength: 30,
28 }, 29 },
29 }, 30 },
30 { 31 {
  32 + field: 'alias',
  33 + label: '别名 ',
  34 + component: 'Input',
  35 + labelWidth: 60,
  36 + colProps: { span: 10 },
  37 + },
  38 + {
31 field: 'sn', 39 field: 'sn',
32 label: 'SN码', 40 label: 'SN码',
33 component: 'Input', 41 component: 'Input',
@@ -53,8 +53,8 @@ @@ -53,8 +53,8 @@
53 </template> 53 </template>
54 <template #name="{ record }"> 54 <template #name="{ record }">
55 <div> 55 <div>
56 - <Tooltip :title="record.name" placement="topRight">  
57 - {{ record.name.slice(0, 13) }} 56 + <Tooltip :title="record.alias || record.name" placement="topRight">
  57 + {{ record.alias || record.name.slice(0, 13) }}
58 </Tooltip> 58 </Tooltip>
59 </div> 59 </div>
60 <Tooltip title="设备SN码" placement="topRight"> 60 <Tooltip title="设备SN码" placement="topRight">
@@ -304,7 +304,7 @@ @@ -304,7 +304,7 @@
304 async function handleEdit(record: Recordable) { 304 async function handleEdit(record: Recordable) {
305 if (record.deviceType === 'SENSOR') { 305 if (record.deviceType === 'SENSOR') {
306 const res = await getGATEWAY(record.tbDeviceId); 306 const res = await getGATEWAY(record.tbDeviceId);
307 - Reflect.set(record, 'gatewayId', res.id); 307 + Reflect.set(record, 'gatewayId', res.tbDeviceId);
308 } 308 }
309 openModal(true, { 309 openModal(true, {
310 isUpdate: true, 310 isUpdate: true,
@@ -63,8 +63,11 @@ @@ -63,8 +63,11 @@
63 通知,如告警,需要被及时处理。`; 63 通知,如告警,需要被及时处理。`;
64 const activeKey = ref<FunctionType>(FunctionType.PROPERTIES); 64 const activeKey = ref<FunctionType>(FunctionType.PROPERTIES);
65 const size = ref('small'); 65 const size = ref('small');
  66 +
66 const AttrRef = ref<InstanceType<typeof Attribute>>(); 67 const AttrRef = ref<InstanceType<typeof Attribute>>();
  68 +
67 const ServiceRef = ref<InstanceType<typeof Service>>(); 69 const ServiceRef = ref<InstanceType<typeof Service>>();
  70 +
68 const EventsRef = ref<InstanceType<typeof Events>>(); 71 const EventsRef = ref<InstanceType<typeof Events>>();
69 const openModalMode = ref<OpenModelMode>(OpenModelMode.CREATE); 72 const openModalMode = ref<OpenModelMode>(OpenModelMode.CREATE);
70 const openModalParams = ref<OpenModelOfMatterModelParams>(); 73 const openModalParams = ref<OpenModelOfMatterModelParams>();
@@ -53,9 +53,4 @@ @@ -53,9 +53,4 @@
53 setFormData, 53 setFormData,
54 }); 54 });
55 </script> 55 </script>
56 -<style lang="less" scoped>  
57 - .add-style {  
58 - color: #0170cc;  
59 - cursor: pointer;  
60 - }  
61 -</style> 56 +<style lang="less" scoped></style>
@@ -37,9 +37,4 @@ @@ -37,9 +37,4 @@
37 getFormData, 37 getFormData,
38 }); 38 });
39 </script> 39 </script>
40 -<style lang="less" scoped>  
41 - .add-style {  
42 - color: #0170cc;  
43 - cursor: pointer;  
44 - }  
45 -</style> 40 +<style lang="less" scoped></style>
@@ -40,9 +40,4 @@ @@ -40,9 +40,4 @@
40 getFormData, 40 getFormData,
41 }); 41 });
42 </script> 42 </script>
43 -<style lang="less" scoped>  
44 - .add-style {  
45 - color: #0170cc;  
46 - cursor: pointer;  
47 - }  
48 -</style> 43 +<style lang="less" scoped></style>
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <div> 3 <div>
4 <Typography> 4 <Typography>
5 <TypographyParagraph> 5 <TypographyParagraph>
6 - <blockquote style="background: #f2f2f2">{{ blockContent }}</blockquote> 6 + <blockquote style="background: #f2f2f2">{{ useBlockContent }}</blockquote>
7 </TypographyParagraph> 7 </TypographyParagraph>
8 </Typography> 8 </Typography>
9 </div> 9 </div>
@@ -38,14 +38,18 @@ @@ -38,14 +38,18 @@
38 import 'jsoneditor/dist/jsoneditor.min.css'; 38 import 'jsoneditor/dist/jsoneditor.min.css';
39 import { Button, Typography, TypographyParagraph } from 'ant-design-vue'; 39 import { Button, Typography, TypographyParagraph } from 'ant-design-vue';
40 import { defaultTslContent } from './config'; 40 import { defaultTslContent } from './config';
  41 + import useCommon from '../hook/useCommon';
41 42
42 const { createMessage } = useMessage(); 43 const { createMessage } = useMessage();
43 - const blockContent = `物模型是对设备在云端的功能描述,包括设备的属性、服务和事件。物联网平台通过定义一种物的描述语言来描述物模型,称之为 TSL(即 Thing  
44 -Specification Language),采用 JSON 格式,您可以根据 TSL 组装上报设备的数据。您可以导出完整物模型,用于云端应用开发;您也可以只导出  
45 -精简物模型,配合设备端 SDK 实现设备开发。`; 44 +
  45 + const { useBlockContent } = useCommon();
  46 +
46 const jsonValue = ref(defaultTslContent); 47 const jsonValue = ref(defaultTslContent);
  48 +
47 const jsonInstance = ref(); 49 const jsonInstance = ref();
  50 +
48 const jsoneditorRef = ref(); 51 const jsoneditorRef = ref();
  52 +
49 onMounted(() => { 53 onMounted(() => {
50 nextTick(() => { 54 nextTick(() => {
51 let options = { 55 let options = {
@@ -58,7 +62,9 @@ Specification Language),采用 JSON æ ¼å¼ï¼Œæ‚¨å¯ä»¥æ ¹æ® TSL ç»„è£…ä¸ŠæŠ @@ -58,7 +62,9 @@ Specification Language),采用 JSON æ ¼å¼ï¼Œæ‚¨å¯ä»¥æ ¹æ® TSL 组装上æŠ
58 jsonInstance.value = editor; 62 jsonInstance.value = editor;
59 }); 63 });
60 }); 64 });
  65 +
61 const { clipboardRef, copiedRef } = useCopyToClipboard(); 66 const { clipboardRef, copiedRef } = useCopyToClipboard();
  67 +
62 const handleCopy = () => { 68 const handleCopy = () => {
63 try { 69 try {
64 const valueRef = unref(jsonInstance).get(); 70 const valueRef = unref(jsonInstance).get();
@@ -81,9 +87,11 @@ Specification Language),采用 JSON æ ¼å¼ï¼Œæ‚¨å¯ä»¥æ ¹æ® TSL ç»„è£…ä¸ŠæŠ @@ -81,9 +87,11 @@ Specification Language),采用 JSON æ ¼å¼ï¼Œæ‚¨å¯ä»¥æ ¹æ® TSL 组装上æŠ
81 if (!value) return; 87 if (!value) return;
82 return value; 88 return value;
83 }; 89 };
  90 +
84 const resetFormData = () => { 91 const resetFormData = () => {
85 unref(jsonInstance).set(defaultTslContent); 92 unref(jsonInstance).set(defaultTslContent);
86 }; 93 };
  94 +
87 const handlePremitter = () => { 95 const handlePremitter = () => {
88 const value = unref(jsonInstance).get(); 96 const value = unref(jsonInstance).get();
89 return unref(jsonInstance).set(value); 97 return unref(jsonInstance).set(value);
@@ -2,50 +2,35 @@ @@ -2,50 +2,35 @@
2 <div> 2 <div>
3 <BasicForm @register="registerForm"> 3 <BasicForm @register="registerForm">
4 <template #structSlot> 4 <template #structSlot>
5 - <div>  
6 - <template v-for="item in outputParamData" :key="item.id">  
7 - <span class="hidden">{{ item }}</span>  
8 - <InputParamItem  
9 - :item="item"  
10 - class="mt-4"  
11 - :ref="dynamicBindRef.outputParamItemRef"  
12 - @delete="deleteOutParItem"  
13 - @edit="editOutParItem"  
14 - />  
15 - </template>  
16 - <div class="flex" :class="{ 'mt-2': outputParamData.length > 0 }">  
17 - <span class="add-style">  
18 - <PlusOutlined />  
19 - </span>  
20 - <span class="add-style" @click="handleAddOutParam">增加参数</span>  
21 - </div>  
22 - </div> 5 + <CommomParam
  6 + ref="CommomParamInParamRef"
  7 + :isExcludeStruct="true"
  8 + :isInputParam="true"
  9 + :inputParamData="inputParamData"
  10 + @emitAddInParam="handleAddInParam"
  11 + @emitEditInParam="handleEditInParam"
  12 + @emitDeletelnParam="handleDelInParam"
  13 + />
23 </template> 14 </template>
24 </BasicForm> 15 </BasicForm>
25 <AddParamsModal @register="registerModal" @data="getData" /> 16 <AddParamsModal @register="registerModal" @data="getData" />
26 </div> 17 </div>
27 </template> 18 </template>
28 <script lang="ts" setup> 19 <script lang="ts" setup>
29 - import { ref, unref } from 'vue'; 20 + import { unref } from 'vue';
30 import { BasicForm, useForm } from '/@/components/Form'; 21 import { BasicForm, useForm } from '/@/components/Form';
31 - import { addParamsSchemas, FormField } from '../config'; 22 + import { addParamsSchemas } from '../config';
32 import { useModal } from '/@/components/Modal'; 23 import { useModal } from '/@/components/Modal';
33 - import InputParamItem from './InputParamItem.vue'; 24 + import useCommon from '../../hook/useCommon';
34 import AddParamsModal from './AddParamsModal.vue'; 25 import AddParamsModal from './AddParamsModal.vue';
35 - import { buildUUID } from '/@/utils/uuid';  
36 - import { PlusOutlined } from '@ant-design/icons-vue';  
37 - import { FunctionJson, ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';  
38 - import { transformFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/util';  
39 - import { StructFormValue } from '/@/components/Form/src/externalCompns/components/StructForm/type';  
40 - type OutputParam = FunctionJson & { id: string }; 26 + import CommomParam from './CommomParam.vue';
  27 + import useDefineVar from '../../hook/useDefineVar';
41 28
42 defineEmits(['register']); 29 defineEmits(['register']);
43 30
44 - const outputParamData = ref<OutputParam[]>([]); 31 + const { inputParamData, CommomParamInParamRef } = useDefineVar();
45 32
46 - const dynamicBindRef = {  
47 - outputParamItemRef: ref([]),  
48 - }; 33 + const { useChangeTypeGetTypeForm, useGetInOrOutData, useUpdateFormExcludeStruct } = useCommon();
49 34
50 const [registerModal, { openModal }] = useModal(); 35 const [registerModal, { openModal }] = useModal();
51 36
@@ -60,57 +45,94 @@ @@ -60,57 +45,94 @@
60 showActionButtonGroup: false, 45 showActionButtonGroup: false,
61 }); 46 });
62 47
63 - const getData = (value: FunctionJson) => {  
64 - unref(outputParamData).push({ ...value, id: buildUUID() });  
65 - }; 48 + const getData = (d, f) => useGetInOrOutData(d, f, unref(inputParamData), []);
66 49
67 - const handleAddOutParam = () => {  
68 - openModal(true, {  
69 - isUpdate: true,  
70 - flag: 'output',  
71 - excludeStruct: true,  
72 - });  
73 - }; 50 + const handleAddInParam = (b, o) => openModal(b, o);
  51 +
  52 + const handleEditInParam = (b, o) => openModal(b, o);
  53 +
  54 + const handleDelInParam = (i) => unref(inputParamData).splice(i, 1);
74 55
75 - const deleteOutParItem = (value: OutputParam) => {  
76 - const index = unref(outputParamData).findIndex((item) => item.id === value.id);  
77 - ~index && unref(outputParamData).splice(index, 1); 56 + const updateFormExcludeStruct = (flag) => useUpdateFormExcludeStruct(flag, updateSchema);
  57 +
  58 + const getOutputStructList = () => CommomParamInParamRef.value?.getInputStructList();
  59 +
  60 + const getBoolOrStruct = (T, S, B) => {
  61 + if (T === 'STRUCT') {
  62 + return S;
  63 + } else if (T === 'INT' || T === 'DOUBLE' || T === 'TEXT') {
  64 + return null;
  65 + } else {
  66 + return B;
  67 + }
78 }; 68 };
79 69
80 - const editOutParItem = (item: FunctionJson) => {  
81 - openModal(true, {  
82 - isUpdate: false,  
83 - record: item,  
84 - flag: 'output',  
85 - excludeStruct: true,  
86 - }); 70 + const getIntOrText = (T, D) => {
  71 + if (T === 'STRUCT') {
  72 + return null;
  73 + } else if (T === 'INT' || T === 'DOUBLE' || T === 'TEXT') {
  74 + return D;
  75 + }
87 }; 76 };
88 77
89 - const updateFormExcludeStruct = () => {  
90 - const options = useUpdateFormExcludeStruct();  
91 - updateSchema({  
92 - field: FormField.TYPE,  
93 - componentProps: { options }, 78 + const getFormData = async () => {
  79 + const values = await validate();
  80 + if (!values) return;
  81 + const outputParams = getOutputStructList();
  82 + outputParams?.forEach((f) => {
  83 + f.dataType = 'STRUCT';
  84 + f.childSpecsDTO = getIntOrText(f.childDataType, f.dataSpecs);
  85 + f.childEnumSpecsDTO = getBoolOrStruct(f.childDataType, null, f.dataSpecsList);
94 }); 86 });
  87 + const dataSpecs = useChangeTypeGetTypeForm(values.dataType, values);
  88 + const dataSpecsList = useChangeTypeGetTypeForm(values.dataType, values);
  89 + const { boolClose, boolOpen, step, unit, valueRange, length, ...value } = values;
  90 + const none = [valueRange, step, unit, boolOpen, boolClose, length]; //没用,防止eslint报未使用变量
  91 + console.log(none);
  92 + return {
  93 + ...{ childName: value.name },
  94 + ...{ childDataType: value.dataType },
  95 + ...value,
  96 + ...{
  97 + dataSpecs: getIntOrText(values.dataType, dataSpecs),
  98 + },
  99 + ...{
  100 + dataSpecsList: getBoolOrStruct(values.dataType, outputParams, dataSpecsList),
  101 + },
  102 + };
95 }; 103 };
96 104
97 - const getFormData = async (): Promise<Partial<ModelOfMatterParams>> => { 105 + const setFormData = (v) => {
98 try { 106 try {
99 - const values = (await validate()) as StructFormValue;  
100 - if (!values) return {} as unknown as ModelOfMatterParams;  
101 - const functionJson = transformFormValue(values);  
102 - return functionJson;  
103 - } catch (error) {}  
104 - return {} as unknown as ModelOfMatterParams;  
105 - };  
106 -  
107 - const setFormData = (value: FunctionJson) => {  
108 - setFormData(value); 107 + setFieldsValue(v);
  108 + setFieldsValue({
  109 + ...v.dataSpecs,
  110 + valueRange: v.dataSpecs,
  111 + });
  112 + setFieldsValue({
  113 + boolClose: v.dataType == 'BOOL' ? v.dataSpecsList[0].name : '',
  114 + boolOpen: v.dataType == 'BOOL' ? v.dataSpecsList[1].name : '',
  115 + });
  116 + const { dataSpecsList, dataType, childDataType } = v;
  117 + if (childDataType == 'BOOL') {
  118 + setFieldsValue({
  119 + dataType: childDataType,
  120 + boolClose: dataSpecsList[0].name,
  121 + boolOpen: dataSpecsList[1].name,
  122 + });
  123 + }
  124 + if (dataType == 'BOOL' || dataType == 'STRUCT') {
  125 + inputParamData.value = [...new Array(dataSpecsList.length).keys()];
  126 + inputParamData.value = dataSpecsList;
  127 + }
  128 + } catch (e) {
  129 + console.log('AddParamForm error info', e);
  130 + }
109 }; 131 };
110 132
111 const resetFormData = () => { 133 const resetFormData = () => {
112 resetFields(); 134 resetFields();
113 - outputParamData.value = []; 135 + inputParamData.value = [];
114 }; 136 };
115 137
116 defineExpose({ 138 defineExpose({
@@ -17,15 +17,24 @@ @@ -17,15 +17,24 @@
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 useParitalValid from '../../hook/useParitalValid';
20 21
21 const emits = defineEmits(['register', 'data']); 22 const emits = defineEmits(['register', 'data']);
  23 +
  24 + const {} = useParitalValid();
  25 +
22 const setEditData: any = reactive({ 26 const setEditData: any = reactive({
23 getEditData: {}, 27 getEditData: {},
24 }); 28 });
  29 +
25 const AddParamFormRef = ref<InstanceType<typeof AddParamForm>>(); 30 const AddParamFormRef = ref<InstanceType<typeof AddParamForm>>();
  31 +
26 const isUpdate = ref(false); 32 const isUpdate = ref(false);
  33 +
27 const isFlag = ref(''); 34 const isFlag = ref('');
  35 +
28 const excludeStruct = ref(false); 36 const excludeStruct = ref(false);
  37 +
29 const getTitle = computed(() => (!isUpdate.value ? '编辑参数' : '新增参数')); 38 const getTitle = computed(() => (!isUpdate.value ? '编辑参数' : '新增参数'));
30 39
31 const [register, { setModalProps }] = useModalInner(async (data) => { 40 const [register, { setModalProps }] = useModalInner(async (data) => {
  1 +<template>
  2 + <!-- 输入参数 -->
  3 + <div v-if="isInputParam">
  4 + <template v-for="(item, index) in inputParamData" :key="item.name">
  5 + <span style="display: none">{{ item }}</span>
  6 + <InputParamItem
  7 + :title="item.name"
  8 + :item="item"
  9 + class="mt-4"
  10 + :index="index"
  11 + :ref="dynamicBindRef.inputParamItemRef"
  12 + @delete="deleteInParItem"
  13 + @edit="editInParItem"
  14 + />
  15 + </template>
  16 + <div style="display: flex" :class="{ 'mt-2': inputParamData.length > 0 }">
  17 + <span class="add-style">+</span>
  18 + <span class="add-style" @click="handleAddInParam">增加参数</span>
  19 + </div>
  20 + </div>
  21 + <!-- 输出参数 -->
  22 + <div v-if="isOutputParam">
  23 + <template v-for="(item, index) in outputParamData" :key="item.name">
  24 + <span style="display: none">{{ item + index }}</span>
  25 + <InputParamItem
  26 + :title="item.name"
  27 + :item="item"
  28 + class="mt-4"
  29 + :index="index"
  30 + :ref="dynamicBindRef.outputParamItemRef"
  31 + @delete="deleteOutParItem"
  32 + @edit="editOutParItem"
  33 + />
  34 + </template>
  35 + <div style="display: flex" :class="{ 'mt-2': outputParamData.length > 0 }">
  36 + <span class="add-style">+</span>
  37 + <span class="add-style" @click="handleAddOutParam">增加参数</span>
  38 + </div>
  39 + </div>
  40 +</template>
  41 +<script lang="ts" setup>
  42 + import { ref, unref } from 'vue';
  43 + import InputParamItem from './InputParamItem.vue';
  44 +
  45 + const props = defineProps({
  46 + isExcludeStruct: { type: Boolean, default: true },
  47 + isInputParam: { type: Boolean, default: false },
  48 + isOutputParam: { type: Boolean, default: false },
  49 + inputParamData: {
  50 + type: Array as PropType<any[]>,
  51 + default: () => [],
  52 + },
  53 + outputParamData: {
  54 + type: Array as PropType<any[]>,
  55 + default: () => [],
  56 + },
  57 + });
  58 +
  59 + const emit = defineEmits([
  60 + 'emitAddInParam',
  61 + 'emitEditInParam',
  62 + 'emitDeletelnParam',
  63 + 'emitAddOutParam',
  64 + 'emitEditOutParam',
  65 + 'emitDeleteOutParam',
  66 + ]);
  67 +
  68 + const dynamicBindRef = {
  69 + inputParamItemRef: ref([]),
  70 + outputParamItemRef: ref([]),
  71 + };
  72 +
  73 + const commomAddParamObj = {
  74 + isUpdate: true,
  75 + excludeStruct: props.isExcludeStruct ? true : false,
  76 + };
  77 +
  78 + const commomEditParamObj = {
  79 + isUpdate: false,
  80 + excludeStruct: props.isExcludeStruct ? true : false,
  81 + };
  82 +
  83 + const handleAddInParam = () => {
  84 + emit('emitAddInParam', true, {
  85 + ...commomAddParamObj,
  86 + flag: 'input',
  87 + });
  88 + };
  89 +
  90 + const deleteInParItem = (index) => {
  91 + emit('emitDeletelnParam', index);
  92 + };
  93 +
  94 + const editInParItem = (item) => {
  95 + emit('emitEditInParam', true, {
  96 + ...commomEditParamObj,
  97 + record: item,
  98 + flag: 'input',
  99 + });
  100 + };
  101 +
  102 + const handleAddOutParam = () => {
  103 + emit('emitAddOutParam', true, {
  104 + ...commomAddParamObj,
  105 + flag: 'output',
  106 + });
  107 + };
  108 +
  109 + const deleteOutParItem = (index) => {
  110 + emit('emitDeleteOutParam', index);
  111 + };
  112 +
  113 + const editOutParItem = (item) => {
  114 + emit('emitEditOutParam', true, {
  115 + ...commomEditParamObj,
  116 + record: item,
  117 + flag: 'output',
  118 + });
  119 + };
  120 +
  121 + const getInputStructList = () =>
  122 + unref(dynamicBindRef.inputParamItemRef)?.map((item: any) => item.getFormData());
  123 +
  124 + const getOutputStructList = () =>
  125 + unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData());
  126 +
  127 + defineExpose({
  128 + getInputStructList,
  129 + getOutputStructList,
  130 + });
  131 +</script>
  132 +<style lang="less" scoped>
  133 + .add-style {
  134 + color: #0170cc;
  135 + cursor: pointer;
  136 + }
  137 +</style>
1 import { buildUUID } from '/@/utils/uuid'; 1 import { buildUUID } from '/@/utils/uuid';
2 2
3 -//模拟阿里云属性服务事件服务端格式 3 +//模拟的阿里云(属性、服务、事件)服务端格式
4 export const mockData = { 4 export const mockData = {
5 _ppk: {}, 5 _ppk: {},
6 events: [ 6 events: [
7 { 7 {
8 - createTs: 1666596472189, 8 + createTs: 1668151471327,
9 custom: true, 9 custom: true,
10 - description: '监播动作结果上报事件',  
11 - eventName: '监播动作结果上报事件', 10 + eventName: 'SDK运行状态',
12 eventType: 'INFO_EVENT_TYPE', 11 eventType: 'INFO_EVENT_TYPE',
13 - identifier: 'MonitorActionEvent', 12 + identifier: 'ContentSdkStatusEvent',
14 outputData: [ 13 outputData: [
15 { 14 {
16 id: buildUUID(), 15 id: buildUUID(),
  16 +
17 custom: true, 17 custom: true,
18 dataSpecs: { 18 dataSpecs: {
19 dataType: 'INT', 19 dataType: 'INT',
@@ -26,12 +26,13 @@ export const mockData = { @@ -26,12 +26,13 @@ export const mockData = {
26 }, 26 },
27 dataType: 'INT', 27 dataType: 'INT',
28 direction: 'PARAM_OUTPUT', 28 direction: 'PARAM_OUTPUT',
29 - identifier: 'ActionType',  
30 - name: '监播操作类型', 29 + identifier: 'Status',
  30 + name: '状态类型值',
31 paraOrder: 0, 31 paraOrder: 0,
32 }, 32 },
33 { 33 {
34 id: buildUUID(), 34 id: buildUUID(),
  35 +
35 custom: true, 36 custom: true,
36 dataSpecs: { 37 dataSpecs: {
37 dataType: 'TEXT', 38 dataType: 'TEXT',
@@ -39,293 +40,247 @@ export const mockData = { @@ -39,293 +40,247 @@ export const mockData = {
39 }, 40 },
40 dataType: 'TEXT', 41 dataType: 'TEXT',
41 direction: 'PARAM_OUTPUT', 42 direction: 'PARAM_OUTPUT',
42 - identifier: 'FileKey',  
43 - name: '上传文件ossKey', 43 + identifier: 'Message',
  44 + name: '消息内容',
44 paraOrder: 1, 45 paraOrder: 1,
45 }, 46 },
46 { 47 {
47 id: buildUUID(), 48 id: buildUUID(),
  49 +
48 custom: true, 50 custom: true,
49 dataSpecsList: [ 51 dataSpecsList: [
50 { 52 {
51 id: buildUUID(), 53 id: buildUUID(),
52 - dataType: 'BOOL',  
53 - name: '1',  
54 - value: 0,  
55 - },  
56 - {  
57 - id: buildUUID(),  
58 - dataType: 'BOOL',  
59 - name: '0',  
60 - value: 1,  
61 - },  
62 - ],  
63 - dataType: 'BOOL',  
64 - direction: 'PARAM_OUTPUT',  
65 - identifier: 'Extension',  
66 - name: '扩展信息',  
67 - paraOrder: 2,  
68 - },  
69 - {  
70 - id: buildUUID(),  
71 - custom: true,  
72 - dataSpecsList: [  
73 - {  
74 - id: buildUUID(),  
75 - childDataType: 'DOUBLE',  
76 - childName: '峰值', 54 +
  55 + childDataType: 'INT',
  56 + childName: '测试结构体回显1',
77 childSpecsDTO: { 57 childSpecsDTO: {
78 - dataType: 'DOUBLE',  
79 - max: '33',  
80 - min: '22',  
81 - step: '2',  
82 - unit: 'm³/s',  
83 - unitName: '立方米每秒', 58 + dataType: 'INT',
  59 + max: '22',
  60 + min: '11',
  61 + step: '3',
84 }, 62 },
85 custom: true, 63 custom: true,
86 dataSpecs: { 64 dataSpecs: {
87 - dataType: 'DOUBLE',  
88 - max: '33',  
89 - min: '22',  
90 - step: '2',  
91 - unit: 'm³/s',  
92 - unitName: '立方米每秒', 65 + dataType: 'INT',
  66 + max: '22',
  67 + min: '11',
  68 + step: '3',
93 }, 69 },
94 dataType: 'STRUCT', 70 dataType: 'STRUCT',
95 - identifier: 'bass', 71 + identifier: '1',
96 isStd: 0, 72 isStd: 0,
97 - name: '峰值', 73 + name: '测试结构体回显1',
98 }, 74 },
99 { 75 {
100 id: buildUUID(), 76 id: buildUUID(),
  77 +
101 childDataType: 'BOOL', 78 childDataType: 'BOOL',
102 childEnumSpecsDTO: [ 79 childEnumSpecsDTO: [
103 { 80 {
104 dataType: 'BOOL', 81 dataType: 'BOOL',
105 - name: '1', 82 + name: 'ffg',
106 value: 0, 83 value: 0,
107 }, 84 },
108 { 85 {
109 dataType: 'BOOL', 86 dataType: 'BOOL',
110 - name: '0', 87 + name: 'ggg',
111 value: 1, 88 value: 1,
112 }, 89 },
113 ], 90 ],
114 - childName: '平均速率', 91 + childName: '测试结构体回显2',
115 custom: true, 92 custom: true,
116 dataSpecsList: [ 93 dataSpecsList: [
117 { 94 {
118 - id: buildUUID(),  
119 dataType: 'BOOL', 95 dataType: 'BOOL',
120 - name: '1', 96 + name: 'ffg',
121 value: 0, 97 value: 0,
122 }, 98 },
123 { 99 {
124 - id: buildUUID(),  
125 dataType: 'BOOL', 100 dataType: 'BOOL',
126 - name: '0', 101 + name: 'ggg',
127 value: 1, 102 value: 1,
128 }, 103 },
129 ], 104 ],
130 dataType: 'STRUCT', 105 dataType: 'STRUCT',
131 - identifier: 'average', 106 + identifier: '3',
132 isStd: 0, 107 isStd: 0,
133 - name: '平均速率', 108 + name: '测试结构体回显2',
134 }, 109 },
135 - ],  
136 - dataType: 'STRUCT',  
137 - direction: 'PARAM_OUTPUT',  
138 - identifier: 'ceshi',  
139 - name: '网速',  
140 - paraOrder: 3,  
141 - },  
142 - ],  
143 - productKey: 'hsrnXEfGFDv',  
144 - required: false,  
145 - },  
146 - ],  
147 - productKey: 'hsrnXEfGFDv',  
148 - properties: [  
149 - // {  
150 - // createTs: 1667876342551,  
151 - // custom: true,  
152 - // customFlag: true,  
153 - // dataSpecs: {  
154 - // dataType: 'TEXT',  
155 - // length: 10240,  
156 - // },  
157 - // dataType: 'TEXT',  
158 - // description: '内容推荐',  
159 - // identifier: 'Brightness',  
160 - // name: '亮度百分比',  
161 - // productKey: 'hsrnXEfGFDv',  
162 - // required: false,  
163 - // rwFlag: 'READ_WRITE',  
164 - // std: false,  
165 - // },  
166 - // {  
167 - // createTs: 1667876342551,  
168 - // custom: true,  
169 - // customFlag: true,  
170 - // dataSpecsList: [  
171 - // {  
172 - // dataType: 'BOOL',  
173 - // name: '开',  
174 - // value: 0,  
175 - // },  
176 - // {  
177 - // dataType: 'BOOL',  
178 - // name: '关',  
179 - // value: 1,  
180 - // },  
181 - // ],  
182 - // dataType: 'BOOL',  
183 - // description: '内容推荐',  
184 - // identifier: 'Brightness',  
185 - // name: '亮度百分比',  
186 - // productKey: 'hsrnXEfGFDv',  
187 - // required: false,  
188 - // rwFlag: 'READ_WRITE',  
189 - // std: false,  
190 - // },  
191 - // {  
192 - // createTs: 1667876342551,  
193 - // custom: true,  
194 - // customFlag: true,  
195 - // dataSpecs: {  
196 - // dataType: 'INT',  
197 - // max: '1024',  
198 - // min: '-1024',  
199 - // step: '1',  
200 - // unit: 'var',  
201 - // },  
202 - // dataType: 'INT',  
203 - // description: '内容推荐。0:未知状态,1:熄屏,2:亮屏',  
204 - // identifier: 'RunningState',  
205 - // name: '运行状态',  
206 - // productKey: 'hsrnXEfGFDv',  
207 - // required: false,  
208 - // rwFlag: 'READ_WRITE',  
209 - // std: false,  
210 - // },  
211 - {  
212 - createTs: 1666604372638,  
213 - custom: true,  
214 - customFlag: true,  
215 - dataSpecsList: [  
216 - {  
217 - childDataType: 'BOOL',  
218 - childEnumSpecsDTO: [  
219 { 110 {
220 - dataType: 'BOOL',  
221 - name: '左眼',  
222 - value: 0, 111 + id: buildUUID(),
  112 +
  113 + childDataType: 'TEXT',
  114 + childName: '测试结构体回显3',
  115 + childSpecsDTO: {
  116 + dataType: 'TEXT',
  117 + length: 10240,
  118 + },
  119 + custom: true,
  120 + dataSpecs: {
  121 + dataType: 'TEXT',
  122 + length: 10240,
  123 + },
  124 + dataType: 'STRUCT',
  125 + identifier: '33',
  126 + isStd: 0,
  127 + name: '测试结构体回显3',
223 }, 128 },
224 { 129 {
225 - dataType: 'BOOL',  
226 - name: '右眼',  
227 - value: 1, 130 + id: buildUUID(),
  131 +
  132 + childDataType: 'DOUBLE',
  133 + childName: '测试结构体回显4',
  134 + childSpecsDTO: {
  135 + dataType: 'DOUBLE',
  136 + max: '44.0',
  137 + min: '33.0',
  138 + step: '5.0',
  139 + unit: 'gear',
  140 + unitName: '档',
  141 + },
  142 + custom: true,
  143 + dataSpecs: {
  144 + dataType: 'DOUBLE',
  145 + max: '44.0',
  146 + min: '33.0',
  147 + step: '5.0',
  148 + unit: 'gear',
  149 + unitName: '档',
  150 + },
  151 + dataType: 'STRUCT',
  152 + identifier: '4',
  153 + isStd: 0,
  154 + name: '测试结构体回显4',
228 }, 155 },
229 ], 156 ],
230 - childName: '眼睛', 157 + dataType: 'STRUCT',
  158 + direction: 'PARAM_OUTPUT',
  159 + identifier: '1',
  160 + name: '测试结构体回显',
  161 + paraOrder: 2,
  162 + },
  163 + {
  164 + id: buildUUID(),
  165 +
231 custom: true, 166 custom: true,
232 dataSpecsList: [ 167 dataSpecsList: [
233 { 168 {
234 dataType: 'BOOL', 169 dataType: 'BOOL',
235 - name: '左眼', 170 + name: 'er',
236 value: 0, 171 value: 0,
237 }, 172 },
238 { 173 {
239 dataType: 'BOOL', 174 dataType: 'BOOL',
240 - name: '右眼', 175 + name: 'dd',
241 value: 1, 176 value: 1,
242 }, 177 },
243 ], 178 ],
244 - dataType: 'STRUCT',  
245 - identifier: 'Eye',  
246 - isStd: 0,  
247 - name: '眼睛', 179 + dataType: 'BOOL',
  180 + direction: 'PARAM_OUTPUT',
  181 + identifier: '2212',
  182 + name: 'bool类型',
  183 + paraOrder: 3,
248 }, 184 },
  185 + ],
  186 + productKey: 'hsrnXEfGFDv',
  187 + required: false,
  188 + },
  189 + ],
  190 + productKey: 'hsrnXEfGFDv',
  191 + properties: [
  192 + {
  193 + createTs: 1668152010679,
  194 + custom: true,
  195 + customFlag: true,
  196 + dataSpecsList: [
249 { 197 {
250 - childDataType: 'INT',  
251 - childName: '鼻子', 198 + id: buildUUID(),
  199 +
  200 + childDataType: 'TEXT',
  201 + childName: '测试化学需氧量text类型',
252 childSpecsDTO: { 202 childSpecsDTO: {
253 - dataType: 'INT',  
254 - max: '22',  
255 - min: '12',  
256 - step: '5',  
257 - unit: '只',  
258 - unitName: '只', 203 + dataType: 'TEXT',
  204 + length: 10240,
259 }, 205 },
260 custom: true, 206 custom: true,
261 dataSpecs: { 207 dataSpecs: {
262 - dataType: 'INT',  
263 - max: '22',  
264 - min: '12',  
265 - step: '5',  
266 - unit: '只',  
267 - unitName: '只', 208 + dataType: 'TEXT',
  209 + length: 10240,
268 }, 210 },
269 dataType: 'STRUCT', 211 dataType: 'STRUCT',
270 - identifier: 'Boless', 212 + identifier: 'text',
271 isStd: 0, 213 isStd: 0,
272 - name: '鼻子', 214 + name: '测试化学需氧量text类型',
273 }, 215 },
274 { 216 {
275 - childDataType: 'TEXT',  
276 - childName: '脸颊', 217 + id: buildUUID(),
  218 +
  219 + childDataType: 'INT',
  220 + childName: '测试化学需氧量int类型',
277 childSpecsDTO: { 221 childSpecsDTO: {
278 - dataType: 'TEXT',  
279 - length: 10240, 222 + dataType: 'INT',
  223 + max: '22',
  224 + min: '11',
  225 + step: '2',
  226 + unit: 'mm/hour',
  227 + unitName: '降雨量',
280 }, 228 },
281 custom: true, 229 custom: true,
282 dataSpecs: { 230 dataSpecs: {
283 - dataType: 'TEXT',  
284 - length: 10240, 231 + dataType: 'INT',
  232 + max: '22',
  233 + min: '11',
  234 + step: '2',
  235 + unit: 'mm/hour',
  236 + unitName: '降雨量',
285 }, 237 },
286 dataType: 'STRUCT', 238 dataType: 'STRUCT',
287 - identifier: 'Facebook', 239 + identifier: 'ibt',
288 isStd: 0, 240 isStd: 0,
289 - name: '脸颊', 241 + name: '测试化学需氧量int类型',
290 }, 242 },
291 { 243 {
  244 + id: buildUUID(),
  245 +
292 childDataType: 'BOOL', 246 childDataType: 'BOOL',
293 childEnumSpecsDTO: [ 247 childEnumSpecsDTO: [
294 { 248 {
295 dataType: 'BOOL', 249 dataType: 'BOOL',
296 - name: '左耳', 250 + name: '需要',
297 value: 0, 251 value: 0,
298 }, 252 },
299 { 253 {
300 dataType: 'BOOL', 254 dataType: 'BOOL',
301 - name: '右耳', 255 + name: '不需要',
302 value: 1, 256 value: 1,
303 }, 257 },
304 ], 258 ],
305 - childName: '耳朵', 259 + childName: '测试化学需氧量bool类型',
306 custom: true, 260 custom: true,
307 dataSpecsList: [ 261 dataSpecsList: [
308 { 262 {
309 dataType: 'BOOL', 263 dataType: 'BOOL',
310 - name: '左耳', 264 + name: '需要',
311 value: 0, 265 value: 0,
312 }, 266 },
313 { 267 {
314 dataType: 'BOOL', 268 dataType: 'BOOL',
315 - name: '右耳', 269 + name: '不需要',
316 value: 1, 270 value: 1,
317 }, 271 },
318 ], 272 ],
319 dataType: 'STRUCT', 273 dataType: 'STRUCT',
320 - identifier: 'Eyear', 274 + identifier: 'bol',
321 isStd: 0, 275 isStd: 0,
322 - name: '耳朵', 276 + name: '测试化学需氧量bool类型',
323 }, 277 },
324 ], 278 ],
325 dataType: 'STRUCT', 279 dataType: 'STRUCT',
326 - description: '用于人脸特征下发,基于人脸门禁1.0物模型\n设备级开关',  
327 - identifier: 'SupportFaceFeature',  
328 - name: '支持人脸特征下发', 280 + description:
  281 + '化学需氧量COD(Chemical Oxygen Demand)是以化学方法测量水样中需要被氧化的还原性物质的量',
  282 + identifier: 'COD',
  283 + name: '化学需氧量',
329 productKey: 'hsrnXEfGFDv', 284 productKey: 'hsrnXEfGFDv',
330 required: false, 285 required: false,
331 rwFlag: 'READ_WRITE', 286 rwFlag: 'READ_WRITE',
@@ -334,13 +289,14 @@ export const mockData = { @@ -334,13 +289,14 @@ export const mockData = {
334 ], 289 ],
335 services: [ 290 services: [
336 { 291 {
337 - callType: 'ASYNC',  
338 - createTs: 1667963835032, 292 + callType: 'SYNC',
  293 + createTs: 1668148397946,
339 custom: true, 294 custom: true,
340 - description: '配置模型',  
341 - identifier: 'ConfigModel', 295 + description: '删除模型1',
  296 + identifier: 'DeleteModel',
342 inputParams: [ 297 inputParams: [
343 { 298 {
  299 + id: buildUUID(),
344 custom: true, 300 custom: true,
345 dataSpecs: { 301 dataSpecs: {
346 dataType: 'TEXT', 302 dataType: 'TEXT',
@@ -349,100 +305,269 @@ export const mockData = { @@ -349,100 +305,269 @@ export const mockData = {
349 dataType: 'TEXT', 305 dataType: 'TEXT',
350 direction: 'PARAM_INPUT', 306 direction: 'PARAM_INPUT',
351 identifier: 'AlgorithmID', 307 identifier: 'AlgorithmID',
352 - name: '算法任务-人脸识别', 308 + name: 'text类型',
353 paraOrder: 0, 309 paraOrder: 0,
354 }, 310 },
355 { 311 {
  312 + id: buildUUID(),
  313 + custom: true,
  314 + dataSpecsList: [
  315 + {
  316 + id: buildUUID(),
  317 +
  318 + childDataType: 'INT',
  319 + childName: '结构体里面1',
  320 + childSpecsDTO: {
  321 + dataType: 'INT',
  322 + max: '22',
  323 + min: '11',
  324 + step: '3',
  325 + unit: 'W/㎡',
  326 + unitName: '太阳总辐射',
  327 + },
  328 + custom: true,
  329 + dataSpecs: {
  330 + dataType: 'INT',
  331 + max: '22',
  332 + min: '11',
  333 + step: '3',
  334 + unit: 'W/㎡',
  335 + unitName: '太阳总辐射',
  336 + },
  337 + dataType: 'STRUCT',
  338 + identifier: '1',
  339 + isStd: 0,
  340 + name: '结构体里面1',
  341 + },
  342 + {
  343 + id: buildUUID(),
  344 +
  345 + childDataType: 'BOOL',
  346 + childEnumSpecsDTO: [
  347 + {
  348 + dataType: 'BOOL',
  349 + name: '关',
  350 + value: 0,
  351 + },
  352 + {
  353 + dataType: 'BOOL',
  354 + name: '开',
  355 + value: 1,
  356 + },
  357 + ],
  358 + childName: '结构体里面2',
  359 + custom: true,
  360 + dataSpecsList: [
  361 + {
  362 + dataType: 'BOOL',
  363 + name: '关',
  364 + value: 0,
  365 + },
  366 + {
  367 + dataType: 'BOOL',
  368 + name: '开',
  369 + value: 1,
  370 + },
  371 + ],
  372 + dataType: 'STRUCT',
  373 + identifier: '2',
  374 + isStd: 0,
  375 + name: '结构体里面2',
  376 + },
  377 + {
  378 + id: buildUUID(),
  379 +
  380 + childDataType: 'TEXT',
  381 + childName: '结构体里面3',
  382 + childSpecsDTO: {
  383 + dataType: 'TEXT',
  384 + length: 10240,
  385 + },
  386 + custom: true,
  387 + dataSpecs: {
  388 + dataType: 'TEXT',
  389 + length: 10240,
  390 + },
  391 + dataType: 'STRUCT',
  392 + identifier: '3',
  393 + isStd: 0,
  394 + name: '结构体里面3',
  395 + },
  396 + ],
  397 + dataType: 'STRUCT',
  398 + direction: 'PARAM_INPUT',
  399 + identifier: '1',
  400 + name: '结构体里面数据',
  401 + paraOrder: 1,
  402 + },
  403 + {
  404 + id: buildUUID(),
  405 +
  406 + custom: true,
  407 + dataSpecsList: [
  408 + {
  409 + dataType: 'BOOL',
  410 + name: '开启',
  411 + value: 0,
  412 + },
  413 + {
  414 + dataType: 'BOOL',
  415 + name: '战斗',
  416 + value: 1,
  417 + },
  418 + ],
  419 + dataType: 'BOOL',
  420 + direction: 'PARAM_INPUT',
  421 + identifier: 'bool',
  422 + name: '布尔类型',
  423 + paraOrder: 2,
  424 + },
  425 + {
  426 + id: buildUUID(),
  427 +
356 custom: true, 428 custom: true,
357 dataSpecs: { 429 dataSpecs: {
358 - dataType: 'DOUBLE', 430 + dataType: 'INT',
359 max: '22', 431 max: '22',
360 min: '11', 432 min: '11',
361 - step: '3',  
362 - unit: 'mm/hour',  
363 - unitName: '降雨量', 433 + step: '4',
  434 + unit: 'dS/m',
  435 + unitName: '土壤EC值',
364 }, 436 },
365 - dataType: 'DOUBLE', 437 + dataType: 'INT',
366 direction: 'PARAM_INPUT', 438 direction: 'PARAM_INPUT',
367 - identifier: 'Threshold',  
368 - name: '结果置信度阈值',  
369 - paraOrder: 1, 439 + identifier: 'int',
  440 + name: 'int类型',
  441 + paraOrder: 3,
370 }, 442 },
  443 + ],
  444 + outputParams: [
371 { 445 {
  446 + id: buildUUID(),
  447 +
  448 + custom: true,
  449 + dataSpecs: {
  450 + dataType: 'TEXT',
  451 + length: 10240,
  452 + },
  453 + dataType: 'TEXT',
  454 + direction: 'PARAM_OUTPUT',
  455 + identifier: '2',
  456 + name: '测试输出回显text类型',
  457 + paraOrder: 0,
  458 + },
  459 + {
  460 + id: buildUUID(),
  461 +
372 custom: true, 462 custom: true,
373 dataSpecs: { 463 dataSpecs: {
374 dataType: 'INT', 464 dataType: 'INT',
375 - max: '1024',  
376 - min: '-1024',  
377 - step: '1', 465 + max: '22',
  466 + min: '11',
  467 + step: '3',
378 unit: 'W/㎡', 468 unit: 'W/㎡',
379 unitName: '太阳总辐射', 469 unitName: '太阳总辐射',
380 }, 470 },
381 dataType: 'INT', 471 dataType: 'INT',
382 - direction: 'PARAM_INPUT',  
383 - identifier: 'Switch',  
384 - name: '功能开关',  
385 - paraOrder: 2, 472 + direction: 'PARAM_OUTPUT',
  473 + identifier: 'int',
  474 + name: '测试输出回显int类型',
  475 + paraOrder: 1,
386 }, 476 },
387 { 477 {
  478 + id: buildUUID(),
  479 +
388 custom: true, 480 custom: true,
389 dataSpecsList: [ 481 dataSpecsList: [
390 { 482 {
391 dataType: 'BOOL', 483 dataType: 'BOOL',
392 - name: '', 484 + name: 'd',
393 value: 0, 485 value: 0,
394 }, 486 },
395 { 487 {
396 dataType: 'BOOL', 488 dataType: 'BOOL',
397 - name: '', 489 + name: 'ff',
398 value: 1, 490 value: 1,
399 }, 491 },
400 ], 492 ],
401 dataType: 'BOOL', 493 dataType: 'BOOL',
402 - direction: 'PARAM_INPUT',  
403 - identifier: 'NumThreads',  
404 - name: '使用线程数',  
405 - paraOrder: 3, 494 + direction: 'PARAM_OUTPUT',
  495 + identifier: 'bol',
  496 + name: '测试输出回显bool类型',
  497 + paraOrder: 2,
406 }, 498 },
407 { 499 {
  500 + id: buildUUID(),
  501 +
408 custom: true, 502 custom: true,
409 dataSpecsList: [ 503 dataSpecsList: [
410 { 504 {
  505 + id: buildUUID(),
  506 +
  507 + childDataType: 'INT',
  508 + childName: '测试输出回显结构体类型1',
  509 + childSpecsDTO: {
  510 + dataType: 'INT',
  511 + max: '22',
  512 + min: '11',
  513 + step: '4',
  514 + unit: 'mm/hour',
  515 + unitName: '降雨量',
  516 + },
  517 + custom: true,
  518 + dataSpecs: {
  519 + dataType: 'INT',
  520 + max: '22',
  521 + min: '11',
  522 + step: '4',
  523 + unit: 'mm/hour',
  524 + unitName: '降雨量',
  525 + },
  526 + dataType: 'STRUCT',
  527 + identifier: '1',
  528 + isStd: 0,
  529 + name: '测试输出回显结构体类型1',
  530 + },
  531 + {
  532 + id: buildUUID(),
  533 +
411 childDataType: 'BOOL', 534 childDataType: 'BOOL',
412 childEnumSpecsDTO: [ 535 childEnumSpecsDTO: [
413 { 536 {
414 dataType: 'BOOL', 537 dataType: 'BOOL',
415 - name: '关1', 538 + name: 'ff',
416 value: 0, 539 value: 0,
417 }, 540 },
418 { 541 {
419 dataType: 'BOOL', 542 dataType: 'BOOL',
420 - name: '开1', 543 + name: 'gg',
421 value: 1, 544 value: 1,
422 }, 545 },
423 ], 546 ],
424 - childName: '结构体里面1', 547 + childName: '测试输出回显结构体类型2',
425 custom: true, 548 custom: true,
426 dataSpecsList: [ 549 dataSpecsList: [
427 { 550 {
428 dataType: 'BOOL', 551 dataType: 'BOOL',
429 - name: '关1', 552 + name: 'ff',
430 value: 0, 553 value: 0,
431 }, 554 },
432 { 555 {
433 dataType: 'BOOL', 556 dataType: 'BOOL',
434 - name: '开1', 557 + name: 'gg',
435 value: 1, 558 value: 1,
436 }, 559 },
437 ], 560 ],
438 dataType: 'STRUCT', 561 dataType: 'STRUCT',
439 - identifier: 's11', 562 + identifier: '3',
440 isStd: 0, 563 isStd: 0,
441 - name: '结构体里面1', 564 + name: '测试输出回显结构体类型2',
442 }, 565 },
443 { 566 {
  567 + id: buildUUID(),
  568 +
444 childDataType: 'TEXT', 569 childDataType: 'TEXT',
445 - childName: '结构体里面2', 570 + childName: '测试输出回显结构体类型3',
446 childSpecsDTO: { 571 childSpecsDTO: {
447 dataType: 'TEXT', 572 dataType: 'TEXT',
448 length: 10240, 573 length: 10240,
@@ -453,374 +578,21 @@ export const mockData = { @@ -453,374 +578,21 @@ export const mockData = {
453 length: 10240, 578 length: 10240,
454 }, 579 },
455 dataType: 'STRUCT', 580 dataType: 'STRUCT',
456 - identifier: 's2',  
457 - isStd: 0,  
458 - name: '结构体里面2',  
459 - },  
460 - {  
461 - childDataType: 'DOUBLE',  
462 - childName: '结构体里面3',  
463 - childSpecsDTO: {  
464 - dataType: 'DOUBLE',  
465 - max: '22',  
466 - min: '11',  
467 - step: '3',  
468 - unit: 'mm/s',  
469 - unitName: '毫米每秒',  
470 - },  
471 - custom: true,  
472 - dataSpecs: {  
473 - dataType: 'DOUBLE',  
474 - max: '22',  
475 - min: '11',  
476 - step: '3',  
477 - unit: 'mm/s',  
478 - unitName: '毫米每秒',  
479 - },  
480 - dataType: 'STRUCT',  
481 - identifier: 's3', 581 + identifier: '12',
482 isStd: 0, 582 isStd: 0,
483 - name: '结构体里面3', 583 + name: '测试输出回显结构体类型3',
484 }, 584 },
485 ], 585 ],
486 dataType: 'STRUCT', 586 dataType: 'STRUCT',
487 - direction: 'PARAM_INPUT',  
488 - identifier: 's1',  
489 - name: '结构体1',  
490 - paraOrder: 4, 587 + direction: 'PARAM_OUTPUT',
  588 + identifier: 'struct',
  589 + name: '测试输出回显结构体类型',
  590 + paraOrder: 3,
491 }, 591 },
492 ], 592 ],
493 - outputParams: [],  
494 productKey: 'hsrnXEfGFDv', 593 productKey: 'hsrnXEfGFDv',
495 required: false, 594 required: false,
496 - serviceName: '配置模型', 595 + serviceName: '删除模型1',
497 }, 596 },
498 ], 597 ],
499 - // services: [  
500 - // {  
501 - // callType: 'SYNC',  
502 - // createTs: 1666603858325,  
503 - // custom: true,  
504 - // description: '更新模型',  
505 - // identifier: 'UpdateModel',  
506 - // inputParams: [  
507 - // {  
508 - // id: buildUUID(),  
509 - // custom: true,  
510 - // dataSpecs: {  
511 - // dataType: 'TEXT',  
512 - // length: 128,  
513 - // },  
514 - // dataType: 'TEXT',  
515 - // direction: 'PARAM_INPUT',  
516 - // identifier: 'UpdateTaskID',  
517 - // name: '更新任务ID',  
518 - // paraOrder: 0,  
519 - // },  
520 - // {  
521 - // id: buildUUID(),  
522 - // custom: true,  
523 - // dataSpecs: {  
524 - // dataType: 'TEXT',  
525 - // length: 128,  
526 - // },  
527 - // dataType: 'TEXT',  
528 - // direction: 'PARAM_INPUT',  
529 - // identifier: 'AlgorithmID',  
530 - // name: '算法任务唯一标识',  
531 - // paraOrder: 1,  
532 - // },  
533 - // {  
534 - // id: buildUUID(),  
535 -  
536 - // custom: true,  
537 - // dataSpecs: {  
538 - // dataType: 'TEXT',  
539 - // length: 64,  
540 - // },  
541 - // dataType: 'TEXT',  
542 - // direction: 'PARAM_INPUT',  
543 - // identifier: 'AlgorithmName',  
544 - // name: '算法名称',  
545 - // paraOrder: 2,  
546 - // },  
547 - // {  
548 - // id: buildUUID(),  
549 -  
550 - // custom: true,  
551 - // dataSpecs: {  
552 - // dataType: 'INT',  
553 - // max: '128',  
554 - // min: '0',  
555 - // precise: 0,  
556 - // step: '1',  
557 - // unit: '',  
558 - // unitName: '无',  
559 - // },  
560 - // dataType: 'INT',  
561 - // direction: 'PARAM_INPUT',  
562 - // identifier: 'NumThreads',  
563 - // name: '使用线程数',  
564 - // paraOrder: 4,  
565 - // },  
566 - // {  
567 - // id: buildUUID(),  
568 -  
569 - // custom: true,  
570 - // dataSpecs: {  
571 - // dataType: 'TEXT',  
572 - // length: 128,  
573 - // },  
574 - // dataType: 'TEXT',  
575 - // direction: 'PARAM_INPUT',  
576 - // identifier: 'ModelID',  
577 - // name: '模型唯一标识',  
578 - // paraOrder: 5,  
579 - // },  
580 - // {  
581 - // id: buildUUID(),  
582 -  
583 - // custom: true,  
584 - // dataSpecs: {  
585 - // dataType: 'TEXT',  
586 - // length: 64,  
587 - // },  
588 - // dataType: 'TEXT',  
589 - // direction: 'PARAM_INPUT',  
590 - // identifier: 'ModelName',  
591 - // name: '模型名称',  
592 - // paraOrder: 6,  
593 - // },  
594 - // {  
595 - // id: buildUUID(),  
596 -  
597 - // custom: true,  
598 - // dataSpecs: {  
599 - // dataType: 'TEXT',  
600 - // length: 64,  
601 - // },  
602 - // dataType: 'TEXT',  
603 - // direction: 'PARAM_INPUT',  
604 - // identifier: 'ModelVersion',  
605 - // name: '模型版本',  
606 - // paraOrder: 7,  
607 - // },  
608 - // {  
609 - // id: buildUUID(),  
610 -  
611 - // custom: true,  
612 - // dataSpecs: {  
613 - // dataType: 'TEXT',  
614 - // length: 1024,  
615 - // },  
616 - // dataType: 'TEXT',  
617 - // direction: 'PARAM_INPUT',  
618 - // identifier: 'ModelURL',  
619 - // name: '模型地址',  
620 - // paraOrder: 8,  
621 - // },  
622 - // {  
623 - // id: buildUUID(),  
624 -  
625 - // custom: true,  
626 - // dataSpecs: {  
627 - // dataType: 'TEXT',  
628 - // length: 128,  
629 - // },  
630 - // dataType: 'TEXT',  
631 - // direction: 'PARAM_INPUT',  
632 - // identifier: 'ModelMD5',  
633 - // name: '模型文件MD5',  
634 - // paraOrder: 9,  
635 - // },  
636 - // {  
637 - // id: buildUUID(),  
638 -  
639 - // custom: true,  
640 - // dataSpecs: {  
641 - // dataType: 'TEXT',  
642 - // length: 64,  
643 - // },  
644 - // dataType: 'TEXT',  
645 - // direction: 'PARAM_INPUT',  
646 - // identifier: 'ModelPlatform',  
647 - // name: '模型平台',  
648 - // paraOrder: 10,  
649 - // },  
650 - // {  
651 - // id: buildUUID(),  
652 -  
653 - // custom: true,  
654 - // dataSpecs: {  
655 - // dataType: 'TEXT',  
656 - // length: 128,  
657 - // },  
658 - // dataType: 'TEXT',  
659 - // direction: 'PARAM_INPUT',  
660 - // identifier: 'ModelTaskID',  
661 - // name: '模型生成任务ID',  
662 - // paraOrder: 11,  
663 - // },  
664 - // {  
665 - // id: buildUUID(),  
666 -  
667 - // custom: true,  
668 - // dataSpecs: {  
669 - // dataType: 'TEXT',  
670 - // length: 64,  
671 - // },  
672 - // dataType: 'TEXT',  
673 - // direction: 'PARAM_INPUT',  
674 - // identifier: 'ModelEncryptType',  
675 - // name: '模型加密方式',  
676 - // paraOrder: 12,  
677 - // },  
678 - // {  
679 - // id: buildUUID(),  
680 -  
681 - // custom: true,  
682 - // dataSpecs: {  
683 - // dataType: 'TEXT',  
684 - // length: 2048,  
685 - // },  
686 - // dataType: 'TEXT',  
687 - // direction: 'PARAM_INPUT',  
688 - // identifier: 'ModelExtension',  
689 - // name: '扩展信息',  
690 - // paraOrder: 13,  
691 - // },  
692 - // {  
693 - // id: buildUUID(),  
694 -  
695 - // custom: true,  
696 - // dataSpecsList: [  
697 - // {  
698 - // id: buildUUID(),  
699 -  
700 - // childDataType: 'TEXT',  
701 - // childName: '模型结构体参数1',  
702 - // childSpecsDTO: {  
703 - // dataType: 'TEXT',  
704 - // length: 10240,  
705 - // },  
706 - // custom: true,  
707 - // dataSpecs: {  
708 - // dataType: 'TEXT',  
709 - // length: 10240,  
710 - // },  
711 - // dataType: 'STRUCT',  
712 - // identifier: 'ModelParams1',  
713 - // isStd: 0,  
714 - // name: '模型结构体参数1',  
715 - // },  
716 - // {  
717 - // id: buildUUID(),  
718 -  
719 - // childDataType: 'BOOL',  
720 - // childEnumSpecsDTO: [  
721 - // {  
722 - // dataType: 'BOOL',  
723 - // name: '1',  
724 - // value: 0,  
725 - // },  
726 - // {  
727 - // dataType: 'BOOL',  
728 - // name: '0',  
729 - // value: 1,  
730 - // },  
731 - // ],  
732 - // childName: '模型结构体参数2',  
733 - // custom: true,  
734 - // dataSpecsList: [  
735 - // {  
736 - // id: buildUUID(),  
737 -  
738 - // dataType: 'BOOL',  
739 - // name: '1',  
740 - // value: 0,  
741 - // },  
742 - // {  
743 - // id: buildUUID(),  
744 -  
745 - // dataType: 'BOOL',  
746 - // name: '0',  
747 - // value: 1,  
748 - // },  
749 - // ],  
750 - // dataType: 'STRUCT',  
751 - // identifier: 'ModelParams2',  
752 - // isStd: 0,  
753 - // name: '模型结构体参数2',  
754 - // },  
755 - // ],  
756 - // dataType: 'STRUCT',  
757 - // direction: 'PARAM_INPUT',  
758 - // identifier: 'ModelStruct',  
759 - // name: '模型结构体',  
760 - // paraOrder: 3,  
761 - // },  
762 - // ],  
763 - // outputParams: [  
764 - // {  
765 - // id: buildUUID(),  
766 -  
767 - // custom: true,  
768 - // dataSpecs: {  
769 - // dataType: 'TEXT',  
770 - // length: 10240,  
771 - // },  
772 - // dataType: 'TEXT',  
773 - // direction: 'PARAM_OUTPUT',  
774 - // identifier: 'Django',  
775 - // name: 'django',  
776 - // paraOrder: 0,  
777 - // },  
778 - // {  
779 - // id: buildUUID(),  
780 -  
781 - // custom: true,  
782 - // dataSpecsList: [  
783 - // {  
784 - // id: buildUUID(),  
785 -  
786 - // dataType: 'BOOL',  
787 - // name: '1',  
788 - // value: 0,  
789 - // },  
790 - // {  
791 - // id: buildUUID(),  
792 - // dataType: 'BOOL',  
793 - // name: '0',  
794 - // value: 1,  
795 - // },  
796 - // ],  
797 - // dataType: 'BOOL',  
798 - // direction: 'PARAM_OUTPUT',  
799 - // identifier: 'Flask',  
800 - // name: 'flask',  
801 - // paraOrder: 1,  
802 - // },  
803 - // {  
804 - // id: buildUUID(),  
805 - // custom: true,  
806 - // dataSpecs: {  
807 - // dataType: 'INT',  
808 - // max: '22',  
809 - // min: '11',  
810 - // step: '3',  
811 - // unit: '只',  
812 - // unitName: '只',  
813 - // },  
814 - // dataType: 'INT',  
815 - // direction: 'PARAM_OUTPUT',  
816 - // identifier: 'Tornado',  
817 - // name: 'tornado',  
818 - // paraOrder: 2,  
819 - // },  
820 - // ],  
821 - // productKey: 'hsrnXEfGFDv',  
822 - // required: false,  
823 - // serviceName: '更新模型',  
824 - // },  
825 - // ],  
826 }; 598 };
  1 +import useParitalValid from './useParitalValid';
  2 +import { findDictItemByCode } from '/@/api/system/dict';
  3 +import { buildUUID } from '/@/utils/uuid';
  4 +
  5 +///根据不同数据类型得到不同表单数据(模拟的阿里云数据结构)
  6 +type TForm = {
  7 + dataType: string;
  8 + max?: string;
  9 + min?: string;
  10 + step?: string;
  11 + unit?: string;
  12 + boolClose?: string;
  13 + boolOpen?: string;
  14 + length?: string;
  15 + valueRange?: {
  16 + min: string;
  17 + max: string;
  18 + };
  19 +};
  20 +
  21 +export default () => {
  22 + const { validateValueRangeAndStep, validateValueBool } = useParitalValid();
  23 +
  24 + const useChangeTypeGetTypeForm = (type, options: TForm) => {
  25 + switch (type) {
  26 + //INT和DOUBLE收集表单一样
  27 + case 'INT':
  28 + validateValueRangeAndStep(
  29 + Number(options?.valueRange?.min),
  30 + Number(options?.step),
  31 + Number(options?.valueRange?.max)
  32 + );
  33 + return {
  34 + dataType: options?.dataType,
  35 + max: options?.valueRange?.max,
  36 + min: options?.valueRange?.min,
  37 + step: options?.step,
  38 + unit: options?.unit,
  39 + };
  40 + case 'DOUBLE':
  41 + validateValueRangeAndStep(
  42 + Number(options?.valueRange?.min),
  43 + Number(options?.step),
  44 + Number(options?.valueRange?.max)
  45 + );
  46 + return {
  47 + dataType: options?.dataType,
  48 + max: options?.valueRange?.max,
  49 + min: options?.valueRange?.min,
  50 + step: options?.step,
  51 + unit: options?.unit,
  52 + };
  53 + case 'BOOL':
  54 + validateValueBool(Number(options?.boolClose), Number(options?.boolOpen));
  55 + return [
  56 + {
  57 + dataType: options?.dataType,
  58 + name: options?.boolClose,
  59 + value: 0,
  60 + },
  61 + {
  62 + dataType: options?.dataType,
  63 + name: options?.boolOpen,
  64 + value: 1,
  65 + },
  66 + ];
  67 + case 'TEXT':
  68 + return {
  69 + dataType: options?.dataType,
  70 + length: Number(options?.length),
  71 + };
  72 + }
  73 + };
  74 +
  75 + //是否排除结构体
  76 + const useUpdateFormExcludeStruct = async (F, U) => {
  77 + const res: any = await findDictItemByCode({ dictCode: 'data_type' });
  78 + const optionTrue = res
  79 + .map((m) => {
  80 + if (F) {
  81 + if (m.itemValue !== 'STRUCT') {
  82 + return {
  83 + value: m.itemValue,
  84 + label: m.itemText,
  85 + };
  86 + }
  87 + } else {
  88 + return {
  89 + value: m.itemValue,
  90 + label: m.itemText,
  91 + };
  92 + }
  93 + })
  94 + .filter(Boolean);
  95 + U({
  96 + field: 'dataType',
  97 + componentProps: {
  98 + options: optionTrue,
  99 + },
  100 + });
  101 + };
  102 +
  103 + //获取输入参数或者输出参数弹窗数据
  104 + const useGetInOrOutData = (d, f, inputData, outputData) => {
  105 + if (f == 'input') {
  106 + if (d.id !== null) {
  107 + const findIndex = inputData.findIndex((f) => f.id == d.id);
  108 + if (findIndex !== -1) inputData.splice(findIndex, 1, d);
  109 + } else {
  110 + inputData.push({ ...d, id: buildUUID() });
  111 + }
  112 + } else {
  113 + if (d.id !== null) {
  114 + const findIndex = outputData.findIndex((f) => f.id == d.id);
  115 + if (findIndex !== -1) outputData.splice(findIndex, 1, d);
  116 + } else {
  117 + outputData.push({ ...d, id: buildUUID() });
  118 + }
  119 + }
  120 + };
  121 +
  122 + const useBlockContent = `物模型是对设备在云端的功能描述,包括设备的属性、服务和事件。物联网平台通过定义一种物的描述语言来描述物模型,称之为 TSL(即 Thing
  123 + Specification Language),采用 JSON 格式,您可以根据 TSL 组装上报设备的数据。您可以导出完整物模型,用于云端应用开发;您也可以只导出
  124 + 精简物模型,配合设备端 SDK 实现设备开发。`;
  125 +
  126 + const useBlockPhysicalContent = `属性一般是设备的运行状态,如当前温度等;服务是设备可被调用的方法,支持定义参数,如执行某项任务;事件则是设备上报的
  127 + 通知,如告警,需要被及时处理。`;
  128 +
  129 + return {
  130 + useChangeTypeGetTypeForm,
  131 + useUpdateFormExcludeStruct,
  132 + useGetInOrOutData,
  133 + useBlockContent,
  134 + useBlockPhysicalContent,
  135 + };
  136 +};
  1 +import { ref } from 'vue';
  2 +import CommomParam from './components/CommomParam.vue';
  3 +
  4 +export default () => {
  5 + const inputParamData: any = ref([]);
  6 + const outputParamData: any = ref([]);
  7 + const CommomParamInParamRef = ref<InstanceType<typeof CommomParam>>();
  8 + const CommomParamOutParamRef = ref<InstanceType<typeof CommomParam>>();
  9 +
  10 + return {
  11 + inputParamData,
  12 + outputParamData,
  13 + CommomParamInParamRef,
  14 + CommomParamOutParamRef,
  15 + };
  16 +};
  1 +/**
  2 + * 校验部分字段
  3 + */
  4 +import { useMessage } from '/@/hooks/web/useMessage';
  5 +const { createMessage } = useMessage();
  6 +
  7 +export default () => {
  8 + const validateValueRangeAndStep = (min, step, max) => {
  9 + if (min > max) {
  10 + createMessage.error('最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16');
  11 + throw '最大值必须大于最小值,整数型不能有小数位,单精度有效位为7,双精度为16';
  12 + }
  13 + if (step > max - min) {
  14 + createMessage.error('步长不能大于取值范围的差值');
  15 + throw '步长不能大于取值范围的差值';
  16 + }
  17 + };
  18 +
  19 + const validateValueBool = (boolClose, boolOpen) => {
  20 + if (boolClose == boolOpen) {
  21 + createMessage.error('布尔值不能相同');
  22 + throw '布尔值不能相同';
  23 + }
  24 + };
  25 +
  26 + const validateValueStruct = (data: []) => {
  27 + if (data.length === 0) {
  28 + createMessage.error('struct不能为空');
  29 + throw 'struct不能为空';
  30 + }
  31 + };
  32 + return {
  33 + validateValueRangeAndStep,
  34 + validateValueBool,
  35 + validateValueStruct,
  36 + };
  37 +};
@@ -10,3 +10,11 @@ export interface OpenModelOfMatterModelParams { @@ -10,3 +10,11 @@ export interface OpenModelOfMatterModelParams {
10 mode: OpenModelMode; 10 mode: OpenModelMode;
11 record: ModelOfMatterParams; 11 record: ModelOfMatterParams;
12 } 12 }
  13 +
  14 +export interface IAllData {
  15 + properties: string[];
  16 + events: string[];
  17 + services: string[];
  18 + productKey: '';
  19 + _ppk: {};
  20 +}