<template>
|
<el-dialog
|
:title="!dataForm.id ? '新增' : '修改'"
|
:close-on-click-modal="false"
|
:visible.sync="visible"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
@keyup.enter.native="dataFormSubmit()"
|
label-width="120px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="10"
|
><div class="grid-content bg-purple">
|
<el-form-item label="订/工单号" prop="orderNo">
|
<el-input
|
v-model="dataForm.orderNo"
|
placeholder="订/工单号"
|
disabled
|
></el-input>
|
</el-form-item>
|
|
<el-form-item label="零件编号" prop="partNo">
|
<el-input
|
v-model="dataForm.partNo"
|
placeholder="零件编号"
|
disabled
|
>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="零件批次" prop="partBatch">
|
<el-input
|
v-model="dataForm.partBatch"
|
placeholder="零件批次"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="零件名称" prop="partDesc">
|
<el-input
|
v-model="dataForm.partDesc"
|
placeholder="零件名称"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="模板描述" prop="templateDesc">
|
<el-input
|
v-model="dataForm.templateDesc"
|
placeholder="模板描述"
|
disabled
|
></el-input>
|
</el-form-item></div
|
></el-col>
|
|
<el-col :span="12"
|
><div class="grid-content bg-purple">
|
<el-form-item label="检测人" prop="testUser">
|
<el-input
|
v-model="dataForm.testUser"
|
placeholder="检测人"
|
disabled
|
></el-input>
|
</el-form-item>
|
<el-form-item label="检测结论" prop="testResult">
|
<el-select
|
v-model="dataForm.testResult"
|
filterable
|
placeholder="请选择"
|
>
|
<el-option
|
v-for="(item, index) in testCheckTypeOptions"
|
:key="index"
|
:label="item.value"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
<!--<el-input v-model="dataForm.testResult" placeholder="检测结论"></el-input>-->
|
</el-form-item>
|
<el-form-item label="检测次数" prop="testCount">
|
<el-input
|
type="number"
|
v-model="dataForm.testCount"
|
placeholder="检测次数"
|
></el-input>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
type="textarea"
|
v-model="dataForm.remark"
|
placeholder="备注"
|
></el-input>
|
</el-form-item></div
|
></el-col>
|
</el-row>
|
<!--检测汇报关联的检验项-->
|
<el-row>
|
<el-tabs type="border-card">
|
<el-tab-pane label="检验项">
|
<el-table
|
:data="dataForm.reportItems"
|
height="300"
|
class="tableItems"
|
>
|
<el-table-column
|
prop="testItems"
|
header-align="center"
|
align="center"
|
label="检测项目"
|
>
|
<template slot-scope="scope">
|
<el-input v-model="scope.row.testItems" disabled></el-input>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
prop="testRequirements"
|
header-align="center"
|
align="center"
|
label="检测要求"
|
>
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.testRequirements"
|
disabled
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="testUnit"
|
header-align="center"
|
align="center"
|
label="计量单位"
|
>
|
<template slot-scope="scope"
|
><el-input v-model="scope.row.testUnit" disabled></el-input
|
></template>
|
</el-table-column>
|
<el-table-column
|
prop="testMethod"
|
header-align="center"
|
align="center"
|
label="检验方法"
|
>
|
<template slot-scope="scope"
|
><el-input v-model="scope.row.testMethod" disabled></el-input
|
></template>
|
</el-table-column>
|
<el-table-column
|
prop="testValue"
|
header-align="center"
|
align="center"
|
label="检测值"
|
>
|
<template slot-scope="scope">
|
<el-form-item
|
:prop="'reportItems.' + scope.$index + '.testValue'"
|
:rules="dataRule.testValue"
|
class="testValue"
|
>
|
<el-input v-model="scope.row.testValue"></el-input>
|
</el-form-item>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="testResult"
|
header-align="center"
|
align="center"
|
label="检测结果"
|
>
|
<template slot-scope="scope">
|
<el-form-item
|
:prop="'reportItems.' + scope.$index + '.testResult'"
|
class="testResult"
|
>
|
<el-input v-model="scope.row.testResult"></el-input>
|
</el-form-item>
|
</template>
|
</el-table-column>
|
<el-table-column
|
prop="remark"
|
header-align="center"
|
align="center"
|
label="备注"
|
>
|
<template slot-scope="scope"
|
><el-input v-model="scope.row.remark"></el-input
|
></template>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
</el-tabs>
|
</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>
|
|
<script>
|
import { getReportObj, addObj, putObj } from '@/api/quality/testreport'
|
import { getObj } from '@/api/basic/part'
|
import { dir } from '@/api/quality/template'
|
export default {
|
data() {
|
return {
|
visible: false,
|
showTask: false,
|
updateData: false,
|
testCheckTypeOptions: [],
|
dataForm: {
|
id: 0,
|
testTaskId: '',
|
testResult: '',
|
testTime: '',
|
testUser: '',
|
testCount: '',
|
remark: '',
|
orderNo: '',
|
reportItems: [],
|
templates: [],
|
tasks: [],
|
items: [],
|
taskId: null,
|
partNo: '',
|
partBatch: '',
|
partDesc: '',
|
templateId: 0,
|
templateDesc: '',
|
testReportId: 0
|
},
|
dataRule: {
|
partNo: [
|
{ required: true, message: '零件编号不能为空', trigger: 'blur' }
|
],
|
testResult: [
|
{ required: true, message: '检测结论不能为空', trigger: 'blur' }
|
],
|
testTime: [
|
{ required: true, message: '检测时间不能为空', trigger: 'blur' }
|
],
|
testCount: [
|
{ required: true, message: '检测次数不能为空', trigger: 'blur' }
|
],
|
testValue: [
|
{ required: true, message: '检测值不能为空', trigger: 'blur' }
|
]
|
}
|
}
|
},
|
methods: {
|
init(id) {
|
this.initCheckType('check_type')
|
this.updateData = false
|
this.initDefaultForm()
|
this.dataForm.id = id || 0
|
this.visible = true
|
this.$nextTick(() => {
|
this.$refs.dataForm.resetFields()
|
if (this.dataForm.id) {
|
this.updateData = true
|
getReportObj(this.dataForm.id).then((response) => {
|
this.dataForm = response.data.data
|
this.dataForm.templateDesc =
|
response.data.data.templates[0].qtplDesc
|
this.dataForm.partBatch = response.data.data.tasks[0].partBatch
|
this.getPartById(response.data.data.tasks[0].partId)
|
})
|
}
|
})
|
},
|
// 初始化表单
|
initDefaultForm() {
|
;(this.dataForm.id = 0),
|
(this.dataForm.testTaskId = null),
|
(this.dataForm.testResult = null),
|
(this.dataForm.testTime = null),
|
(this.dataForm.testUser = null),
|
(this.dataForm.testCount = null),
|
(this.dataForm.remark = null),
|
(this.dataForm.orderNo = null),
|
(this.dataForm.templates = []),
|
(this.dataForm.tasks = []),
|
(this.dataForm.items = []),
|
(this.dataForm.reportItems = [])
|
;(this.dataForm.partNo = null),
|
(this.dataForm.partBatch = null),
|
(this.dataForm.partDesc = null),
|
(this.dataForm.templateId = 0),
|
(this.dataForm.templateDesc = null)
|
},
|
// 表单提交
|
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')
|
})
|
}
|
}
|
})
|
},
|
// 修改时根据零件id 获取零件信息
|
getPartById(id) {
|
getObj(id).then((response) => {
|
this.dataForm.partNo = response.data.data.partNo
|
this.dataForm.partDesc = response.data.data.description
|
})
|
},
|
// 数据字典获取
|
initCheckType(index) {
|
dir(index).then((res) => {
|
this.testCheckTypeOptions = res.data.data
|
})
|
}
|
}
|
}
|
</script>
|
<style>
|
.tableItems td {
|
padding: 0px 0px !important;
|
}
|
.testResult {
|
padding-bottom: 0px !important;
|
padding-top: 17px !important;
|
}
|
.testResult .el-form-item__content {
|
margin-left: 0px !important;
|
}
|
|
.testValue {
|
padding-bottom: 0px !important;
|
padding-top: 17px !important;
|
}
|
.testValue .el-form-item__content {
|
margin-left: 0px !important;
|
}
|
</style>
|