feat: 回收站文件支持批量还原 (#5497)

Refs #5148
pull/5500/head
John Bro 5 months ago committed by GitHub
parent f17db1d6d5
commit 4c59090180
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1171,6 +1171,8 @@ const message = {
recycleBin: 'Recycle bin',
sourcePath: 'Original path',
deleteTime: 'Delete time',
confirmReduce: 'Are you sure you want to restore the following files?',
reduceSuccess: 'Restore successful',
reduce: 'Reduction',
reduceHelper:
'If a file or directory with the same name exists in the original path, it will be overwritten. Do you want to continue?',

@ -1111,6 +1111,8 @@ const message = {
recycleBin: '',
sourcePath: '',
deleteTime: '',
confirmReduce: '',
reduceSuccess: '',
reduce: '',
reduceHelper: '',
clearRecycleBin: '',

@ -1114,6 +1114,8 @@ const message = {
sourcePath: '',
deleteTime: '',
reduce: '',
confirmReduce: '',
reduceSuccess: '',
reduceHelper: '',
clearRecycleBin: '',
clearRecycleBinHelper: '',

@ -16,6 +16,9 @@
<el-button @click="patchDelete" :disabled="data == null || selects.length == 0">
{{ $t('commons.button.delete') }}
</el-button>
<el-button @click="patchReduce" :disabled="data == null || selects.length == 0">
{{ $t('file.reduce') }}
</el-button>
<el-form-item :label="$t('file.fileRecycleBin')">
<el-switch v-model="status" active-value="enable" inactive-value="disable" @change="changeStatus" />
</el-form-item>
@ -53,6 +56,7 @@
<fu-table-operations :buttons="buttons" :label="$t('commons.table.operate')" fix />
</ComplexTable>
<Delete ref="deleteRef" @close="search" />
<Reduce ref="reduceRef" @close="search" />
</el-drawer>
</template>
@ -62,6 +66,7 @@ import { reactive, ref } from 'vue';
import { dateFormat, computeSize } from '@/utils/util';
import i18n from '@/lang';
import Delete from './delete/index.vue';
import Reduce from './reduce/index.vue';
import { updateSetting } from '@/api/modules/setting';
import { MsgSuccess } from '@/utils/message';
@ -85,6 +90,7 @@ const paginationConfig = reactive({
});
const deleteRef = ref();
const reduceRef = ref();
const handleClose = () => {
open.value = false;
@ -138,6 +144,11 @@ const patchDelete = () => {
deleteRef.value.acceptParams(files.value);
};
const patchReduce = () => {
files.value = selects.value;
reduceRef.value.acceptParams(files.value);
};
const rdFile = async (row: any) => {
ElMessageBox.confirm(i18n.global.t('file.reduceHelper'), i18n.global.t('file.reduce'), {
confirmButtonText: i18n.global.t('commons.button.confirm'),

@ -0,0 +1,73 @@
<template>
<el-dialog v-model="open" :title="$t('file.reduce')" width="30%" :close-on-click-modal="false">
<el-row>
<el-col :span="20" :offset="2">
<el-alert :title="$t('file.confirmReduce')" show-icon type="error" :closable="false"></el-alert>
<div class="flx-align-center mb-1 mt-1" v-for="(row, index) in files" :key="index">
<div>
<svg-icon v-if="row.isDir" className="table-icon mr-1 " iconName="p-file-folder"></svg-icon>
<svg-icon v-else className="table-icon mr-1" :iconName="getIconName(row.extension)"></svg-icon>
</div>
<span class="sle">{{ row.name }}</span>
</div>
</el-col>
</el-row>
<template #footer>
<span class="dialog-footer">
<el-button @click="open = false" :disabled="loading">
{{ $t('commons.button.cancel') }}
</el-button>
<el-button type="primary" @click="onConfirm" v-loading="loading">
{{ $t('commons.button.confirm') }}
</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { getIcon } from '@/utils/util';
import { reduceFile } from '@/api/modules/files';
import { MsgSuccess } from '@/utils/message';
import i18n from '@/lang';
import { File } from '@/api/interface/file';
const open = ref(false);
const em = defineEmits(['close']);
const files = ref();
const loading = ref(false);
const forceDelete = ref(false);
const acceptParams = (props: File.RecycleBin[]) => {
files.value = props;
open.value = true;
forceDelete.value = false;
};
const onConfirm = () => {
const pros = [];
for (const s of files.value) {
pros.push(reduceFile({ from: s.from, rName: s.rName, name: s.name }));
}
loading.value = true;
Promise.all(pros)
.then(() => {
MsgSuccess(i18n.global.t('file.reduceSuccess'));
open.value = false;
em('close');
})
.finally(() => {
loading.value = false;
});
};
const getIconName = (extension: string) => {
return getIcon(extension);
};
defineExpose({
acceptParams,
});
</script>
Loading…
Cancel
Save