文件存储添加分组功能
This commit is contained in:
parent
b3c36e27cf
commit
a0748feb3f
@ -24,3 +24,12 @@ export function delOss(ossId) {
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
// 修改OSS对象存储
|
||||
export function editOss(params) {
|
||||
return request({
|
||||
url: '/resource/oss/update',
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
@ -4,13 +4,16 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
|
||||
<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 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 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 label="创建时间">
|
||||
<el-date-picker
|
||||
@ -24,7 +27,8 @@
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<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-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
|
||||
@ -38,13 +42,18 @@
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<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 :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 :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-col>
|
||||
@ -56,11 +65,15 @@
|
||||
v-hasPermi="['system:oss:edit']"
|
||||
>预览开关 :
|
||||
{{
|
||||
previewListResource ? "禁用" : "启用" }}</el-button
|
||||
previewListResource ? "禁用" : "启用"
|
||||
}}
|
||||
</el-button
|
||||
>
|
||||
</el-col>
|
||||
<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>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -74,11 +87,36 @@
|
||||
@header-click="handleHeaderCLick"
|
||||
v-if="showTable"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="对象存储主键" align="center" prop="ossId" v-if="false" />
|
||||
<el-table-column label="文件名" align="center" prop="fileName" />
|
||||
<el-table-column label="原名" align="center" prop="originalName" />
|
||||
<el-table-column label="文件后缀" align="center" prop="fileSuffix" />
|
||||
<el-table-column type="selection" width="55" align="center"/>
|
||||
<el-table-column label="对象存储主键" align="center" prop="ossId" v-if="false"/>
|
||||
<el-table-column label="文件名" align="center" prop="fileName"/>
|
||||
<el-table-column label="原名" align="center" prop="originalName"/>
|
||||
<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">
|
||||
<template #default="scope">
|
||||
<ImagePreview
|
||||
@ -88,7 +126,7 @@
|
||||
:src="scope.row.url"
|
||||
:preview-src-list="[scope.row.url]"
|
||||
/>
|
||||
<span v-text="scope.row.url" v-if="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource" />
|
||||
<span v-text="scope.row.url" v-if="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180" sortable="custom">
|
||||
@ -96,28 +134,31 @@
|
||||
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="上传人" align="center" prop="createByName" />
|
||||
<el-table-column label="服务商" align="center" prop="service" sortable="custom" />
|
||||
<el-table-column label="上传人" align="center" prop="createByName"/>
|
||||
<el-table-column label="服务商" align="center" prop="service" sortable="custom"/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<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 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>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</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>
|
||||
<!-- 添加或修改OSS对象存储对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="ossFormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="文件名">
|
||||
<fileUpload v-model="form.file" v-if="type === 0" />
|
||||
<imageUpload v-model="form.file" v-if="type === 1" />
|
||||
<fileUpload v-model="form.file" v-if="type === 0"/>
|
||||
<imageUpload v-model="form.file" v-if="type === 1"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -131,12 +172,13 @@
|
||||
</template>
|
||||
|
||||
<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 { getConfigKey,updateConfigByKey } from "@/api/system/config";
|
||||
import {getConfigKey, updateConfigByKey} from "@/api/system/config";
|
||||
import {Edit} from "@element-plus/icons-vue";
|
||||
|
||||
const router = useRouter();
|
||||
const { proxy } = getCurrentInstance();
|
||||
const {proxy} = getCurrentInstance();
|
||||
|
||||
const ossList = ref([]);
|
||||
const showTable = ref(true);
|
||||
@ -150,6 +192,8 @@ const total = ref(0);
|
||||
const type = ref(0);
|
||||
const previewListResource = ref(true);
|
||||
const dateRangeCreateTime = ref(['', '']);
|
||||
const teamList = ref([]);
|
||||
const oss = ref({});
|
||||
|
||||
const dialog = reactive({
|
||||
visible: false,
|
||||
@ -157,13 +201,13 @@ const dialog = reactive({
|
||||
});
|
||||
|
||||
// 默认排序
|
||||
const defaultSort = ref({ prop: 'createTime', order: 'ascending' });
|
||||
const defaultSort = ref({prop: 'createTime', order: 'ascending'});
|
||||
|
||||
const initFormData = {
|
||||
file: undefined,
|
||||
}
|
||||
const data = reactive({
|
||||
form: { ...initFormData },
|
||||
form: {...initFormData},
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@ -178,12 +222,12 @@ const data = reactive({
|
||||
},
|
||||
rules: {
|
||||
file: [
|
||||
{ required: true, message: "文件不能为空", trigger: "blur" }
|
||||
{required: true, message: "文件不能为空", trigger: "blur"}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
const {queryParams, form, rules} = toRefs(data);
|
||||
|
||||
/** 查询OSS对象存储列表 */
|
||||
const getList = async () => {
|
||||
@ -192,31 +236,43 @@ const getList = async () => {
|
||||
previewListResource.value = res?.data === undefined ? true : res.data === "true";
|
||||
const response = await listOss(proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, "CreateTime"));
|
||||
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;
|
||||
loading.value = false;
|
||||
showTable.value = true;
|
||||
}
|
||||
|
||||
function checkFileSuffix(fileSuffix) {
|
||||
let arr = ["png", "jpg", "jpeg"];
|
||||
return arr.some(type => {
|
||||
return fileSuffix.indexOf(type) > -1;
|
||||
});
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
dialog.visible = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
function reset() {
|
||||
form.value = { ...initFormData };
|
||||
form.value = {...initFormData};
|
||||
proxy.resetForm("ossFormRef");
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
showTable.value = false;
|
||||
@ -226,14 +282,16 @@ function resetQuery() {
|
||||
queryParams.value.isAsc = defaultSort.value.order;
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/** 选择条数 */
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.ossId);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 设置列的排序为我们自定义的排序 */
|
||||
const handleHeaderClass = ({ column }) => {
|
||||
const handleHeaderClass = ({column}) => {
|
||||
column.order = column.multiOrder
|
||||
}
|
||||
/** 点击表头进行排序 */
|
||||
@ -312,7 +370,9 @@ const handlePreviewListResource = async (preview) => {
|
||||
await updateConfigByKey("sys.oss.previewListResource", preview);
|
||||
await getList()
|
||||
proxy?.$modal.msgSuccess(text + "成功");
|
||||
} catch { return }
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row) => {
|
||||
@ -324,6 +384,22 @@ const handleDelete = async (row) => {
|
||||
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(() => {
|
||||
getList();
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user