123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <div class="table__content">
- <div class="table__content_label">
- <div class="label-t" v-for="(item, index) in columns" :key="`svvhbcth-${index}`" :style="{ flexBasis }">{{ item.name }}</div>
- </div>
- <Collapse v-model:activeKey="avtiveCollapse" ghost class="table__content_list" :style="{ height: contentHeight }">
- <CollapsePanel
- v-for="(item, index) in data"
- :key="`svvhbct-${index}`"
- class="table__content_list_row"
- :showArrow="item.hideCollapses ? false : showArrow"
- :disabled="item.hideCollapses"
- >
- <template #header>
- <div v-for="(t, i) in columns" :key="`svvhbctr-${i}`" :style="{ flexBasis }">
- <slot :name="t.prop" :scope="item">
- <span>{{ get(item, t.prop) }}</span>
- </slot>
- </div>
- </template>
- <template v-if="!item.hideCollapses" #default>
- <p v-for="(t, i) in collapses" :key="`svvhbctc-${i}`" class="table__content_list_collapse"> {{ t.name }}:{{ get(item, t.prop) }} </p>
- </template>
- </CollapsePanel>
- </Collapse>
- </div>
- </template>
- <script lang="ts" setup>
- import { computed, defineProps, ref } from 'vue';
- import _ from 'lodash';
- import { Collapse, CollapsePanel } from 'ant-design-vue';
- let props = withDefaults(
- defineProps<{
- /** 列表表头配置,每个prop都有其对应的slot来提供定制化功能 */
- columns: { prop: string; name: string }[];
- collapses: { prop: string; name: string }[];
- data: any[];
- defaultValue: string;
- contentHeight: string;
- showArrow: boolean;
- /** 是否自动过滤折叠展开后无有效内容的项 */
- filterNil: boolean;
- }>(),
- {
- columns: () => [],
- collapses: () => [],
- data: () => [],
- defaultValue: '/',
- contentHeight: '220px',
- showArrow: true,
- filterNil: false,
- }
- );
- const avtiveCollapse = ref('svvhbct-0');
- const flexBasis = computed(() => {
- return Math.fround(100 / props.columns.length) + '%';
- });
- function get(o, p) {
- const d = _.get(o, p, props.defaultValue);
- return d === null ? props.defaultValue : d;
- }
- </script>
- <style lang="less" scoped>
- @font-face {
- font-family: 'douyuFont';
- src: url('@/assets/font/douyuFont.otf');
- }
- .table__content {
- height: 100%;
- width: 100%;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- align-items: center;
- .table__content_label {
- width: 366px;
- height: 32px;
- display: flex;
- justify-content: space-around;
- align-items: center;
- background: url('@/assets/images/company/content-label.png') no-repeat;
- .label-t {
- color: #3df6ff;
- text-align: center;
- font-size: 14px;
- }
- }
- .table__content_list {
- height: calc(100% - 32px);
- width: 366px;
- display: flex;
- flex-direction: column;
- // justify-content: space-around;
- justify-content: flex-start;
- padding: 5px 0px;
- box-sizing: border-box;
- overflow-y: auto;
- .table__content_list_row {
- // width: 100%;
- // display: flex;
- // justify-content: space-around;
- // align-items: flex-start;
- background: url('@/assets/images/company/content-text.png') no-repeat;
- background-size: 100% auto;
- color: @white;
- padding: 5px 0;
- // span {
- // display: inline-block;
- // text-align: center;
- // }
- }
- .table__content_list_collapse {
- text-align: left;
- color: @white;
- margin-left: 10px;
- }
- }
- }
- .table__content :deep(.zxm-collapse > .zxm-collapse-item > .zxm-collapse-header) {
- padding: 0;
- color: @white;
- }
- :deep(.zxm-collapse > .zxm-collapse-item > .zxm-collapse-header .zxm-collapse-arrow) {
- position: absolute;
- top: 3px;
- }
- </style>
|