index.vue
9.61 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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<template>
<div class="NCC-common-layout">
<div class="NCC-common-layout-left">
<div class="NCC-common-title">
<h2>{{ $t('common.organization') }}</h2>
</div>
<el-scrollbar class="NCC-common-el-tree-scrollbar">
<el-tree
ref="treeBox"
v-loading="treeLoading"
:data="treeData"
:element-loading-text="$t('common.loadingText')"
:props="defaultProps"
default-expand-all
highlight-current
:expand-on-click-node="false"
node-key="id"
class="NCC-common-el-tree"
@node-click="handleNodeClick"
>
<span slot-scope="{ data, node }" class="custom-tree-node">
<i :class="data.icon" />
<span class="text">{{ node.label }}</span>
</span>
</el-tree>
</el-scrollbar>
</div>
<div class="NCC-common-layout-center NCC-flex-main">
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="统计月份">
<el-date-picker
v-model="monthStr"
type="month"
value-format="yyyy-MM"
format="yyyy-MM"
placeholder="选择月份"
style="width: 100%"
@change="onMonthChange"
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item :label="$t('common.keyWord')">
<el-input
v-model="params.keyword"
:placeholder="$t('common.enterKeyword')"
clearable
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">
{{ $t('common.search') }}
</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">
{{ $t('common.reset') }}
</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<div class="NCC-common-layout-main NCC-flex-main">
<div class="NCC-common-head">
<div class="NCC-common-head-left">
<span class="roster-hint">在职口径:有汇总以汇总「在职」为准;无汇总时入职≤该月末且(无离职日或离职≥该月1日)——当月离职仍显示;查次月时因离职日<次月1日不满足「≥次月1日」,上月离职者不再出现;未入职该月者不出现在该月</span>
</div>
<div class="NCC-common-head-right">
<el-tooltip effect="dark" :content="$t('common.refresh')" placement="top">
<el-link
icon="icon-ym icon-ym-Refresh NCC-common-head-icon"
:underline="false"
@click="initData()"
/>
</el-tooltip>
<screenfull />
</div>
</div>
<NCC-table v-loading="listLoading" :data="tableData">
<el-table-column label="账号" width="168" show-overflow-tooltip>
<template slot-scope="scope">
<i class="icon-ym icon-ym-user roster-icon roster-icon--primary" />
<span>{{ scope.row.account || '无' }}</span>
</template>
</el-table-column>
<el-table-column label="姓名" width="120" show-overflow-tooltip>
<template slot-scope="scope">
<i class="icon-ym icon-ym-header-user roster-icon roster-icon--success" />
<span>{{ scope.row.realName || '无' }}</span>
</template>
</el-table-column>
<el-table-column label="组织" min-width="160" show-overflow-tooltip>
<template slot-scope="scope">
<i class="icon-ym icon-ym-tree-organization3 roster-icon roster-icon--info" />
<span>{{ scope.row.department || '无' }}</span>
</template>
</el-table-column>
<el-table-column label="门店" width="160" show-overflow-tooltip>
<template slot-scope="scope">
<i class="icon-ym icon-ym-generator-store roster-icon roster-icon--warning" />
<span>{{ scope.row.mdName || '无' }}</span>
</template>
</el-table-column>
<el-table-column prop="gw" label="岗位" width="100" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.gw || '无' }}</span>
</template>
</el-table-column>
<el-table-column prop="zw" label="职位" width="100" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.zw || '无' }}</span>
</template>
</el-table-column>
<el-table-column label="主档在职" width="100">
<template slot-scope="scope">
<el-tag
:type="(scope.row.isOnJob === 0 || scope.row.isOnJob === '0') ? 'danger' : 'success'"
size="mini"
disable-transitions
>
{{ (scope.row.isOnJob === 0 || scope.row.isOnJob === '0') ? '离职' : '在职' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="汇总状态" width="100">
<template slot-scope="scope">
<span v-if="scope.row.summaryEmployeeStatus == null">无</span>
<el-tag v-else type="success" size="mini" disable-transitions>在职</el-tag>
</template>
</el-table-column>
<el-table-column label="出勤天数" width="100">
<template slot-scope="scope">
<span>{{ scope.row.workDays != null ? scope.row.workDays : '无' }}</span>
</template>
</el-table-column>
<el-table-column label="启用" width="80">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledMark == 1 ? 'success' : 'danger'" size="mini" disable-transitions>
{{ scope.row.enabledMark == 1 ? '正常' : '停用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="mobilePhone" label="手机" width="130" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.mobilePhone || '无' }}</span>
</template>
</el-table-column>
<el-table-column label="入职日期" width="120">
<template slot-scope="scope">
<span>{{ scope.row.entryDate ? ncc.dateFormat(scope.row.entryDate, 'YYYY-MM-DD') : '无' }}</span>
</template>
</el-table-column>
</NCC-table>
<Pagination
:total="total"
:page.sync="params.currentPage"
:limit.sync="params.pageSize"
@pagination="initData"
/>
</div>
</div>
</div>
</template>
<script>
import { getDepartmentSelector } from '@/api/permission/department'
import { getEmployeeRosterList } from '@/api/permission/employee-roster'
function currentYearMonthStr() {
const d = new Date()
const y = d.getFullYear()
const m = d.getMonth() + 1
return `${y}-${m < 10 ? '0' + m : m}`
}
export default {
name: 'permission-employee-roster',
data() {
const ym = currentYearMonthStr()
const parts = ym.split('-')
return {
treeData: [],
treeLoading: false,
listLoading: true,
tableData: [],
total: 0,
monthStr: ym,
params: {
year: parseInt(parts[0], 10),
month: parseInt(parts[1], 10),
organizeId: '',
keyword: '',
currentPage: 1,
pageSize: 20
},
defaultProps: {
children: 'children',
label: 'fullName'
}
}
},
created() {
this.getOrganizeList()
},
methods: {
onMonthChange(val) {
if (!val) return
const p = val.split('-')
this.params.year = parseInt(p[0], 10)
this.params.month = parseInt(p[1], 10)
},
getOrganizeList() {
this.treeLoading = true
getDepartmentSelector()
.then((res) => {
this.treeData = res.data.list
this.treeLoading = false
this.initData()
})
.catch(() => {
this.treeLoading = false
})
},
search() {
this.params.currentPage = 1
this.initData()
},
reset() {
const ym = currentYearMonthStr()
const parts = ym.split('-')
this.monthStr = ym
this.params.year = parseInt(parts[0], 10)
this.params.month = parseInt(parts[1], 10)
this.params.keyword = ''
this.params.organizeId = ''
this.params.currentPage = 1
this.params.pageSize = 20
if (this.$refs.treeBox) {
this.$refs.treeBox.setCurrentKey(null)
}
this.initData()
},
initData() {
this.listLoading = true
getEmployeeRosterList(this.params)
.then((res) => {
this.tableData = res.data.list || []
this.total = (res.data.pagination && res.data.pagination.total) || 0
this.listLoading = false
})
.catch(() => {
this.listLoading = false
})
},
handleNodeClick(data) {
if (this.params.organizeId === data.id) return
this.params.organizeId = data.id
this.search()
}
}
}
</script>
<style scoped lang="scss">
.roster-hint {
font-size: 12px;
color: #909399;
}
.roster-icon {
margin-right: 6px;
}
.roster-icon--primary {
color: #409eff;
}
.roster-icon--success {
color: #67c23a;
}
.roster-icon--info {
color: #909399;
}
.roster-icon--warning {
color: #e6a23c;
}
</style>