From 07d6499b03d93f381dc0cc1680f5c3e8486f362e Mon Sep 17 00:00:00 2001
From: XieYongHong <18010623010@163.com>
Date: Sat, 15 Jul 2023 17:22:19 +0800
Subject: [PATCH] fix: bug#16423
---
src/views/link/plugin/Save.vue | 17 ++++++++++++++++-
src/views/link/plugin/UploadFile.vue | 11 ++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/views/link/plugin/Save.vue b/src/views/link/plugin/Save.vue
index ffd10549..c5bbf625 100644
--- a/src/views/link/plugin/Save.vue
+++ b/src/views/link/plugin/Save.vue
@@ -39,7 +39,7 @@
@@ -114,6 +114,21 @@ const IdRules = [
},
]
+const versionRule = [
+ { required: true, message: "请上传文件" },
+ // {
+ // validator(_: any, value: any) {
+ // if (value) {
+ // if (value?.err) {
+ // return Promise.reject('文件上传失败,请重新上传')
+ // }
+ // return Promise.resolve()
+ // }
+ // return Promise.reject('请上传文件')
+ // }
+ // }
+]
+
const modelRef = reactive({
id: props.data.id,
name: props.data.name,
diff --git a/src/views/link/plugin/UploadFile.vue b/src/views/link/plugin/UploadFile.vue
index 1f9d0748..2235ca07 100644
--- a/src/views/link/plugin/UploadFile.vue
+++ b/src/views/link/plugin/UploadFile.vue
@@ -30,6 +30,7 @@ import { onlyMessage } from '@/utils/comm';
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
import { notification as Notification } from 'jetlinks-ui-components';
import { useSystem } from '@/store/system';
+import {fileList} from "@/views/device/Instance/Detail/Running/Property/index";
const emit = defineEmits(['update:modelValue', 'change']);
@@ -55,6 +56,7 @@ const paths: string = useSystem().$state.configInfo.paths?.[
const value = ref(props.modelValue);
const list = ref(props.fileName ? [{ name: props.fileName}] : [])
const loading = ref(false);
+const fileCache = ref()
const remove = () => {
list.value = []
@@ -63,32 +65,39 @@ const remove = () => {
}
const beforeUpload: UploadProps['beforeUpload'] = (file, fl) => {
- list.value = fl
+
const arr = file.name.split('.');
const isFile = ['jar', 'zip'].includes(arr[arr.length - 1]); // file.type === 'application/zip' || file.type === 'application/javj-archive'
if (!isFile) {
onlyMessage('请上传.jar,.zip格式的文件', 'error');
loading.value = false;
+ return false
}
+ console.log(fl)
+ list.value = fl
return isFile;
};
const handleChange = async (info: UploadChangeParam) => {
loading.value = true;
+ console.log(info)
if (info.file.status === 'done') {
loading.value = false;
const result = info.file.response?.result;
const f = result.accessUrl;
onlyMessage('上传成功!', 'success');
value.value = f;
+ fileCache.value = info.fileList
emit('update:modelValue', result.version);
emit('change', result);
} else {
if (info.file.error) {
+ list.value = fileCache.value
Notification.error({
// key: '403',
message: '系统提示',
description: '系统未知错误,请反馈给管理员',
});
+ // emit('update:modelValue', { err:'file_upload_error'});
loading.value = false;
} else if (info.file.response) {
loading.value = false;