feat: 优化插件编辑上传回显文件名
This commit is contained in:
parent
a1982f1538
commit
3039b1e42d
|
@ -25,6 +25,7 @@
|
|||
modelRef?.file?.fileType ? `.${modelRef?.file?.fileType}` : '.xlsx'
|
||||
"
|
||||
:before-upload="beforeUpload"
|
||||
:disabled='disabled'
|
||||
>
|
||||
<j-button style='width: 760px;'>
|
||||
<template #icon><AIcon type="UploadOutlined" /></template>
|
||||
|
@ -80,6 +81,7 @@ const importLoading = ref<boolean>(false);
|
|||
const flag = ref<boolean>(false);
|
||||
const count = ref<number>(0);
|
||||
const errMessage = ref<string>('');
|
||||
const disabled = ref(false)
|
||||
|
||||
const downFile = async (type: string) => {
|
||||
const res: any = await templateDownload(props.product!, type);
|
||||
|
@ -107,7 +109,6 @@ const submitData = async (fileUrl: string) => {
|
|||
if (!!fileUrl) {
|
||||
count.value = 0;
|
||||
errMessage.value = '';
|
||||
flag.value = true;
|
||||
const autoDeploy = !!modelRef?.file?.autoDeploy || false;
|
||||
importLoading.value = true;
|
||||
let dt = 0;
|
||||
|
@ -123,10 +124,12 @@ const submitData = async (fileUrl: string) => {
|
|||
} else {
|
||||
errMessage.value = res.message || '失败';
|
||||
}
|
||||
disabled.value = false
|
||||
};
|
||||
source.onerror = (e: { status: number }) => {
|
||||
if (e.status === 403) errMessage.value = '暂无权限,请联系管理员';
|
||||
flag.value = false;
|
||||
disabled.value = false
|
||||
source.close();
|
||||
};
|
||||
source.onopen = () => {};
|
||||
|
@ -136,6 +139,8 @@ const submitData = async (fileUrl: string) => {
|
|||
};
|
||||
|
||||
const uploadChange = async (info: Record<string, any>) => {
|
||||
disabled.value = true
|
||||
console.log(info.file)
|
||||
if (info.file.status === 'done') {
|
||||
const resp: any = info.file.response || { result: '' };
|
||||
await submitData(resp?.result || '');
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
name='version'
|
||||
:rules='[{ required: true, message: "请上传文件" }]'
|
||||
>
|
||||
<UploadFile v-model:modelValue='modelRef.version' @change='uploadChange' />
|
||||
<UploadFile v-model:modelValue='modelRef.version' @change='uploadChange' :fileName='data.filename' />
|
||||
</j-form-item>
|
||||
<div v-if='modelRef.version' class='file-detail'>
|
||||
<div>
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
:before-upload="beforeUpload"
|
||||
:disabled='loading'
|
||||
:maxCount='1'
|
||||
:fileList='list'
|
||||
@remove='remove'
|
||||
>
|
||||
<div>
|
||||
<j-button>上传文件</j-button>
|
||||
|
@ -39,6 +41,10 @@ const props = defineProps({
|
|||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
fileName: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -47,9 +53,17 @@ const paths: string = useSystem().$state.configInfo.paths?.[
|
|||
] as string;
|
||||
|
||||
const value = ref(props.modelValue);
|
||||
const list = ref<any>(props.fileName ? [{ name: props.fileName}] : [])
|
||||
const loading = ref(false);
|
||||
|
||||
const remove = () => {
|
||||
list.value = []
|
||||
emit('update:modelValue', '');
|
||||
emit('change', {});
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -62,7 +76,6 @@ const handleChange = async (info: UploadChangeParam) => {
|
|||
loading.value = true;
|
||||
if (info.file.status === 'done') {
|
||||
loading.value = false;
|
||||
console.log(info.file)
|
||||
const result = info.file.response?.result;
|
||||
const f = result.accessUrl;
|
||||
onlyMessage('上传成功!', 'success');
|
||||
|
|
Loading…
Reference in New Issue