index.vue
25.6 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<template>
<div class="app-container">
<!-- 查询条件 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="50px">
<el-form-item label="单位" prop="companyId">
<el-select v-model="queryParams.companyId" filterable placeholder="请选择">
<el-option v-for="item in companyList" :key="item.id" :label="item.companyName" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<!--
<el-form-item label="人员" prop="personId">
<el-select v-model="queryParams.personId" filterable placeholder="请选择" style="width: 260px;">
<el-option v-for="item in userBList" :key="item.userId" :label="item.nickName" :value="item.userId">
</el-option>
</el-select>
</el-form-item>
-->
<el-form-item label="合同" prop="contractId">
<el-select v-model="queryParams.contractId" filterable placeholder="请选择">
<el-option v-for="item in contractList" :key="item.id" :label="item.contractName" :value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="日期" prop="dateValue">
<el-date-picker v-model="dateValue" type="daterange" align="right" unlink-panels range-separator="至"
start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"
:picker-options="pickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 顶部数据 -->
<el-card>
<div class="flexbox">
<div class="flexitem" v-for="item in topShowList" :class="item.className">
<div class="itemname">{{ item.name }}</div>
<div class="itemvalue">{{ item.value }}<span class="itemunit">{{ item.unit }}</span></div>
</div>
<div class="el-icon-question cus" v-if="$store.state.user.showRules"
style="color: #1890ff; font-size: 22px;" @click="rulsDetail = true">
</div>
</div>
</el-card>
<!-- echarts图标 -->
<el-row :gutter="10" class="spacing-top-10">
<!--左侧tree-->
<el-col :span="14">
<el-card>
<div class="chartsbox1" ref="charts1"></div>
</el-card>
</el-col>
<el-col :span="10">
<el-card>
<div class="chartsbox1" ref="charts2"></div>
</el-card>
</el-col>
</el-row>
<div class="spacing-top-10">
<el-card>
<div class="chartsbox1" ref="charts3"></div>
</el-card>
</div>
<div class="spacing-top-10">
<el-card>
<div class="flex flex-between">
<el-tabs v-model="activeName" type="card">
<el-tab-pane label="实际考勤-合同" name="contract1"></el-tab-pane>
<el-tab-pane label="实际考勤-单位" name="company1"></el-tab-pane>
<el-tab-pane label="有效加班-合同" name="contract3"></el-tab-pane>
<el-tab-pane label="有效加班-单位" name="company3"></el-tab-pane>
<!-- <el-tab-pane label="不含请假-单位" name="company2"></el-tab-pane> -->
<!-- <el-tab-pane label="不含请假-合同" name="contract2"></el-tab-pane> -->
</el-tabs>
<div>
<el-button type="warning" plain icon="el-icon-download" size="mini" class="spacing-right-5"
@click="handleExport">导出</el-button>
<div class="el-icon-question cus" v-if="$store.state.user.showRules"
style="color: #1890ff; font-size: 22px;" @click="bottomRulesDetail = true">
</div>
</div>
</div>
<el-table v-loading="loading"
:data="activeName == 'company1' || activeName == 'company2' || activeName == 'company3' ? attendanceList1 : attendanceList2">
<el-table-column type="index" width="50" key="1" />
<el-table-column key="2" label="单位" prop="companyShortName" />
<el-table-column key="3" label="合同" prop="contractShortName"
v-if="activeName == 'contract1' || activeName == 'contract2' || activeName == 'contract3'"
min-width="200" />
<!-- <el-table-column key="4"
:label="activeName == 'company1' || activeName == 'company2' || activeName == 'company3' ? '单位人数' : '合同人数'"
prop="personNum" align="right" /> -->
<el-table-column key="4" label="合同人数" prop="personNum" align="right" />
<el-table-column key="8" label="夜班出勤数" prop="nmScore" align="right"
v-if="activeName == 'company1' || activeName == 'contract1'" />
<el-table-column key="6" label="上午班出勤数" prop="amScore" align="right"
v-if="activeName == 'company1' || activeName == 'contract1'" />
<el-table-column key="7" label="下午班出勤数" prop="pmScore" align="right"
v-if="activeName == 'company1' || activeName == 'contract1'" />
<el-table-column key="12" label="夜班出勤数" prop="nmScore2" align="right"
v-if="activeName == 'company2' || activeName == 'contract2'" />
<el-table-column key="10" label="上午班出勤数" prop="amScore2" align="right"
v-if="activeName == 'company2' || activeName == 'contract2'" />
<el-table-column key="11" label="下午班出勤数" prop="pmScore2" align="right"
v-if="activeName == 'company2' || activeName == 'contract2'" />
<el-table-column key="16" label="夜班出勤数" prop="nmScore3" align="right"
v-if="activeName == 'company3' || activeName == 'contract3'" />
<el-table-column key="14" label="上午班出勤数" prop="amScore3" align="right"
v-if="activeName == 'company3' || activeName == 'contract3'" />
<el-table-column key="15" label="下午班出勤数" prop="pmScore3" align="right"
v-if="activeName == 'company3' || activeName == 'contract3'" />
<el-table-column key="5" label="应出勤数" prop="shoudScore" align="right" />
<el-table-column key="13" label="实际出勤数" prop="sumScore2" align="right"
v-if="activeName == 'company2' || activeName == 'contract2'" />
<el-table-column key="9" label="实际出勤数" prop="sumScore" align="right"
v-if="activeName == 'company1' || activeName == 'contract1'" />
<el-table-column key="17" label="实际出勤数" prop="sumScore3" align="right"
v-if="activeName == 'company3' || activeName == 'contract3'" />
<el-table-column key="18" label="迟到次数" prop="lateTimes" align="right" />
<el-table-column key="19" label="早退次数" prop="earlyTimes" align="right" />
<el-table-column key="20" label="请假数" prop="leaveTimes" align="right" />
<el-table-column key="21" label="出勤率" prop="percent" align="right"
v-if="activeName == 'company1' || activeName == 'contract1'">
<template slot-scope="scope">
{{ scope.row.percent }}%
</template>
</el-table-column>
<el-table-column key="22" label="出勤率" prop="percent" align="right"
v-if="activeName == 'company2' || activeName == 'contract2'">
<template slot-scope="scope">
{{ scope.row.percent2 }}%
</template>
</el-table-column>
<el-table-column key="23" label="出勤率" prop="percent" align="right"
v-if="activeName == 'company3' || activeName == 'contract3'">
<template slot-scope="scope">
{{ scope.row.percent3 }}%
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="getList" />
</el-card>
</div>
<el-dialog title="统计规则" :visible.sync="rulsDetail" width="1000px">
<div v-html="checkRule"></div>
</el-dialog>
<el-dialog title="统计规则" :visible.sync="bottomRulesDetail" width="1000px">
<div v-html="bottomRule"></div>
</el-dialog>
</div>
</template>
<script>
import { getTopShowList, getBarList, getPieList, getContractBarList, getCompanyList, getContractList, checkRule } from "@/api/view/vcheckon";
import { listCompany } from "@/api/resource/company";
import { listContract, getUserList } from "@/api/resource/contract";
import { checkCount } from "@/api/view/vcompany";
import store from "@/store";
import * as echarts from "echarts";
export default {
name: "Vcheckon",
data() {
return {
loading: false,
total: 0,
// 单位列表
companyList: [],
// 合同列表
contractList: [],
//日期
dateValue: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
companyId: '',//单位
personId: '',//人员
contractId: '',//合同
},
// 日期快捷键
pickerOptions: {
shortcuts: [
{
text: '本周',
onClick(picker) {
const monday = new Date()
const now = new Date()
const todayOfWeek = now.getDay() || 7
monday.setTime(now.getTime() - (todayOfWeek - 1) * 24 * 60 * 60 * 1000)
picker.$emit('pick', [monday, now])
}
},
{
text: '上周',
onClick(picker) {
const monday = new Date()
const sunday = new Date()
const now = new Date()
const todayOfWeek = now.getDay() || 7
sunday.setTime(now.getTime() - todayOfWeek * 24 * 60 * 60 * 1000)
monday.setTime(sunday.getTime() - 6 * 24 * 60 * 60 * 1000)
picker.$emit('pick', [monday, sunday])
}
},
{
text: '本月',
onClick(picker) {
const firstDay = new Date()
const now = new Date()
firstDay.setDate(1)
picker.$emit('pick', [firstDay, now])
}
},
{
text: '上月',
onClick(picker) {
const lastDay = new Date()
lastDay.setDate(0)
const firstDay = new Date(lastDay)
firstDay.setDate(1)
picker.$emit('pick', [firstDay, lastDay])
}
},]
},
// top数据
topShowList: [],
charts1: null,
charts2: null,
charts3: null,
// 图表
barList: {
xAxis: [],
yData: []
},
pieList: [],
contractBarList: {
xAxis: [],
yData: []
},
// 按单位分组表格
attendanceList1: [],
// 按合同分组表格
attendanceList2: [],
userBList: [],
// tab标签
activeName: 'company1',
rulsDetail: false,
checkRule: '',
bottomRulesDetail: false,
bottomRule: '',
}
},
created() {
// 获取当月1日到当天
this.getInitializeDate();
// 人员列表
this.getUsers();
// 单位列表
this.getCompanyList();
// 合同列表
this.getcontractList();
// top数据、表格数据获取
this.getListDatas();
this.getCheckCount();
this.getcheckRule();
},
mounted() {
// 图表数据获取
this.getChartData();
},
methods: {
getCheckCount() {
checkCount().then((res) => {
this.checkRule = res.data.remark;
})
},
getcheckRule() {
checkRule().then((res) => {
this.bottomRule = res.data.remark;
})
},
getInitializeDate() {
let date = new Date()
let year = date.getFullYear().toString()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString()
let day = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate().toString()
let start = year + '-' + month + '-01'
let end = year + '-' + month + '-' + day
this.dateValue = [start, end]
},
// 人员列表
getUsers() {
getUserList({ userType: 2 }).then((res) => {
this.userBList = res.data;
})
},
// 单位列表
getCompanyList() {
listCompany({ pageSize: 999 }).then(response => {
this.companyList = response.rows;
});
},
// 合同列表
getcontractList() {
listContract({ pageSize: 999,status:'1' }).then(response => {
this.contractList = response.rows;
})
},
// top数据、echarts数据
getListDatas() {
let visit = JSON.parse(JSON.stringify(this.queryParams));
visit.beginTime = this.dateValue.length == 0 ? '' : this.dateValue[0]
visit.endTime = this.dateValue.length == 0 ? '' : this.dateValue[1]
delete visit.params;
getTopShowList(visit).then(response => {
this.topShowList = response.data.topShowList;
})
this.getList();
},
// 表格数据
getList() {
let visit = JSON.parse(JSON.stringify(this.queryParams));
visit.beginTime = this.dateValue.length == 0 ? '' : this.dateValue[0]
visit.endTime = this.dateValue.length == 0 ? '' : this.dateValue[1]
delete visit.params;
getCompanyList(visit).then(response => {
this.attendanceList1 = response.data;
this.loading = false;
})
getContractList(visit).then(response => {
this.attendanceList2 = response.data;
this.loading = false;
})
},
getChartData() {
let visit = JSON.parse(JSON.stringify(this.queryParams));
visit.beginTime = this.dateValue.length == 0 ? '' : this.dateValue[0]
visit.endTime = this.dateValue.length == 0 ? '' : this.dateValue[1]
delete visit.params;
getBarList(visit).then(response => {
this.barList.xAxis = response.data.xAxis;
this.barList.yData = response.data.yData;
this.drawBar();
})
getPieList(visit).then(response => {
this.pieList = response.data;
this.drawPie();
})
getContractBarList(visit).then(response => {
this.contractBarList.xAxis = response.data.xAxis;
this.contractBarList.yData = response.data.yData;
this.drawBarContract();
})
},
// 搜索
handleQuery() {
this.queryParams.pageNum = 1;
this.getListDatas();
this.getChartData();
},
// 重置
resetQuery() {
this.resetForm("queryForm");
this.dateValue = [];
this.getInitializeDate();
this.handleQuery();
},
// 柱状图
drawBar() {
const barChart = echarts.init(this.$refs.charts1)
let colorArry = [
new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(0, 192, 240, 1)' // 0% 处的颜色
}, {
offset: 1,
color: 'rgba(101, 105, 255, 1)' // 100% 处的颜色
}], false),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(27, 223, 202, 1)' // 0% 处的颜色
}, {
offset: 1,
color: 'rgba(8, 222, 149, 1)' // 100% 处的颜色
}], false)
]
let option = {
color: colorArry,
title: {
text: '单位出勤率',
left: 'center',
},
grid: {
left: '3%', //默认10%
right: '3%', //默认10%
bottom: '4%', //默认60
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
let template = ''
params.forEach((item, index) => {
template = item.marker + item.name + " : " + item.value + '%' + "<br>"
})
return template;
}
},
xAxis: {
type: 'category',
data: this.barList.xAxis,
axisLabel: {
interval: 0,
rotate: 45,
formatter: function (value) {
if (value.length > 5) {
return value.slice(0, 5) + '...'
} else {
return value
}
},
}
},
yAxis: {
type: 'value',
axisLabel: { formatter: `{value} %` }
},
series: [
{
data: this.barList.yData,
type: 'bar',
barWidth: 20
}
]
};
barChart.setOption(option);
},
// 饼图
drawPie() {
const pieChart = echarts.init(this.$refs.charts2);
let option = {
title: {
text: '夜班占比',
left: 'center'
},
grid: {
left: '3%', //默认10%
right: '3%', //默认10%
bottom: '4%', //默认60
containLabel: true
},
tooltip: {
trigger: 'item',
formatter: function (params) {
var res;
res = '<div>' + params.data.name + ':' + params.data.value + '%</div>'
return res
}
},
legend: {
orient: 'vertical',
left: 'left'
},
series: [
{
type: 'pie',
radius: '50%',
label: {
formatter: function (data) {
return data.name + data.value
}
},
data: this.pieList,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
pieChart.setOption(option);
},
drawBarContract() {
const barChartContract = echarts.init(this.$refs.charts3)
let colorArry = [
new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(0, 192, 240, 1)' // 0% 处的颜色
}, {
offset: 1,
color: 'rgba(101, 105, 255, 1)' // 100% 处的颜色
}], false),
new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(27, 223, 202, 1)' // 0% 处的颜色
}, {
offset: 1,
color: 'rgba(8, 222, 149, 1)' // 100% 处的颜色
}], false)
]
let option = {
color: colorArry,
title: {
text: '合同出勤率',
left: 'center',
},
grid: {
left: '3%', //默认10%
right: '3%', //默认10%
bottom: '4%', //默认60
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function (params) {
let template = ''
params.forEach((item, index) => {
template = item.marker + item.name + " : " + item.value + '%' + "<br>"
})
return template;
}
},
xAxis: {
type: 'category',
data: this.contractBarList.xAxis,
axisLabel: {
interval: 0,
rotate: 45,
formatter: function (value) {
if (value.length > 3) {
return value.slice(0, 3) + '...'
} else {
return value
}
},
}
},
yAxis: {
type: 'value',
axisLabel: { formatter: `{value} %` },
},
series: [
{
data: this.contractBarList.yData,
type: 'bar',
barWidth: 15
}
]
};
barChartContract.setOption(option);
},
// 导出
handleExport() {
this.download('view/vcheckon/export?companyId=' + this.queryParams.companyId + '&personId=' + this.queryParams.personId + '&contractId=' + this.queryParams.contractId + '&beginTime=' + this.dateValue[0] + '&endTime=' + this.dateValue[1], {}, `考勤信息-${new Date().getTime()}.xlsx`)
},
},
}
</script>
<style scoped>
.flexbox {
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
}
.flexitem {
width: 13%;
height: 110px;
/* margin: 10px 13px 10px 14px; */
margin: 10px;
border-radius: 10px;
box-shadow: 4px 5px 5px -4px rgba(204, 204, 204, 0.5)
}
.itemname {
font-size: 18px;
font-weight: 600;
color: #656565;
padding-left: 30px;
padding-top: 15px;
}
.itemvalue {
font-size: 40px;
font-weight: 700;
text-align: center;
height: 55px;
line-height: 55px;
}
.itemunit {
color: #666;
font-size: 18px;
margin-left: 7px;
}
.bg01 {
background: linear-gradient(to top right, rgb(255, 255, 255), rgb(38, 105, 250));
}
.bg02 {
background: linear-gradient(to top right, rgb(255, 255, 255), rgb(133, 196, 255));
}
.bg03 {
background: linear-gradient(to top right, rgb(255, 255, 255), rgb(42, 140, 252));
}
.m-t-15 {
margin-top: 15px;
}
.chartsbox1 {
width: 100%;
height: 330px;
}
</style>