永康嘉持电器有限公司前端
小小儁爺
2025-03-05 c34f771c22b4650c858b7d468ab00541a693bb4f
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
<template>
  <div>
    <div class="body" :style="{height:mainHeight+'px'}">
 
      <div class="bodyTopFormGroup" style="margin-top: 10px;height: 50px;padding:5px 0;">
        <div class="elForm" style="align-items: center;padding:5px 0;">
          <div style="font-weight: bolder;font-size: 14px;margin: 0 15px;color: #606266">
            工号二维码
          </div>
          <el-input
            v-model="form.usercode"
            :name="'usercodeInput'"
            placeholder="请扫描或输入工号二维码"
            style="width: 300px"
            @change="enterNative"
          />
        </div>
      </div>
 
      <div class="bodyTopButtonGroup" style="margin-top: 2px;height: 100px;align-items: center;">
        <el-form
          ref="form"
          :model="form"
          label-width="80px"
          inline
          style="display: flex;width: 50%;"
        >
          <div class="elForm">
            <el-form-item label="员工编号:" style=" display: flex;">
              <div style="width: 200px;">{{ form2.usercode }}</div>
            </el-form-item>
            <el-form-item label="员工姓名:" style=" display: flex;">
              <div style="width: 200px;">{{ form2.username }}</div>
            </el-form-item>
            <el-form-item label="所属车间:" style=" display: flex;">
              <div style="width: 200px;">{{ form2.torg_name }}</div>
            </el-form-item>
            <el-form-item label="所属岗位:" style=" display: flex;">
              <div style="width: 200px;">{{ form2.postname }}</div>
            </el-form-item>
          </div>
        </el-form>
      </div>
 
      <div class="elTableDiv">
        <el-table
          ref="tableDataRef"
          class="tableFixed"
          :data="tableData"
          :height="tableHeight+'px'"
          border
          row-class-name="custom-row"
          :style="{width: 100+'%',height:tableHeight+'px',}"
          highlight-current-row
          :header-cell-style="this.$headerCellStyle"
          :cell-style="this.$cellStyle"
        >
          <el-table-column
            type="index"
            width="50"
            fixed
            label="序号"
          />
          <el-table-column
            prop="wkshop_name"
            label="所属车间"
          />
          <el-table-column
            prop="username"
            label="打卡人员"
          />
          <el-table-column
            prop="createdate"
            label="打卡时间"
          />
          <el-table-column
            prop="workprice"
            label="工价(元/小时)"
          />
        </el-table>
      </div>
      <div
        class="bodyTopButtonGroup"
        style="margin-top: 0;height: 60px;display:flex;align-items: center;justify-content: center"
      >
        <el-button
          v-waves
          :disabled="isDisabled"
          type="primary"
          style="width: 150px;height: 40px;"
          icon="el-icon-alarm-clock"
          @click="clockIn"
        >考勤打卡</el-button>
      </div>
 
    </div>
 
  </div>
</template>
 
<script>
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import { AttendanceSave, AttendanceSearch } from '@/api/attendanceModule'
import $ from 'jquery'
 
export default {
  name: 'AttendanceClockIn',
  directives: { elDragDialog, waves },
  data() {
    return {
      mainHeight: 0,
      tableHeight: 0,
      form: {
        usercode: ''
      },
      form2: {
 
      },
      tableData: [],
      isDisabled: true
    }
  },
  activated() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.inputFocus()
  },
  created() {
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.inputFocus()
  },
  methods: {
    inputFocus() {
      // this.$nextTick(() => {
      $('input[name=\'usercodeInput\']')[0].focus()
      // })
    },
    async enterNative(val) {
      const { data: res } = await AttendanceSearch({ usercode: val })
      this.form.usercode = ''
      if (res.userdate.length === 0 && res.checkcrd.length === 0) {
        this.$message.info('无此员工号!')
        this.form2 = {}
        this.tableData = []
        this.isDisabled = true
      } else {
        this.form2 = res.userdate[0]
        this.tableData = res.checkcrd
        this.isDisabled = false
      }
    },
    async clockIn() {
      const data = {
        'wkshop_code': this.form2.storg_code,
        'user_code': this.form2.usercode
      }
      const res = await AttendanceSave(data)
      if (res.code === '200') {
        await this.enterNative(this.form2.usercode)
        this.$message.success('打卡成功!')
      }
    },
    // 获取页面高度
    getHeight() {
      this.$nextTick(() => {
        this.mainHeight = window.innerHeight - 85
        this.tableHeight = this.mainHeight - 250
        this.$refs.tableDataRef.doLayout()
      })
    }
  }
}
</script>