fix: bug#16423
This commit is contained in:
parent
0f36d7fa60
commit
07d6499b03
|
@ -39,7 +39,7 @@
|
|||
<j-form-item
|
||||
label='文件'
|
||||
name='version'
|
||||
:rules='[{ required: true, message: "请上传文件" }]'
|
||||
:rules='versionRule'
|
||||
>
|
||||
<UploadFile v-model:modelValue='modelRef.version' @change='uploadChange' :fileName='data.filename' />
|
||||
</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>({
|
||||
id: props.data.id,
|
||||
name: props.data.name,
|
||||
|
|
|
@ -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<any>(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;
|
||||
|
|
Loading…
Reference in New Issue