--修复文件上传修改时旧文件

This commit is contained in:
2025-12-18 18:36:34 +08:00
parent cb1e366843
commit e9e901da24
7 changed files with 53 additions and 36 deletions

View File

@ -1,11 +1,16 @@
# 是否开启mock
VITE_USE_MOCK = true
VITE_USE_MOCK = false
#VITE_PROXY=[["/api","http://10.4.126.112:23000"]]
# 资源公共路径,需要以 / 开头和结尾
VITE_PUBLIC_PATH = /
# 是否开启history模式
VITE_ROUTE_MODE = hash
# 是否删除Console.log
VITE_DROP_CONSOLE = true

View File

@ -69,7 +69,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "vscode.html-language-features"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"

View File

@ -35,6 +35,8 @@
import { downloadByUrl } from '/@/utils/file/download';
import { uploadMultiApi } from '/@/api/sys/upload';
import Icon from '/@/components/Icon/index';
import { buildSnowFlakeId } from '/@/utils/uuid';
const uuid = buildSnowFlakeId();
const props = defineProps({
value: String,
@ -79,9 +81,9 @@
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
tableId.value = props.value || uuid;
tableName.value = props.tableName || '';
columnName.value = props.columnName || '';
}
}
@ -96,7 +98,7 @@
const refreshList = async (val:any) => {
if (val) {
fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value });
fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value||uuid });
if (fileList.value.length) {
fileList.value.forEach((x) => {
x.name = x.fileOrg;
@ -143,14 +145,16 @@
fileList.value.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮
x.thumbUrl = x.fileUrl;
x.name = x.fileOrg;
});
emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change');
if(tableIdValue==tableId.value){
await refreshList(tableId.value);
}
// if(tableIdValue==tableId.value){
// await refreshList(tableId.value);
// }
loading.value = false;
} catch (error) {
loading.value = false;

View File

@ -34,6 +34,9 @@
import { uploadMultiApi } from '/@/api/sys/upload';
import { Icon } from '/@/components/Icon';
import { buildSnowFlakeId } from '/@/utils/uuid';
const uuid = buildSnowFlakeId();
const props = defineProps({
value: String,
tableName: {
@ -62,9 +65,9 @@
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
tableId.value = props.value || uuid;
tableName.value = props.tableName || '';
columnName.value = props.columnName || '';
}
}
const deleteFlag = ref(false);
@ -77,7 +80,7 @@
const refreshList = async (val:any) => {
if (val) {
let result = await getFileList({tableName: props.tableName, columnName: props.columnName,tableId: props.value});
let result = await getFileList({tableName: props.tableName, columnName: props.columnName,tableId: props.value||uuid});
if (result.length) {
for (let i = 0; i < result.length; i++) {
let x = result[i];
@ -128,16 +131,15 @@
fileList.value = parseDownloadUrl(x.fileUrl,false,true);
}
bindValues(res[0]);
console.log(fileList.value, 'fileList.value1111111');
}
emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change');
if(tableIdValue==tableId.value){
if(tableIdValue==tableId.value){
await refreshList(tableId.value);
}
}
loading.value = false;
} catch (error) {
console.error(error);

View File

@ -48,6 +48,10 @@
import { Icon } from '/@/components/Icon';
import { Base64 } from 'js-base64';
import { getAppEnvConfig } from '/@/utils/env';
import { buildSnowFlakeId } from '/@/utils/uuid';
const uuid = buildSnowFlakeId();
const { VITE_GLOB_UPLOAD_ALERT_TIP } = getAppEnvConfig();
const props = defineProps({
value: String,
@ -79,9 +83,9 @@
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = '';
tableName.value = '';
columnName.value = '';
tableId.value = props.value || uuid;
tableName.value = props.tableName || '';
columnName.value = props.columnName || '';
}
}
@ -95,7 +99,7 @@
const refreshList = async (val:any) => {
if (val) {
fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value});
fileList.value = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value||uuid});
if (fileList.value.length) {
fileList.value.forEach((x) => {
x.name = x.fileOrg;
@ -139,18 +143,21 @@
tableId.value, tableName.value, columnName.value
);
const tableIdValue = tableId.value;
if(res==undefined) res = [];
bindValues(res[0]);
fileList.value = [...fileList.value, ...res];
fileList.value.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮
x.url = x.fileUrl;
x.thumbUrl = x.thUrl;
x.name = x.fileOrg;
});
name.value = res[0].fileOrg;
emit('update:value', tableId.value);
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change');
if(tableIdValue==tableId.value) await refreshList(tableId.value);
//if(tableIdValue==tableId.value) await refreshList(tableId.value);
loading.value = false;
} catch (error) {
console.error(error);
@ -181,9 +188,7 @@
}
const handleRemove = async (info) => {
const id = info.response ? info.response.data.id : info.id;
const status = await deleteSingleFile(id);
if (status) {
deleteFlag.value = true;
const index = fileList.value.findIndex((x) => x.id === id);

View File

@ -121,6 +121,7 @@
import { useRoute } from 'vue-router';
import { methodOf } from 'lodash-es';
import { buildSnowFlakeId } from '/@/utils/uuid';
const uuid = buildSnowFlakeId();
const route = useRoute();
const { VITE_GLOB_UPLOAD_ALERT_TIP } = getAppEnvConfig();
@ -189,7 +190,7 @@
tableName.value = data.tableName;
columnName.value = data.columnName;
}else{
tableId.value = props.value || buildSnowFlakeId();
tableId.value = props.value || uuid;
tableName.value = props.tableName || '';
columnName.value = props.columnName || '';
}
@ -219,7 +220,7 @@
}
bindValues(fileList.value[0]);
} else {
bindValues(undefined);
bindValues(undefined);
}
if (!val) {
fileList.value = [];
@ -234,7 +235,7 @@
const refreshList = async (val:any) => {
if (val) {
if (props.dataDelete) return
let _list = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value });
let _list = await getFileList({ tableName: props.tableName, columnName: props.columnName,tableId: props.value||uuid });
fileList.value = _list.filter((o) => !removeIds.value.includes(o.id));
if (fileList.value.length) {
fileList.value.forEach((x) => {
@ -274,20 +275,19 @@
if (arr.length <= 0) return;
try {
let res = await uploadMultiApi(
{
name: 'file',
file: arr
},
{ name: 'file',file: arr},
tableId.value, tableName.value, columnName.value
);
fileList.value.forEach((x) => {
x.status = 'done'; //没有则不会展示下载按钮
x.fileSize = x.fileSize
x.name = x.fileOrg;
x.url = x.fileUrl;
x.thumbUrl = x.thUrl;
x.fileSize = x.fileSize
});
let tableIdValue = tableId.value;
// let tableIdValue = tableId.value;
bindValues(res[0]);
if (props.dataDelete) {
let fileArr = res||[]
@ -303,9 +303,9 @@
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change', fileList.value);
if(tableIdValue==tableId.value){
await refreshList(tableId.value);
}
// if(tableIdValue==tableId.value){
// await refreshList(tableId.value);
// }
loading.value = false;
} catch (error) {
console.error(error);
@ -365,7 +365,7 @@
emit('update:tableName', tableName.value);
emit('update:columnName', columnName.value);
emit('change', fileList.value);
await refreshList(tableId.value);
//await refreshList(tableId.value);
notification.success({
message: 'Tip',
description: '删除成功!'

View File

@ -28,6 +28,7 @@
import { parseDownloadUrl} from '/@/api/system/file';
import { downloadByUrl } from '/@/utils/file/download';
import { nextTick, ref, watch, computed } from 'vue';
const dataFile = ref([]);
const { t } = useI18n();
const columns = ref([