<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>
|