<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-radio-group v-model="dataForm.radio">
|
<el-radio :label="1">无</el-radio>
|
<el-radio :label="2">二班</el-radio>
|
<el-radio :label="3">三班</el-radio>
|
</el-radio-group>
|
</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="mini" type="primary" @click="submitForm()" plain>确定</el-button>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { getMachineList, updateMachineShiftType } from '@/api/MdcApi'
|
|
export default {
|
data() {
|
return {
|
dataForm: {
|
machineName: '',
|
radio: ''
|
},
|
machineList: []
|
}
|
},
|
mounted() {
|
this.initDevices()
|
},
|
methods: {
|
initDevices() {
|
this.machineName = []
|
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() {
|
this.listLoading = true
|
this.$refs.dataForm.validate((valid) => {
|
// console.log(this.dataForm.machineName)
|
// console.log(this.dataForm.radio)
|
if (valid) {
|
updateMachineShiftType(this.dataForm.machineName, this.dataForm.radio).then(res => {
|
this.listLoading = false
|
if (res.result === 'SUCCESS') {
|
// console.log('SUCCESS')
|
this.machineList.find(item => {
|
if (item.value === this.dataForm.machineName) {
|
item.shift = this.dataForm.radio
|
}
|
})
|
alert('设置成功')
|
} else {
|
alert('设置失败')
|
}
|
})
|
}
|
})
|
}
|
}
|
}
|
</script>
|