ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts" setup>
import type { PropType } from 'vue';
 
import { computed } from 'vue';
 
import { $t } from '#/locales';
 
defineOptions({ name: 'ChildTableColumn' });
 
const props = defineProps({
  data: { type: Array as PropType<any[]>, default: () => [] },
  head: { type: Array as PropType<any[]>, default: () => [] },
  defaultNumber: { type: Number, default: 3 },
  expand: { type: Boolean, default: false },
  showOverflow: { type: Boolean, default: true },
});
const emit = defineEmits(['toggleExpand', 'toDetail']);
 
const fewData = computed(() => (props.data ? props.data.slice(0, props.defaultNumber) : []));
 
function toggleExpand() {
  emit('toggleExpand');
}
function toDetail(modelId, id, propsValue) {
  emit('toDetail', modelId, id, propsValue);
}
</script>
 
<template>
  <div class="child-table-column">
    <template v-if="!expand">
      <tr v-for="(item, index) in fewData" class="child-table__row" :key="index">
        <td
          v-for="(headItem, i) in head"
          :key="i"
          :style="{ width: `${headItem.width || headItem.minWidth}px`, 'text-align': headItem.align }"
          :class="{ 'td-flex-1': !headItem.width }">
          <div class="cell" v-if="headItem.jnpfKey === 'relationForm'">
            <p class="link-text" :title="item[headItem.__vModel__]" @click="toDetail(headItem.modelId, item[`${headItem.__vModel__}_id`], headItem.propsValue)">
              {{ item[headItem.__vModel__] }}
            </p>
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'inputNumber'">
            <jnpf-input-number v-model:value="item[headItem.__vModel__]" :precision="headItem.precision" :thousands="headItem.thousands" disabled detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'calculate'">
            <jnpf-calculate
              v-model:value="item[headItem.__vModel__]"
              :is-storage="headItem.isStorage"
              :precision="headItem.precision"
              :thousands="headItem.thousands"
              :round-type="headItem.roundType"
              :type="headItem.type"
              :date-cal-config="headItem.dateCalConfig"
              detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'sign'">
            <jnpf-sign v-model:value="item[headItem.__vModel__]" detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'signature'">
            <jnpf-signature v-model:value="item[headItem.__vModel__]" detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'rate'">
            <jnpf-rate v-model:value="item[headItem.__vModel__]" :count="headItem.count" :allow-half="headItem.allowHalf" disabled />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'slider'">
            <jnpf-slider v-model:value="item[headItem.__vModel__]" :min="headItem.min" :max="headItem.max" :step="headItem.step" disabled />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'uploadImg'">
            <jnpf-upload-img v-model:value="item[headItem.__vModel__]" disabled detailed simple v-if="item[headItem.__vModel__]?.length" />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'uploadFile'">
            <jnpf-upload-file v-model:value="item[headItem.__vModel__]" disabled detailed simple v-if="item[headItem.__vModel__]?.length" />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'input'">
            <jnpf-input
              v-model:value="item[headItem.__vModel__]"
              :use-mask="headItem.useMask"
              :mask-config="headItem.maskConfig"
              :show-overflow="showOverflow"
              detailed />
          </div>
          <div class="cell" :class="{ ellipsis: showOverflow }" :title="item[headItem.__vModel__]" v-else>{{ item[headItem.__vModel__] }}</div>
        </td>
      </tr>
    </template>
    <template v-if="expand">
      <tr v-for="(item, index) in data" class="child-table__row" :key="index">
        <td
          v-for="(headItem, i) in head"
          :key="i"
          :style="{ width: `${headItem.width || headItem.minWidth}px`, 'text-align': headItem.align }"
          :class="{ 'td-flex-1': !headItem.width }">
          <div class="cell" v-if="headItem.jnpfKey === 'relationForm'">
            <p class="link-text" :title="item[headItem.__vModel__]" @click="toDetail(headItem.modelId, item[`${headItem.__vModel__}_id`], headItem.propsValue)">
              {{ item[headItem.__vModel__] }}
            </p>
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'inputNumber'">
            <jnpf-input-number v-model:value="item[headItem.__vModel__]" :precision="headItem.precision" :thousands="headItem.thousands" disabled detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'calculate'">
            <jnpf-calculate
              v-model:value="item[headItem.__vModel__]"
              :is-storage="headItem.isStorage"
              :precision="headItem.precision"
              :thousands="headItem.thousands"
              :round-type="headItem.roundType"
              detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'sign'">
            <jnpf-sign v-model:value="item[headItem.__vModel__]" detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'signature '">
            <jnpf-signature v-model:value="item[headItem.__vModel__]" detailed />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'rate'">
            <jnpf-rate v-model:value="item[headItem.__vModel__]" :count="headItem.count" :allow-half="headItem.allowHalf" disabled />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'slider'">
            <jnpf-slider v-model:value="item[headItem.__vModel__]" :min="headItem.min" :max="headItem.max" :step="headItem.step" disabled />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'uploadImg'">
            <jnpf-upload-img v-model:value="item[headItem.__vModel__]" disabled detailed simple v-if="item[headItem.__vModel__]?.length" />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'uploadFile'">
            <jnpf-upload-file v-model:value="item[headItem.__vModel__]" disabled detailed simple v-if="item[headItem.__vModel__]?.length" />
          </div>
          <div class="cell" v-else-if="headItem.jnpfKey === 'input'">
            <jnpf-input
              v-model:value="item[headItem.__vModel__]"
              :use-mask="headItem.useMask"
              :mask-config="headItem.maskConfig"
              :show-overflow="showOverflow"
              detailed />
          </div>
          <div class="cell" :class="{ ellipsis: showOverflow }" :title="item[headItem.__vModel__]" v-else>{{ item[headItem.__vModel__] }}</div>
        </td>
      </tr>
    </template>
    <div class="expand-more-btn" v-if="data && data.length > defaultNumber">
      <a-button v-if="expand" type="link" @click="toggleExpand">{{ $t('views.dynamicModel.hideSome') }}</a-button>
      <a-button v-if="!expand" type="link" @click="toggleExpand">{{ $t('views.dynamicModel.showMore') }}</a-button>
    </div>
  </div>
</template>