cuilei
2025-06-13 1e653db94c24389cc7615fd4a7ef1d63b00af534
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
<template>
  <div class="full-screen-container">
    <slot name="function"/>
 
    <a-tabs default-active-key="1">
      <a-tab-pane tab="打卡上下班" key="1" dataset="first">
        <a-form-model ref="form" :model="model" :rules="validateRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-row>
            <a-col :span="24">
              <a-form-model-item label="设备名称" prop="equipmentIdList">
                <a-select v-model="model.equipmentIdList" mode="multiple" placeholder="请选择设备" :maxTagCount="3"
                          allow-clear>
                  <a-select-option v-for="item in equipmentList" :key="item.equipmentId">
                    {{item.equipmentId+`[${item.equipmentName}]`}}
                  </a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
          </a-row>
 
          <div style="text-align: center;margin-top: 150px">
            <a-space>
              <a-button size="large" type="primary" @click="handleClockInAndOut('In',1)" :loading="clockInLoading1"
                        :disabled="clockOutLoading1||clockInLoading2||clockOutLoading2">早班上班
              </a-button>
              <a-button size="large" type="primary" @click="handleClockInAndOut('Out',1)" :loading="clockOutLoading1"
                        :disabled="clockInLoading1||clockInLoading2||clockOutLoading2">
                早班下班
              </a-button>
              <a-button size="large" type="primary" @click="handleClockInAndOut('In',2)" :loading="clockInLoading2"
                        :disabled="clockOutLoading1||clockInLoading1||clockOutLoading2">晚班上班
              </a-button>
              <a-button size="large" type="primary" @click="handleClockInAndOut('Out',2)" :loading="clockOutLoading2"
                        :disabled="clockOutLoading1||clockInLoading2||clockInLoading1">
                晚班下班
              </a-button>
            </a-space>
          </div>
        </a-form-model>
 
 
      </a-tab-pane>
 
      <a-tab-pane tab="当前设备状态" key="2">
        <a-table :dataSource="dataSource" :columns="columns" rowKey="id" bordered :pagination="false"
                 :loading="loading"/>
      </a-tab-pane>
    </a-tabs>
  </div>
</template>
 
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction, postAction } from '@/api/manage'
  import moment from 'moment'
 
  export default {
    name: 'EquipmentStartWork',
    mixins: [JeecgListMixin],
    data() {
      return {
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 8 }
        },
        equipmentList: [],
        columns: [
          {
            title: '用户编号',
            align: 'center',
            dataIndex: 'punchUserUserName',
            width: 250
          },
          {
            title: '用户名称',
            align: 'center',
            dataIndex: 'punchUserRealName'
          },
          {
            title: '设备编号',
            align: 'center',
            dataIndex: 'equipmentId',
            width: 200
          },
          {
            title: '班次',
            align: 'center',
            dataIndex: 'shiftScheduleName',
            width: 150
          },
          {
            title: '上班打卡时间',
            align: 'center',
            dataIndex: 'checkInTime'
          },
          {
            title: '下班打卡时间',
            align: 'center',
            dataIndex: 'checkOutTime'
          }
        ],
        validateRules: {
          equipmentIdList: [
            { required: true, message: '请选择设备!', trigger: 'change' }
          ]
        },
        clockInLoading1: false,
        clockOutLoading1: false,
        clockInLoading2: false,
        clockOutLoading2: false,
        url: {
          equipmentList: '/mdc/mdcEquipment/getEquipmentList',
          clockIn: '/mdcEquipmentPunch/workUp',
          clockOut: '/mdcEquipmentPunch/workDown',
          list: '/mdcEquipmentPunch/list'
        }
      }
    },
    created() {
      this.getEquipmentListByApi()
    },
    methods: {
      // 获取设备列表
      getEquipmentListByApi() {
        const that = this
        getAction(this.url.equipmentList)
          .then(res => {
            if (res.success) that.equipmentList = res.result
          })
      },
 
      /**
       * 打卡上下班事件
       * @param clockInOrOut In为上班 Out为下班
       * @param shiftSchedule 1为早班 2为晚班
       */
      handleClockInAndOut(clockInOrOut, shiftSchedule) {
        const that = this
        this.$refs.form.validate(valid => {
          if (valid) {
            that['clock' + clockInOrOut + 'Loading' + shiftSchedule] = true
            that.queryParam = {}
            that.queryParam['shiftSchedule'] = shiftSchedule
            that.queryParam['check' + clockInOrOut + 'Time'] = moment().format('YYYY-MM-DD HH:mm:ss')
            that.queryParam.equipmentId = that.model.equipmentIdList.join()
            console.log('queryParam', that.queryParam)
 
            postAction(that.url['clock' + clockInOrOut], that.queryParam)
              .then(res => {
                console.log('res', res)
                if (res.success) {
                  that.$notification.success({
                    message: '消息',
                    description: res.message
                  })
                  that.loadData()
                } else {
                  that.$notification.warning({
                    message: '消息',
                    description: res.message
                  })
                }
              })
              .finally(() => {
                that['clock' + clockInOrOut + 'Loading' + shiftSchedule] = false
              })
          } else {
            return false
          }
        })
      }
    }
  }
</script>
 
<style scoped lang="less">
  /deep/ .ant-tabs {
    flex: 1;
    display: flex;
    flex-direction: column;
 
    .ant-tabs-content {
      width: 100%;
      flex: 1;
 
      .ant-tabs-tabpane[dataset='first'] {
        display: flex;
        flex-direction: column;
        justify-content: center;
      }
    }
  }
</style>