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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<template>
<el-row class="el-table-self">
<el-table
ref="selftab"
v-loading="listLoading"
:max-height="maxHeight || maxTableHeight"
:height="tableHeight"
:data="tableData"
:show-overflow-tooltip="true"
:highlight-current-row="highLight"
:header-row-class-name="headerClass"
style="width: 100%"
>
<el-table-column v-if="showIndex" type="index" width="120" label="序号"></el-table-column>
<template v-for="(column, index) in columns">
<template v-if="!column.type && !column.operType">
<el-table-column
:key="column.value"
:show-overflow-tooltip="true"
:fixed="column.fixed"
:prop="column.value"
:label="column.label"
:width="column.width"
:min-width="column.minWidth"
align="center"
:sortable="column.sortable"
:formatter="column.formatter"
:class-name="column.className"
:label-class-name="column.labelClassName"
>
<!-- 表头插槽 -->
<template slot="header" slot-scope="scope">
<span :style="{ fontSize: fontSize + 'px' }">{{column.label}}</span>
</template>
<!-- 表内容插槽 -->
<template slot-scope="scope">
<span :style="{ fontSize: fontSize + 'px' }">
<span>{{scope.row[column.value]|| "--"}}</span>
</span>
</template>
</el-table-column>
</template>
<template v-else>
<el-table-column
:key="index"
:show-overflow-tooltip="column.type === 'img' ? false : true"
:fixed="column.fixed"
:prop="column.value"
:label="column.label"
:sortable="column.sortable"
:width="column.width"
:min-width="column.minWidth"
align="center"
>
<!-- 表头插槽 -->
<template slot="header" slot-scope="scope">
<span :style="{ fontSize: fontSize + 'px' }">
{{
column.label
}}
</span>
</template>
<!-- 表内容插槽 -->
<template slot-scope="scope">
<!-- 按钮 -->
<template v-if="column.type === 'button' || column.operType === 'button'">
<!-- 按钮数组 -->
<template v-for="(op, opIndex) in column.operations">
<el-button
:key="opIndex"
:disabled="
op.formatter ? op.formatter(scope.row).disabled : false
"
:style="[{ fontSize: fontSize + 'px' }, op.style]"
:type="
op.formatter
? op.formatter(scope.row).type
: op.type || ''
"
:icon="op.icon"
@click="op.func(scope.row, scope.$index)"
>
{{
op.formatter
? op.formatter(scope.row).label
: op.label
? op.label
: scope.row[column.value]
}}
</el-button>
</template>
</template>
<!-- 图片 -->
<template v-if="column.type === 'img'">
<el-image
style="width: 100px; height: 100px"
:src="
scope.row[column.value]
? 'https://ds.cixincloud.com/geca-api' +
'/disease-data/file/info/' +
scope.row[column.value][0].bucketName +
'/' +
scope.row[column.value][0].uuidName
: ''
"
:preview-src-list="[
scope.row[column.value]
? 'https://ds.cixincloud.com/geca-api' +
'/disease-data/file/info/' +
scope.row[column.value][0].bucketName +
'/' +
scope.row[column.value][0].uuidName
: '',
]"
></el-image>
</template>
<!-- 文件 -->
<template v-if="column.type === 'file'">
<span>
{{
scope.row[column.value]
? scope.row[column.value][0].fileName
: ""
}}
</span>
</template>
<!-- html -->
<template v-if="column.type === 'html'">
<div class="highlight" v-html="scope.row[column.value]"></div>
</template>
<!-- switch切换 启用 -->
<template v-if="column.type === 'switch'">
<el-switch
v-model="scope.row[column.value]"
:active-value="1"
:inactive-value="0"
@change="column.func(scope.row, scope.$index)"
></el-switch>
</template>
</template>
</el-table-column>
</template>
</template>
</el-table>
<!-- 分页 -->
<div v-if="pageSize && totalCounts > 0" class="pagination-footer">
<!-- <span class="description">{{ description }}</span> -->
<el-pagination
background
:current-page="currentPage"
:page-sizes="pageSizes"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="totalCounts"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
></el-pagination>
</div>
</el-row>
</template>
<script>
import resize from "../TabComponents/resize.js"
import { mapGetters } from "vuex"
export default {
mixins: [resize],
props: {
tableHeight: Number, // 表格的高度
maxHeight: Number, // 表格的最大高度
listLoading: Boolean, // table 加载层
pageSizes: Array, // 决定每页显示的条数[10,15,20,25]
pageSize: Number,
totalCount: [Number, String], // 表格数据总数
currentPage: { type: Number, default: 1 },
highLight: { type: Boolean, default: true },
headerClass: { type: String, default: "default" }, // 头部背景色Class名称,默认default
columns: Array, // 表格列配置数据,{vlaue:对应数据对象中的属性,label:对应的是标题文字,fixed:列是否固定,width:列宽, sortable:是否可排序,formatter:列格式化, className:对应的是列的样式类名}
tableData: Array, // 表格数据
showIndex: { default: false }, // 是否展示索引
},
data() {
return {
httpPrefix:
process.env.NODE_ENV === "development"
? "/api"
: process.env.VUE_APP_BASE_API,
}
},
computed: {
...mapGetters({
fontSize: "table/fontSize",
}),
totalCounts() {
return this.totalCount - 0
},
},
watch: {},
mounted() {},
methods: {
// 切换页面显示条数
handleSizeChange(val) {
this.$emit("pageSizeChange", val)
},
// 跳转页码
handleCurrentChange(val) {
this.$emit("currentPageChange", val)
},
},
}
</script>
<style lang="scss" scoped>
.el-table__empty-block {
position: relative;
min-height: 60px;
text-align: center;
width: 100%;
height: 100%;
}
.el-table__empty-text {
position: absolute;
left: 50%;
width: 110px;
height: 110px;
top: 50%;
line-height: 220px;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
color: #5e7382;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
}
::v-deep {
.el-table {
thead {
.newHeader {
height: 60px;
background: #f6f6f6;
}
}
}
}
</style>