Commit 40d46207c702078395c656fe1b1b5a2153a1e646

Authored by ww
1 parent 5c3d3140

wip: model of matter

@@ -9,12 +9,15 @@ export interface Specs { @@ -9,12 +9,15 @@ export interface Specs {
9 length: string; 9 length: string;
10 boolOpen: string; 10 boolOpen: string;
11 boolClose: string; 11 boolClose: string;
  12 + valueRange?: {
  13 + min: string;
  14 + max: string;
  15 + };
12 } 16 }
13 17
14 export interface FunctionJson { 18 export interface FunctionJson {
15 type: string; 19 type: string;
16 - specs?: Partial<Specs>;  
17 - specsList?: ModelOfMatterParams[]; 20 + specs?: Partial<Specs> | ModelOfMatterParams[];
18 } 21 }
19 22
20 export interface ModelOfMatterParams { 23 export interface ModelOfMatterParams {
1 <template> 1 <template>
2 - <div style="display: flex">  
3 - <a-input 2 + <div class="flex">
  3 + <InputNumber
4 placeholder="最小值" 4 placeholder="最小值"
5 - v-model:value="param.min" 5 + :value="getValue.min"
6 style="width: 38%" 6 style="width: 38%"
7 - @input="emitChange" 7 + @change="(value) => emitChange(value, 'min')"
8 /> 8 />
9 <span style="width: 8px"></span> 9 <span style="width: 8px"></span>
10 <span>~</span> 10 <span>~</span>
11 <span style="width: 8px"></span> 11 <span style="width: 8px"></span>
12 - <a-input 12 + <InputNumber
13 placeholder="最大值" 13 placeholder="最大值"
14 - v-model:value="param.max" 14 + :value="getValue.max"
15 style="width: 38%" 15 style="width: 38%"
16 - @input="emitChange" 16 + @change="(value) => emitChange(value, 'max')"
17 /> 17 />
18 </div> 18 </div>
19 </template> 19 </template>
20 <script lang="ts"> 20 <script lang="ts">
21 - import { defineComponent, reactive, watchEffect } from 'vue';  
22 - import { propTypes } from '/@/utils/propTypes';  
23 - import { isEmpty } from '/@/utils/is';  
24 -  
25 - export default defineComponent({  
26 - name: 'JAddInput',  
27 - //--------------不继承Antd Design Vue Input的所有属性 否则控制台报大片警告-------------- 21 + export default {
28 inheritAttrs: false, 22 inheritAttrs: false,
29 - props: {  
30 - value: propTypes.object.def({}),  
31 - },  
32 - emits: ['change', 'update:value'],  
33 - setup(props, { emit }) {  
34 - const param = reactive({  
35 - min: '',  
36 - max: '',  
37 - });  
38 - watchEffect(() => {  
39 - initVal();  
40 - });  
41 - function initVal() {  
42 - if (props.value) {  
43 - param.min = props.value.min;  
44 - param.max = props.value.max;  
45 - }  
46 - }  
47 - function emitChange() {  
48 - emit('change', isEmpty(param) ? '' : param);  
49 - emit('update:value', isEmpty(param) ? '' : param);  
50 - }  
51 - return {  
52 - emitChange,  
53 - param, 23 + };
  24 +</script>
  25 +<script lang="ts" setup>
  26 + import { computed } from 'vue';
  27 + import { InputNumber } from 'ant-design-vue';
  28 +
  29 + const emit = defineEmits(['change', 'update:value']);
  30 + const props = withDefaults(
  31 + defineProps<{
  32 + value?: {
  33 + min: Nullable<number>;
  34 + max: Nullable<number>;
54 }; 35 };
55 - }, 36 + }>(),
  37 + {
  38 + value: () => ({ min: null, max: null }),
  39 + }
  40 + );
  41 +
  42 + const getValue = computed(() => {
  43 + const { value } = props;
  44 + return value;
56 }); 45 });
  46 +
  47 + function emitChange(value: number, key: 'min' | 'max') {
  48 + const _value = { ...props.value, [key]: value };
  49 + emit('update:value', _value);
  50 + }
57 </script> 51 </script>
58 <style scoped></style> 52 <style scoped></style>
@@ -62,6 +62,8 @@ export const formSchemas: FormSchema[] = [ @@ -62,6 +62,8 @@ export const formSchemas: FormSchema[] = [
62 field: FormField.VALUE_RANGE, 62 field: FormField.VALUE_RANGE,
63 label: '取值范围', 63 label: '取值范围',
64 component: 'CustomMinMaxInput', 64 component: 'CustomMinMaxInput',
  65 + valueField: 'value',
  66 + changeEvent: 'update:value',
65 colProps: { 67 colProps: {
66 span: 18, 68 span: 18,
67 }, 69 },
@@ -72,7 +74,7 @@ export const formSchemas: FormSchema[] = [ @@ -72,7 +74,7 @@ export const formSchemas: FormSchema[] = [
72 { 74 {
73 field: FormField.STEP, 75 field: FormField.STEP,
74 label: '步长', 76 label: '步长',
75 - component: 'Input', 77 + component: 'InputNumber',
76 colProps: { 78 colProps: {
77 span: 18, 79 span: 18,
78 }, 80 },
@@ -198,6 +200,15 @@ export const formSchemas: FormSchema[] = [ @@ -198,6 +200,15 @@ export const formSchemas: FormSchema[] = [
198 changeEvent: 'update:value', 200 changeEvent: 'update:value',
199 colProps: { span: 24 }, 201 colProps: { span: 24 },
200 ifShow: ({ values }) => values[FormField.TYPE] === DateTypeEnum.IS_STRUCT, 202 ifShow: ({ values }) => values[FormField.TYPE] === DateTypeEnum.IS_STRUCT,
  203 + rules: [
  204 + {
  205 + required: true,
  206 + validator(_rule, value, _callback) {
  207 + console.log(value);
  208 + return Promise.resolve();
  209 + },
  210 + },
  211 + ],
201 }, 212 },
202 { 213 {
203 field: FormField.REFARK, 214 field: FormField.REFARK,
@@ -48,18 +48,19 @@ export function transformFormValue(value: StructFormValue): Partial<ModelOfMatte @@ -48,18 +48,19 @@ export function transformFormValue(value: StructFormValue): Partial<ModelOfMatte
48 functionName, 48 functionName,
49 identifier, 49 identifier,
50 remark, 50 remark,
51 - specsList, 51 + specs,
52 } = value; 52 } = value;
53 const { min, max } = valueRange! || {}; 53 const { min, max } = valueRange! || {};
54 const basic = { functionName, identifier, remark }; 54 const basic = { functionName, identifier, remark };
55 let functionJson = {} as unknown as ModelOfMatterParams['functionJson']; 55 let functionJson = {} as unknown as ModelOfMatterParams['functionJson'];
56 56
  57 + console.log(value);
57 switch (type) { 58 switch (type) {
58 case DateTypeEnum.IS_NUMBER_INT: 59 case DateTypeEnum.IS_NUMBER_INT:
59 validateValueRangeAndStep(Number(min), Number(step), Number(max)); 60 validateValueRangeAndStep(Number(min), Number(step), Number(max));
60 functionJson = { 61 functionJson = {
61 type, 62 type,
62 - specs: { max, min, step, unit, unitName }, 63 + specs: { max, min, valueRange, step, unit, unitName },
63 }; 64 };
64 break; 65 break;
65 66
@@ -67,7 +68,7 @@ export function transformFormValue(value: StructFormValue): Partial<ModelOfMatte @@ -67,7 +68,7 @@ export function transformFormValue(value: StructFormValue): Partial<ModelOfMatte
67 validateValueRangeAndStep(Number(min), Number(step), Number(max)); 68 validateValueRangeAndStep(Number(min), Number(step), Number(max));
68 functionJson = { 69 functionJson = {
69 type, 70 type,
70 - specs: { max, min, step, unit, unitName }, 71 + specs: { max, min, valueRange, step, unit, unitName },
71 }; 72 };
72 break; 73 break;
73 74
@@ -92,7 +93,7 @@ export function transformFormValue(value: StructFormValue): Partial<ModelOfMatte @@ -92,7 +93,7 @@ export function transformFormValue(value: StructFormValue): Partial<ModelOfMatte
92 case DateTypeEnum.IS_STRUCT: 93 case DateTypeEnum.IS_STRUCT:
93 functionJson = { 94 functionJson = {
94 type, 95 type,
95 - specsList: specsList! as unknown as ModelOfMatterParams[], 96 + specs: specs! as unknown as ModelOfMatterParams[],
96 }; 97 };
97 break; 98 break;
98 } 99 }
@@ -99,7 +99,7 @@ @@ -99,7 +99,7 @@
99 </div> 99 </div>
100 </template> 100 </template>
101 <script lang="ts" setup> 101 <script lang="ts" setup>
102 - import { ref, nextTick, onUnmounted, onMounted } from 'vue'; 102 + import { ref, nextTick, onUnmounted } from 'vue';
103 import { BasicTable, TableImg, useTable, TableAction, BasicColumn } from '/@/components/Table'; 103 import { BasicTable, TableImg, useTable, TableAction, BasicColumn } from '/@/components/Table';
104 import { columns, searchFormSchema, defaultObj } from './device.profile.data'; 104 import { columns, searchFormSchema, defaultObj } from './device.profile.data';
105 import { useMessage } from '/@/hooks/web/useMessage'; 105 import { useMessage } from '/@/hooks/web/useMessage';
@@ -258,7 +258,6 @@ @@ -258,7 +258,6 @@
258 } 258 }
259 259
260 const [registerDrawer, { openDrawer }] = useDrawer(); 260 const [registerDrawer, { openDrawer }] = useDrawer();
261 - onMounted(() => openDrawer(true));  
262 //详情 261 //详情
263 function handleDetailView(record: Recordable) { 262 function handleDetailView(record: Recordable) {
264 openDrawer(true, { record }); 263 openDrawer(true, { record });
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 <div class="flex justify-between items-end"> 27 <div class="flex justify-between items-end">
28 <div class="flex gap-2"> 28 <div class="flex gap-2">
29 <Authority value=""> 29 <Authority value="">
30 - <Button v-if="isShowBtn" type="primary" @click="handleCreateOrEdit"> 30 + <Button v-if="isShowBtn" type="primary" @click="handleCreateOrEdit()">
31 新增物模型 31 新增物模型
32 </Button> 32 </Button>
33 <Button type="primary" @click="handleOpenTsl"> 物模型TSL </Button> 33 <Button type="primary" @click="handleOpenTsl"> 物模型TSL </Button>
@@ -106,7 +106,6 @@ @@ -106,7 +106,6 @@
106 </div> 106 </div>
107 </template> 107 </template>
108 <script lang="ts" setup> 108 <script lang="ts" setup>
109 - import { ref } from 'vue';  
110 import { BasicTable, useTable, TableAction } from '/@/components/Table'; 109 import { BasicTable, useTable, TableAction } from '/@/components/Table';
111 import { useModal } from '/@/components/Modal'; 110 import { useModal } from '/@/components/Modal';
112 import { physicalColumn } from '../device.profile.data'; 111 import { physicalColumn } from '../device.profile.data';
@@ -120,6 +119,7 @@ @@ -120,6 +119,7 @@
120 import { deleteModel, getModelList } from '/@/api/device/modelOfMatter'; 119 import { deleteModel, getModelList } from '/@/api/device/modelOfMatter';
121 import { OpenModelOfMatterModelParams, OpenModelMode } from './cpns/physical/types'; 120 import { OpenModelOfMatterModelParams, OpenModelMode } from './cpns/physical/types';
122 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; 121 import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
  122 + import { ref } from 'vue';
123 defineEmits(['register']); 123 defineEmits(['register']);
124 124
125 defineProps<{ 125 defineProps<{
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 <div> 2 <div>
3 <BasicModal 3 <BasicModal
4 :maskClosable="false" 4 :maskClosable="false"
  5 + destroy-on-close
5 v-bind="$attrs" 6 v-bind="$attrs"
6 width="55rem" 7 width="55rem"
7 @register="register" 8 @register="register"
@@ -24,7 +25,11 @@ @@ -24,7 +25,11 @@
24 > 25 >
25 <TabPane :key="FunctionType.PROPERTIES" tab="属性" /> 26 <TabPane :key="FunctionType.PROPERTIES" tab="属性" />
26 <TabPane :key="FunctionType.SERVICE" tab="服务" /> 27 <TabPane :key="FunctionType.SERVICE" tab="服务" />
27 - <TabPane :key="FunctionType.EVENTS" tab="事件" /> 28 + <TabPane
  29 + :key="FunctionType.EVENTS"
  30 + tab="事件"
  31 + :disabled="$props.record.transportType === 'TCP'"
  32 + />
28 </Tabs> 33 </Tabs>
29 <Attribute v-show="activeKey === FunctionType.PROPERTIES" ref="AttrRef" /> 34 <Attribute v-show="activeKey === FunctionType.PROPERTIES" ref="AttrRef" />
30 <Service v-show="activeKey === FunctionType.SERVICE" ref="ServiceRef" /> 35 <Service v-show="activeKey === FunctionType.SERVICE" ref="ServiceRef" />
@@ -62,6 +67,7 @@ @@ -62,6 +67,7 @@
62 const ServiceRef = ref<InstanceType<typeof Service>>(); 67 const ServiceRef = ref<InstanceType<typeof Service>>();
63 const EventsRef = ref<InstanceType<typeof Events>>(); 68 const EventsRef = ref<InstanceType<typeof Events>>();
64 const openModalMode = ref<OpenModelMode>(OpenModelMode.CREATE); 69 const openModalMode = ref<OpenModelMode>(OpenModelMode.CREATE);
  70 + const openModalParams = ref<OpenModelOfMatterModelParams>();
65 71
66 const functionType = ref<FunctionType>(); 72 const functionType = ref<FunctionType>();
67 const { createMessage } = useMessage(); 73 const { createMessage } = useMessage();
@@ -83,6 +89,7 @@ @@ -83,6 +89,7 @@
83 89
84 const [register, { closeModal, setModalProps }] = useModalInner( 90 const [register, { closeModal, setModalProps }] = useModalInner(
85 async (data: OpenModelOfMatterModelParams) => { 91 async (data: OpenModelOfMatterModelParams) => {
  92 + openModalParams.value = data;
86 const { mode, record } = data; 93 const { mode, record } = data;
87 openModalMode.value = mode; 94 openModalMode.value = mode;
88 if (record) { 95 if (record) {
@@ -121,7 +128,7 @@ @@ -121,7 +128,7 @@
121 if (activeKey.value == FunctionType.PROPERTIES) { 128 if (activeKey.value == FunctionType.PROPERTIES) {
122 params = (await AttrRef.value?.getFormData()) || {}; 129 params = (await AttrRef.value?.getFormData()) || {};
123 } else if (activeKey.value == FunctionType.SERVICE) { 130 } else if (activeKey.value == FunctionType.SERVICE) {
124 - params = await ServiceRef.value?.getFormData(); 131 + params = (await ServiceRef.value?.getFormData()) || {};
125 } else { 132 } else {
126 params = await EventsRef.value?.getFormData(); 133 params = await EventsRef.value?.getFormData();
127 } 134 }
@@ -130,7 +137,7 @@ @@ -130,7 +137,7 @@
130 await createModel(params); 137 await createModel(params);
131 createMessage.success('创建成功'); 138 createMessage.success('创建成功');
132 } else { 139 } else {
133 - params.id = props.record.id; 140 + params.id = unref(openModalParams)?.record.id;
134 await updateModel(params); 141 await updateModel(params);
135 createMessage.success('修改成功'); 142 createMessage.success('修改成功');
136 } 143 }
1 <template> 1 <template>
2 - <div>  
3 - <BasicForm @register="register" />  
4 - </div> 2 + <BasicForm @register="register" />
5 </template> 3 </template>
6 <script lang="ts" setup> 4 <script lang="ts" setup>
7 import { BasicForm, useForm } from '/@/components/Form'; 5 import { BasicForm, useForm } from '/@/components/Form';
@@ -12,6 +10,7 @@ @@ -12,6 +10,7 @@
12 StructFormValue, 10 StructFormValue,
13 StructRecord, 11 StructRecord,
14 } from '/@/components/Form/src/externalCompns/components/StructForm/type'; 12 } from '/@/components/Form/src/externalCompns/components/StructForm/type';
  13 + import { isObject } from 'lodash';
15 14
16 const [register, { validate, resetFields, setFieldsValue }] = useForm({ 15 const [register, { validate, resetFields, setFieldsValue }] = useForm({
17 labelWidth: 100, 16 labelWidth: 100,
@@ -42,11 +41,7 @@ @@ -42,11 +41,7 @@
42 const value = { 41 const value = {
43 ...record, 42 ...record,
44 ...functionJson, 43 ...functionJson,
45 - ...specs,  
46 - valueRange: {  
47 - min: specs.min,  
48 - max: specs.max,  
49 - }, 44 + ...(isObject(specs) ? specs : {}),
50 }; 45 };
51 46
52 setFieldsValue(value); 47 setFieldsValue(value);
1 <template> 1 <template>
2 - <div>  
3 - <BasicForm @register="register">  
4 - <template #outputParamSlot>  
5 - <div>  
6 - <template v-for="(item, index) in outputParamData" :key="item">  
7 - <span style="display: none">{{ item }}</span>  
8 - <InputParamItem  
9 - :title="item.name"  
10 - :item="item"  
11 - class="mt-4"  
12 - :index="index"  
13 - :ref="dynamicBindRef.outputParamItemRef"  
14 - @delete="deleteOutParItem"  
15 - @edit="editOutParItem"  
16 - />  
17 - </template>  
18 - <div style="display: flex" :class="{ 'mt-2': outputParamData.length > 0 }">  
19 - <span class="add-style">+</span>  
20 - <span class="add-style" @click="handleAddOutParam">增加参数</span>  
21 - </div>  
22 - </div>  
23 - </template>  
24 - </BasicForm>  
25 - <AddParamsModal @register="registerModal" @data="getData" />  
26 - </div> 2 + <BasicForm @register="register" />
27 </template> 3 </template>
28 <script lang="ts" setup> 4 <script lang="ts" setup>
29 - import { ref, unref } from 'vue';  
30 import { BasicForm, useForm } from '/@/components/Form'; 5 import { BasicForm, useForm } from '/@/components/Form';
31 import { eventSchemas } from './config'; 6 import { eventSchemas } from './config';
32 - import { useModal } from '/@/components/Modal';  
33 - import InputParamItem from './components/InputParamItem.vue';  
34 - import AddParamsModal from './components/AddParamsModal.vue';  
35 - import { buildUUID } from '/@/utils/uuid'; 7 + import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
36 8
37 - const outputParamData: any = ref([]);  
38 - const dynamicBindRef = {  
39 - outputParamItemRef: ref([]),  
40 - };  
41 -  
42 - const [registerModal, { openModal }] = useModal();  
43 -  
44 - const [register, { validate, setFieldsValue, resetFields }] = useForm({ 9 + const [register, { validate, resetFields }] = useForm({
45 labelWidth: 100, 10 labelWidth: 100,
46 schemas: eventSchemas, 11 schemas: eventSchemas,
47 actionColOptions: { 12 actionColOptions: {
@@ -52,70 +17,18 @@ @@ -52,70 +17,18 @@
52 showActionButtonGroup: false, 17 showActionButtonGroup: false,
53 }); 18 });
54 19
55 - const getData = (d, f) => {  
56 - if (f == 'output') {  
57 - if (d.id !== null) {  
58 - const findIndex = unref(outputParamData).findIndex((f) => f.id == d.id);  
59 - if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1, d);  
60 - } else {  
61 - unref(outputParamData).push({ ...d, id: buildUUID() });  
62 - }  
63 - }  
64 - };  
65 -  
66 - const handleAddOutParam = () => {  
67 - openModal(true, {  
68 - isUpdate: true,  
69 - flag: 'output',  
70 - excludeStruct: false,  
71 - });  
72 - };  
73 -  
74 - const deleteOutParItem = (index) => {  
75 - unref(outputParamData).splice(index, 1);  
76 - };  
77 -  
78 - const editOutParItem = (item) => {  
79 - openModal(true, {  
80 - isUpdate: false,  
81 - record: item,  
82 - flag: 'output',  
83 - excludeStruct: false,  
84 - });  
85 - };  
86 -  
87 //回显数据 20 //回显数据
88 - const setFormData = (v) => {  
89 - setFieldsValue(v[0]);  
90 - const { outputData } = v[0];  
91 - if (outputData !== undefined) {  
92 - outputParamData.value = [...new Array(outputData.length).keys()];  
93 - outputParamData.value = outputData;  
94 - }  
95 - };  
96 -  
97 - //获取数据  
98 - const getStructList = () => {  
99 - const val = unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData());  
100 - return val;  
101 - }; 21 + const setFormData = () => {};
102 22
103 async function getFormData() { 23 async function getFormData() {
104 - const values = await validate(); 24 + const values = (await validate()) as ModelOfMatterParams;
105 if (!values) return; 25 if (!values) return;
106 - const outputData = getStructList();  
107 - const { outputParam, ...value } = values;  
108 - console.log(outputParam);  
109 - return {  
110 - ...value,  
111 - ...{ outputData },  
112 - }; 26 + console.log(values);
113 } 27 }
114 28
115 //清空数据 29 //清空数据
116 const resetFormData = () => { 30 const resetFormData = () => {
117 resetFields(); 31 resetFields();
118 - outputParamData.value = [];  
119 }; 32 };
120 33
121 defineExpose({ 34 defineExpose({
1 <template> 1 <template>
2 - <div>  
3 - <BasicForm @register="register">  
4 - <template #inputParamSlot>  
5 - <div>  
6 - <template v-for="(item, index) in inputParamData" :key="item.id">  
7 - <span style="display: none">{{ item }}</span>  
8 - <InputParamItem  
9 - :title="item.name"  
10 - :item="item"  
11 - class="mt-4"  
12 - :index="index"  
13 - :ref="dynamicBindRef.inputParamItemRef"  
14 - @delete="deleteInParItem"  
15 - @edit="editInParItem"  
16 - />  
17 - </template>  
18 - <div style="display: flex" :class="{ 'mt-2': inputParamData.length > 0 }">  
19 - <span class="add-style">+</span>  
20 - <span class="add-style" @click="handleAddInParam">增加参数</span>  
21 - </div>  
22 - </div>  
23 - </template>  
24 - <template #outputParamSlot>  
25 - <div>  
26 - <template v-for="(item, index) in outputParamData" :key="item.id">  
27 - <span style="display: none">{{ item }}</span>  
28 - <InputParamItem  
29 - :title="item.name"  
30 - :item="item"  
31 - class="mt-4"  
32 - :index="index"  
33 - :ref="dynamicBindRef.outputParamItemRef"  
34 - @delete="deleteOutParItem"  
35 - @edit="editOutParItem"  
36 - />  
37 - </template>  
38 - <div style="display: flex" :class="{ 'mt-2': outputParamData.length > 0 }">  
39 - <span class="add-style">+</span>  
40 - <span class="add-style" @click="handleAddOutParam">增加参数</span>  
41 - </div>  
42 - </div>  
43 - </template>  
44 - </BasicForm>  
45 - <AddParamsModal @register="registerModal" @data="getData" />  
46 - </div> 2 + <BasicForm @register="register" />
47 </template> 3 </template>
48 <script lang="ts" setup> 4 <script lang="ts" setup>
49 - import { ref, unref } from 'vue';  
50 import { BasicForm, useForm } from '/@/components/Form'; 5 import { BasicForm, useForm } from '/@/components/Form';
51 import { serviceSchemas } from './config'; 6 import { serviceSchemas } from './config';
52 - import { useModal } from '/@/components/Modal';  
53 - import InputParamItem from './components/InputParamItem.vue';  
54 - import AddParamsModal from './components/AddParamsModal.vue';  
55 - import { buildUUID } from '/@/utils/uuid';  
56 -  
57 - const inputParamData: any = ref([]);  
58 - const outputParamData: any = ref([]);  
59 - const dynamicBindRef = {  
60 - inputParamItemRef: ref([]),  
61 - outputParamItemRef: ref([]),  
62 - };  
63 -  
64 - const [registerModal, { openModal }] = useModal();  
65 -  
66 - const [register, { validate, setFieldsValue, resetFields }] = useForm({ 7 + import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel';
  8 + import { FunctionType } from './config';
  9 + const [register, { validate, resetFields }] = useForm({
67 labelWidth: 100, 10 labelWidth: 100,
68 schemas: serviceSchemas, 11 schemas: serviceSchemas,
69 actionColOptions: { 12 actionColOptions: {
@@ -74,111 +17,21 @@ @@ -74,111 +17,21 @@
74 showActionButtonGroup: false, 17 showActionButtonGroup: false,
75 }); 18 });
76 19
77 - const getData = (d, f) => {  
78 - if (f == 'input') {  
79 - if (d.id !== null) {  
80 - const findIndex = unref(inputParamData).findIndex((f) => f.id == d.id);  
81 - if (findIndex !== -1) unref(inputParamData).splice(findIndex, 1, d);  
82 - } else {  
83 - unref(inputParamData).push({ ...d, id: buildUUID() });  
84 - }  
85 - } else {  
86 - if (d.id !== null) {  
87 - const findIndex = unref(outputParamData).findIndex((f) => f.id == d.id);  
88 - if (findIndex !== -1) unref(outputParamData).splice(findIndex, 1, d);  
89 - } else {  
90 - unref(outputParamData).push({ ...d, id: buildUUID() });  
91 - }  
92 - }  
93 - };  
94 -  
95 - const handleAddInParam = () => {  
96 - openModal(true, {  
97 - isUpdate: true,  
98 - flag: 'input',  
99 - excludeStruct: false,  
100 - });  
101 - };  
102 -  
103 - const deleteInParItem = (index) => {  
104 - unref(inputParamData).splice(index, 1);  
105 - };  
106 -  
107 - const editInParItem = (item) => {  
108 - openModal(true, {  
109 - isUpdate: false,  
110 - record: item,  
111 - flag: 'input',  
112 - excludeStruct: false,  
113 - });  
114 - };  
115 -  
116 - const handleAddOutParam = () => {  
117 - openModal(true, {  
118 - isUpdate: true,  
119 - flag: 'output',  
120 - excludeStruct: false,  
121 - });  
122 - };  
123 -  
124 - const deleteOutParItem = (index) => {  
125 - unref(outputParamData).splice(index, 1);  
126 - };  
127 -  
128 - const editOutParItem = (item) => {  
129 - openModal(true, {  
130 - isUpdate: false,  
131 - record: item,  
132 - flag: 'output',  
133 - excludeStruct: false,  
134 - });  
135 - };  
136 -  
137 //回显数据 20 //回显数据
138 - const setFormData = (v) => {  
139 - setFieldsValue(v[0]);  
140 - const { inputParams, outputParams } = v[0];  
141 - if (outputParams !== undefined) {  
142 - outputParamData.value = [...new Array(outputParams.length).keys()];  
143 - outputParamData.value = outputParams;  
144 - }  
145 - if (inputParams !== undefined) {  
146 - inputParamData.value = [...new Array(inputParams.length).keys()];  
147 - inputParamData.value = inputParams;  
148 - }  
149 - };  
150 -  
151 - const getInputStructList = () => {  
152 - const val = unref(dynamicBindRef.inputParamItemRef)?.map((item: any) => item.getFormData());  
153 - return val;  
154 - };  
155 -  
156 - const getOutputStructList = () => {  
157 - const val = unref(dynamicBindRef.outputParamItemRef)?.map((item: any) => item.getFormData());  
158 - return val;  
159 - }; 21 + const setFormData = () => {};
160 22
161 //获取数据 23 //获取数据
162 async function getFormData() { 24 async function getFormData() {
163 - const values = await validate(); 25 + const values = (await validate()) as ModelOfMatterParams;
164 if (!values) return; 26 if (!values) return;
165 - const inputParams = getInputStructList();  
166 - const outputParams = getOutputStructList();  
167 - const { inputParam, outputParam, ...value } = values;  
168 - console.log(inputParam);  
169 - console.log(outputParam);  
170 - return {  
171 - ...value,  
172 - ...{ inputParams },  
173 - ...{ outputParams },  
174 - }; 27 + values.functionType = FunctionType.SERVICE;
  28 + console.log(values);
  29 + return values;
175 } 30 }
176 31
177 //清空数据 32 //清空数据
178 const resetFormData = () => { 33 const resetFormData = () => {
179 resetFields(); 34 resetFields();
180 - inputParamData.value = [];  
181 - outputParamData.value = [];  
182 }; 35 };
183 36
184 defineExpose({ 37 defineExpose({
@@ -18,9 +18,10 @@ export enum FormField { @@ -18,9 +18,10 @@ export enum FormField {
18 BOOL_OPEN = 'boolOpen', 18 BOOL_OPEN = 'boolOpen',
19 LENGTH = 'length', 19 LENGTH = 'length',
20 R_W_FLAG = 'rwFlag', 20 R_W_FLAG = 'rwFlag',
21 - SPECS_LIST = 'specsList', 21 + SPECS_LIST = 'specs',
22 CALL_TYPE = 'callType', 22 CALL_TYPE = 'callType',
23 - INPUT_PARAM = 'inputParam', 23 + INPUT_PARAM = 'inputData',
  24 + OUTPUT_PARAM = 'outputData',
24 EVENT_TYPE = 'eventType', 25 EVENT_TYPE = 'eventType',
25 26
26 STRUCT = 'struct', 27 STRUCT = 'struct',
@@ -130,15 +131,17 @@ export const serviceSchemas: FormSchema[] = [ @@ -130,15 +131,17 @@ export const serviceSchemas: FormSchema[] = [
130 { 131 {
131 field: FormField.INPUT_PARAM, 132 field: FormField.INPUT_PARAM,
132 label: '输入参数', 133 label: '输入参数',
133 - component: 'Input',  
134 - slot: 'inputParamSlot', 134 + component: 'StructForm',
  135 + valueField: 'value',
  136 + changeEvent: 'update:value',
135 colProps: { span: 24 }, 137 colProps: { span: 24 },
136 }, 138 },
137 { 139 {
138 - field: FormField.SPECS_LIST, 140 + field: FormField.OUTPUT_PARAM,
139 label: '输出参数', 141 label: '输出参数',
140 - component: 'Input',  
141 - slot: 'outputParamSlot', 142 + component: 'StructForm',
  143 + valueField: 'value',
  144 + changeEvent: 'update:value',
142 colProps: { span: 24 }, 145 colProps: { span: 24 },
143 }, 146 },
144 { 147 {
@@ -200,10 +203,11 @@ export const eventSchemas: FormSchema[] = [ @@ -200,10 +203,11 @@ export const eventSchemas: FormSchema[] = [
200 }, 203 },
201 }, 204 },
202 { 205 {
203 - field: FormField.SPECS_LIST, 206 + field: FormField.OUTPUT_PARAM,
204 label: '输出参数', 207 label: '输出参数',
205 - component: 'Input',  
206 - slot: 'outputParamSlot', 208 + component: 'StructForm',
  209 + valueField: 'value',
  210 + changeEvent: 'update:value',
207 colProps: { span: 24 }, 211 colProps: { span: 24 },
208 }, 212 },
209 { 213 {