yangys
2024-01-13 f466ae4fdc645c66c9f25e2e4598b9809e2b41af
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
<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-form-item label="设备名称" prop="machineName">
            <el-select v-model="dataForm.machineName" @change="changeMachine" filterable clearable placeholder="选择或搜索">
              <el-option
                v-for="(item, index) in machineList"
                :key="index"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24":sm="12":md="12":lg="12":xl="12">
          <el-form-item label="" prop="shift">
            <el-date-picker
              v-model="clearDate"
              type="date"
              format="yyyy-MM-dd"
              value-format="yyyyMMdd"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div style="display: flex;justify-content: center;align-items: center;margin-top:15px;">
      <el-button size="medium" type="primary" @click="submitForm()">清零</el-button>
    </div>
  </div>
</template>
 
<script>
import { getMachineList, utilizationClearDownTime } from '@/api/MdcApi'
 
export default {
  data() {
    return {
      dataForm: {
        machineName: '',
        radio: ''
      },
      machineList: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now()
        }
      },
      clearDate: ''
    }
  },
  mounted() {
    this.initDevices()
  },
  methods: {
    initDevices() {
      this.machineName = []
      this.machineList.push({
        label: '全选',
        value: 'all',
        id: 'all'
      })
      getMachineList().then(res => {
        res.list.map(item => {
          this.machineList.push({
            label: item.name,
            value: item.name,
            id: item.id,
            shift: item.shiftType
          })
        })
      })
    },
    changeMachine() {
      this.machineList.find(item => {
        if (item.value === this.dataForm.machineName) {
          this.dataForm.radio = parseInt(item.shift)
        }
      })
    },
    submitForm() {
      if ((this.dataForm.machineName === null) || (this.dataForm.machineName === '')) {
        this.$message.error('请选择机床')
        return
      }
      if ((this.clearDate === null) || (this.clearDate === '')) {
        this.$message.error('请选择日期')
        return
      }
      this.listLoading = true
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          console.log(this.dataForm.machineName)
          console.log(this.clearDate)
          utilizationClearDownTime(this.dataForm.machineName, this.clearDate).then(res => {
            this.listLoading = false
            if (res.result === 'SUCCESS') {
              this.$message.success('清除成功')
            } else {
              this.$message.error(res.result)
            }
          })
        }
      })
    }
  }
}
</script>