Coap.vue
4.57 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
<div
style="
margin-top: -5vh;
padding-left: 1.5vw;
border: 1px solid gray;
margin-left: 0.1vw;
border-radius: 5px;
"
>
<div style="margin-top: 1.2vh">
<BasicForm :showResetButton="false" :showSubmitButton="false" @register="register" />
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import { CoapSchemas } from './Coap';
import { Alert, Divider, Descriptions } from 'ant-design-vue';
export default defineComponent({
components: {
BasicForm,
[Alert.name]: Alert,
[Divider.name]: Divider,
[Descriptions.name]: Descriptions,
[Descriptions.Item.name]: Descriptions.Item,
},
emits: ['next', 'prev', 'register'],
setup(_, { emit }) {
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: 80,
schemas: CoapSchemas,
actionColOptions: {
span: 14,
},
});
const setStepFieldsValueFunc = (v) => {
setFieldsValue({
coapDeviceType: v?.coapDeviceTypeConfiguration?.coapDeviceType,
transportPayloadType:
v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration?.transportPayloadType,
powerMode: v?.clientSettings.powerMode,
psmActivityTimer: v.clientSettings?.psmActivityTimer,
edrxCycle: v?.clientSettings.edrxCycle,
pagingTransmissionWindow: v.clientSettings?.pagingTransmissionWindow,
deviceTelemetryProtoSchema:
v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration
?.deviceTelemetryProtoSchema,
deviceAttributesProtoSchema:
v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration
?.deviceAttributesProtoSchema,
deviceRpcRequestProtoSchema:
v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration
?.deviceRpcRequestProtoSchema,
deviceRpcResponseProtoSchema:
v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration
?.deviceRpcResponseProtoSchema,
});
};
const customClearStepTwoValueFunc = () => {
resetFields();
};
async function customResetFunc() {
emit('prev');
}
const getDataFunc = 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;
};
return {
customResetFunc,
register,
customClearStepTwoValueFunc,
getDataFunc,
setStepFieldsValueFunc,
};
},
});
</script>
<style lang="less" scoped></style>