From 8167603faee7ff7df77adaa942e2a1c19187f9fa Mon Sep 17 00:00:00 2001 From: jackhoo_98 Date: Thu, 16 Mar 2023 18:17:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=90=E7=BB=B4=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E5=8D=87=E7=BA=A7=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/device/Firmware/Save/FileUpload.vue | 4 +- src/views/device/Firmware/Save/index.vue | 66 ++++++++++--------- src/views/device/Firmware/Task/Save/index.vue | 6 +- src/views/device/Firmware/index.vue | 13 ++-- 4 files changed, 50 insertions(+), 39 deletions(-) diff --git a/src/views/device/Firmware/Save/FileUpload.vue b/src/views/device/Firmware/Save/FileUpload.vue index ab78e403..81b0f0f8 100644 --- a/src/views/device/Firmware/Save/FileUpload.vue +++ b/src/views/device/Firmware/Save/FileUpload.vue @@ -53,7 +53,7 @@ const handleChange = async (info: UploadChangeParam) => { if (info.file.status === 'done') { loading.value = false; const result = info.file.response?.result; - const api = await querySystemApi(['paths']); + const api: any = await querySystemApi(['paths']); const path = api.result[0]?.properties ? api.result[0]?.properties['base-path'] : ''; @@ -88,6 +88,8 @@ watch( .upload-box { :deep(.ant-btn) { width: 110px; + border-top-left-radius: 0; + border-bottom-left-radius: 0; } .upload-text { margin: 0 10px; diff --git a/src/views/device/Firmware/Save/index.vue b/src/views/device/Firmware/Save/index.vue index 478a9c2c..df4b2730 100644 --- a/src/views/device/Firmware/Save/index.vue +++ b/src/views/device/Firmware/Save/index.vue @@ -78,7 +78,16 @@ + > + - + 添加 @@ -198,13 +207,13 @@ const dynamicValidateForm = reactive<{ properties: Properties[] }>({ properties: [], }); -const removeUser = (item: Properties) => { +const removeList = (item: Properties) => { let index = dynamicValidateForm.properties.indexOf(item); if (index !== -1) { dynamicValidateForm.properties.splice(index, 1); } }; -const addUser = () => { +const addList = () => { dynamicValidateForm.properties.push({ id: '', value: '', @@ -226,8 +235,9 @@ const props = defineProps({ const emit = defineEmits(['change']); const id = props.data.id; +const VersionOrder = props.data.versionOrder; -const formData = ref({ +const formData: any = ref({ name: '', productId: undefined, version: '', @@ -239,7 +249,7 @@ const formData = ref({ description: '', }); -const extraValue = ref({}); +const extraValue: any = ref({}); const validatorSign = async (_: Record, value: string) => { const { signMethod, url } = formData.value; @@ -252,18 +262,16 @@ const validatorSign = async (_: Record, value: string) => { } }; const validatorVersionOrder = async (_: Record, value: string) => { - const { signMethod, productId } = formData.value; - if (value && !!signMethod && productId) { - const res = await validateVersion(productId, value); - if (res.status === 200) { - if (id && props.data.versionOrder === value) { - formData.value.versionOrder = ''; - } else { - Promise.reject(res.result ? ['版本序号已存在'] : ''); + if (id && VersionOrder === value) { + return Promise.resolve(); + } else { + const { signMethod, productId } = formData.value; + if (value && !!signMethod && productId) { + const res = await validateVersion(productId, value); + if (res.status === 200) { + Promise.reject(res.result ? '版本序号已存在' : ''); } } - } else { - return Promise.resolve(); } }; @@ -278,7 +286,6 @@ const { resetFields, validate, validateInfos } = useForm( version: [ { required: true, message: '请输入版本号' }, { max: 64, message: '最多可输入64个字符', trigger: 'change' }, - { validator: validatorVersionOrder, trigger: 'blur' }, ], versionOrder: [ { required: true, message: '请输入版本序号' }, @@ -298,13 +305,13 @@ const filterOption = (input: string, option: any) => { return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0; }; -const onSubmit = async () => { - const { properties } = await formRef.value?.validate(); +const handleOk = async () => { + const { properties }: any = await formRef.value?.validate(); validate() - .then(async (res) => { - const product = productOptions.value.find( - (item) => item?.value === res.productId, + .then(async (res: any) => { + const product: any = productOptions.value.find( + (item: any) => item?.value === res.productId, ); const productName = product?.label || props.data?.url; const size = extraValue.value?.length || props.data?.size; @@ -317,9 +324,9 @@ const onSubmit = async () => { }; loading.value = true; const response = !id - ? await save(params) - : await update({ ...props.data, ...params }); - if (response.status === 200) { + ? await save(params).catch(() => {}) + : await update({ ...props.data, ...params }).catch(() => {}); + if (response?.status === 200) { message.success('操作成功'); emit('change', true); } @@ -330,9 +337,6 @@ const onSubmit = async () => { }); }; -const handleOk = () => { - onSubmit(); -}; const handleCancel = () => { emit('change', false); }; @@ -347,8 +351,8 @@ onMounted(() => { paging: false, terms: [{ column: 'state', value: 1 }], sorts: [{ name: 'createTime', order: 'desc' }], - }).then((resp) => { - productOptions.value = resp.result.map((item) => ({ + }).then((resp: any) => { + productOptions.value = resp.result.map((item: any) => ({ value: item.id, label: item.name, })); diff --git a/src/views/device/Firmware/Task/Save/index.vue b/src/views/device/Firmware/Task/Save/index.vue index e51d0be9..89bdb16b 100644 --- a/src/views/device/Firmware/Task/Save/index.vue +++ b/src/views/device/Firmware/Task/Save/index.vue @@ -132,7 +132,7 @@ const firmwareId = route.query.id; const productId = route.query.productId; const view = props.data.view; -const formData = ref({ +const formData: any = ref({ name: '', mode: undefined, responseTimeoutSeconds: '', @@ -187,8 +187,8 @@ onMounted(() => { paging: false, terms: [{ column: 'state', value: 1 }], sorts: [{ name: 'createTime', order: 'desc' }], - }).then((resp) => { - productOptions.value = resp.result.map((item) => ({ + }).then((resp: any) => { + productOptions.value = resp.result.map((item: any) => ({ value: item.id, label: item.name, })); diff --git a/src/views/device/Firmware/index.vue b/src/views/device/Firmware/index.vue index 03020c95..468b175f 100644 --- a/src/views/device/Firmware/index.vue +++ b/src/views/device/Firmware/index.vue @@ -1,7 +1,11 @@