gaoluyang
昨天 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
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
<script lang="ts" setup>
import { ref } from 'vue';
 
import { useVbenModal } from '#/packages/effects/common-ui/src';
 
import { message } from 'ant-design-vue';
 
import { clockIn, clockOut } from '#/api/hrm/attendance/record';
 
const emit = defineEmits(['success']);
 
const location = ref('公司前台');
const loading = ref(false);
 
/** 上班打卡 */
async function handleClockIn() {
  loading.value = true;
  try {
    await clockIn({ location: location.value });
    message.success('上班打卡成功');
    emit('success');
  } catch (e: any) {
    message.error(e.message || '打卡失败');
  } finally {
    loading.value = false;
  }
}
 
/** 下班打卡 */
async function handleClockOut() {
  loading.value = true;
  try {
    await clockOut({ location: location.value });
    message.success('下班打卡成功');
    emit('success');
  } catch (e: any) {
    message.error(e.message || '打卡失败');
  } finally {
    loading.value = false;
  }
}
 
const [Modal, modalApi] = useVbenModal({
  onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      location.value = '公司前台';
    }
  },
});
</script>
 
<template>
  <Modal title="打卡" class="w-[400px]">
    <div class="p-4">
      <div class="mb-4">
        <label class="mr-2">打卡地点:</label>
        <a-input
          v-model:value="location"
          placeholder="请输入打卡地点"
          style="width: 200px"
        />
      </div>
      <div class="flex gap-4">
        <a-button
          type="primary"
          size="large"
          :loading="loading"
          @click="handleClockIn"
        >
          上班打卡
        </a-button>
        <a-button
          size="large"
          :loading="loading"
          @click="handleClockOut"
        >
          下班打卡
        </a-button>
      </div>
    </div>
  </Modal>
</template>