2024-10-09 16:45:34 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onMounted, ref } from 'vue';
|
2025-04-24 13:43:37 +08:00
|
|
|
import {
|
|
|
|
auth,
|
|
|
|
columns,
|
|
|
|
onAdd,
|
|
|
|
onDelete,
|
|
|
|
onDeleteBatch,
|
|
|
|
onDownload,
|
|
|
|
onDownloadBatch,
|
|
|
|
onSearch,
|
|
|
|
onUpdate,
|
|
|
|
selectRows,
|
|
|
|
} from '@/views/system/files/utils';
|
2024-10-09 16:45:34 +08:00
|
|
|
import PureTableBar from '@/components/TableBar/src/bar';
|
|
|
|
import AddFill from '@iconify-icons/ri/add-circle-line';
|
|
|
|
import PureTable from '@pureadmin/table';
|
|
|
|
import Delete from '@iconify-icons/ep/delete';
|
2024-10-13 02:41:56 +08:00
|
|
|
import Download from '@iconify-icons/ep/download';
|
2024-10-09 16:45:34 +08:00
|
|
|
import EditPen from '@iconify-icons/ep/edit-pen';
|
|
|
|
import Refresh from '@iconify-icons/ep/refresh';
|
|
|
|
import { selectUserinfo } from '@/components/Table/Userinfo/columns';
|
|
|
|
import { $t } from '@/plugins/i18n';
|
2024-10-12 16:57:13 +08:00
|
|
|
import { useFilesStore } from '@/store/monitor/files';
|
2025-04-25 16:21:15 +08:00
|
|
|
import { useRenderIcon } from '@/components/ReIcon/src/hooks';
|
2024-10-11 10:44:16 +08:00
|
|
|
import { FormInstance } from 'element-plus';
|
2024-11-05 02:07:20 +08:00
|
|
|
import { hasAuth } from '@/router/utils';
|
2025-04-25 16:21:15 +08:00
|
|
|
import ReAuth from '@/components/ReAuth/src/auth';
|
2024-10-09 16:45:34 +08:00
|
|
|
|
2025-04-26 08:57:23 +08:00
|
|
|
defineOptions({ name: 'FileManger' });
|
|
|
|
|
2024-10-09 16:45:34 +08:00
|
|
|
const tableRef = ref();
|
|
|
|
const formRef = ref();
|
|
|
|
const filesStore = useFilesStore();
|
|
|
|
|
2024-10-12 16:57:13 +08:00
|
|
|
/** 当前页改变时 */
|
2024-10-09 16:45:34 +08:00
|
|
|
const onCurrentPageChange = async (value: number) => {
|
2025-04-24 13:43:37 +08:00
|
|
|
filesStore.pagination.currentPage = value;
|
|
|
|
await onSearch();
|
2024-10-09 16:45:34 +08:00
|
|
|
};
|
|
|
|
|
2024-10-12 16:57:13 +08:00
|
|
|
/** 当分页发生变化 */
|
2024-10-09 16:45:34 +08:00
|
|
|
const onPageSizeChange = async (value: number) => {
|
2025-04-24 13:43:37 +08:00
|
|
|
filesStore.pagination.pageSize = value;
|
|
|
|
await onSearch();
|
2024-10-09 16:45:34 +08:00
|
|
|
};
|
|
|
|
|
2024-10-12 16:57:13 +08:00
|
|
|
/** 重置表单 */
|
2024-10-11 10:44:16 +08:00
|
|
|
const resetForm = async (formEl: FormInstance) => {
|
2025-04-24 13:43:37 +08:00
|
|
|
if (!formEl) return;
|
|
|
|
formEl.resetFields();
|
|
|
|
await onSearch();
|
2024-10-09 16:45:34 +08:00
|
|
|
};
|
|
|
|
|
2024-10-12 16:57:13 +08:00
|
|
|
/** 选择多行 */
|
|
|
|
const onSelectionChange = (rows: Array<any>) => {
|
2025-04-24 13:43:37 +08:00
|
|
|
selectRows.value = rows;
|
2024-10-12 16:57:13 +08:00
|
|
|
};
|
|
|
|
|
2024-10-09 16:45:34 +08:00
|
|
|
onMounted(() => {
|
2025-04-24 13:43:37 +08:00
|
|
|
onSearch();
|
2024-10-09 16:45:34 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2025-04-24 13:43:37 +08:00
|
|
|
<div class="main">
|
2025-04-27 22:16:06 +08:00
|
|
|
<ReAuth :value="auth.query">
|
2025-04-24 13:43:37 +08:00
|
|
|
<el-form
|
|
|
|
ref="formRef"
|
|
|
|
:inline="true"
|
|
|
|
:model="filesStore.form"
|
|
|
|
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto"
|
|
|
|
>
|
|
|
|
<el-form-item :label="$t('files_filename')" prop="filename">
|
|
|
|
<el-input
|
|
|
|
v-model="filesStore.form.filename"
|
|
|
|
:placeholder="`${$t('input')}${$t('files_filename')}`"
|
|
|
|
class="!w-[180px]"
|
|
|
|
clearable
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('files_filepath')" prop="filepath">
|
|
|
|
<el-input
|
|
|
|
v-model="filesStore.form.filepath"
|
|
|
|
:placeholder="`${$t('input')}${$t('files_filepath')}`"
|
|
|
|
class="!w-[180px]"
|
|
|
|
clearable
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('files_fileType')" prop="fileType">
|
|
|
|
<el-input
|
|
|
|
v-model="filesStore.form.fileType"
|
|
|
|
:placeholder="`${$t('input')}${$t('files_fileType')}`"
|
|
|
|
class="!w-[180px]"
|
|
|
|
clearable
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="$t('files_downloadCount')" prop="downloadCount">
|
|
|
|
<el-input
|
|
|
|
v-model="filesStore.form.downloadCount"
|
|
|
|
:placeholder="`${$t('input')}${$t('files_downloadCount')}`"
|
|
|
|
class="!w-[180px]"
|
|
|
|
clearable
|
|
|
|
min="0"
|
|
|
|
type="number"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
|
|
<el-button
|
|
|
|
:icon="useRenderIcon('ri:search-line')"
|
|
|
|
:loading="filesStore.loading"
|
|
|
|
type="primary"
|
|
|
|
@click="onSearch"
|
|
|
|
>
|
|
|
|
{{ $t('search') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">{{ $t('buttons.reset') }}</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
2025-04-25 16:21:15 +08:00
|
|
|
</ReAuth>
|
2024-10-09 16:45:34 +08:00
|
|
|
|
2025-04-24 13:43:37 +08:00
|
|
|
<PureTableBar
|
|
|
|
:columns="columns"
|
|
|
|
:title="$t('system_file')"
|
|
|
|
@fullscreen="tableRef.setAdaptive()"
|
|
|
|
@refresh="onSearch"
|
|
|
|
>
|
|
|
|
<template #buttons>
|
2025-04-25 16:21:15 +08:00
|
|
|
<el-button v-if="hasAuth(auth.add)" :icon="useRenderIcon(AddFill)" plain type="primary" @click="onAdd">
|
2025-04-24 13:43:37 +08:00
|
|
|
{{ $t('addNew') }}
|
|
|
|
</el-button>
|
2024-10-12 16:57:13 +08:00
|
|
|
|
2025-04-24 13:43:37 +08:00
|
|
|
<!-- 批量下载 -->
|
|
|
|
<el-button
|
2025-04-27 22:16:06 +08:00
|
|
|
v-if="hasAuth(auth.download)"
|
2025-04-24 13:43:37 +08:00
|
|
|
:disabled="!(selectRows.length > 0)"
|
|
|
|
:icon="useRenderIcon(Download)"
|
2025-04-25 16:21:15 +08:00
|
|
|
plain
|
2025-04-24 13:43:37 +08:00
|
|
|
type="success"
|
|
|
|
@click="onDownloadBatch"
|
|
|
|
>
|
|
|
|
{{ $t('download_batch') }}
|
|
|
|
</el-button>
|
2024-10-13 02:41:56 +08:00
|
|
|
|
2025-04-24 13:43:37 +08:00
|
|
|
<!-- 批量删除按钮 -->
|
|
|
|
<el-button
|
2025-04-27 22:16:06 +08:00
|
|
|
v-if="hasAuth(auth.delete)"
|
2025-04-24 13:43:37 +08:00
|
|
|
:disabled="!(selectRows.length > 0)"
|
|
|
|
:icon="useRenderIcon(Delete)"
|
2025-04-25 16:21:15 +08:00
|
|
|
plain
|
2025-04-24 13:43:37 +08:00
|
|
|
type="danger"
|
|
|
|
@click="onDeleteBatch"
|
|
|
|
>
|
|
|
|
{{ $t('deleteBatches') }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
2024-10-09 16:45:34 +08:00
|
|
|
|
2025-04-24 13:43:37 +08:00
|
|
|
<template v-slot="{ size, dynamicColumns }">
|
|
|
|
<pure-table
|
|
|
|
ref="tableRef"
|
|
|
|
:adaptiveConfig="{ offsetBottom: 96 }"
|
|
|
|
:columns="dynamicColumns"
|
|
|
|
:data="filesStore.datalist"
|
|
|
|
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
|
|
|
:loading="filesStore.loading"
|
|
|
|
:pagination="filesStore.pagination"
|
|
|
|
:size="size"
|
|
|
|
adaptive
|
|
|
|
align-whole="center"
|
|
|
|
border
|
|
|
|
highlight-current-row
|
|
|
|
row-key="id"
|
|
|
|
showOverflowTooltip
|
|
|
|
table-layout="auto"
|
|
|
|
@page-size-change="onPageSizeChange"
|
|
|
|
@selection-change="onSelectionChange"
|
|
|
|
@page-current-change="onCurrentPageChange"
|
|
|
|
>
|
|
|
|
<template #createUser="{ row }">
|
|
|
|
<el-button v-show="row.createUser" link type="primary" @click="selectUserinfo(row.createUser)">
|
|
|
|
{{ row.createUsername }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
2024-10-09 16:45:34 +08:00
|
|
|
|
2025-04-24 13:43:37 +08:00
|
|
|
<template #updateUser="{ row }">
|
|
|
|
<el-button v-show="row.updateUser" link type="primary" @click="selectUserinfo(row.updateUser)">
|
|
|
|
{{ row.updateUsername }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
2024-10-09 16:45:34 +08:00
|
|
|
|
2025-04-24 13:43:37 +08:00
|
|
|
<template #operation="{ row }">
|
|
|
|
<el-button
|
|
|
|
v-if="hasAuth(auth.update)"
|
|
|
|
:icon="useRenderIcon(EditPen)"
|
|
|
|
:size="size"
|
|
|
|
class="reset-margin"
|
|
|
|
link
|
|
|
|
type="primary"
|
|
|
|
@click="onUpdate(row)"
|
|
|
|
>
|
|
|
|
{{ $t('modify') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button
|
2025-04-27 22:16:06 +08:00
|
|
|
v-if="hasAuth(auth.download)"
|
2025-04-24 13:43:37 +08:00
|
|
|
:icon="useRenderIcon(EditPen)"
|
|
|
|
:size="size"
|
|
|
|
class="reset-margin"
|
|
|
|
link
|
|
|
|
type="primary"
|
|
|
|
@click="onDownload(row)"
|
|
|
|
>
|
|
|
|
{{ $t('download') }}
|
|
|
|
</el-button>
|
|
|
|
<el-popconfirm
|
2025-04-27 22:16:06 +08:00
|
|
|
v-if="hasAuth(auth.delete)"
|
2025-04-24 13:43:37 +08:00
|
|
|
:title="`${$t('delete')} ${row.filename}?`"
|
|
|
|
@confirm="onDelete(row)"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
|
|
|
{{ $t('delete') }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
</el-popconfirm>
|
|
|
|
</template>
|
|
|
|
</pure-table>
|
|
|
|
</template>
|
|
|
|
</PureTableBar>
|
|
|
|
</div>
|
2024-10-09 16:45:34 +08:00
|
|
|
</template>
|