Showing
4 changed files
with
251 additions
and
83 deletions
| ... | ... | @@ -243,14 +243,14 @@ export const modeKafkaForm: FormSchema[] = [ |
| 243 | 243 | }, |
| 244 | 244 | { |
| 245 | 245 | field: '1', |
| 246 | - label: '', | |
| 246 | + label: '其他属性', | |
| 247 | 247 | colProps: { span: 24 }, |
| 248 | 248 | slot: 'addValue', |
| 249 | 249 | component: 'Input', |
| 250 | 250 | }, |
| 251 | 251 | { |
| 252 | 252 | field: 'addMetadataKeyValuesAsKafkaHeaders', |
| 253 | - label: '选择', | |
| 253 | + label: '', | |
| 254 | 254 | colProps: { span: 12 }, |
| 255 | 255 | component: 'Checkbox', |
| 256 | 256 | renderComponentContent: '将消息的元数据以键值对的方式添加到Kafka消息头中', |
| ... | ... | @@ -282,7 +282,7 @@ export const modeKafkaForm: FormSchema[] = [ |
| 282 | 282 | field: 'description', |
| 283 | 283 | label: '说明', |
| 284 | 284 | colProps: { span: 12 }, |
| 285 | - component: 'Input', | |
| 285 | + component: 'InputTextArea', | |
| 286 | 286 | componentProps: { |
| 287 | 287 | maxLength: 255, |
| 288 | 288 | placeholder: '请输入说明', |
| ... | ... | @@ -308,6 +308,7 @@ export const modeMqttForm: FormSchema[] = [ |
| 308 | 308 | colProps: { span: 12 }, |
| 309 | 309 | required: true, |
| 310 | 310 | component: 'Input', |
| 311 | + defaultValue: 'my-topic', | |
| 311 | 312 | componentProps: { |
| 312 | 313 | maxLength: 255, |
| 313 | 314 | placeholder: '请输入Topic pattern', |
| ... | ... | @@ -319,7 +320,6 @@ export const modeMqttForm: FormSchema[] = [ |
| 319 | 320 | colProps: { span: 12 }, |
| 320 | 321 | component: 'Input', |
| 321 | 322 | required: true, |
| 322 | - defaultValue: 'localhost', | |
| 323 | 323 | componentProps: { |
| 324 | 324 | maxLength: 255, |
| 325 | 325 | placeholder: '请输入Host', |
| ... | ... | @@ -354,12 +354,37 @@ export const modeMqttForm: FormSchema[] = [ |
| 354 | 354 | label: 'Client ID', |
| 355 | 355 | colProps: { span: 12 }, |
| 356 | 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 | 388 | field: 'cleanSession', |
| 364 | 389 | label: 'Clean', |
| 365 | 390 | colProps: { span: 12 }, |
| ... | ... | @@ -406,7 +431,7 @@ export const modeMqttForm: FormSchema[] = [ |
| 406 | 431 | field: 'password', |
| 407 | 432 | label: '密码', |
| 408 | 433 | colProps: { span: 12 }, |
| 409 | - component: 'Input', | |
| 434 | + component: 'InputPassword', | |
| 410 | 435 | componentProps: { |
| 411 | 436 | maxLength: 255, |
| 412 | 437 | placeholder: '请输入密码', |
| ... | ... | @@ -452,7 +477,7 @@ export const modeMqttForm: FormSchema[] = [ |
| 452 | 477 | field: 'description', |
| 453 | 478 | label: '说明', |
| 454 | 479 | colProps: { span: 12 }, |
| 455 | - component: 'Input', | |
| 480 | + component: 'InputTextArea', | |
| 456 | 481 | componentProps: { |
| 457 | 482 | maxLength: 255, |
| 458 | 483 | placeholder: '请输入说明', |
| ... | ... | @@ -575,7 +600,7 @@ export const modeRabbitMqForm: FormSchema[] = [ |
| 575 | 600 | field: 'password', |
| 576 | 601 | label: 'Password', |
| 577 | 602 | colProps: { span: 12 }, |
| 578 | - component: 'Input', | |
| 603 | + component: 'InputPassword', | |
| 579 | 604 | defaultValue: 'guest', |
| 580 | 605 | componentProps: { |
| 581 | 606 | maxLength: 255, |
| ... | ... | @@ -613,12 +638,11 @@ export const modeRabbitMqForm: FormSchema[] = [ |
| 613 | 638 | }, |
| 614 | 639 | { |
| 615 | 640 | field: '1', |
| 616 | - label: '', | |
| 641 | + label: '客户端属性', | |
| 617 | 642 | colProps: { span: 24 }, |
| 618 | - component: 'Input', | |
| 643 | + component: 'InputTextArea', | |
| 619 | 644 | slot: 'addKeyAndValue', |
| 620 | 645 | }, |
| 621 | - | |
| 622 | 646 | { |
| 623 | 647 | field: 'description', |
| 624 | 648 | label: '说明', |
| ... | ... | @@ -925,7 +949,7 @@ export const modeApiForm: FormSchema[] = [ |
| 925 | 949 | field: 'password', |
| 926 | 950 | label: 'Password', |
| 927 | 951 | colProps: { span: 12 }, |
| 928 | - component: 'Input', | |
| 952 | + component: 'InputPassword', | |
| 929 | 953 | required: true, |
| 930 | 954 | componentProps: { |
| 931 | 955 | maxLength: 255, |
| ... | ... | @@ -961,7 +985,7 @@ export const modeApiForm: FormSchema[] = [ |
| 961 | 985 | field: 'password', |
| 962 | 986 | label: 'Password', |
| 963 | 987 | colProps: { span: 12 }, |
| 964 | - component: 'Input', | |
| 988 | + component: 'InputPassword', | |
| 965 | 989 | componentProps: { |
| 966 | 990 | maxLength: 255, |
| 967 | 991 | placeholder: '请输入Password', |
| ... | ... | @@ -973,7 +997,7 @@ export const modeApiForm: FormSchema[] = [ |
| 973 | 997 | field: 'description', |
| 974 | 998 | label: '说明', |
| 975 | 999 | colProps: { span: 12 }, |
| 976 | - component: 'Input', | |
| 1000 | + component: 'InputTextArea', | |
| 977 | 1001 | componentProps: { |
| 978 | 1002 | maxLength: 255, |
| 979 | 1003 | placeholder: '请输入说明', | ... | ... |
| ... | ... | @@ -23,57 +23,60 @@ |
| 23 | 23 | <template #uploadAdd1="{ field }"> |
| 24 | 24 | <span style="display: none">{{ field }}</span> |
| 25 | 25 | <a-upload-dragger |
| 26 | - v-model:fileList="fileList" | |
| 26 | + v-model:fileList="fileList1" | |
| 27 | 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 | 32 | <p class="ant-upload-drag-icon"> |
| 33 | 33 | <InboxOutlined /> |
| 34 | 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 | 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 | 40 | </p> |
| 40 | 41 | </a-upload-dragger> |
| 41 | 42 | </template> |
| 42 | 43 | <template #uploadAdd2="{ field }"> |
| 43 | 44 | <span style="display: none">{{ field }}</span> |
| 44 | 45 | <a-upload-dragger |
| 45 | - v-model:fileList="fileList" | |
| 46 | + v-model:fileList="fileList2" | |
| 46 | 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 | 52 | <p class="ant-upload-drag-icon"> |
| 52 | 53 | <InboxOutlined /> |
| 53 | 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 | 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 | 60 | </p> |
| 59 | 61 | </a-upload-dragger> |
| 60 | 62 | </template> |
| 61 | 63 | <template #uploadAdd3="{ field }"> |
| 62 | 64 | <span style="display: none">{{ field }}</span> |
| 63 | 65 | <a-upload-dragger |
| 64 | - v-model:fileList="fileList" | |
| 66 | + v-model:fileList="fileList3" | |
| 65 | 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 | 72 | <p class="ant-upload-drag-icon"> |
| 71 | 73 | <InboxOutlined /> |
| 72 | 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 | 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 | 80 | </p> |
| 78 | 81 | </a-upload-dragger> |
| 79 | 82 | </template> |
| ... | ... | @@ -83,9 +86,12 @@ |
| 83 | 86 | <script lang="ts"> |
| 84 | 87 | import { defineComponent, ref, reactive, nextTick } from 'vue'; |
| 85 | 88 | import { BasicForm, useForm } from '/@/components/Form'; |
| 86 | - import { modeApiForm, modeApiInseretKeyAndValueForm } from '../config'; | |
| 89 | + import { modeApiForm, modeApiInseretKeyAndValueForm, CredentialsEnum } from '../config'; | |
| 87 | 90 | import { InboxOutlined } from '@ant-design/icons-vue'; |
| 88 | 91 | import { Upload } from 'ant-design-vue'; |
| 92 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
| 93 | + import { uploadApi } from '/@/api/personal/index'; | |
| 94 | + | |
| 89 | 95 | interface IKeyAndValue { |
| 90 | 96 | key: string; |
| 91 | 97 | value: string; |
| ... | ... | @@ -98,14 +104,20 @@ |
| 98 | 104 | }, |
| 99 | 105 | emits: ['next', 'prev', 'register'], |
| 100 | 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 | 114 | const keyAndValueArr = ref<[]>([]); |
| 103 | 115 | const temp = ref({}); |
| 104 | 116 | let tempObj = ref({}); |
| 105 | 117 | const otherPropertiesValues = reactive({ |
| 106 | 118 | headers: {}, |
| 107 | 119 | }); |
| 108 | - const credentialsV = reactive({ | |
| 120 | + const credentialsV: any = reactive({ | |
| 109 | 121 | credentials: { |
| 110 | 122 | type: '', |
| 111 | 123 | }, |
| ... | ... | @@ -126,9 +138,7 @@ |
| 126 | 138 | }, |
| 127 | 139 | resetButtonOptions: { |
| 128 | 140 | text: '上一步', |
| 129 | - type: 'primary', | |
| 130 | 141 | }, |
| 131 | - | |
| 132 | 142 | resetFunc: customResetFunc, |
| 133 | 143 | submitFunc: customSubmitFunc, |
| 134 | 144 | }); |
| ... | ... | @@ -148,11 +158,25 @@ |
| 148 | 158 | setFieldsValue({ |
| 149 | 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 | 170 | const customClearStepTwoValueFunc = async () => { |
| 153 | 171 | nextTick(() => { |
| 154 | 172 | defineClearFunc(); |
| 155 | 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 | 182 | async function customResetFunc() { |
| ... | ... | @@ -184,7 +208,39 @@ |
| 184 | 208 | const removeKeyAndValueFunc = () => { |
| 185 | 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 | 245 | const getSonValueFunc = async () => { |
| 190 | 246 | sonValues.configuration = await validate(); |
| ... | ... | @@ -192,6 +248,17 @@ |
| 192 | 248 | await getDefaultValue(); |
| 193 | 249 | } |
| 194 | 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 | 262 | const kong = {}; |
| 196 | 263 | let kongTemp = {}; |
| 197 | 264 | keyAndValueArrTemp.value.map((item: any) => { |
| ... | ... | @@ -211,9 +278,19 @@ |
| 211 | 278 | getSonValueFunc, |
| 212 | 279 | keyAndValueArr, |
| 213 | 280 | registerKeyAndValue, |
| 214 | - fileList, | |
| 215 | 281 | handleChange, |
| 282 | + fileList1, | |
| 283 | + fileList2, | |
| 284 | + fileList3, | |
| 285 | + caCertFileName, | |
| 286 | + privateKeyFileName, | |
| 287 | + certFileName, | |
| 216 | 288 | }; |
| 217 | 289 | }, |
| 218 | 290 | }); |
| 219 | 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 | 26 | </div> |
| 27 | 27 | </template> |
| 28 | 28 | <script lang="ts"> |
| 29 | - import { defineComponent, ref, reactive, nextTick } from 'vue'; | |
| 29 | + import { defineComponent, ref, reactive, nextTick, watch } from 'vue'; | |
| 30 | 30 | import { BasicForm, useForm } from '/@/components/Form'; |
| 31 | 31 | import { modeKafkaForm, modeKafkaInseretKeyAndValueForm } from '../config'; |
| 32 | 32 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; |
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | setup(_, { emit }) { |
| 49 | 49 | const temp = ref({}); |
| 50 | 50 | let tempObj = ref({}); |
| 51 | - const keyAndValueArr = ref<[]>([]); | |
| 51 | + const keyAndValueArr: any = ref<[]>([]); | |
| 52 | 52 | const keyAndValueArrTemp = ref<[]>([]); |
| 53 | 53 | const vType = ref(''); |
| 54 | 54 | const keyAndValueObj = reactive<IKeyAndValue>({ |
| ... | ... | @@ -72,7 +72,6 @@ |
| 72 | 72 | }, |
| 73 | 73 | resetButtonOptions: { |
| 74 | 74 | text: '上一步', |
| 75 | - type: 'primary', | |
| 76 | 75 | }, |
| 77 | 76 | resetFunc: customResetFunc, |
| 78 | 77 | }); |
| ... | ... | @@ -114,12 +113,12 @@ |
| 114 | 113 | const tempGetKeyAndVal = async () => { |
| 115 | 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 | 123 | const getDefaultValue = async () => { |
| 125 | 124 | await tempGetKeyAndVal(); | ... | ... |
| ... | ... | @@ -4,57 +4,62 @@ |
| 4 | 4 | <template #uploadAdd1="{ field }"> |
| 5 | 5 | <span style="display: none">{{ field }}</span> |
| 6 | 6 | <a-upload-dragger |
| 7 | - v-model:fileList="fileList" | |
| 7 | + v-model:fileList="fileList1" | |
| 8 | 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 | 13 | <p class="ant-upload-drag-icon"> |
| 14 | 14 | <InboxOutlined /> |
| 15 | 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 | 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 | 21 | </p> |
| 21 | 22 | </a-upload-dragger> |
| 22 | 23 | </template> |
| 24 | + <div style="margin-top: 50px"></div> | |
| 23 | 25 | <template #uploadAdd2="{ field }"> |
| 24 | 26 | <span style="display: none">{{ field }}</span> |
| 25 | 27 | <a-upload-dragger |
| 26 | - v-model:fileList="fileList" | |
| 28 | + v-model:fileList="fileList2" | |
| 27 | 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 | 34 | <p class="ant-upload-drag-icon"> |
| 33 | 35 | <InboxOutlined /> |
| 34 | 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 | 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 | 42 | </p> |
| 40 | 43 | </a-upload-dragger> |
| 41 | 44 | </template> |
| 45 | + <div style="margin-top: 50px"></div> | |
| 42 | 46 | <template #uploadAdd3="{ field }"> |
| 43 | 47 | <span style="display: none">{{ field }}</span> |
| 44 | 48 | <a-upload-dragger |
| 45 | - v-model:fileList="fileList" | |
| 49 | + v-model:fileList="fileList3" | |
| 46 | 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 | 55 | <p class="ant-upload-drag-icon"> |
| 52 | 56 | <InboxOutlined /> |
| 53 | 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 | 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 | 63 | </p> |
| 59 | 64 | </a-upload-dragger> |
| 60 | 65 | </template> |
| ... | ... | @@ -67,6 +72,8 @@ |
| 67 | 72 | import { CredentialsEnum, modeMqttForm } from '../config'; |
| 68 | 73 | import { InboxOutlined } from '@ant-design/icons-vue'; |
| 69 | 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 | 78 | export default defineComponent({ |
| 72 | 79 | components: { |
| ... | ... | @@ -80,8 +87,14 @@ |
| 80 | 87 | }, |
| 81 | 88 | emits: ['next', 'prev', 'register'], |
| 82 | 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 | 98 | credentials: { |
| 86 | 99 | type: '', |
| 87 | 100 | }, |
| ... | ... | @@ -97,26 +110,67 @@ |
| 97 | 110 | }, |
| 98 | 111 | resetButtonOptions: { |
| 99 | 112 | text: '上一步', |
| 100 | - type: 'primary', | |
| 101 | 113 | }, |
| 102 | - | |
| 103 | 114 | resetFunc: customResetFunc, |
| 104 | 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 | 151 | const setStepTwoFieldsValueFunc = (v, v1) => { |
| 107 | 152 | setFieldsValue(v); |
| 108 | 153 | setFieldsValue({ |
| 109 | 154 | name: v1, |
| 110 | 155 | }); |
| 111 | 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 | 165 | const customClearStepTwoValueFunc = async () => { |
| 118 | 166 | nextTick(() => { |
| 119 | 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 | 176 | async function customResetFunc() { |
| ... | ... | @@ -130,7 +184,6 @@ |
| 130 | 184 | } finally { |
| 131 | 185 | } |
| 132 | 186 | } |
| 133 | - const handleChange = () => {}; | |
| 134 | 187 | const getSonValueFunc = async () => { |
| 135 | 188 | sonValues.configuration = await validate(); |
| 136 | 189 | credentialsV.credentials.type = sonValues.configuration.type; |
| ... | ... | @@ -139,6 +192,10 @@ |
| 139 | 192 | credentialsV.credentials.password = sonValues.configuration.password; |
| 140 | 193 | sonValues.configuration.username = undefined; |
| 141 | 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 | 200 | Object.assign(sonValues.configuration, credentialsV); |
| 144 | 201 | return sonValues; |
| ... | ... | @@ -148,9 +205,20 @@ |
| 148 | 205 | register, |
| 149 | 206 | setStepTwoFieldsValueFunc, |
| 150 | 207 | customClearStepTwoValueFunc, |
| 151 | - fileList, | |
| 208 | + fileList1, | |
| 209 | + fileList2, | |
| 210 | + fileList3, | |
| 152 | 211 | handleChange, |
| 212 | + caCertFileName, | |
| 213 | + privateKeyFileName, | |
| 214 | + certFileName, | |
| 153 | 215 | }; |
| 154 | 216 | }, |
| 155 | 217 | }); |
| 156 | 218 | </script> |
| 219 | + | |
| 220 | +<style lang="less" scoped> | |
| 221 | + :deep(.ant-col-24) { | |
| 222 | + margin-bottom: 20px !important; | |
| 223 | + } | |
| 224 | +</style> | ... | ... |