index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="card-container">
  3. <el-row :gutter="20">
  4. <el-col
  5. v-for="(item, index) in list"
  6. :key="index"
  7. :xs="24"
  8. :sm="8"
  9. :md="8"
  10. :lg="8"
  11. :xl="4"
  12. >
  13. <el-card shadow="hover">
  14. <div slot="header">
  15. <span>{{ item.title }}</span>
  16. </div>
  17. <div style="width: 100%; height: 200px">
  18. <vab-image
  19. :big-src="item.img"
  20. :percent="item.percent"
  21. :small-src="item.smallImg"
  22. @clickBig="bigClick(item)"
  23. @clickSmall="smallClick(item)"
  24. ></vab-image>
  25. </div>
  26. </el-card>
  27. </el-col>
  28. </el-row>
  29. <el-pagination
  30. :background="background"
  31. :current-page="pageNo"
  32. :layout="layout"
  33. :page-size="pageSize"
  34. :total="total"
  35. @current-change="handleCurrentChange"
  36. @size-change="handleSizeChange"
  37. ></el-pagination>
  38. </div>
  39. </template>
  40. <script>
  41. import { getList } from "@/api/table";
  42. import VabImage from "@/components/VabImage";
  43. export default {
  44. name: "Card",
  45. components: {
  46. VabImage,
  47. },
  48. data() {
  49. return {
  50. value: true,
  51. currentDate: new Date(),
  52. list: null,
  53. listLoading: true,
  54. pageNo: 1,
  55. pageSize: 10,
  56. layout: "total, sizes, prev, pager, next, jumper",
  57. total: 0,
  58. background: true,
  59. height: 0,
  60. elementLoadingText: "正在加载...",
  61. dialogFormVisible: false,
  62. };
  63. },
  64. created() {
  65. this.fetchData();
  66. this.height = this.$baseTableHeight(1);
  67. },
  68. methods: {
  69. bigClick(val) {
  70. this.$baseAlert("点击了大图");
  71. },
  72. smallClick(val) {
  73. this.$baseAlert("点击了小图");
  74. },
  75. handleSizeChange(val) {
  76. this.pageSize = val;
  77. this.fetchData();
  78. },
  79. handleCurrentChange(val) {
  80. this.pageNo = val;
  81. this.fetchData();
  82. },
  83. async fetchData() {
  84. this.listLoading = true;
  85. const { data, totalCount } = await getList({
  86. pageNo: this.pageNo,
  87. pageSize: this.pageSize,
  88. });
  89. this.list = data;
  90. this.total = totalCount;
  91. setTimeout(() => {
  92. this.listLoading = false;
  93. }, 300);
  94. },
  95. },
  96. };
  97. </script>