Showing
4 changed files
with
251 additions
and
83 deletions
@@ -243,14 +243,14 @@ export const modeKafkaForm: FormSchema[] = [ | @@ -243,14 +243,14 @@ export const modeKafkaForm: FormSchema[] = [ | ||
243 | }, | 243 | }, |
244 | { | 244 | { |
245 | field: '1', | 245 | field: '1', |
246 | - label: '', | 246 | + label: '其他属性', |
247 | colProps: { span: 24 }, | 247 | colProps: { span: 24 }, |
248 | slot: 'addValue', | 248 | slot: 'addValue', |
249 | component: 'Input', | 249 | component: 'Input', |
250 | }, | 250 | }, |
251 | { | 251 | { |
252 | field: 'addMetadataKeyValuesAsKafkaHeaders', | 252 | field: 'addMetadataKeyValuesAsKafkaHeaders', |
253 | - label: '选择', | 253 | + label: '', |
254 | colProps: { span: 12 }, | 254 | colProps: { span: 12 }, |
255 | component: 'Checkbox', | 255 | component: 'Checkbox', |
256 | renderComponentContent: '将消息的元数据以键值对的方式添加到Kafka消息头中', | 256 | renderComponentContent: '将消息的元数据以键值对的方式添加到Kafka消息头中', |
@@ -282,7 +282,7 @@ export const modeKafkaForm: FormSchema[] = [ | @@ -282,7 +282,7 @@ export const modeKafkaForm: FormSchema[] = [ | ||
282 | field: 'description', | 282 | field: 'description', |
283 | label: '说明', | 283 | label: '说明', |
284 | colProps: { span: 12 }, | 284 | colProps: { span: 12 }, |
285 | - component: 'Input', | 285 | + component: 'InputTextArea', |
286 | componentProps: { | 286 | componentProps: { |
287 | maxLength: 255, | 287 | maxLength: 255, |
288 | placeholder: '请输入说明', | 288 | placeholder: '请输入说明', |
@@ -308,6 +308,7 @@ export const modeMqttForm: FormSchema[] = [ | @@ -308,6 +308,7 @@ export const modeMqttForm: FormSchema[] = [ | ||
308 | colProps: { span: 12 }, | 308 | colProps: { span: 12 }, |
309 | required: true, | 309 | required: true, |
310 | component: 'Input', | 310 | component: 'Input', |
311 | + defaultValue: 'my-topic', | ||
311 | componentProps: { | 312 | componentProps: { |
312 | maxLength: 255, | 313 | maxLength: 255, |
313 | placeholder: '请输入Topic pattern', | 314 | placeholder: '请输入Topic pattern', |
@@ -319,7 +320,6 @@ export const modeMqttForm: FormSchema[] = [ | @@ -319,7 +320,6 @@ export const modeMqttForm: FormSchema[] = [ | ||
319 | colProps: { span: 12 }, | 320 | colProps: { span: 12 }, |
320 | component: 'Input', | 321 | component: 'Input', |
321 | required: true, | 322 | required: true, |
322 | - defaultValue: 'localhost', | ||
323 | componentProps: { | 323 | componentProps: { |
324 | maxLength: 255, | 324 | maxLength: 255, |
325 | placeholder: '请输入Host', | 325 | placeholder: '请输入Host', |
@@ -354,12 +354,37 @@ export const modeMqttForm: FormSchema[] = [ | @@ -354,12 +354,37 @@ export const modeMqttForm: FormSchema[] = [ | ||
354 | label: 'Client ID', | 354 | label: 'Client ID', |
355 | colProps: { span: 12 }, | 355 | colProps: { span: 12 }, |
356 | component: 'Input', | 356 | component: 'Input', |
357 | - componentProps: { | ||
358 | - maxLength: 255, | ||
359 | - placeholder: '请输入Client ID', | 357 | + componentProps: ({ formActionType }) => { |
358 | + const { updateSchema } = formActionType; | ||
359 | + return { | ||
360 | + onChange(e) { | ||
361 | + if (e == null || e == undefined) { | ||
362 | + updateSchema({ | ||
363 | + field: 'appendClientIdSuffix', | ||
364 | + show: false, | ||
365 | + }); | ||
366 | + } else { | ||
367 | + updateSchema({ | ||
368 | + field: 'appendClientIdSuffix', | ||
369 | + show: true, | ||
370 | + }); | ||
371 | + } | ||
372 | + }, | ||
373 | + maxLength: 255, | ||
374 | + placeholder: '请输入Client ID', | ||
375 | + }; | ||
360 | }, | 376 | }, |
361 | }, | 377 | }, |
362 | { | 378 | { |
379 | + field: 'appendClientIdSuffix', | ||
380 | + label: '', | ||
381 | + colProps: { span: 12 }, | ||
382 | + defaultValue: false, | ||
383 | + component: 'Checkbox', | ||
384 | + renderComponentContent: 'Add Service ID as suffix to Client ID', | ||
385 | + show: false, | ||
386 | + }, | ||
387 | + { | ||
363 | field: 'cleanSession', | 388 | field: 'cleanSession', |
364 | label: 'Clean', | 389 | label: 'Clean', |
365 | colProps: { span: 12 }, | 390 | colProps: { span: 12 }, |
@@ -406,7 +431,7 @@ export const modeMqttForm: FormSchema[] = [ | @@ -406,7 +431,7 @@ export const modeMqttForm: FormSchema[] = [ | ||
406 | field: 'password', | 431 | field: 'password', |
407 | label: '密码', | 432 | label: '密码', |
408 | colProps: { span: 12 }, | 433 | colProps: { span: 12 }, |
409 | - component: 'Input', | 434 | + component: 'InputPassword', |
410 | componentProps: { | 435 | componentProps: { |
411 | maxLength: 255, | 436 | maxLength: 255, |
412 | placeholder: '请输入密码', | 437 | placeholder: '请输入密码', |
@@ -452,7 +477,7 @@ export const modeMqttForm: FormSchema[] = [ | @@ -452,7 +477,7 @@ export const modeMqttForm: FormSchema[] = [ | ||
452 | field: 'description', | 477 | field: 'description', |
453 | label: '说明', | 478 | label: '说明', |
454 | colProps: { span: 12 }, | 479 | colProps: { span: 12 }, |
455 | - component: 'Input', | 480 | + component: 'InputTextArea', |
456 | componentProps: { | 481 | componentProps: { |
457 | maxLength: 255, | 482 | maxLength: 255, |
458 | placeholder: '请输入说明', | 483 | placeholder: '请输入说明', |
@@ -575,7 +600,7 @@ export const modeRabbitMqForm: FormSchema[] = [ | @@ -575,7 +600,7 @@ export const modeRabbitMqForm: FormSchema[] = [ | ||
575 | field: 'password', | 600 | field: 'password', |
576 | label: 'Password', | 601 | label: 'Password', |
577 | colProps: { span: 12 }, | 602 | colProps: { span: 12 }, |
578 | - component: 'Input', | 603 | + component: 'InputPassword', |
579 | defaultValue: 'guest', | 604 | defaultValue: 'guest', |
580 | componentProps: { | 605 | componentProps: { |
581 | maxLength: 255, | 606 | maxLength: 255, |
@@ -613,12 +638,11 @@ export const modeRabbitMqForm: FormSchema[] = [ | @@ -613,12 +638,11 @@ export const modeRabbitMqForm: FormSchema[] = [ | ||
613 | }, | 638 | }, |
614 | { | 639 | { |
615 | field: '1', | 640 | field: '1', |
616 | - label: '', | 641 | + label: '客户端属性', |
617 | colProps: { span: 24 }, | 642 | colProps: { span: 24 }, |
618 | - component: 'Input', | 643 | + component: 'InputTextArea', |
619 | slot: 'addKeyAndValue', | 644 | slot: 'addKeyAndValue', |
620 | }, | 645 | }, |
621 | - | ||
622 | { | 646 | { |
623 | field: 'description', | 647 | field: 'description', |
624 | label: '说明', | 648 | label: '说明', |
@@ -925,7 +949,7 @@ export const modeApiForm: FormSchema[] = [ | @@ -925,7 +949,7 @@ export const modeApiForm: FormSchema[] = [ | ||
925 | field: 'password', | 949 | field: 'password', |
926 | label: 'Password', | 950 | label: 'Password', |
927 | colProps: { span: 12 }, | 951 | colProps: { span: 12 }, |
928 | - component: 'Input', | 952 | + component: 'InputPassword', |
929 | required: true, | 953 | required: true, |
930 | componentProps: { | 954 | componentProps: { |
931 | maxLength: 255, | 955 | maxLength: 255, |
@@ -961,7 +985,7 @@ export const modeApiForm: FormSchema[] = [ | @@ -961,7 +985,7 @@ export const modeApiForm: FormSchema[] = [ | ||
961 | field: 'password', | 985 | field: 'password', |
962 | label: 'Password', | 986 | label: 'Password', |
963 | colProps: { span: 12 }, | 987 | colProps: { span: 12 }, |
964 | - component: 'Input', | 988 | + component: 'InputPassword', |
965 | componentProps: { | 989 | componentProps: { |
966 | maxLength: 255, | 990 | maxLength: 255, |
967 | placeholder: '请输入Password', | 991 | placeholder: '请输入Password', |
@@ -973,7 +997,7 @@ export const modeApiForm: FormSchema[] = [ | @@ -973,7 +997,7 @@ export const modeApiForm: FormSchema[] = [ | ||
973 | field: 'description', | 997 | field: 'description', |
974 | label: '说明', | 998 | label: '说明', |
975 | colProps: { span: 12 }, | 999 | colProps: { span: 12 }, |
976 | - component: 'Input', | 1000 | + component: 'InputTextArea', |
977 | componentProps: { | 1001 | componentProps: { |
978 | maxLength: 255, | 1002 | maxLength: 255, |
979 | placeholder: '请输入说明', | 1003 | placeholder: '请输入说明', |
@@ -23,57 +23,60 @@ | @@ -23,57 +23,60 @@ | ||
23 | <template #uploadAdd1="{ field }"> | 23 | <template #uploadAdd1="{ field }"> |
24 | <span style="display: none">{{ field }}</span> | 24 | <span style="display: none">{{ field }}</span> |
25 | <a-upload-dragger | 25 | <a-upload-dragger |
26 | - v-model:fileList="fileList" | 26 | + v-model:fileList="fileList1" |
27 | name="file" | 27 | name="file" |
28 | - :multiple="true" | ||
29 | - action="https://www.mocky.io/v2/5cc8019d300000980a055e76" | ||
30 | - @change="handleChange" | 28 | + :multiple="false" |
29 | + @change="handleChange('T', $event)" | ||
30 | + :before-upload="() => false" | ||
31 | > | 31 | > |
32 | <p class="ant-upload-drag-icon"> | 32 | <p class="ant-upload-drag-icon"> |
33 | <InboxOutlined /> | 33 | <InboxOutlined /> |
34 | </p> | 34 | </p> |
35 | - <p class="ant-upload-text">Click or drag file to this area to upload</p> | 35 | + <p class="ant-upload-text">点击或将文件拖拽到这里上传</p> |
36 | <p class="ant-upload-hint"> | 36 | <p class="ant-upload-hint"> |
37 | - Support for a single or bulk upload. Strictly prohibit from uploading company data or | ||
38 | - other band files | 37 | + 支持扩展名:.jpeg .png .jpg ... |
38 | + <br /> | ||
39 | + 文件大小:最大支持5M | ||
39 | </p> | 40 | </p> |
40 | </a-upload-dragger> | 41 | </a-upload-dragger> |
41 | </template> | 42 | </template> |
42 | <template #uploadAdd2="{ field }"> | 43 | <template #uploadAdd2="{ field }"> |
43 | <span style="display: none">{{ field }}</span> | 44 | <span style="display: none">{{ field }}</span> |
44 | <a-upload-dragger | 45 | <a-upload-dragger |
45 | - v-model:fileList="fileList" | 46 | + v-model:fileList="fileList2" |
46 | name="file" | 47 | name="file" |
47 | - :multiple="true" | ||
48 | - action="https://www.mocky.io/v2/5cc8019d300000980a055e76" | ||
49 | - @change="handleChange" | 48 | + :multiple="false" |
49 | + @change="handleChange('F', $event)" | ||
50 | + :before-upload="() => false" | ||
50 | > | 51 | > |
51 | <p class="ant-upload-drag-icon"> | 52 | <p class="ant-upload-drag-icon"> |
52 | <InboxOutlined /> | 53 | <InboxOutlined /> |
53 | </p> | 54 | </p> |
54 | - <p class="ant-upload-text">Click or drag file to this area to upload</p> | 55 | + <p class="ant-upload-text">点击或将文件拖拽到这里上传</p> |
55 | <p class="ant-upload-hint"> | 56 | <p class="ant-upload-hint"> |
56 | - Support for a single or bulk upload. Strictly prohibit from uploading company data or | ||
57 | - other band files | 57 | + 支持扩展名:.jpeg .png .jpg ... |
58 | + <br /> | ||
59 | + 文件大小:最大支持5M | ||
58 | </p> | 60 | </p> |
59 | </a-upload-dragger> | 61 | </a-upload-dragger> |
60 | </template> | 62 | </template> |
61 | <template #uploadAdd3="{ field }"> | 63 | <template #uploadAdd3="{ field }"> |
62 | <span style="display: none">{{ field }}</span> | 64 | <span style="display: none">{{ field }}</span> |
63 | <a-upload-dragger | 65 | <a-upload-dragger |
64 | - v-model:fileList="fileList" | 66 | + v-model:fileList="fileList3" |
65 | name="file" | 67 | name="file" |
66 | - :multiple="true" | ||
67 | - action="https://www.mocky.io/v2/5cc8019d300000980a055e76" | ||
68 | - @change="handleChange" | 68 | + :multiple="false" |
69 | + @change="handleChange('C', $event)" | ||
70 | + :before-upload="() => false" | ||
69 | > | 71 | > |
70 | <p class="ant-upload-drag-icon"> | 72 | <p class="ant-upload-drag-icon"> |
71 | <InboxOutlined /> | 73 | <InboxOutlined /> |
72 | </p> | 74 | </p> |
73 | - <p class="ant-upload-text">Click or drag file to this area to upload</p> | 75 | + <p class="ant-upload-text">点击或将文件拖拽到这里上传</p> |
74 | <p class="ant-upload-hint"> | 76 | <p class="ant-upload-hint"> |
75 | - Support for a single or bulk upload. Strictly prohibit from uploading company data or | ||
76 | - other band files | 77 | + 支持扩展名:.jpeg .png .jpg ... |
78 | + <br /> | ||
79 | + 文件大小:最大支持5M | ||
77 | </p> | 80 | </p> |
78 | </a-upload-dragger> | 81 | </a-upload-dragger> |
79 | </template> | 82 | </template> |
@@ -83,9 +86,12 @@ | @@ -83,9 +86,12 @@ | ||
83 | <script lang="ts"> | 86 | <script lang="ts"> |
84 | import { defineComponent, ref, reactive, nextTick } from 'vue'; | 87 | import { defineComponent, ref, reactive, nextTick } from 'vue'; |
85 | import { BasicForm, useForm } from '/@/components/Form'; | 88 | import { BasicForm, useForm } from '/@/components/Form'; |
86 | - import { modeApiForm, modeApiInseretKeyAndValueForm } from '../config'; | 89 | + import { modeApiForm, modeApiInseretKeyAndValueForm, CredentialsEnum } from '../config'; |
87 | import { InboxOutlined } from '@ant-design/icons-vue'; | 90 | import { InboxOutlined } from '@ant-design/icons-vue'; |
88 | import { Upload } from 'ant-design-vue'; | 91 | import { Upload } from 'ant-design-vue'; |
92 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
93 | + import { uploadApi } from '/@/api/personal/index'; | ||
94 | + | ||
89 | interface IKeyAndValue { | 95 | interface IKeyAndValue { |
90 | key: string; | 96 | key: string; |
91 | value: string; | 97 | value: string; |
@@ -98,14 +104,20 @@ | @@ -98,14 +104,20 @@ | ||
98 | }, | 104 | }, |
99 | emits: ['next', 'prev', 'register'], | 105 | emits: ['next', 'prev', 'register'], |
100 | setup(_, { emit }) { | 106 | setup(_, { emit }) { |
101 | - const fileList = ref<[]>([]); | 107 | + const { createMessage } = useMessage(); |
108 | + let caCertFileName = ref(''); | ||
109 | + let privateKeyFileName = ref(''); | ||
110 | + let certFileName = ref(''); | ||
111 | + let fileList1: any = ref<[]>([]); | ||
112 | + let fileList2: any = ref<[]>([]); | ||
113 | + let fileList3: any = ref<[]>([]); | ||
102 | const keyAndValueArr = ref<[]>([]); | 114 | const keyAndValueArr = ref<[]>([]); |
103 | const temp = ref({}); | 115 | const temp = ref({}); |
104 | let tempObj = ref({}); | 116 | let tempObj = ref({}); |
105 | const otherPropertiesValues = reactive({ | 117 | const otherPropertiesValues = reactive({ |
106 | headers: {}, | 118 | headers: {}, |
107 | }); | 119 | }); |
108 | - const credentialsV = reactive({ | 120 | + const credentialsV: any = reactive({ |
109 | credentials: { | 121 | credentials: { |
110 | type: '', | 122 | type: '', |
111 | }, | 123 | }, |
@@ -126,9 +138,7 @@ | @@ -126,9 +138,7 @@ | ||
126 | }, | 138 | }, |
127 | resetButtonOptions: { | 139 | resetButtonOptions: { |
128 | text: '上一步', | 140 | text: '上一步', |
129 | - type: 'primary', | ||
130 | }, | 141 | }, |
131 | - | ||
132 | resetFunc: customResetFunc, | 142 | resetFunc: customResetFunc, |
133 | submitFunc: customSubmitFunc, | 143 | submitFunc: customSubmitFunc, |
134 | }); | 144 | }); |
@@ -148,11 +158,25 @@ | @@ -148,11 +158,25 @@ | ||
148 | setFieldsValue({ | 158 | setFieldsValue({ |
149 | name: v1, | 159 | name: v1, |
150 | }); | 160 | }); |
161 | + setFieldsValue({ | ||
162 | + password: v.credentials?.password, | ||
163 | + username: v.credentials?.username, | ||
164 | + type: v.credentials?.type, | ||
165 | + }); | ||
166 | + fileList1.value = [{ name: v.credentials?.caCertFileName.slice(39) }]; | ||
167 | + fileList2.value = [{ name: v.credentials?.certFileName.slice(39) }]; | ||
168 | + fileList3.value = [{ name: v.credentials?.privateKeyFileName.slice(39) }]; | ||
151 | }; | 169 | }; |
152 | const customClearStepTwoValueFunc = async () => { | 170 | const customClearStepTwoValueFunc = async () => { |
153 | nextTick(() => { | 171 | nextTick(() => { |
154 | defineClearFunc(); | 172 | defineClearFunc(); |
155 | defineClearKeyAndValueFunc(); | 173 | defineClearKeyAndValueFunc(); |
174 | + fileList1.value = []; | ||
175 | + fileList2.value = []; | ||
176 | + fileList3.value = []; | ||
177 | + caCertFileName.value = ''; | ||
178 | + privateKeyFileName.value = ''; | ||
179 | + certFileName.value = ''; | ||
156 | }); | 180 | }); |
157 | }; | 181 | }; |
158 | async function customResetFunc() { | 182 | async function customResetFunc() { |
@@ -184,7 +208,39 @@ | @@ -184,7 +208,39 @@ | ||
184 | const removeKeyAndValueFunc = () => { | 208 | const removeKeyAndValueFunc = () => { |
185 | keyAndValueArr.value.splice(0, 1); | 209 | keyAndValueArr.value.splice(0, 1); |
186 | }; | 210 | }; |
187 | - const handleChange = () => {}; | 211 | + /** |
212 | + * 上传图片 | ||
213 | + */ | ||
214 | + const handleChange = async (e, { file }) => { | ||
215 | + if (file.status === 'removed') { | ||
216 | + e == 'T' | ||
217 | + ? (fileList1.value = []) | ||
218 | + : e == 'F' | ||
219 | + ? (fileList2.value = []) | ||
220 | + : (fileList3.value = []); | ||
221 | + } else { | ||
222 | + const isLt5M = file.size / 1024 / 1024 < 5; | ||
223 | + if (!isLt5M) { | ||
224 | + createMessage.error('图片大小不能超过5MB!'); | ||
225 | + } else { | ||
226 | + e == 'T' | ||
227 | + ? (fileList1.value = [file]) | ||
228 | + : e == 'F' | ||
229 | + ? (fileList2.value = [file]) | ||
230 | + : (fileList3.value = [file]); | ||
231 | + const formData = new FormData(); | ||
232 | + formData.append('file', file); | ||
233 | + const response = await uploadApi(formData); | ||
234 | + if (response.fileStaticUri) { | ||
235 | + e == 'T' | ||
236 | + ? (caCertFileName.value = response.fileStaticUri) | ||
237 | + : e == 'F' | ||
238 | + ? (certFileName.value = response.fileStaticUri) | ||
239 | + : (privateKeyFileName.value = response.fileStaticUri); | ||
240 | + } | ||
241 | + } | ||
242 | + } | ||
243 | + }; | ||
188 | 244 | ||
189 | const getSonValueFunc = async () => { | 245 | const getSonValueFunc = async () => { |
190 | sonValues.configuration = await validate(); | 246 | sonValues.configuration = await validate(); |
@@ -192,6 +248,17 @@ | @@ -192,6 +248,17 @@ | ||
192 | await getDefaultValue(); | 248 | await getDefaultValue(); |
193 | } | 249 | } |
194 | credentialsV.credentials.type = sonValues.configuration.type; | 250 | credentialsV.credentials.type = sonValues.configuration.type; |
251 | + if (credentialsV.credentials.type == CredentialsEnum.IS_BASIC) { | ||
252 | + credentialsV.credentials.username = sonValues.configuration.username; | ||
253 | + credentialsV.credentials.password = sonValues.configuration.password; | ||
254 | + sonValues.configuration.username = undefined; | ||
255 | + sonValues.configuration.password = undefined; | ||
256 | + } else if (credentialsV.credentials.type == CredentialsEnum.IS_PEM) { | ||
257 | + credentialsV.credentials.caCertFileName = caCertFileName.value; | ||
258 | + credentialsV.credentials.certFileName = certFileName.value; | ||
259 | + credentialsV.credentials.privateKeyFileName = privateKeyFileName.value; | ||
260 | + credentialsV.credentials.password = sonValues.configuration.password; | ||
261 | + } | ||
195 | const kong = {}; | 262 | const kong = {}; |
196 | let kongTemp = {}; | 263 | let kongTemp = {}; |
197 | keyAndValueArrTemp.value.map((item: any) => { | 264 | keyAndValueArrTemp.value.map((item: any) => { |
@@ -211,9 +278,19 @@ | @@ -211,9 +278,19 @@ | ||
211 | getSonValueFunc, | 278 | getSonValueFunc, |
212 | keyAndValueArr, | 279 | keyAndValueArr, |
213 | registerKeyAndValue, | 280 | registerKeyAndValue, |
214 | - fileList, | ||
215 | handleChange, | 281 | handleChange, |
282 | + fileList1, | ||
283 | + fileList2, | ||
284 | + fileList3, | ||
285 | + caCertFileName, | ||
286 | + privateKeyFileName, | ||
287 | + certFileName, | ||
216 | }; | 288 | }; |
217 | }, | 289 | }, |
218 | }); | 290 | }); |
219 | </script> | 291 | </script> |
292 | +<style lang="less" scoped> | ||
293 | + :deep(.ant-col-24) { | ||
294 | + margin-bottom: 20px !important; | ||
295 | + } | ||
296 | +</style> |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | </div> | 26 | </div> |
27 | </template> | 27 | </template> |
28 | <script lang="ts"> | 28 | <script lang="ts"> |
29 | - import { defineComponent, ref, reactive, nextTick } from 'vue'; | 29 | + import { defineComponent, ref, reactive, nextTick, watch } from 'vue'; |
30 | import { BasicForm, useForm } from '/@/components/Form'; | 30 | import { BasicForm, useForm } from '/@/components/Form'; |
31 | import { modeKafkaForm, modeKafkaInseretKeyAndValueForm } from '../config'; | 31 | import { modeKafkaForm, modeKafkaInseretKeyAndValueForm } from '../config'; |
32 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; | 32 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; |
@@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
48 | setup(_, { emit }) { | 48 | setup(_, { emit }) { |
49 | const temp = ref({}); | 49 | const temp = ref({}); |
50 | let tempObj = ref({}); | 50 | let tempObj = ref({}); |
51 | - const keyAndValueArr = ref<[]>([]); | 51 | + const keyAndValueArr: any = ref<[]>([]); |
52 | const keyAndValueArrTemp = ref<[]>([]); | 52 | const keyAndValueArrTemp = ref<[]>([]); |
53 | const vType = ref(''); | 53 | const vType = ref(''); |
54 | const keyAndValueObj = reactive<IKeyAndValue>({ | 54 | const keyAndValueObj = reactive<IKeyAndValue>({ |
@@ -72,7 +72,6 @@ | @@ -72,7 +72,6 @@ | ||
72 | }, | 72 | }, |
73 | resetButtonOptions: { | 73 | resetButtonOptions: { |
74 | text: '上一步', | 74 | text: '上一步', |
75 | - type: 'primary', | ||
76 | }, | 75 | }, |
77 | resetFunc: customResetFunc, | 76 | resetFunc: customResetFunc, |
78 | }); | 77 | }); |
@@ -114,12 +113,12 @@ | @@ -114,12 +113,12 @@ | ||
114 | const tempGetKeyAndVal = async () => { | 113 | const tempGetKeyAndVal = async () => { |
115 | temp.value = await validateKeyAndValue(); | 114 | temp.value = await validateKeyAndValue(); |
116 | }; | 115 | }; |
117 | - // const defaultAddKeyAndValueFunc = () => { | ||
118 | - // if (keyAndValueArr.value.length == 0) { | ||
119 | - // keyAndValueArr.value.push(keyAndValueObj as never); | ||
120 | - // } | ||
121 | - // }; | ||
122 | - // defaultAddKeyAndValueFunc(); | 116 | + watch( |
117 | + () => temp.value, | ||
118 | + (n) => { | ||
119 | + console.log(n); | ||
120 | + } | ||
121 | + ); | ||
123 | 122 | ||
124 | const getDefaultValue = async () => { | 123 | const getDefaultValue = async () => { |
125 | await tempGetKeyAndVal(); | 124 | await tempGetKeyAndVal(); |
@@ -4,57 +4,62 @@ | @@ -4,57 +4,62 @@ | ||
4 | <template #uploadAdd1="{ field }"> | 4 | <template #uploadAdd1="{ field }"> |
5 | <span style="display: none">{{ field }}</span> | 5 | <span style="display: none">{{ field }}</span> |
6 | <a-upload-dragger | 6 | <a-upload-dragger |
7 | - v-model:fileList="fileList" | 7 | + v-model:fileList="fileList1" |
8 | name="file" | 8 | name="file" |
9 | - :multiple="true" | ||
10 | - action="https://www.mocky.io/v2/5cc8019d300000980a055e76" | ||
11 | - @change="handleChange" | 9 | + :multiple="false" |
10 | + @change="handleChange('T', $event)" | ||
11 | + :before-upload="() => false" | ||
12 | > | 12 | > |
13 | <p class="ant-upload-drag-icon"> | 13 | <p class="ant-upload-drag-icon"> |
14 | <InboxOutlined /> | 14 | <InboxOutlined /> |
15 | </p> | 15 | </p> |
16 | - <p class="ant-upload-text">Click or drag file to this area to upload</p> | 16 | + <p class="ant-upload-text">点击或将文件拖拽到这里上传</p> |
17 | <p class="ant-upload-hint"> | 17 | <p class="ant-upload-hint"> |
18 | - Support for a single or bulk upload. Strictly prohibit from uploading company data or | ||
19 | - other band files | 18 | + 支持扩展名:.jpeg .png .jpg ... |
19 | + <br /> | ||
20 | + 文件大小:最大支持5M | ||
20 | </p> | 21 | </p> |
21 | </a-upload-dragger> | 22 | </a-upload-dragger> |
22 | </template> | 23 | </template> |
24 | + <div style="margin-top: 50px"></div> | ||
23 | <template #uploadAdd2="{ field }"> | 25 | <template #uploadAdd2="{ field }"> |
24 | <span style="display: none">{{ field }}</span> | 26 | <span style="display: none">{{ field }}</span> |
25 | <a-upload-dragger | 27 | <a-upload-dragger |
26 | - v-model:fileList="fileList" | 28 | + v-model:fileList="fileList2" |
27 | name="file" | 29 | name="file" |
28 | - :multiple="true" | ||
29 | - action="https://www.mocky.io/v2/5cc8019d300000980a055e76" | ||
30 | - @change="handleChange" | 30 | + :multiple="false" |
31 | + @change="handleChange('F', $event)" | ||
32 | + :before-upload="() => false" | ||
31 | > | 33 | > |
32 | <p class="ant-upload-drag-icon"> | 34 | <p class="ant-upload-drag-icon"> |
33 | <InboxOutlined /> | 35 | <InboxOutlined /> |
34 | </p> | 36 | </p> |
35 | - <p class="ant-upload-text">Click or drag file to this area to upload</p> | 37 | + <p class="ant-upload-text">点击或将文件拖拽到这里上传</p> |
36 | <p class="ant-upload-hint"> | 38 | <p class="ant-upload-hint"> |
37 | - Support for a single or bulk upload. Strictly prohibit from uploading company data or | ||
38 | - other band files | 39 | + 支持扩展名:.jpeg .png .jpg ... |
40 | + <br /> | ||
41 | + 文件大小:最大支持5M | ||
39 | </p> | 42 | </p> |
40 | </a-upload-dragger> | 43 | </a-upload-dragger> |
41 | </template> | 44 | </template> |
45 | + <div style="margin-top: 50px"></div> | ||
42 | <template #uploadAdd3="{ field }"> | 46 | <template #uploadAdd3="{ field }"> |
43 | <span style="display: none">{{ field }}</span> | 47 | <span style="display: none">{{ field }}</span> |
44 | <a-upload-dragger | 48 | <a-upload-dragger |
45 | - v-model:fileList="fileList" | 49 | + v-model:fileList="fileList3" |
46 | name="file" | 50 | name="file" |
47 | - :multiple="true" | ||
48 | - action="https://www.mocky.io/v2/5cc8019d300000980a055e76" | ||
49 | - @change="handleChange" | 51 | + :multiple="false" |
52 | + @change="handleChange('C', $event)" | ||
53 | + :before-upload="() => false" | ||
50 | > | 54 | > |
51 | <p class="ant-upload-drag-icon"> | 55 | <p class="ant-upload-drag-icon"> |
52 | <InboxOutlined /> | 56 | <InboxOutlined /> |
53 | </p> | 57 | </p> |
54 | - <p class="ant-upload-text">Click or drag file to this area to upload</p> | 58 | + <p class="ant-upload-text">点击或将文件拖拽到这里上传</p> |
55 | <p class="ant-upload-hint"> | 59 | <p class="ant-upload-hint"> |
56 | - Support for a single or bulk upload. Strictly prohibit from uploading company data or | ||
57 | - other band files | 60 | + 支持扩展名:.jpeg .png .jpg ... |
61 | + <br /> | ||
62 | + 文件大小:最大支持5M | ||
58 | </p> | 63 | </p> |
59 | </a-upload-dragger> | 64 | </a-upload-dragger> |
60 | </template> | 65 | </template> |
@@ -67,6 +72,8 @@ | @@ -67,6 +72,8 @@ | ||
67 | import { CredentialsEnum, modeMqttForm } from '../config'; | 72 | import { CredentialsEnum, modeMqttForm } from '../config'; |
68 | import { InboxOutlined } from '@ant-design/icons-vue'; | 73 | import { InboxOutlined } from '@ant-design/icons-vue'; |
69 | import { Alert, Divider, Descriptions, Upload } from 'ant-design-vue'; | 74 | import { Alert, Divider, Descriptions, Upload } from 'ant-design-vue'; |
75 | + import { uploadApi } from '/@/api/personal/index'; | ||
76 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
70 | 77 | ||
71 | export default defineComponent({ | 78 | export default defineComponent({ |
72 | components: { | 79 | components: { |
@@ -80,8 +87,14 @@ | @@ -80,8 +87,14 @@ | ||
80 | }, | 87 | }, |
81 | emits: ['next', 'prev', 'register'], | 88 | emits: ['next', 'prev', 'register'], |
82 | setup(_, { emit }) { | 89 | setup(_, { emit }) { |
83 | - const fileList = ref<[]>([]); | ||
84 | - const credentialsV = reactive({ | 90 | + const { createMessage } = useMessage(); |
91 | + let caCertFileName = ref(''); | ||
92 | + let privateKeyFileName = ref(''); | ||
93 | + let certFileName = ref(''); | ||
94 | + let fileList1: any = ref<[]>([]); | ||
95 | + let fileList2: any = ref<[]>([]); | ||
96 | + let fileList3: any = ref<[]>([]); | ||
97 | + const credentialsV: any = reactive({ | ||
85 | credentials: { | 98 | credentials: { |
86 | type: '', | 99 | type: '', |
87 | }, | 100 | }, |
@@ -97,26 +110,67 @@ | @@ -97,26 +110,67 @@ | ||
97 | }, | 110 | }, |
98 | resetButtonOptions: { | 111 | resetButtonOptions: { |
99 | text: '上一步', | 112 | text: '上一步', |
100 | - type: 'primary', | ||
101 | }, | 113 | }, |
102 | - | ||
103 | resetFunc: customResetFunc, | 114 | resetFunc: customResetFunc, |
104 | submitFunc: customSubmitFunc, | 115 | submitFunc: customSubmitFunc, |
105 | }); | 116 | }); |
117 | + | ||
118 | + /** | ||
119 | + * 上传图片 | ||
120 | + */ | ||
121 | + const handleChange = async (e, { file }) => { | ||
122 | + if (file.status === 'removed') { | ||
123 | + e == 'T' | ||
124 | + ? (fileList1.value = []) | ||
125 | + : e == 'F' | ||
126 | + ? (fileList2.value = []) | ||
127 | + : (fileList3.value = []); | ||
128 | + } else { | ||
129 | + const isLt5M = file.size / 1024 / 1024 < 5; | ||
130 | + if (!isLt5M) { | ||
131 | + createMessage.error('图片大小不能超过5MB!'); | ||
132 | + } else { | ||
133 | + e == 'T' | ||
134 | + ? (fileList1.value = [file]) | ||
135 | + : e == 'F' | ||
136 | + ? (fileList2.value = [file]) | ||
137 | + : (fileList3.value = [file]); | ||
138 | + const formData = new FormData(); | ||
139 | + formData.append('file', file); | ||
140 | + const response = await uploadApi(formData); | ||
141 | + if (response.fileStaticUri) { | ||
142 | + e == 'T' | ||
143 | + ? (caCertFileName.value = response.fileStaticUri) | ||
144 | + : e == 'F' | ||
145 | + ? (certFileName.value = response.fileStaticUri) | ||
146 | + : (privateKeyFileName.value = response.fileStaticUri); | ||
147 | + } | ||
148 | + } | ||
149 | + } | ||
150 | + }; | ||
106 | const setStepTwoFieldsValueFunc = (v, v1) => { | 151 | const setStepTwoFieldsValueFunc = (v, v1) => { |
107 | setFieldsValue(v); | 152 | setFieldsValue(v); |
108 | setFieldsValue({ | 153 | setFieldsValue({ |
109 | name: v1, | 154 | name: v1, |
110 | }); | 155 | }); |
111 | setFieldsValue({ | 156 | setFieldsValue({ |
112 | - password: v.credentials.password, | ||
113 | - type: v.credentials.type, | ||
114 | - username: v.credentials.username, | 157 | + password: v.credentials?.password, |
158 | + username: v.credentials?.username, | ||
159 | + type: v.credentials?.type, | ||
115 | }); | 160 | }); |
161 | + fileList1.value = [{ name: v.credentials?.caCertFileName.slice(39) }]; | ||
162 | + fileList2.value = [{ name: v.credentials?.certFileName.slice(39) }]; | ||
163 | + fileList3.value = [{ name: v.credentials?.privateKeyFileName.slice(39) }]; | ||
116 | }; | 164 | }; |
117 | const customClearStepTwoValueFunc = async () => { | 165 | const customClearStepTwoValueFunc = async () => { |
118 | nextTick(() => { | 166 | nextTick(() => { |
119 | defineClearFunc(); | 167 | defineClearFunc(); |
168 | + fileList1.value = []; | ||
169 | + fileList2.value = []; | ||
170 | + fileList3.value = []; | ||
171 | + caCertFileName.value = ''; | ||
172 | + privateKeyFileName.value = ''; | ||
173 | + certFileName.value = ''; | ||
120 | }); | 174 | }); |
121 | }; | 175 | }; |
122 | async function customResetFunc() { | 176 | async function customResetFunc() { |
@@ -130,7 +184,6 @@ | @@ -130,7 +184,6 @@ | ||
130 | } finally { | 184 | } finally { |
131 | } | 185 | } |
132 | } | 186 | } |
133 | - const handleChange = () => {}; | ||
134 | const getSonValueFunc = async () => { | 187 | const getSonValueFunc = async () => { |
135 | sonValues.configuration = await validate(); | 188 | sonValues.configuration = await validate(); |
136 | credentialsV.credentials.type = sonValues.configuration.type; | 189 | credentialsV.credentials.type = sonValues.configuration.type; |
@@ -139,6 +192,10 @@ | @@ -139,6 +192,10 @@ | ||
139 | credentialsV.credentials.password = sonValues.configuration.password; | 192 | credentialsV.credentials.password = sonValues.configuration.password; |
140 | sonValues.configuration.username = undefined; | 193 | sonValues.configuration.username = undefined; |
141 | sonValues.configuration.password = undefined; | 194 | sonValues.configuration.password = undefined; |
195 | + } else if (credentialsV.credentials.type == CredentialsEnum.IS_PEM) { | ||
196 | + credentialsV.credentials.caCertFileName = caCertFileName.value; | ||
197 | + credentialsV.credentials.certFileName = certFileName.value; | ||
198 | + credentialsV.credentials.privateKeyFileName = privateKeyFileName.value; | ||
142 | } | 199 | } |
143 | Object.assign(sonValues.configuration, credentialsV); | 200 | Object.assign(sonValues.configuration, credentialsV); |
144 | return sonValues; | 201 | return sonValues; |
@@ -148,9 +205,20 @@ | @@ -148,9 +205,20 @@ | ||
148 | register, | 205 | register, |
149 | setStepTwoFieldsValueFunc, | 206 | setStepTwoFieldsValueFunc, |
150 | customClearStepTwoValueFunc, | 207 | customClearStepTwoValueFunc, |
151 | - fileList, | 208 | + fileList1, |
209 | + fileList2, | ||
210 | + fileList3, | ||
152 | handleChange, | 211 | handleChange, |
212 | + caCertFileName, | ||
213 | + privateKeyFileName, | ||
214 | + certFileName, | ||
153 | }; | 215 | }; |
154 | }, | 216 | }, |
155 | }); | 217 | }); |
156 | </script> | 218 | </script> |
219 | + | ||
220 | +<style lang="less" scoped> | ||
221 | + :deep(.ant-col-24) { | ||
222 | + margin-bottom: 20px !important; | ||
223 | + } | ||
224 | +</style> |