gaoshp
2024-01-05 b5db49ce1e4c678ce4a7120928811a9621128b8e
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
<template>
  <div class="app-container">
    <el-form :model="dataForm" status-icon ref="dataForm" label-width="100px" style="margin-top:10px;">
      <el-row>
        <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
          <el-date-picker
            v-model="yearMonth"
            type="month"
            format="yyyy-MM"
            value-format="yyyyMM"
            @change="changeYearMonth"
            placeholder="选择月">
          </el-date-picker>
        </el-col>
        <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
          <el-input v-model="days2" placeholder="二班制度时间(小时)"></el-input>
          <el-input v-model="days3" placeholder="三班制度时间(小时)"></el-input>
        </el-col>
      </el-row>
    </el-form>
    <div style="display: flex;justify-content: center;align-items: center;margin-top:15px;">
      <el-button size="medium" slot="trigger" type="primary" @click="submitForm()">确定</el-button>
    </div>
  </div>
</template>
 
<script>
import { getWorkDays, setWorkDays } from '@/api/MdcApi'
 
export default {
  data() {
    return {
      dataForm: {
      },
      yearMonth: '',
      days2: '',
      days3: '',
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now()
        }
      },
      clearDate: ''
    }
  },
  mounted() {
  },
  methods: {
    changeYearMonth() {
      getWorkDays(this.yearMonth).then(res => {
        this.listLoading = false
        if (res.result === 'SUCCESS') {
          this.days2 = (res.days2 == null) ? '' : res.days2
          this.days3 = (res.days3 == null) ? '' : res.days3
        }
      })
    },
    submitForm() {
      if ((this.yearMonth === null) || (this.yearMonth === '')) {
        this.$message.error('请选择月份')
        return
      }
      if ((this.days2 === null) || (this.days2 === '')) {
        this.$message.error('请输入二班制度时间')
        return
      }
      if ((this.days3 === null) || (this.days3 === '')) {
        this.$message.error('请输入三班制度时间')
        return
      }
      this.listLoading = true
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          console.log(this.yearMonth)
          console.log(this.days2)
          console.log(this.days3)
          setWorkDays(this.yearMonth, this.days2, this.days3).then(res => {
            this.listLoading = false
            if (res.result === 'SUCCESS') {
              this.$message.success('设置成功')
            } else {
              this.$message.error(res.result)
            }
          })
        }
      })
    }
  }
}
</script>