Blame view

antis-ncc-admin/src/views/attendance/index.vue 11.8 KB
5b6e99a5   李宇   ```
1
2
3
4
5
  <template>
  	<div class="NCC-common-layout">
  		<div class="NCC-common-layout-center">
  			<el-row class="NCC-common-search-box" :gutter="16">
  				<el-form @submit.native.prevent>
ecbae9ec   李宇   最新
6
7
8
9
10
  				<el-col :span="6">
  					<el-form-item label="员工姓名">
  						<user-select v-model="query.userId" placeholder="请选择员工" clearable />	
  					</el-form-item>
  				</el-col>
5b6e99a5   李宇   ```
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
  					<el-col :span="6">
  						<el-form-item label="年份">
  							<el-select v-model="query.year" placeholder="年份" clearable>
  								<el-option v-for="year in yearOptions" :key="year" :label="year + '年'" :value="year" />
  							</el-select>
  						</el-form-item>
  					</el-col>
  					<el-col :span="6">
  						<el-form-item label="月份">
  							<el-select v-model="query.month" placeholder="月份" clearable>
  								<el-option v-for="month in monthOptions" :key="month" :label="month + '月'" :value="month" />
  							</el-select>
  						</el-form-item>
  					</el-col>
  					<el-col :span="6">
  						<el-form-item label="员工状态">
  							<el-select v-model="query.employeeStatus" placeholder="员工状态" clearable>
  								<el-option label="在职" :value="1" />
  								<el-option label="离职" :value="0" />
  							</el-select>
  						</el-form-item>
  					</el-col>
  					<el-col :span="6">
  						<el-form-item>
  							<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
  							<el-button icon="el-icon-refresh-right" @click="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>
db9c79c0   “wangming”   feat: punch-based...
44
  						<el-button type="primary" icon="el-icon-refresh" :loading="syncLoading" @click="handleSyncFromRecords()">从打卡同步汇总</el-button>
5b6e99a5   李宇   ```
45
46
47
48
49
50
51
52
53
  						<el-button type="text" icon="el-icon-delete" @click="handleBatchDelete()">批量删除</el-button>
  					</div>
  					<div class="NCC-common-head-right">
  						<el-tooltip effect="dark" content="刷新" placement="top">
  							<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false" @click="reset()" />
  						</el-tooltip>
  						<screenfull isContainer />
  					</div>
  				</div>
db9c79c0   “wangming”   feat: punch-based...
54
                  <div class="attendance-summary-table-wrap">
5b6e99a5   李宇   ```
55
                  <NCC-table v-loading="listLoading" :data="list" has-c @selection-change="handleSelectionChange">
db9c79c0   “wangming”   feat: punch-based...
56
57
58
59
60
61
62
63
64
  					<el-table-column prop="userName" label="员工姓名" align="left" min-width="100" fixed="left" />
  					<el-table-column prop="year" label="年份" align="left" width="72" fixed="left" />
  					<el-table-column prop="month" label="月份" align="left" width="72" fixed="left" />
  					<el-table-column prop="attendanceGroupDisplay" label="当月考勤组" align="left" min-width="140" show-overflow-tooltip fixed="left">
  						<template slot-scope="scope">
  							{{ scope.row.attendanceGroupDisplay || '无' }}
  						</template>
  					</el-table-column>
  					<el-table-column label="员工状态" prop="employeeStatus" align="left" width="88" fixed="left">
5b6e99a5   李宇   ```
65
66
67
68
69
70
  						<template slot-scope="scope">
  							<el-tag :type="scope.row.employeeStatus === 1 ? 'success' : 'danger'" size="small">
  								{{ scope.row.employeeStatus === 1 ? '在职' : '离职' }}
  							</el-tag>
  						</template>
  					</el-table-column>
db9c79c0   “wangming”   feat: punch-based...
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
  					<el-table-column label="应休天数" align="left" min-width="88">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthEntitledRestDays) }}</template>
  					</el-table-column>
  					<el-table-column label="到岗天数" align="left" min-width="88">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthOnDutyDays) }}</template>
  					</el-table-column>
  					<el-table-column label="工作天数(应休+到岗)" align="left" min-width="150" show-overflow-tooltip>
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthCompositeWorkDays) }}</template>
  					</el-table-column>
  					<el-table-column label="带薪请假天数" align="left" min-width="108">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthPaidLeaveDays) }}</template>
  					</el-table-column>
  					<el-table-column label="请假天数" align="left" min-width="88">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthLeaveDaysTotal) }}</template>
  					</el-table-column>
  					<el-table-column label="迟到早退天数" align="left" min-width="108">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthLateEarlyDays) }}</template>
  					</el-table-column>
  					<el-table-column label="旷工天数" align="left" min-width="88">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthAbsenteeismDays) }}</template>
  					</el-table-column>
  					<el-table-column label="迟到/早退扣款" align="left" min-width="120" show-overflow-tooltip>
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthLateDeductionAmount) }}</template>
  					</el-table-column>
  					<el-table-column label="请假扣款" align="left" min-width="96">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthLeaveDeductionAmount) }}</template>
  					</el-table-column>
  					<el-table-column label="旷工扣款" align="left" min-width="96">
  						<template slot-scope="scope">{{ formatDecimal(scope.row.monthAbsenteeismDeductionAmount) }}</template>
  					</el-table-column>
  					<el-table-column prop="remark" label="备注" align="left" min-width="100" show-overflow-tooltip />
5b6e99a5   李宇   ```
102
103
104
105
106
107
108
109
110
111
112
  					<el-table-column label="创建时间" prop="createTime" align="left" width="150">
  						<template slot-scope="scope">
  							{{ formatTime(scope.row.createTime) }}
  						</template>
  					</el-table-column>
  					<el-table-column label="更新时间" prop="updateTime" align="left" width="150">
  						<template slot-scope="scope">
  							{{ formatTime(scope.row.updateTime) }}
  						</template>
  					</el-table-column>
  				</NCC-table>
db9c79c0   “wangming”   feat: punch-based...
113
                  </div>
5b6e99a5   李宇   ```
114
115
116
117
                  <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
              </div>
          </div>
  		
5b6e99a5   李宇   ```
118
119
120
121
122
123
124
  		<!-- 批量删除弹窗 -->
  		<BatchDeleteDialog v-if="batchDeleteVisible" ref="BatchDeleteDialog" @refresh="refresh" />
  	</div>
  </template>
  
  <script>
      import request from '@/utils/request'
5b6e99a5   李宇   ```
125
      import BatchDeleteDialog from './BatchDeleteDialog'
5b6e99a5   李宇   ```
126
127
      
  	export default {
db9c79c0   “wangming”   feat: punch-based...
128
          components: { BatchDeleteDialog },
5b6e99a5   李宇   ```
129
          data() {
ecbae9ec   李宇   最新
130
  			return {
5b6e99a5   李宇   ```
131
  				query: {
ecbae9ec   李宇   最新
132
                      userId: undefined,
5b6e99a5   李宇   ```
133
134
135
136
137
138
139
140
141
142
143
144
145
146
                      year: undefined,
                      month: undefined,
                      employeeStatus: undefined,
  				},
                  list: [],
                  listLoading: true,
                  multipleSelection: [], 
                  total: 0,
                  listQuery: {
                      currentPage: 1,
                      pageSize: 20,
  					sort: "desc",
                      sidx: "",
                  },
db9c79c0   “wangming”   feat: punch-based...
147
                  syncLoading: false,
5b6e99a5   李宇   ```
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
                  batchDeleteVisible: false,
                  yearOptions: [],
                  monthOptions: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
  			}
          },
  		computed: {},
  		created() {
  			this.initYearOptions()
  			this.initData()
  		},
  		methods: {
  			initYearOptions() {
  				const currentYear = new Date().getFullYear()
  				for (let i = currentYear - 5; i <= currentYear + 1; i++) {
  					this.yearOptions.push(i)
  				}
  			},
  			initData() {
                  this.listLoading = true;
                  let _query = {
                      ...this.listQuery,
                      ...this.query
                  };
                  let query = {}
                  for (let key in _query) {
                      if (Array.isArray(_query[key])) {
                          query[key] = _query[key].join()
                      } else {
                          query[key] = _query[key]
                      }
                  }
                  request({
                      url: `/api/Extend/lqattendancesummary`,
                      method: 'GET',
                      data: query
                  }).then(res => {
                      this.list = res.data.list
                      this.total = res.data.pagination.total
                      this.listLoading = false
                  })
              },
  			handleDel(id) {
                  this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
                      type: 'warning'
                  }).then(() => {
                      request({
                          url: `/api/Extend/lqattendancesummary/${id}`,
                          method: 'DELETE'
                      }).then(res => {
                          this.$message({
                              type: 'success',
                              message: res.msg,
                              onClose: () => {
                                  this.initData()
                              }
                          });
                      })
                  }).catch(() => {
                  });
              },
  			handleSelectionChange(val) {
                  const res = val.map(item => item.id)
                  this.multipleSelection = res
              },
db9c79c0   “wangming”   feat: punch-based...
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
              handleSyncFromRecords() {
                  if (!this.query.year || !this.query.month) {
                      this.$message.warning('请先在上方选择年份和月份')
                      return
                  }
                  this.$confirm(
                      `将删除 ${this.query.year} 年 ${this.query.month} 月已有汇总数据,并按考勤打卡记录重新生成,是否继续?`,
                      '提示',
                      { type: 'warning' }
                  ).then(() => {
                      this.syncLoading = true
                      return request({
                          url: `/api/Extend/lqattendancesummary/SyncFromAttendanceRecords/${this.query.year}/${this.query.month}`,
                          method: 'POST'
                      })
                  }).then(res => {
                      if (res.code === 200) {
                          this.$message.success((res.data && res.data.message) || res.msg || '同步成功')
                          this.initData()
                      }
                  }).catch(() => {}).finally(() => {
                      this.syncLoading = false
5b6e99a5   李宇   ```
234
235
236
237
238
239
240
241
                  })
              },
              handleBatchDelete() {
                  this.batchDeleteVisible = true
                  this.$nextTick(() => {
                      this.$refs.BatchDeleteDialog.init()
                  })
              },
5b6e99a5   李宇   ```
242
243
244
245
246
247
248
249
250
251
252
253
              formatTime(timestamp) {
                  if (!timestamp) return '无'
                  const date = new Date(timestamp)
                  return date.toLocaleString('zh-CN', {
                      year: 'numeric',
                      month: '2-digit',
                      day: '2-digit',
                      hour: '2-digit',
                      minute: '2-digit',
                      second: '2-digit'
                  })
              },
db9c79c0   “wangming”   feat: punch-based...
254
255
256
257
258
259
              formatDecimal(val) {
                  if (val === null || val === undefined || val === '') return '无'
                  const n = Number(val)
                  if (!Number.isFinite(n)) return '无'
                  return n.toFixed(2)
              },
5b6e99a5   李宇   ```
260
261
262
263
264
265
266
267
268
269
  			search() {
                  this.listQuery = {
                      currentPage: 1,
                      pageSize: 20,
                      sort: "desc",
                      sidx: "",
                  }
                  this.initData()
              },
              refresh(isrRefresh) {
5b6e99a5   李宇   ```
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
                  this.batchDeleteVisible = false
                  if (isrRefresh) this.reset()
              },
              reset() {
                  for (let key in this.query) {
                      this.query[key] = undefined
                  }
                  this.listQuery = {
                      currentPage: 1,
                      pageSize: 20,
                      sort: "desc",
                      sidx: "",
                  }
                  this.initData()
              }
  		}
      }
  </script>
db9c79c0   “wangming”   feat: punch-based...
288
289
290
291
292
293
294
295
296
297
  
  <style scoped lang="scss">
  .attendance-summary-table-wrap {
    width: 100%;
    overflow-x: auto;
  }
  .attendance-summary-table-wrap ::v-deep .el-table .cell {
    white-space: nowrap;
  }
  </style>