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
<template>
  <div class="portrait-table">
    <el-row v-for="(tableItem, tableIndex) in portraitTableList" :key="tableIndex">
      <el-col v-for="item in tableItem" :key="item.key" class="portrait-table-item">
        <div class="portrait-table-item-label-wrapper">
          <div
            class="label"
            :style="{
              width: labelWidth,
              textAlign: labelPosition,
            }"
          >
            <slot name="label">
              {{ item.label }}
            </slot>
          </div>
        </div>
        <div class="portrait-table-item-value-wrapper">
          <TextOverTooltip>
            <div class="value ellipsis">
              <slot :name="item.key">
                <ProTableColumn
                  v-bind="_.omit(item, 'label')"
                  :data="props.data[item.key]"
                  :row="props.data"
                ></ProTableColumn>
              </slot>
            </div>
          </TextOverTooltip>
        </div>
      </el-col>
    </el-row>
    <slot name="annex"> </slot>
  </div>
</template>
 
<script setup lang="ts">
import { ProTableColumn, TextOverTooltip } from '@bole-core/components';
import _ from 'lodash';
import { UsePortraitTableColumnsItem } from '@/hooks';
 
defineOptions({
  name: 'PortraitTable',
});
 
type Props = {
  columns: UsePortraitTableColumnsItem[];
  data: { [key: string]: any };
  labelWidth?: string;
  labelPosition?: any;
  colNumber?: number;
};
 
const props = withDefaults(defineProps<Props>(), {
  labelWidth: 'auto',
  labelPosition: 'right',
  colNumber: 2,
});
 
const portraitTableList = computed(() => {
  return _.chunk(props.columns, props.colNumber);
});
</script>
 
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
 
.portrait-table {
  --bole-pro-form-input-height: 14px;
 
  border: 1px solid #e8e8e8;
  border-radius: 4px;
 
  :deep(.el-row) {
    border-bottom: #e8e8e8 1px solid;
 
    &:last-child {
      border-bottom: none;
    }
  }
 
  .portrait-table-item {
    display: inline-flex;
    flex: 1;
    min-width: 0;
 
    .portrait-table-item-label-wrapper {
      display: flex;
      align-items: center;
      padding: 12px;
      background-color: #fafafa;
    }
 
    .label {
      font-size: 14px;
      color: getCssVar('text-color', 'regular');
      line-height: 19px;
    }
 
    .portrait-table-item-value-wrapper {
      padding: 12px;
      min-width: 0;
      flex: 1;
    }
 
    .value {
      font-size: 14px;
      color: getCssVar('text-color', 'primary');
      line-height: 19px;
      word-wrap: break-word;
    }
  }
}
</style>