<template>
|
<el-dialog
|
:title="'杂工登记'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
class="handyman-dialog"
|
width="40%">
|
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="100px" class="l-mes">
|
<el-row type="flex" justify="space-between">
|
<el-col>
|
<el-form-item label="杂工类型" prop="handymanType">
|
<el-select v-model="dataForm.handymanType" placeholder="请选择" style="width: 100%" @change="changeHandy">
|
<el-option
|
v-for="item in handymanTypeOptions"
|
:key="item.handymanNo"
|
:label="item.handymanName"
|
:value="item.handymanNo">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col>
|
<el-form-item label="工作量" prop="workload">
|
<el-input v-model="dataForm.workload" style="width: 90%">
|
<template slot="append">
|
<span>{{dataForm.workloadUnit}}</span>
|
</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
</span>
|
</el-dialog>
|
</template>
|
<style>
|
.handyman-dialog .el-dialog__header{
|
text-align:left;
|
}
|
</style>
|
<script>
|
import {getHandymanTypeList} from '@/api/product/workstationoperateutil';
|
export default {
|
data () {
|
return {
|
visible: false,
|
dataForm: {
|
id: 0,
|
handymanType:null,
|
workload:null,
|
workloadUnit:null
|
},
|
dataRule: {
|
handymanType: [
|
{ required: true, message: '杂工类型', trigger: 'blur' }
|
],
|
workload: [
|
{ required: true, message: '工作量', trigger: 'blur' }
|
],
|
workloadUnit: [
|
{ required: true, message: '单位', trigger: 'blur' }
|
]
|
},
|
handymanTypeOptions:[]
|
}
|
},
|
created(){
|
this.getHandymanTypeOptions();
|
},
|
methods: {
|
getHandymanTypeOptions(){
|
this.handymanTypeOptions=[];
|
getHandymanTypeList().then(response => {
|
var data=response.data;
|
if(data.code==0) {
|
this.handymanTypeOptions=data.data;
|
}else{
|
this.$message.error('获取杂工类型失败');
|
}
|
}).catch(error => {
|
});
|
},
|
changeHandy(){
|
var _this=this;
|
var currHandyManType=_this.handymanTypeOptions.find(function (item) {
|
return item.handymanNo == _this.dataForm.handymanType;
|
});
|
_this.dataForm.workloadUnit=currHandyManType.unit;
|
},
|
init (id) {
|
this.dataForm.id = id || 0
|
this.visible = true;
|
this.$nextTick(() => {
|
this.$refs['dataForm'].resetFields()
|
if (this.dataForm.id) {
|
/*getObj(this.dataForm.id).then(response => {
|
this.dataForm = response.data.data
|
})*/
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit () {
|
this.$refs['dataForm'].validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
/*putObj(this.dataForm).then(data => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
});*/
|
} else {
|
/*addObj(this.dataForm).then(data => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.$emit('refreshDataList')
|
})*/
|
}
|
}
|
});
|
this.visible = false;
|
}
|
}
|
}
|
</script>
|