修改文件上传为多个

This commit is contained in:
miao 2023-02-13 14:13:44 +08:00 committed by fangxiang
parent c35ff719c6
commit e4827b4fe6
1 changed files with 121 additions and 117 deletions

View File

@ -346,6 +346,7 @@
style="height: 69vh; width: 70%" style="height: 69vh; width: 70%"
:disable="uploader_loading" :disable="uploader_loading"
:url="getUrl" :url="getUrl"
multiple
method="post" method="post"
:headers="generatorFileUploadHeaders" :headers="generatorFileUploadHeaders"
:label="$t('select file') + ':'" :label="$t('select file') + ':'"
@ -687,7 +688,6 @@ export default defineComponent({
loading.value = false; loading.value = false;
}; };
const refresh_file_list_async = async () => { const refresh_file_list_async = async () => {
const response = await _request_list_files(path.value); const response = await _request_list_files(path.value);
_show_files(response); _show_files(response);
@ -912,67 +912,34 @@ export default defineComponent({
resolve_value = null; resolve_value = null;
}, },
async onCreateNewFolder() { async onCreateNewFolder() {
$q.dialog({ $q.dialog({
title: $t.t("create folder"), title: $t.t("create folder"),
message: $t.t("input folder name") + ":", message: $t.t("input folder name") + ":",
prompt: { prompt: {
model: "", model: "",
isValid: (val: string) => !!val && val.trim().length > 0, isValid: (val: string) => !!val && val.trim().length > 0,
type: "text", type: "text",
}, },
ok: { ok: {
label: $t.t("ok"), label: $t.t("ok"),
noCaps: true, noCaps: true,
flat: true, flat: true,
}, },
cancel: { cancel: {
label: $t.t("cancel"), label: $t.t("cancel"),
noCaps: true, noCaps: true,
flat: true, flat: true,
}, },
persistent: true, persistent: true,
}).onOk(async (data: string) => { }).onOk(async (data: string) => {
const response = await GlobalData.getInstance() const response = await GlobalData.getInstance()
.getCurrentClient() .getCurrentClient()
?.CreateDirectoryFileManager(path.value, data); ?.CreateDirectoryFileManager(path.value, data);
if (response && response.success) {
refresh_file_list();
$q.notify({
type: "positive",
message: $t.t("create folder") + $t.t("success") + "!",
position: "top",
timeout: 1500,
});
} else {
$q.notify({
type: "warning",
message:
$t.t("create folder") +
$t.t("fail") +
"!" +
(response ? response.error_message : ""),
position: "top",
timeout: 1500,
});
}
});
},
selectFile,
async deleteFile(file: FileEntity) {
let response = null;
try {
response = await GlobalData.getInstance()
.getCurrentClient()
?.DeleteFileManager(path.value, file.name);
} catch (e) {
console.log(e);
}
if (response && response.success) { if (response && response.success) {
refresh_file_list(); refresh_file_list();
$q.notify({ $q.notify({
type: "positive", type: "positive",
message: $t.t("delete file") + $t.t("success") + "!", message: $t.t("create folder") + $t.t("success") + "!",
position: "top", position: "top",
timeout: 1500, timeout: 1500,
}); });
@ -980,7 +947,7 @@ export default defineComponent({
$q.notify({ $q.notify({
type: "warning", type: "warning",
message: message:
$t.t("delete file") + $t.t("create folder") +
$t.t("fail") + $t.t("fail") +
"!" + "!" +
(response ? response.error_message : ""), (response ? response.error_message : ""),
@ -988,55 +955,88 @@ export default defineComponent({
timeout: 1500, timeout: 1500,
}); });
} }
});
},
selectFile,
async deleteFile(file: FileEntity) {
let response = null;
try {
response = await GlobalData.getInstance()
.getCurrentClient()
?.DeleteFileManager(path.value, file.name);
} catch (e) {
console.log(e);
}
if (response && response.success) {
refresh_file_list();
$q.notify({
type: "positive",
message: $t.t("delete file") + $t.t("success") + "!",
position: "top",
timeout: 1500,
});
} else {
$q.notify({
type: "warning",
message:
$t.t("delete file") +
$t.t("fail") +
"!" +
(response ? response.error_message : ""),
position: "top",
timeout: 1500,
});
}
}, },
renameFile(file: FileEntity) { renameFile(file: FileEntity) {
$q.dialog({ $q.dialog({
title: $t.t("rename"), title: $t.t("rename"),
message: $t.t("input new file name") + ":", message: $t.t("input new file name") + ":",
prompt: { prompt: {
model: file.name, model: file.name,
isValid: (val: string) => !!val && val.trim().length > 0, isValid: (val: string) => !!val && val.trim().length > 0,
type: "text", type: "text",
}, },
ok: { ok: {
label: $t.t("ok"), label: $t.t("ok"),
noCaps: true, noCaps: true,
flat: true, flat: true,
}, },
cancel: { cancel: {
label: $t.t("cancel"), label: $t.t("cancel"),
noCaps: true, noCaps: true,
flat: true, flat: true,
}, },
persistent: true, persistent: true,
}).onOk(async (data: string) => { }).onOk(async (data: string) => {
if (data == file.name) { if (data == file.name) {
return; return;
} }
let response = await GlobalData.getInstance() let response = await GlobalData.getInstance()
.getCurrentClient() .getCurrentClient()
?.RenameFileManager(path.value, file.name, data); ?.RenameFileManager(path.value, file.name, data);
if (response && response.success) { if (response && response.success) {
refresh_file_list(); refresh_file_list();
$q.notify({ $q.notify({
type: "positive", type: "positive",
message: $t.t("file rename") + $t.t("success") + "!", message: $t.t("file rename") + $t.t("success") + "!",
position: "top", position: "top",
timeout: 1500, timeout: 1500,
}); });
} else { } else {
$q.notify({ $q.notify({
type: "warning", type: "warning",
message: message:
$t.t("file rename") + $t.t("file rename") +
$t.t("fail") + $t.t("fail") +
"!" + "!" +
(response ? response.error_message : ""), (response ? response.error_message : ""),
position: "top", position: "top",
timeout: 1500, timeout: 1500,
}); });
} }
}); });
}, },
copyStringToClipboard(value: string) { copyStringToClipboard(value: string) {
copyToClipboard(value); copyToClipboard(value);
@ -1148,7 +1148,7 @@ export default defineComponent({
} }
}, 1); }, 1);
}, },
onUploaded() { onUploaded(info: any) {
uploading.value = false; uploading.value = false;
uploader.value.reset(); uploader.value.reset();
refresh_file_list(); refresh_file_list();
@ -1161,16 +1161,20 @@ export default defineComponent({
}); });
loading.value = false; loading.value = false;
}, },
onFailed(info: any) { async onFailed(info: any) {
console.log(info); let file_list: any = await _request_list_files(path.value);
$q.notify({ setTimeout(() => {
type: "warning", if (files.value.length != file_list.files.length) {
message: $t.t("file upload") + $t.t("fail") + "!", $q.notify({
position: "top", type: "warning",
timeout: 1500, message: $t.t("file upload") + $t.t("fail") + "!",
}); position: "top",
loading.value = false; timeout: 1500,
loading.value = false; });
loading.value = false;
}
}, 500);
}, },
copyFile(file: FileEntity) { copyFile(file: FileEntity) {
if (file) { if (file) {