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