项目框架
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { pageResource, removeResource, type ResourceQuery, type VersionResource } from '@/api/resource'
|
||||
import { GOVERN_STATUS, governStatusLabel, governStatusTagType } from '@/constants/dict'
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<VersionResource[]>([])
|
||||
const total = ref(0)
|
||||
|
||||
const query = reactive<ResourceQuery>({
|
||||
current: 1,
|
||||
size: 20,
|
||||
title: '',
|
||||
author: '',
|
||||
mediaType: '',
|
||||
sourceLibrary: '',
|
||||
governStatus: ''
|
||||
})
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await pageResource(query)
|
||||
list.value = res.records || []
|
||||
total.value = res.total || 0
|
||||
} catch {
|
||||
// 错误已由响应拦截器统一提示
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
query.current = 1
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
query.title = ''
|
||||
query.author = ''
|
||||
query.mediaType = ''
|
||||
query.sourceLibrary = ''
|
||||
query.governStatus = ''
|
||||
handleSearch()
|
||||
}
|
||||
|
||||
async function handleDelete(row: VersionResource) {
|
||||
await ElMessageBox.confirm(`确认删除《${row.title}》?`, '提示', { type: 'warning' })
|
||||
await removeResource(row.id as number)
|
||||
ElMessage.success('删除成功')
|
||||
fetchData()
|
||||
}
|
||||
|
||||
onMounted(fetchData)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="page-card mb-16">
|
||||
<el-form :inline="true" :model="query" @submit.prevent>
|
||||
<el-form-item label="题名">
|
||||
<el-input v-model="query.title" placeholder="正题名" clearable style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="责任者">
|
||||
<el-input v-model="query.author" placeholder="作者" clearable style="width: 160px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="媒体类型">
|
||||
<el-select v-model="query.mediaType" placeholder="全部" clearable style="width: 130px">
|
||||
<el-option label="纸质" value="纸质" />
|
||||
<el-option label="电子" value="电子" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="来源馆">
|
||||
<el-input v-model="query.sourceLibrary" placeholder="来源馆" clearable style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="治理状态">
|
||||
<el-select v-model="query.governStatus" placeholder="全部" clearable style="width: 130px">
|
||||
<el-option v-for="s in GOVERN_STATUS" :key="s.value" :label="s.label" :value="s.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
|
||||
<el-button :icon="Refresh" @click="handleReset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="page-card">
|
||||
<h3 class="page-title">版本资源库(元数据)</h3>
|
||||
<el-table v-loading="loading" :data="list" border stripe>
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="title" label="正题名" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="author" label="责任者" width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="clcCode" label="中图分类" width="110" />
|
||||
<el-table-column prop="mediaType" label="媒体类型" width="90" />
|
||||
<el-table-column prop="publishYear" label="出版年份" width="100" />
|
||||
<el-table-column prop="sourceLibrary" label="来源馆" width="180" show-overflow-tooltip />
|
||||
<el-table-column label="治理状态" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="governStatusTagType(row.governStatus)">
|
||||
{{ governStatusLabel(row.governStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="错漏" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.abnormalFlag === 1" size="small" type="danger">疑似</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" size="small" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
class="pager"
|
||||
background
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
v-model:current-page="query.current"
|
||||
v-model:page-size="query.size"
|
||||
:page-sizes="[20, 50, 100, 200]"
|
||||
@current-change="fetchData"
|
||||
@size-change="fetchData"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pager {
|
||||
margin-top: 16px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user