Coap.vue
3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
<div style="margin-top: -5vh; border: 1px solid gray; border-radius: 5px">
<div style="margin-top: 1.2vh">
<BasicForm :showResetButton="false" :showSubmitButton="false" @register="register" />
</div>
</div>
</template>
<script lang="ts" setup>
import { reactive } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import {
CoapSchemas,
// deviceTelemetryProtoSchemaData,
// deviceAttributesProtoSchemaData,
// deviceRpcRequestProtoSchemaData,
// deviceRpcResponseProtoSchemaData,
} from './Coap';
const emits = defineEmits(['prev']);
let coapAllData = reactive({});
const transportCoapData: any = reactive({
coapDeviceTypeConfiguration: {
coapDeviceType: null,
transportPayloadTypeConfiguration: {
transportPayloadType: null,
deviceTelemetryProtoSchema: null,
deviceAttributesProtoSchema: null,
deviceRpcRequestProtoSchema: null,
deviceRpcResponseProtoSchema: null,
},
},
clientSettings: {
powerMode: null,
edrxCycle: null,
pagingTransmissionWindow: null,
psmActivityTimer: null,
},
type: 'COAP',
});
const [register, { validate, resetFields, setFieldsValue }] = useForm({
labelWidth: 200,
schemas: CoapSchemas,
actionColOptions: {
span: 14,
},
});
const setFormData = (v) => {
setFieldsValue({
...v?.clientSettings,
...v?.coapDeviceTypeConfiguration,
...v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration,
});
};
const resetFormData = () => {
resetFields();
};
function customResetFunc() {
emits('prev');
}
const getFormData = async () => {
const val = await validate();
if (!val) return;
transportCoapData.coapDeviceTypeConfiguration.coapDeviceType = val.coapDeviceType;
transportCoapData.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.transportPayloadType =
val.transportPayloadType;
transportCoapData.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.deviceTelemetryProtoSchema =
val.deviceTelemetryProtoSchema;
transportCoapData.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.deviceAttributesProtoSchema =
val.deviceAttributesProtoSchema;
transportCoapData.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.deviceRpcRequestProtoSchema =
val.deviceRpcRequestProtoSchema;
transportCoapData.coapDeviceTypeConfiguration.transportPayloadTypeConfiguration.deviceRpcResponseProtoSchema =
val.deviceRpcResponseProtoSchema;
transportCoapData.clientSettings.powerMode = val.powerMode;
transportCoapData.clientSettings.edrxCycle = val.edrxCycle;
transportCoapData.clientSettings.pagingTransmissionWindow = val.pagingTransmissionWindow;
transportCoapData.clientSettings.psmActivityTimer = val.psmActivityTimer;
coapAllData = {
...transportCoapData,
};
return coapAllData;
};
defineExpose({
getFormData,
resetFormData,
setFormData,
customResetFunc,
});
</script>
<style lang="less" scoped></style>