219 lines
5.3 KiB
Vue
219 lines
5.3 KiB
Vue
<template>
|
|
<MyHeader></MyHeader>
|
|
<div class="container">
|
|
<div class="bread-container">
|
|
<el-breadcrumb separator=">">
|
|
<el-breadcrumb-item :to="{ path: '/myUpload' }">个人中心</el-breadcrumb-item>
|
|
<el-breadcrumb-item>我的上传</el-breadcrumb-item>
|
|
</el-breadcrumb>
|
|
</div>
|
|
|
|
<el-card class="news-card" v-loading="loading" element-loading-text="数据加载中...">
|
|
<template #header>
|
|
<div class="card-header">
|
|
<div class="header-search">
|
|
<el-space wrap>
|
|
<span>名称</span>
|
|
<el-input v-model="queryParams.title" style="width: 300px" placeholder="请输入关键词" clearable
|
|
@clear="handleClear" />
|
|
|
|
<span>格式</span>
|
|
<el-select v-model="queryParams.fileSuffix" placeholder="请选择格式" style="width: 300px"
|
|
@keyup.enter="handleQuery">
|
|
<el-option v-for="item in formatOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
<el-button type="primary" :icon="Search" @click="handleQuery">搜索</el-button>
|
|
</el-space>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<el-table v-if="tableData.length > 0" @row-click="handleRowClick" :data="tableData" class="table" stripe>
|
|
<el-table-column prop="fileName" label="课件名称" align="center" />
|
|
<el-table-column prop="fileSuffix" label="课件格式" align="center" />
|
|
<el-table-column prop="volume" label="课件大小" align="center" />
|
|
<el-table-column prop="filePath" label="目录" align="center" width="320" />
|
|
<el-table-column prop="createTime" label="创建时间" align="center" />
|
|
<el-table-column label="操作" align="center">
|
|
<template #default="scope">
|
|
<el-button link type="primary" @click="preview(scope.row)">预览</el-button>
|
|
<el-button link type="primary" @click="downloadFile(scope.row)">下载</el-button>
|
|
|
|
<el-popconfirm confirm-button-text="确认" cancel-button-text="取消" :icon="InfoFilled" icon-color="#626AEF"
|
|
title="确认删除吗?" @confirm="handleDelete(scope.row)">
|
|
<template #reference>
|
|
<el-button link type="danger">删除</el-button>
|
|
</template>
|
|
</el-popconfirm>
|
|
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<el-empty v-else description="暂无数据" />
|
|
|
|
<template #footer>
|
|
<el-pagination class="footer" background layout="prev, pager, next, sizes,jumper" :total="total"
|
|
@current-change="handleCurrentChange" @size-change="handleSizeChange" />
|
|
</template>
|
|
|
|
|
|
</el-card>
|
|
</div>
|
|
<MyFooter></MyFooter>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { Search, InfoFilled } from '@element-plus/icons-vue'
|
|
import { deleteMyUpload, myUploadList } from '@/apis/user'
|
|
import { download } from '@/utils/utils'
|
|
|
|
const router = useRouter()
|
|
|
|
const formatOptions = [
|
|
{
|
|
value: '.doc',
|
|
label: 'doc',
|
|
},
|
|
{
|
|
value: '.docx',
|
|
label: 'docx',
|
|
},
|
|
{
|
|
value: '.xls',
|
|
label: 'xls',
|
|
},
|
|
{
|
|
value: '.xlsx',
|
|
label: 'xlsx',
|
|
},
|
|
{
|
|
value: '.ppt',
|
|
label: 'ppt',
|
|
},
|
|
{
|
|
value: '.pptx',
|
|
label: 'pptx',
|
|
},
|
|
{
|
|
value: '.pdf',
|
|
label: 'pdf',
|
|
},
|
|
{
|
|
value: '.txt',
|
|
label: 'txt',
|
|
}
|
|
]
|
|
|
|
const loading = ref(false)
|
|
const queryParams = ref({
|
|
title: '',
|
|
fileSuffix: '',
|
|
pageNum: 1,
|
|
pageSize: 10
|
|
})
|
|
const tableData = ref([])
|
|
const total = ref(0)
|
|
const myUploadListData = async () => {
|
|
loading.value = true
|
|
const res = await myUploadList(queryParams.value)
|
|
tableData.value = res.rows
|
|
total.value = res.total
|
|
loading.value = false
|
|
}
|
|
|
|
onMounted(() => {
|
|
myUploadListData()
|
|
})
|
|
|
|
const handleCurrentChange = (val) => {
|
|
queryParams.value.pageNum = val
|
|
myUploadListData()
|
|
}
|
|
|
|
const handleSizeChange = (val) => {
|
|
queryParams.value.pageSize = val
|
|
myUploadListData()
|
|
}
|
|
|
|
const handleQuery = () => {
|
|
if (!queryParams.value.title) {
|
|
ElMessage.error('请输入查询关键字!')
|
|
return
|
|
}
|
|
myUploadListData()
|
|
}
|
|
|
|
const handleClear = () => {
|
|
queryParams.value.title = ''
|
|
myUploadListData()
|
|
}
|
|
|
|
const goTarget = (url) => {
|
|
window.open(url, '__blank');
|
|
}
|
|
|
|
const handleRowClick = (row) => {
|
|
if (row.type == 1) {
|
|
goTarget(row.url)
|
|
} else {
|
|
router.push(`news/${row.trendId}`)
|
|
}
|
|
}
|
|
|
|
const preview = (item) => {
|
|
router.push({ path: '/myUploadDetail', query: { id: item.id } })
|
|
}
|
|
|
|
const downloadFile = (item) => {
|
|
download(`/oss/person/download/${item.id}`, {}, item.fileName)
|
|
}
|
|
|
|
const handleDelete = async (row) => {
|
|
await deleteMyUpload(row.id);
|
|
ElMessage({
|
|
message: '删除成功',
|
|
type: 'success',
|
|
})
|
|
await myUploadListData();
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.container {
|
|
.bread-container {
|
|
padding: 25px 0;
|
|
|
|
:deep(.el-breadcrumb__inner) {
|
|
color: #fff;
|
|
font-size: 16px;
|
|
}
|
|
|
|
:deep(.el-breadcrumb__separator) {
|
|
color: #fff;
|
|
}
|
|
}
|
|
|
|
.news-card {
|
|
margin-top: 20px;
|
|
|
|
.card-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
|
|
.title {
|
|
font-size: 20px;
|
|
font-weight: bold;
|
|
margin-bottom: 5px;
|
|
}
|
|
}
|
|
|
|
.footer {
|
|
display: flex;
|
|
justify-content: end;
|
|
}
|
|
}
|
|
|
|
}
|
|
</style> |