SubElTableColumn.vue
4.43 KB
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
<template>
<div class='sub-el-table-column'>
<el-table-column
v-for='(item, index) in reverseData'
:key="index + 'child'"
:label='item.label'
:prop='item.prop'
:width='item.width'
:min-width='item.minWidth'
:fixed='item.fixed'
:align="item.align || 'left'"
:sortable='item.sortable'
:render-header='item.renderHeader'
v-bind='item.columnattrs ? item.columnattrs : {}'
v-on='item.columnlisteners ? item.columnlisteners : {}'>
<template slot-scope='scope'>
<slot v-if='item.addHtml' :name='item.addHtml' :scope='scope.row' :prop='item.prop' :width='item.width'></slot>
<template v-else-if='item.formatter'>
<el-popover
v-if='scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 14) * item.line'
placement='top' popper-class='base-popper' trigger='hover' :content='item.formatter(scope.row)'>
<span slot='reference' class='line-ellipsis' :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ item.formatter(scope.row) | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class='line-ellipsis' :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
<!-- {{ item.formatter(scope.row) || '--' }} -->
{{ item.formatter(scope.row) | tableCellFormat }}
</span>
</template>
<template v-else-if='getListApi'>
<el-popover
v-if='scope.row[item.prop] && scope.row[item.prop].length >= Math.ceil((item.width - 36) / 14) * item.line'
placement='top' popper-class='base-popper' trigger='hover' :content='scope.row[item.prop]'>
<span slot='reference' class='line-ellipsis' :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ scope.row[item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<span v-else class='line-ellipsis' :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
<!-- {{ scope.row[item.prop] || '--' }} -->
{{ scope.row[item.prop] | tableCellFormat }}
</span>
</template>
<template v-else>
<!-- 大于10或 20个字节长度 -->
<el-popover
v-if='tableData[scope.$index][item.prop] && tableData[scope.$index][item.prop].length >= Math.ceil((item.width - 36) / 14) * item.line'
placement='top' width='200' trigger='hover' :content='tableData[scope.$index][item.prop]'>
<span slot='reference' class='line-ellipsis' :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
{{ tableData[scope.$index][item.prop] | lineEllipsis(item.width, item.line) }}
</span>
</el-popover>
<!-- <span v-else class="line-ellipsis" :style="{ '-webkit-line-clamp': item.line ? item.line : '' }" v-text="tableData[scope.$index][item.prop]"></span> -->
<span v-else class='line-ellipsis' :style="{ '-webkit-line-clamp': item.line ? item.line : '' }">
<!-- {{ tableData[scope.$index][item.prop] || '--' }} -->
{{ tableData[scope.$index][item.prop] | tableCellFormat }}
</span>
</template>
<template v-if='item.addSymbol'>
<span v-text='item.addSymbol'></span>
</template>
</template>
<!-- 递归 -->
<sub-el-table-column v-if='item.children' :data='item.children' :tableData='tableData'
:getListApi='getListApi'></sub-el-table-column>
</el-table-column>
</div>
</template>
<script>
// import GlSubTableColumn from '../../GlSubTableColumn'
export default {
name: 'SubElTableColumn',
props: {
data: {
type: Array,
default: () => []
},
// 表格数据-外部传入
tableData: {
type: Array,
default: () => []
},
// 获取列表接口
getListApi: {
type: Function,
default: null
}
},
computed: {
reverseData() {
const arr = [...this.data]
const temp = arr.pop()
arr.unshift(temp)
console.log(arr)
console.log(this.tableData)
arr.forEach(item => {
console.log(item.addHtml)
})
return arr
}
}
// components: {
// GlSubTableColumn
// }
// created(){
// // console.log('data',this.data)
// }
}
</script>
<style lang='scss'>
// .sub-el-table-column {
// }
</style>