index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <page-pane class="stack-page">
  3. <div class="stack">
  4. <div class="stack-left">
  5. <sidebar @select="handleSelect" />
  6. </div>
  7. <div class="stack-main">
  8. <div style="padding-right: 68px; width: 100%; box-sizing: border-box">
  9. <el-breadcrumb
  10. class="stack-breadcrumb"
  11. :separator-icon="ArrowRight"
  12. style="width: 100%"
  13. >
  14. <el-breadcrumb-item v-for="item in breadcrumb" :key="item.id">{{
  15. item.name
  16. }}</el-breadcrumb-item>
  17. </el-breadcrumb>
  18. </div>
  19. <el-scrollbar
  20. v-loading="loading"
  21. style="flex: 1; width: 100%; height: 0"
  22. >
  23. <ul class="stack-list">
  24. <li v-for="item in list" :key="item.id">
  25. <book-card type="row" size="large" :item="item" />
  26. </li>
  27. </ul>
  28. <el-empty v-if="noData" description="暂无数据" />
  29. </el-scrollbar>
  30. <el-pagination
  31. class="stack-page-pagination"
  32. hide-on-single-page
  33. background
  34. layout="prev, pager, next"
  35. :total="total"
  36. :page-size="DEFAULT_PAGE_SIZE"
  37. @change="handlePage"
  38. />
  39. </div>
  40. </div>
  41. </page-pane>
  42. </template>
  43. <script setup>
  44. import { ref } from "vue";
  45. import { useRouteQuery } from "@vueuse/router";
  46. import { ArrowRight } from "@element-plus/icons-vue";
  47. import { DEFAULT_PAGE_SIZE, usePagination } from "@lsq/base";
  48. import { getBookListApi, getStorageSonListApi } from "@/api";
  49. import Sidebar from "./components/Sidebar/index.vue";
  50. import BookCard from "@/components/BookCard/index.vue";
  51. const breadcrumb = ref([]);
  52. const activeTab = useRouteQuery("active", "book");
  53. const searchKey = useRouteQuery("keyword");
  54. const { pageNum, total, loading, list, noData, getList } = usePagination(
  55. async (params) => {
  56. const id = breadcrumb.value[breadcrumb.value.length - 1].id;
  57. // 查找书籍分类指定分类
  58. if (activeTab.value === "book" && id > -1) {
  59. const data = await getStorageSonListApi(id);
  60. // 模拟分页
  61. return {
  62. pages: 1,
  63. total: data.length,
  64. records: data.slice(
  65. (params.pageNum - 1) * params.pageSize,
  66. params.pageNum * params.pageSize
  67. ),
  68. };
  69. }
  70. const p = {
  71. ...params,
  72. searchKey: searchKey.value,
  73. };
  74. if (breadcrumb.value.length) {
  75. if (activeTab.value === "collection" && id > -1) {
  76. p.exhibitTypeId = id;
  77. } else if (id > -1) {
  78. p.storageId = id;
  79. }
  80. }
  81. return getBookListApi(p);
  82. }
  83. );
  84. const handlePage = (page) => {
  85. pageNum.value = page;
  86. getList();
  87. };
  88. const resetSearch = () => {
  89. pageNum.value = 1;
  90. getList();
  91. };
  92. const handleSelect = (type, data) => {
  93. if (type === "classify") {
  94. // 切换分类
  95. breadcrumb.value = data;
  96. }
  97. resetSearch();
  98. };
  99. </script>
  100. <style lang="scss" scoped>
  101. @import "./index.scss";
  102. </style>