<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="100px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="车间" prop="workShop">
|
<el-select
|
v-model="dataForm.workShop"
|
filterable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in this.dataTypeList"
|
:key="index"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="产品类型" prop="type">
|
<el-select
|
v-model="dataForm.type"
|
filterable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in this.typeOptions"
|
:key="index"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="处理方式" prop="processMode">
|
<el-select
|
v-model="dataForm.processMode"
|
filterable
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in this.processModeOptions"
|
:key="index"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="审核人" prop="examiner">
|
<el-input
|
v-model="dataForm.examiner"
|
placeholder="审核人"
|
clearable
|
style="width: 100%;"
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openStaffDialog('examiner')"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<!-- <el-col :span="12">
|
<el-form-item label="发起人" prop="originator">
|
<el-input
|
v-model="dataForm.originator"
|
placeholder="发起人"
|
style="width: 100%;"
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openStaffDialog('originator')"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col> -->
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="处理人" prop="handler">
|
<el-input
|
v-model="dataForm.handler"
|
placeholder="处理人"
|
clearable
|
style="width: 100%;"
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openStaffDialog('handler')"
|
></el-button>
|
</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"
|
:disabled="isSubmit"
|
v-thinclick="`dataFormSubmit`"
|
>确定</el-button
|
>
|
</span>
|
<staffDialog
|
:currshowlist.sync="showStaff"
|
ref="staffDialog"
|
:multiSelect="multiSelect"
|
@handleSelectionChange="selectStaffCallback"
|
/>
|
</el-dialog>
|
</template>
|
|
<script>
|
import {
|
getqualityConfiguration,
|
addqualityUnqualifiedConfiguration,
|
updatequalityUnqualifiedConfiguration
|
} from '@/api/quality/unqualifiedprocess'
|
import { remote } from '@/api/admin/dict'
|
import staffDialog from '@/views/common/staff.vue'
|
|
export default {
|
data() {
|
return {
|
visible: false,
|
showStaff: false,
|
multiSelect: true,
|
dataTypeList: [],
|
typeOptions: [],
|
processModeOptions: [],
|
dataForm: {
|
id: 0,
|
workShop: '',
|
type: '',
|
processMode: '',
|
originator: '',
|
examiner: '',
|
handler: ''
|
},
|
dataRule: {
|
workShop: [
|
{ required: true, message: '车间不能为空', trigger: 'blur' }
|
],
|
type: [
|
{ required: true, message: '产品类型不能为空', trigger: 'blur' }
|
],
|
processMode: [
|
{ required: true, message: '处理方式不能为空', trigger: 'blur' }
|
],
|
originator: [
|
{ required: true, message: '发起人不能为空', trigger: 'blur' }
|
],
|
examiner: [
|
{ required: true, message: '审核人不能为空', trigger: 'blur' }
|
],
|
handler: [
|
{ required: true, message: '处理人不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false
|
}
|
},
|
components: {
|
staffDialog
|
},
|
created() {
|
this.getParamApplyDict()
|
},
|
methods: {
|
init(id) {
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
getqualityConfiguration(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
})
|
}
|
})
|
},
|
openStaffDialog(param) {
|
this.showStaff = true
|
this.$nextTick(() => {
|
this.$refs.staffDialog.init(param)
|
})
|
},
|
selectStaffCallback(param, paramName) {
|
console.log(paramName)
|
if (param) {
|
if (paramName == 'originator') {
|
this.dataForm.originator = ''
|
for (let i = 0; i < param.length; i++) {
|
this.dataForm.originator += param[i].staffName + ', '
|
}
|
this.dataForm.originator = this.dataForm.originator.slice(
|
0,
|
this.dataForm.originator.length - 2
|
)
|
}
|
if (paramName == 'examiner') {
|
for (let i = 0; i < param.length; i++) {
|
if (this.dataForm.examiner.indexOf(param[i].staffName) != -1) {
|
} else {
|
this.dataForm.examiner += param[i].staffName + ' '
|
}
|
}
|
this.dataForm.examiner = this.dataForm.examiner.slice(
|
0,
|
this.dataForm.examiner.length
|
)
|
}
|
if (paramName == 'handler') {
|
for (let i = 0; i < param.length; i++) {
|
if (this.dataForm.handler.indexOf(param[i].staffName) != -1) {
|
} else {
|
this.dataForm.handler += param[i].staffName + ' '
|
}
|
}
|
this.dataForm.handler = this.dataForm.handler.slice(
|
0,
|
this.dataForm.handler.length
|
)
|
}
|
}
|
},
|
// 获取字典
|
getParamApplyDict() {
|
remote('work_shop').then((response) => {
|
if (response.data.code === 0) {
|
this.dataTypeList = response.data.data
|
console.log(this.dataTypeList)
|
} else {
|
this.dataTypeList = []
|
}
|
})
|
remote('unqualified_handle_type').then((response) => {
|
if (response.data.code === 0) {
|
this.typeOptions = response.data.data
|
}
|
})
|
remote('unqualified_process_mode').then((response) => {
|
if (response.data.code === 0) {
|
this.processModeOptions = response.data.data
|
}
|
})
|
},
|
// 表单提交
|
dataFormSubmit() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
updatequalityUnqualifiedConfiguration(this.dataForm)
|
.then((data) => {
|
this.$message.success('修改成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
.catch((error) => {
|
this.isSubmit = false
|
console.log(error)
|
})
|
} else {
|
addqualityUnqualifiedConfiguration(this.dataForm)
|
.then((data) => {
|
this.$message.success('添加成功')
|
this.visible = false
|
this.isSubmit = false
|
this.$emit('refreshDataList')
|
})
|
.catch((error) => {
|
this.isSubmit = false
|
console.log(error)
|
})
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
}
|
}
|
}
|
</script>
|
<style scoped></style>
|