Blame view

src/views/oa/staffAttendanceManageList.vue 9.99 KB
d4a6b78f   wuxw   OA 中考勤功能开发完成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  <template>
    <div class="staff-attendance-manage-container">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-card class="box-card">
            <div class="filter-wrapper">
              <el-date-picker v-model="staffAttendanceManageInfo.curDate" type="month"
                :placeholder="$t('staffAttendance.monthPlaceholder')" value-format="yyyy-MM" class="filter-item"
                @change="handleDateChange"></el-date-picker>
  
              <el-input v-model="staffAttendanceManageInfo.orgName" readonly
                :placeholder="$t('staffAttendance.orgPlaceholder')" class="filter-item"
                @focus="handleOrgFocus"></el-input>
  
              <el-input v-model="staffAttendanceManageInfo.staffNameLike"
                :placeholder="$t('staffAttendance.staffPlaceholder')" class="filter-item"
                @keyup.enter.native="loadStaffs"></el-input>
  
6f916870   wuxw   优化甘肃客户反馈bug
19
20
21
22
23
              <div class="filter-item text-right">
                <el-button type="primary" @click="loadStaffs">
                  {{ $t('common.search') }}
                </el-button>
              </div>
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
            </div>
  
            <div class="staff-list">
              <ul class="staff-ul">
                <li v-for="(item, index) in staffAttendanceManageInfo.staffs" :key="index" class="staff-item"
                  :class="{ 'active': staffAttendanceManageInfo.curStaffId === item.userId }" @click="switchStaff(item)">
                  {{ item.name }}
                </li>
              </ul>
            </div>
          </el-card>
        </el-col>
  
        <el-col :span="20">
          <el-card class="box-card">
            <div class="attendance-grid">
              <el-row :gutter="20">
                <el-col v-for="index in staffAttendanceManageInfo.maxDay" :key="index" :span="4" class="attendance-day"
                  :style="{ backgroundColor: getBgColor(index) }">
                  <div class="day-header">
                    {{ staffAttendanceManageInfo.curYear }}-{{ staffAttendanceManageInfo.curMonth }}-{{ index }}
                  </div>
  
                  <div v-if="getDayAttendance(index) && getDayAttendance(index).state !== '30000'" class="replenish-btn"
                    @click="replenishCheckIn(index)">
                    {{ $t('staffAttendance.replenish') }}
                  </div>
  
                  <div v-for="(item, detailIndex) in getAttendanceDetail(index)" :key="detailIndex"
                    class="attendance-detail">
                    <div v-if="item.rest">{{ item.rest }}</div>
                    <div v-else>
                      {{ item.specCd === '1001' ? $t('staffAttendance.work') : $t('staffAttendance.offWork') }}:
                      <span v-if="item.state !== '10000'">{{ formatTime(item.checkTime) }}</span>
                      <span v-else> - </span>
                      <span>({{ item.stateName }})</span>
                    </div>
                  </div>
  
                  <div class="log-link">
                    <el-link type="primary" @click="checkInLog(index)">
                      {{ $t('staffAttendance.log') }}
                    </el-link>
                  </div>
                </el-col>
              </el-row>
            </div>
          </el-card>
        </el-col>
      </el-row>
  
      <!-- 子组件 -->
6f916870   wuxw   优化甘肃客户反馈bug
76
  
d4a6b78f   wuxw   OA 中考勤功能开发完成
77
78
79
80
81
82
83
84
85
86
87
      <choose-org-tree ref="chooseOrgTree" @switchOrg="handleSwitchOrg"></choose-org-tree>
      <staff-attendance-detail ref="staffAttendanceDetail"></staff-attendance-detail>
      <staff-attendance-replenish-check-in ref="staffAttendanceReplenishCheckIn"></staff-attendance-replenish-check-in>
    </div>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import {
    queryStaffInfos,
    queryAttendanceClassesTask,
6f916870   wuxw   优化甘肃客户反馈bug
88
  
d4a6b78f   wuxw   OA 中考勤功能开发完成
89
  } from '@/api/oa/staffAttendanceManageApi'
1a0bdbe0   wuxw   优化缴费页面
90
  import { dateFormat } from '@/utils/dateUtil'
56732765   wuxw   修改员工界面部分bug
91
92
93
  import ChooseOrgTree from '@/components/org/ChooseOrgTree'
  import StaffAttendanceDetail from '@/components/oa/staffAttendanceDetail'
  import StaffAttendanceReplenishCheckIn from '@/components/oa/staffAttendanceReplenishCheckIn'
d4a6b78f   wuxw   OA 中考勤功能开发完成
94
95
96
97
  
  export default {
    name: 'StaffAttendanceManageList',
    components: {
56732765   wuxw   修改员工界面部分bug
98
99
100
      ChooseOrgTree,
      StaffAttendanceDetail,
      StaffAttendanceReplenishCheckIn
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
    },
    data() {
      return {
        communityId: '',
        staffAttendanceManageInfo: {
          staffs: [],
          attendances: [],
          classesId: '',
          orgId: '',
          orgName: '',
          curDate: '',
          curYear: '',
          curMonth: '',
          curStaffId: '',
          maxDay: 31,
          staffNameLike: ''
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
      this.initStaffDate()
      this.loadStaffs()
    },
    methods: {
      initStaffDate() {
        const date = new Date()
        this.staffAttendanceManageInfo.curMonth = date.getMonth() + 1
        this.staffAttendanceManageInfo.curYear = date.getFullYear()
        this.staffAttendanceManageInfo.curDate = `${date.getFullYear()}-${date.getMonth() + 1}`
        this.staffAttendanceManageInfo.maxDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate()
      },
  
      handleDateChange(val) {
        if (val) {
          const values = val.split('-')
          this.staffAttendanceManageInfo.curYear = values[0]
          this.staffAttendanceManageInfo.curMonth = values[1]
          this.staffAttendanceManageInfo.maxDay = new Date(values[0], values[1], 0).getDate()
          this.loadStaffAttendances()
        }
      },
  
      async loadStaffs() {
        try {
          const params = {
            page: 1,
            row: 100,
            orgId: this.staffAttendanceManageInfo.orgId,
            staffName: this.staffAttendanceManageInfo.staffNameLike,
            communityId: this.communityId
          }
  
6f916870   wuxw   优化甘肃客户反馈bug
154
          const data = await queryStaffInfos(params)
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
          this.staffAttendanceManageInfo.staffs = data.staffs || []
  
          if (this.staffAttendanceManageInfo.staffs.length > 0) {
            this.staffAttendanceManageInfo.curStaffId = this.staffAttendanceManageInfo.staffs[0].userId
            this.loadStaffAttendances()
          }
        } catch (error) {
          console.error('Failed to load staffs:', error)
        }
      },
  
      async loadStaffAttendances() {
        if (!this.staffAttendanceManageInfo.curStaffId || !this.staffAttendanceManageInfo.curDate) return
  
        try {
          const params = {
            page: 1,
            row: 1000,
            date: this.staffAttendanceManageInfo.curDate,
            staffId: this.staffAttendanceManageInfo.curStaffId,
            communityId: this.communityId
          }
  
          const { data } = await queryAttendanceClassesTask(params)
          this.staffAttendanceManageInfo.attendances = data || []
        } catch (error) {
          console.error('Failed to load staff attendances:', error)
        }
      },
  
      handleOrgFocus() {
        this.$refs.chooseOrgTree.open()
      },
  
      handleSwitchOrg(org) {
        this.staffAttendanceManageInfo.orgId = org.orgId
        this.staffAttendanceManageInfo.orgName = org.allOrgName
        this.loadStaffs()
      },
  
      switchStaff(staff) {
        this.staffAttendanceManageInfo.curStaffId = staff.userId
        this.loadStaffAttendances()
      },
  
      getDayAttendance(day) {
        if (!this.staffAttendanceManageInfo.attendances) return null
  
        return this.staffAttendanceManageInfo.attendances.find(item => item.taskDay === day) || null
      },
  
      getAttendanceDetail(day) {
        const attendance = this.getDayAttendance(day)
  
        if (!attendance) {
          const date = new Date()
          const taskYear = this.staffAttendanceManageInfo.curYear
          const taskMonth = this.staffAttendanceManageInfo.curMonth
  
          if (taskYear == date.getFullYear() && parseInt(taskMonth) == (date.getMonth() + 1) && day > date.getDate()) {
            return [{ rest: this.$t('staffAttendance.notTime') }]
          }
  
          return [{ rest: this.$t('staffAttendance.noNeed') }]
        }
  
        return attendance.attendanceClassesTaskDetails || []
      },
  
      getBgColor(day) {
        console.log(day)
        return '#fff'
      },
  
      formatTime(time) {
        if (!time) return ''
1a0bdbe0   wuxw   优化缴费页面
231
        return dateFormat(time)
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
      },
  
      checkInLog(day) {
        let month = this.staffAttendanceManageInfo.curMonth
        if (month < 10) month = `0${month}`
        if (day < 10) day = `0${day}`
  
        const date = `${this.staffAttendanceManageInfo.curYear}-${month}-${day}`
        this.$refs.staffAttendanceDetail.open({
          staffId: this.staffAttendanceManageInfo.curStaffId,
          date: date
        })
      },
  
      replenishCheckIn(day) {
        const details = this.getAttendanceDetail(day)
        if (!details || details.length < 1) {
          this.$message.warning(this.$t('staffAttendance.noTask'))
          return
        }
  
        const newDetails = details.filter(item => item.state === '10000')
        if (newDetails.length < 1) {
          this.$message.warning(this.$t('staffAttendance.noTask'))
          return
        }
  
        this.$refs.staffAttendanceReplenishCheckIn.open(newDetails)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .staff-attendance-manage-container {
    padding: 20px;
  
    .box-card {
      margin-bottom: 20px;
    }
  
    .filter-wrapper {
      .filter-item {
        margin-bottom: 15px;
        width: 100%;
      }
    }
  
    .staff-list {
      max-height: 600px;
      overflow-y: auto;
  
      .staff-ul {
        list-style: none;
        padding: 0;
        margin: 0;
  
        .staff-item {
          padding: 10px;
          margin-bottom: 5px;
          cursor: pointer;
          border-radius: 4px;
          text-align: center;
  
          &:hover {
            background-color: #f5f7fa;
          }
  
          &.active {
            background-color: #409eff;
            color: #fff;
          }
        }
      }
    }
  
    .attendance-grid {
      .attendance-day {
        padding: 10px;
        margin-bottom: 20px;
        border-radius: 4px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  
        .day-header {
          font-weight: bold;
          margin-bottom: 10px;
          text-align: center;
        }
  
        .replenish-btn {
          color: #409eff;
          cursor: pointer;
          text-align: center;
          margin-bottom: 10px;
  
          &:hover {
            text-decoration: underline;
          }
        }
  
        .attendance-detail {
          margin-bottom: 5px;
          font-size: 12px;
        }
  
        .log-link {
          text-align: center;
          margin-top: 10px;
        }
      }
    }
  }
  </style>