|
@@ -0,0 +1,215 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="library-stack-container">
|
|
|
|
+ <el-card class="box-card">
|
|
|
|
+ <template #header>
|
|
|
|
+ <div class="card-header">
|
|
|
|
+ <span>书库列表</span>
|
|
|
|
+ <el-button type="primary">添加书库</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <!-- 搜索区域 -->
|
|
|
|
+ <div class="search-container">
|
|
|
|
+ <el-form :inline="true" :model="searchForm" class="form-inline">
|
|
|
|
+ <el-form-item label="书库名称">
|
|
|
|
+ <el-input v-model="searchForm.name" placeholder="请输入书库名称" clearable></el-input>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item label="状态">
|
|
|
|
+ <el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
|
|
|
|
+ <el-option label="正常" value="normal"></el-option>
|
|
|
|
+ <el-option label="禁用" value="disabled"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
|
|
|
|
+ <el-button @click="resetSearch">重置</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <!-- 表格区域 -->
|
|
|
|
+ <el-table :data="tableData" style="width: 100%" v-loading="loading">
|
|
|
|
+ <el-table-column prop="id" label="ID" width="80"></el-table-column>
|
|
|
|
+ <el-table-column prop="name" label="书库名称"></el-table-column>
|
|
|
|
+ <el-table-column prop="bookCount" label="书籍数量"></el-table-column>
|
|
|
|
+ <el-table-column prop="createdTime" label="创建时间"></el-table-column>
|
|
|
|
+ <el-table-column prop="status" label="状态">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-tag :type="scope.row.status === 'normal' ? 'success' : 'danger'">
|
|
|
|
+ {{ scope.row.status === 'normal' ? '正常' : '禁用' }}
|
|
|
|
+ </el-tag>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="180">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-button type="primary" link size="small" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
|
+ <el-button type="primary" link size="small" @click="handleView(scope.row)">查看</el-button>
|
|
|
|
+ <el-button type="danger" link size="small" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+
|
|
|
|
+ <!-- 分页区域 -->
|
|
|
|
+ <div class="pagination-container">
|
|
|
|
+ <el-pagination
|
|
|
|
+ v-model:current-page="currentPage"
|
|
|
|
+ v-model:page-size="pageSize"
|
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
+ :total="total"
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </el-card>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import { ref, reactive, onMounted } from 'vue'
|
|
|
|
+
|
|
|
|
+// 定义数据类型
|
|
|
|
+interface SearchForm {
|
|
|
|
+ name: string;
|
|
|
|
+ status: string;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+interface TableItem {
|
|
|
|
+ id: number;
|
|
|
|
+ name: string;
|
|
|
|
+ bookCount: number;
|
|
|
|
+ createdTime: string;
|
|
|
|
+ status: string;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 搜索表单
|
|
|
|
+const searchForm = reactive<SearchForm>({
|
|
|
|
+ name: '',
|
|
|
|
+ status: ''
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+// 表格数据
|
|
|
|
+const tableData = ref<TableItem[]>([
|
|
|
|
+ {
|
|
|
|
+ id: 1,
|
|
|
|
+ name: '主要书库',
|
|
|
|
+ bookCount: 1250,
|
|
|
|
+ createdTime: '2023-08-15',
|
|
|
|
+ status: 'normal'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: 2,
|
|
|
|
+ name: '历史文献',
|
|
|
|
+ bookCount: 850,
|
|
|
|
+ createdTime: '2023-08-16',
|
|
|
|
+ status: 'normal'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: 3,
|
|
|
|
+ name: '科技资料',
|
|
|
|
+ bookCount: 620,
|
|
|
|
+ createdTime: '2023-08-17',
|
|
|
|
+ status: 'disabled'
|
|
|
|
+ }
|
|
|
|
+])
|
|
|
|
+
|
|
|
|
+// 加载状态
|
|
|
|
+const loading = ref(false)
|
|
|
|
+
|
|
|
|
+// 分页相关
|
|
|
|
+const currentPage = ref(1)
|
|
|
|
+const pageSize = ref(10)
|
|
|
|
+const total = ref(100)
|
|
|
|
+
|
|
|
|
+// 生命周期钩子
|
|
|
|
+onMounted(() => {
|
|
|
|
+ // 初始化数据,可以调用API获取数据
|
|
|
|
+ // fetchData()
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+// 搜索方法
|
|
|
|
+const handleSearch = () => {
|
|
|
|
+ console.log('搜索条件:', searchForm)
|
|
|
|
+ currentPage.value = 1
|
|
|
|
+ // fetchData()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 重置搜索
|
|
|
|
+const resetSearch = () => {
|
|
|
|
+ searchForm.name = '';
|
|
|
|
+ searchForm.status = '';
|
|
|
|
+ currentPage.value = 1
|
|
|
|
+ // fetchData()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 编辑
|
|
|
|
+const handleEdit = (row: TableItem) => {
|
|
|
|
+ console.log('编辑', row)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 查看
|
|
|
|
+const handleView = (row: TableItem) => {
|
|
|
|
+ console.log('查看', row)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 删除
|
|
|
|
+const handleDelete = (row: TableItem) => {
|
|
|
|
+ console.log('删除', row)
|
|
|
|
+ // 可以调用删除API
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 分页大小变化
|
|
|
|
+const handleSizeChange = (val: number) => {
|
|
|
|
+ pageSize.value = val
|
|
|
|
+ // fetchData()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 页码变化
|
|
|
|
+const handleCurrentChange = (val: number) => {
|
|
|
|
+ currentPage.value = val
|
|
|
|
+ // fetchData()
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 获取数据方法(实际项目中可以调用API)
|
|
|
|
+/*
|
|
|
|
+const fetchData = async () => {
|
|
|
|
+ loading.value = true
|
|
|
|
+ try {
|
|
|
|
+ // 调用API获取数据
|
|
|
|
+ // const res = await api.getLibraryList({
|
|
|
|
+ // page: currentPage.value,
|
|
|
|
+ // pageSize: pageSize.value,
|
|
|
|
+ // ...searchForm
|
|
|
|
+ // })
|
|
|
|
+ // tableData.value = res.data.list
|
|
|
|
+ // total.value = res.data.total
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('获取数据失败', error)
|
|
|
|
+ } finally {
|
|
|
|
+ loading.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+*/
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style scoped lang="scss">
|
|
|
|
+.library-stack-container {
|
|
|
|
+ padding: 20px;
|
|
|
|
+
|
|
|
|
+ .card-header {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+ align-items: center;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .search-container {
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .pagination-container {
|
|
|
|
+ margin-top: 20px;
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|