transferConfigMqtt.vue
5.04 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<template>
<div class="transfer-config-mode">
<BasicForm :showSubmitButton="false" @register="register">
<template #uploadAdd1="{ field }">
<span style="display: none">{{ field }}</span>
<a-upload-dragger
v-model:fileList="fileList"
name="file"
:multiple="true"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<InboxOutlined />
</p>
<p class="ant-upload-text">Click or drag file to this area to upload</p>
<p class="ant-upload-hint">
Support for a single or bulk upload. Strictly prohibit from uploading company data or
other band files
</p>
</a-upload-dragger>
</template>
<template #uploadAdd2="{ field }">
<span style="display: none">{{ field }}</span>
<a-upload-dragger
v-model:fileList="fileList"
name="file"
:multiple="true"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<InboxOutlined />
</p>
<p class="ant-upload-text">Click or drag file to this area to upload</p>
<p class="ant-upload-hint">
Support for a single or bulk upload. Strictly prohibit from uploading company data or
other band files
</p>
</a-upload-dragger>
</template>
<template #uploadAdd3="{ field }">
<span style="display: none">{{ field }}</span>
<a-upload-dragger
v-model:fileList="fileList"
name="file"
:multiple="true"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<InboxOutlined />
</p>
<p class="ant-upload-text">Click or drag file to this area to upload</p>
<p class="ant-upload-hint">
Support for a single or bulk upload. Strictly prohibit from uploading company data or
other band files
</p>
</a-upload-dragger>
</template>
</BasicForm>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, reactive, nextTick } from 'vue';
import { BasicForm, useForm } from '/@/components/Form';
import { CredentialsEnum, modeMqttForm } from '../config';
import { InboxOutlined } from '@ant-design/icons-vue';
import { Alert, Divider, Descriptions, Upload } from 'ant-design-vue';
export default defineComponent({
components: {
BasicForm,
[Alert.name]: Alert,
[Divider.name]: Divider,
[Descriptions.name]: Descriptions,
[Descriptions.Item.name]: Descriptions.Item,
InboxOutlined,
[Upload.Dragger.name]: Upload.Dragger,
},
emits: ['next', 'prev', 'register'],
setup(_, { emit }) {
const fileList = ref<[]>([]);
const credentialsV = reactive({
credentials: {
type: '',
},
});
const sonValues: any = reactive({
configuration: {},
});
const [register, { validate, setFieldsValue, resetFields: defineClearFunc }] = useForm({
labelWidth: 80,
schemas: modeMqttForm,
actionColOptions: {
span: 14,
},
resetButtonOptions: {
text: '上一步',
type: 'primary',
},
resetFunc: customResetFunc,
submitFunc: customSubmitFunc,
});
const setStepTwoFieldsValueFunc = (v, v1) => {
setFieldsValue(v);
setFieldsValue({
name: v1,
});
setFieldsValue({
password: v.credentials.password,
type: v.credentials.type,
username: v.credentials.username,
});
};
const customClearStepTwoValueFunc = async () => {
nextTick(() => {
defineClearFunc();
});
};
async function customResetFunc() {
emit('prev');
}
async function customSubmitFunc() {
try {
const values = await validate();
emit('next', values);
} catch (error) {
} finally {
}
}
const handleChange = () => {};
const getSonValueFunc = async () => {
sonValues.configuration = await validate();
credentialsV.credentials.type = sonValues.configuration.type;
if (credentialsV.credentials.type == CredentialsEnum.IS_BASIC) {
credentialsV.credentials.username = sonValues.configuration.username;
credentialsV.credentials.password = sonValues.configuration.password;
sonValues.configuration.username = undefined;
sonValues.configuration.password = undefined;
}
Object.assign(sonValues.configuration, credentialsV);
return sonValues;
};
return {
getSonValueFunc,
register,
setStepTwoFieldsValueFunc,
customClearStepTwoValueFunc,
fileList,
handleChange,
};
},
});
</script>