fix: bug#16423
This commit is contained in:
parent
0f36d7fa60
commit
07d6499b03
|
@ -39,7 +39,7 @@
|
||||||
<j-form-item
|
<j-form-item
|
||||||
label='文件'
|
label='文件'
|
||||||
name='version'
|
name='version'
|
||||||
:rules='[{ required: true, message: "请上传文件" }]'
|
:rules='versionRule'
|
||||||
>
|
>
|
||||||
<UploadFile v-model:modelValue='modelRef.version' @change='uploadChange' :fileName='data.filename' />
|
<UploadFile v-model:modelValue='modelRef.version' @change='uploadChange' :fileName='data.filename' />
|
||||||
</j-form-item>
|
</j-form-item>
|
||||||
|
@ -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<any>({
|
const modelRef = reactive<any>({
|
||||||
id: props.data.id,
|
id: props.data.id,
|
||||||
name: props.data.name,
|
name: props.data.name,
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { onlyMessage } from '@/utils/comm';
|
||||||
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
|
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
|
||||||
import { notification as Notification } from 'jetlinks-ui-components';
|
import { notification as Notification } from 'jetlinks-ui-components';
|
||||||
import { useSystem } from '@/store/system';
|
import { useSystem } from '@/store/system';
|
||||||
|
import {fileList} from "@/views/device/Instance/Detail/Running/Property/index";
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'change']);
|
const emit = defineEmits(['update:modelValue', 'change']);
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ const paths: string = useSystem().$state.configInfo.paths?.[
|
||||||
const value = ref(props.modelValue);
|
const value = ref(props.modelValue);
|
||||||
const list = ref<any>(props.fileName ? [{ name: props.fileName}] : [])
|
const list = ref<any>(props.fileName ? [{ name: props.fileName}] : [])
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const fileCache = ref()
|
||||||
|
|
||||||
const remove = () => {
|
const remove = () => {
|
||||||
list.value = []
|
list.value = []
|
||||||
|
@ -63,32 +65,39 @@ const remove = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const beforeUpload: UploadProps['beforeUpload'] = (file, fl) => {
|
const beforeUpload: UploadProps['beforeUpload'] = (file, fl) => {
|
||||||
list.value = fl
|
|
||||||
const arr = file.name.split('.');
|
const arr = file.name.split('.');
|
||||||
const isFile = ['jar', 'zip'].includes(arr[arr.length - 1]); // file.type === 'application/zip' || file.type === 'application/javj-archive'
|
const isFile = ['jar', 'zip'].includes(arr[arr.length - 1]); // file.type === 'application/zip' || file.type === 'application/javj-archive'
|
||||||
if (!isFile) {
|
if (!isFile) {
|
||||||
onlyMessage('请上传.jar,.zip格式的文件', 'error');
|
onlyMessage('请上传.jar,.zip格式的文件', 'error');
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
console.log(fl)
|
||||||
|
list.value = fl
|
||||||
return isFile;
|
return isFile;
|
||||||
};
|
};
|
||||||
const handleChange = async (info: UploadChangeParam) => {
|
const handleChange = async (info: UploadChangeParam) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
console.log(info)
|
||||||
if (info.file.status === 'done') {
|
if (info.file.status === 'done') {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
const result = info.file.response?.result;
|
const result = info.file.response?.result;
|
||||||
const f = result.accessUrl;
|
const f = result.accessUrl;
|
||||||
onlyMessage('上传成功!', 'success');
|
onlyMessage('上传成功!', 'success');
|
||||||
value.value = f;
|
value.value = f;
|
||||||
|
fileCache.value = info.fileList
|
||||||
emit('update:modelValue', result.version);
|
emit('update:modelValue', result.version);
|
||||||
emit('change', result);
|
emit('change', result);
|
||||||
} else {
|
} else {
|
||||||
if (info.file.error) {
|
if (info.file.error) {
|
||||||
|
list.value = fileCache.value
|
||||||
Notification.error({
|
Notification.error({
|
||||||
// key: '403',
|
// key: '403',
|
||||||
message: '系统提示',
|
message: '系统提示',
|
||||||
description: '系统未知错误,请反馈给管理员',
|
description: '系统未知错误,请反馈给管理员',
|
||||||
});
|
});
|
||||||
|
// emit('update:modelValue', { err:'file_upload_error'});
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
} else if (info.file.response) {
|
} else if (info.file.response) {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
Loading…
Reference in New Issue