zhengyiming
2025-02-10 958b79ed89b9e742540f714a80261d222c0fc09b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
  <component
    :is="view"
    class="page-card-list-layout"
    :class="[{ scrollEnable }]"
    v-if="tableData.length > 0"
    v-bind="$attrs"
  >
    <template v-if="useChunk">
      <!-- <div v-for="(group, index) in chunkGroup" :key="index" class="page-card-list-row-wrapper">
        <el-row :gutter="gutter">
          <el-col :span="colSpan" v-for="(item, i) in group" :key="i">
            <slot name="item" :item="item" :index="index * chunkSize + i" />
          </el-col>
        </el-row>
      </div> -->
      <GridView :chunkSize="chunkSize" :gutter="gutter" :tableData="tableData">
        <template #item="{ item, index }">
          <slot name="item" :item="item" :index="index" />
        </template>
      </GridView>
    </template>
    <template v-else>
      <template v-for="(item, index) in tableData">
        <slot name="item" :item="item" :index="index" />
      </template>
    </template>
  </component>
  <div v-if="showPagination" class="page-card-list-layout-pagination">
    <ProPagination
      @getDataSource="$emit('getDataSource', $event)"
      @update:page-size="(val:number) => $emit('update:page-size',val)"
      v-bind="paginationProps"
      :tableData="tableData"
    />
  </div>
  <NoData v-if="tableData.length === 0" style="margin-top: 170px"> </NoData>
</template>
 
<script lang="ts">
import type { PaginationProps } from 'element-plus';
import { paginationEmits, ElScrollbar } from 'element-plus';
import { ProPagination } from '@bole-core/components';
import _ from 'lodash';
import GridView from './GridView.vue';
// import PaginationCardContainer from './PaginationCardContainer.vue';
 
export default defineComponent({
  name: 'PageCardListLayout',
  inheritAttrs: false,
  components: { ProPagination, ElScrollbar, GridView },
  props: {
    paginationProps: {
      type: Object as PropType<Partial<PaginationProps>>,
      default: () => ({} as Partial<PaginationProps>),
    },
    tableData: {
      type: Array as PropType<any[]>,
      default: () => [],
      required: true,
    },
    showPagination: {
      type: Boolean,
      default: false,
    },
    chunkSize: {
      type: Number,
      default: 0,
    },
    gutter: {
      type: Number,
      default: 0,
    },
    useScrollBar: {
      type: Boolean,
      default: true,
    },
    scrollEnable: {
      type: Boolean,
      default: false,
    },
  },
  emits: {
    ...paginationEmits,
    getDataSource: (pageIndex: number) => typeof pageIndex === 'number',
  },
 
  setup(props) {
    const colSpan = computed(() => Math.ceil(24 / props.chunkSize));
 
    const chunkGroup = computed(() => _.chunk(props.tableData, props.chunkSize));
 
    const useChunk = computed(() => props.chunkSize !== 0);
 
    // const gutterStyle = computed(() => props.gutter / 2);
 
    const view = computed(() => (props.useScrollBar ? 'el-scrollbar' : 'div'));
 
    return {
      chunkGroup,
      useChunk,
      colSpan,
      view,
    };
  },
});
</script>
 
<style lang="scss" scoped>
.page-card-list-layout {
  padding: 20px;
  padding-bottom: 0;
  min-height: 0;
  background-color: #ffffff;
  flex: 1;
 
  &.scrollEnable {
    overflow-y: auto;
  }
 
  :deep(.el-scrollbar__wrap) {
    overflow-x: hidden;
    overflow-y: auto;
  }
 
  .page-card-list-row-wrapper {
    overflow: hidden;
 
    :deep(.el-row) {
      // width: 100%;
    }
  }
 
  &::-webkit-scrollbar {
    display: none;
  }
}
 
.page-card-list-layout-pagination {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  background-color: #ffffff;
}
</style>
 
<style lang="scss">
.center-layout-main-container .page-card-list-layout {
  padding: 20px 30px;
}
</style>