文件存储添加分组功能

This commit is contained in:
huangge1199 2024-09-02 09:20:25 +08:00
parent b3c36e27cf
commit a0748feb3f
2 changed files with 147 additions and 62 deletions

View File

@ -24,3 +24,12 @@ export function delOss(ossId) {
method: 'delete' method: 'delete'
}); });
} }
// 修改OSS对象存储
export function editOss(params) {
return request({
url: '/resource/oss/update',
method: 'get',
params: params
});
}

View File

@ -4,13 +4,16 @@
<el-card shadow="hover"> <el-card shadow="hover">
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
<el-form-item label="文件名" prop="fileName"> <el-form-item label="文件名" prop="fileName">
<el-input v-model="queryParams.fileName" placeholder="请输入文件名" clearable style="width: 200px" @keyup.enter="handleQuery" /> <el-input v-model="queryParams.fileName" placeholder="请输入文件名" clearable style="width: 200px"
@keyup.enter="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="原名" prop="originalName"> <el-form-item label="原名" prop="originalName">
<el-input v-model="queryParams.originalName" placeholder="请输入原名" clearable style="width: 200px" @keyup.enter="handleQuery" /> <el-input v-model="queryParams.originalName" placeholder="请输入原名" clearable style="width: 200px"
@keyup.enter="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="文件后缀" prop="fileSuffix"> <el-form-item label="文件后缀" prop="fileSuffix">
<el-input v-model="queryParams.fileSuffix" placeholder="请输入文件后缀" clearable style="width: 200px" @keyup.enter="handleQuery" /> <el-input v-model="queryParams.fileSuffix" placeholder="请输入文件后缀" clearable style="width: 200px"
@keyup.enter="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="创建时间">
<el-date-picker <el-date-picker
@ -24,7 +27,8 @@
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="服务商" prop="service"> <el-form-item label="服务商" prop="service">
<el-input v-model="queryParams.service" placeholder="请输入服务商" clearable style="width: 200px" @keyup.enter="handleQuery" /> <el-input v-model="queryParams.service" placeholder="请输入服务商" clearable style="width: 200px"
@keyup.enter="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="search" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
@ -38,13 +42,18 @@
<template #header> <template #header>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Upload" @click="handleFile" v-hasPermi="['system:oss:upload']">上传文件</el-button> <el-button type="primary" plain icon="Upload" @click="handleFile" v-hasPermi="['system:oss:upload']">
上传文件
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Upload" @click="handleImage" v-hasPermi="['system:oss:upload']">上传图片</el-button> <el-button type="primary" plain icon="Upload" @click="handleImage" v-hasPermi="['system:oss:upload']">
上传图片
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:oss:remove']"> <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"
v-hasPermi="['system:oss:remove']">
删除 删除
</el-button> </el-button>
</el-col> </el-col>
@ -56,11 +65,15 @@
v-hasPermi="['system:oss:edit']" v-hasPermi="['system:oss:edit']"
>预览开关 : >预览开关 :
{{ {{
previewListResource ? "禁用" : "启用" }}</el-button previewListResource ? "禁用" : "启用"
}}
</el-button
> >
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="info" plain icon="Operation" @click="handleOssConfig" v-hasPermi="['system:oss:list']">配置管理</el-button> <el-button type="info" plain icon="Operation" @click="handleOssConfig" v-hasPermi="['system:oss:list']">
配置管理
</el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -79,6 +92,31 @@
<el-table-column label="文件名" align="center" prop="fileName"/> <el-table-column label="文件名" align="center" prop="fileName"/>
<el-table-column label="原名" align="center" prop="originalName"/> <el-table-column label="原名" align="center" prop="originalName"/>
<el-table-column label="文件后缀" align="center" prop="fileSuffix"/> <el-table-column label="文件后缀" align="center" prop="fileSuffix"/>
<el-table-column label="分组" align="center" prop="team">
<template #default="scope">
<span v-if="scope.row.isEdit===true">
<el-select
v-model="oss.team"
filterable
allow-create
default-first-option
:reserve-keyword="false"
placeholder="请选择分组"
@change="changeTeam(scope.row)"
>
<el-option
v-for="item in teamList"
:key="item"
:label="item"
:value="item"
/>
</el-select>
</span>
<span v-else>{{ scope.row.team }}
<el-button :icon="Edit" type="primary" link @click="onClick(scope.row)"/>
</span>
</template>
</el-table-column>
<el-table-column label="文件展示" align="center" prop="url"> <el-table-column label="文件展示" align="center" prop="url">
<template #default="scope"> <template #default="scope">
<ImagePreview <ImagePreview
@ -101,16 +139,19 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip content="下载" placement="top"> <el-tooltip content="下载" placement="top">
<el-button link type="primary" icon="Download" @click="handleDownload(scope.row)" v-hasPermi="['system:oss:download']"></el-button> <el-button link type="primary" icon="Download" @click="handleDownload(scope.row)"
v-hasPermi="['system:oss:download']"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:oss:remove']"></el-button> <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['system:oss:remove']"></el-button>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList"/>
</el-card> </el-card>
<!-- 添加或修改OSS对象存储对话框 --> <!-- 添加或修改OSS对象存储对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
@ -131,9 +172,10 @@
</template> </template>
<script setup name="Oss"> <script setup name="Oss">
import { listOss, delOss } from "@/api/system/oss"; import {listOss, delOss, editOss} from "@/api/system/oss";
import ImagePreview from "@/components/ImagePreview/index.vue"; import ImagePreview from "@/components/ImagePreview/index.vue";
import {getConfigKey, updateConfigByKey} from "@/api/system/config"; import {getConfigKey, updateConfigByKey} from "@/api/system/config";
import {Edit} from "@element-plus/icons-vue";
const router = useRouter(); const router = useRouter();
const {proxy} = getCurrentInstance(); const {proxy} = getCurrentInstance();
@ -150,6 +192,8 @@ const total = ref(0);
const type = ref(0); const type = ref(0);
const previewListResource = ref(true); const previewListResource = ref(true);
const dateRangeCreateTime = ref(['', '']); const dateRangeCreateTime = ref(['', '']);
const teamList = ref([]);
const oss = ref({});
const dialog = reactive({ const dialog = reactive({
visible: false, visible: false,
@ -192,31 +236,43 @@ const getList = async () => {
previewListResource.value = res?.data === undefined ? true : res.data === "true"; previewListResource.value = res?.data === undefined ? true : res.data === "true";
const response = await listOss(proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, "CreateTime")); const response = await listOss(proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, "CreateTime"));
ossList.value = response.rows; ossList.value = response.rows;
teamList.value = []
ossList.value.forEach((item, index) => {
item.isEdit = false;
if (!teamList.value.includes(item.team)) {
teamList.value.push(item.team)
}
})
total.value = response.total; total.value = response.total;
loading.value = false; loading.value = false;
showTable.value = true; showTable.value = true;
} }
function checkFileSuffix(fileSuffix) { function checkFileSuffix(fileSuffix) {
let arr = ["png", "jpg", "jpeg"]; let arr = ["png", "jpg", "jpeg"];
return arr.some(type => { return arr.some(type => {
return fileSuffix.indexOf(type) > -1; return fileSuffix.indexOf(type) > -1;
}); });
} }
/** 取消按钮 */ /** 取消按钮 */
function cancel() { function cancel() {
dialog.visible = false; dialog.visible = false;
reset(); reset();
} }
/** 表单重置 */ /** 表单重置 */
function reset() { function reset() {
form.value = {...initFormData}; form.value = {...initFormData};
proxy.resetForm("ossFormRef"); proxy.resetForm("ossFormRef");
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
function handleQuery() { function handleQuery() {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
function resetQuery() { function resetQuery() {
showTable.value = false; showTable.value = false;
@ -226,12 +282,14 @@ function resetQuery() {
queryParams.value.isAsc = defaultSort.value.order; queryParams.value.isAsc = defaultSort.value.order;
handleQuery(); handleQuery();
} }
/** 选择条数 */ /** 选择条数 */
function handleSelectionChange(selection) { function handleSelectionChange(selection) {
ids.value = selection.map(item => item.ossId); ids.value = selection.map(item => item.ossId);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
} }
/** 设置列的排序为我们自定义的排序 */ /** 设置列的排序为我们自定义的排序 */
const handleHeaderClass = ({column}) => { const handleHeaderClass = ({column}) => {
column.order = column.multiOrder column.order = column.multiOrder
@ -312,7 +370,9 @@ const handlePreviewListResource = async (preview) => {
await updateConfigByKey("sys.oss.previewListResource", preview); await updateConfigByKey("sys.oss.previewListResource", preview);
await getList() await getList()
proxy?.$modal.msgSuccess(text + "成功"); proxy?.$modal.msgSuccess(text + "成功");
} catch { return } } catch {
return
}
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row) => { const handleDelete = async (row) => {
@ -324,6 +384,22 @@ const handleDelete = async (row) => {
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess("删除成功");
} }
/** 编辑分组 */
function onClick(row) {
row.isEdit = true
oss.value = row
}
/** 修改分组 */
function changeTeam(row) {
loading.value = true;
editOss(oss.value).then(response => {
proxy?.$modal.msgSuccess("修改成功");
row.isEdit = false
getList()
})
}
onMounted(() => { onMounted(() => {
getList(); getList();
}) })