7
7
8
8
<template>
9
9
<ProTable ref="table" :request="request" :columns="columns" tableTitle="员工管理" fullHeight orderCondition="timestamp desc" v-bind="$attrs" v-on="$listeners">
10
- <template #columnFormatter="{row,prop}">
11
- <el-tag v-if="prop === 'jobno'">{{ row.jobno }}</el-tag>
12
- <span v-if="prop === 'personname'"><i class="el-icon el-icon-user" style="color: red"></i>{{ row.personname }}</span>
13
- </template>
10
+ <template #columnFormatter="{row,prop}">
11
+ <el-tag v-if="prop === 'jobno'">{{ row.jobno }}</el-tag>
12
+ <span v-if="prop === 'personname'"><i class="el-icon el-icon-user" style="color: red"></i>{{ row.personname }}</span>
13
+ <el-image style="width: 50px; height: 50px" fit="fill" v-if="prop === 'avatar'" :src="getAvatarUrl(row)" :preview-src-list="[getAvatarUrl(row)]">
14
+ <div slot="error" style="height: 100%">
15
+ <div class="error"><i class="el-icon-picture-outline"></i></div>
16
+ </div>
17
+ </el-image>
18
+ </template>
14
19
</ProTable>
15
20
</template>
16
21
@@ -23,29 +28,38 @@ import { Vue, Component, Prop } from 'vue-property-decorator';
23
28
})
24
29
export default class PersonProTable extends Vue {
25
30
columns = {
26
- name: 'person',
27
- position: '人员信息列表',
28
31
columns: [
32
+ {
33
+ prop: 'avatar',
34
+ label: '照片',
35
+ align: 'center',
36
+ headerAlign: 'center',
37
+ showOverflowTooltip: true,
38
+ minWidth: 140,
39
+ sortable: 'custom',
40
+ searchable: true,
41
+ slotName: 'columnFormatter',
42
+ },
29
43
{
30
44
prop: 'jobno',
31
45
label: '工号',
32
- minWidth: 140 ,
46
+ minWidth: '100' ,
33
47
align: 'center',
34
48
headerAlign: 'center',
35
49
showOverflowTooltip: true,
36
50
sortable: 'custom',
37
- slotName: '',
51
+ slotName: 'columnFormatter ',
38
52
searchable: true,
39
53
},
40
54
{
41
55
prop: 'personname',
42
56
label: '姓名',
43
- minWidth: 140 ,
57
+ minWidth: '70' ,
44
58
align: 'center',
45
59
headerAlign: 'center',
46
60
showOverflowTooltip: true,
47
61
sortable: 'custom',
48
- slotName: '',
62
+ slotName: 'columnFormatter ',
49
63
searchable: true,
50
64
},
51
65
{
@@ -62,7 +76,7 @@ export default class PersonProTable extends Vue {
62
76
{
63
77
prop: 'deptname',
64
78
label: '所在部门',
65
- minWidth: 140 ,
79
+ minWidth: '100' ,
66
80
align: 'center',
67
81
headerAlign: 'center',
68
82
showOverflowTooltip: true,
@@ -73,7 +87,7 @@ export default class PersonProTable extends Vue {
73
87
{
74
88
prop: 'post',
75
89
label: '岗位',
76
- minWidth: 140 ,
90
+ minWidth: '100' ,
77
91
align: 'center',
78
92
headerAlign: 'center',
79
93
showOverflowTooltip: true,
@@ -84,7 +98,7 @@ export default class PersonProTable extends Vue {
84
98
{
85
99
prop: 'level',
86
100
label: '职级',
87
- minWidth: 140 ,
101
+ minWidth: '100' ,
88
102
align: 'center',
89
103
headerAlign: 'center',
90
104
showOverflowTooltip: true,
@@ -104,6 +118,8 @@ export default class PersonProTable extends Vue {
104
118
searchable: true,
105
119
},
106
120
],
121
+ name: 'person',
122
+ position: '员工管理',
107
123
}
108
124
109
125
async request(axiosParams: Params): Promise<DataSource> {
@@ -113,5 +129,21 @@ export default class PersonProTable extends Vue {
113
129
total: res.data.total,
114
130
};
115
131
}
132
+
133
+ getAvatarUrl(row) {
134
+ return window.__HOST__URL__ + row.avatar;
135
+ }
116
136
}
117
137
</script>
138
+ <style lang="scss" scoped>
139
+ .error {
140
+ display: flex;
141
+ justify-content: center;
142
+ align-items: center;
143
+ width: 100%;
144
+ height: 100%;
145
+ background: #f5f7fa;
146
+ color: #909399;
147
+ font-size: 30px;
148
+ }
149
+ </style>
0 commit comments