Blame view

src/components/oa/staffAttendanceReplenishCheckIn.vue 2.37 KB
d4a6b78f   wuxw   OA 中考勤功能开发完成
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
  <template>
    <el-dialog
      :title="$t('staffAttendance.replenishCheckIn')"
      :visible.sync="visible"
      width="50%"
    >
      <el-form label-position="left" label-width="120px">
        <el-form-item :label="$t('staffAttendance.attendanceTask')" required>
          <el-select 
            v-model="form.detailId" 
            :placeholder="$t('staffAttendance.selectTask')"
            style="width:100%"
          >
            <el-option
              v-for="(item,index) in details"
              :key="index"
              :label="`${item.specName}(${item.value})`"
              :value="item.detailId"
            ></el-option>
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('staffAttendance.reason')" required>
          <el-input
            type="textarea"
            :rows="4"
            v-model="form.remark"
            :placeholder="$t('staffAttendance.inputReason')"
          ></el-input>
        </el-form-item>
      </el-form>
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleSubmit">{{ $t('staffAttendance.submitReplenish') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { attendanceReplenishCheckIn } from '@/api/oa/staffAttendanceManageApi'
  
  export default {
    name: 'StaffAttendanceReplenishCheckIn',
    data() {
      return {
        visible: false,
        details: [],
        form: {
          detailId: '',
          remark: ''
        }
      }
    },
    methods: {
      open(details) {
        this.details = details || []
        this.form = {
          detailId: '',
          remark: ''
        }
        this.visible = true
      },
  
      async handleSubmit() {
        if (!this.form.detailId) {
          this.$message.warning(this.$t('staffAttendance.selectTaskFirst'))
          return
        }
  
        if (!this.form.remark) {
          this.$message.warning(this.$t('staffAttendance.inputReasonFirst'))
          return
        }
  
        try {
          await attendanceReplenishCheckIn(this.form)
          this.$message.success(this.$t('staffAttendance.replenishSuccess'))
          this.$emit('success')
          this.visible = false
        } catch (error) {
          console.error('Failed to submit replenish:', error)
          this.$message.error(this.$t('staffAttendance.replenishFailed'))
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .dialog-footer {
    text-align: right;
  }
  </style>