<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="80px"
|
class="l-mes"
|
>
|
<el-form-item label="班组名称" prop="crewName">
|
<el-input v-model="dataForm.crewName" placeholder="班组名称"></el-input>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="visible = false">取消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`dataFormSubmit`"
|
>确定</el-button
|
>
|
</span>
|
<staffDialog
|
:currshowlist.sync="showStaff"
|
:multiSelect="true"
|
@handleSelectionChange="selectStaff"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import { getObj, addObj, putObj } from '@/api/basic/crew'
|
import staffDialog from '@/views/common/staff.vue'
|
|
export default {
|
components: {
|
staffDialog
|
},
|
data() {
|
return {
|
showStaff: false,
|
visible: false,
|
dataForm: {
|
id: 0,
|
crewName: '',
|
staffList: []
|
},
|
dataRule: {
|
crewName: [
|
{ required: true, message: '班组名称不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false
|
}
|
},
|
methods: {
|
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.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putObj(this.dataForm).then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
} else {
|
addObj(this.dataForm).then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
}
|
}
|
}
|
</script>
|