<template>
|
<div style="height: 100%">
|
<div class="page-header">
|
<div class="header-left">
|
<a @click="$router.go(-1)"><i class="icon-btn-back"></i></a>
|
<h2>编辑-检测计划</h2>
|
</div>
|
<div class="btn-group header-right">
|
<el-button title="保存" :disabled="isSubmit" v-thinclick="`save`"
|
>保存</el-button
|
>
|
</div>
|
</div>
|
<div class="page-main">
|
<div class="testplan-basic">
|
<el-form
|
:inline="true"
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="120px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="计划编号" prop="testPlanNo">
|
<el-input
|
v-model="dataForm.testPlanNo"
|
placeholder="计划编号"
|
disabled
|
>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="计划名称" prop="testPlanName">
|
<el-input
|
v-model="dataForm.testPlanName"
|
placeholder="计划名称"
|
>
|
</el-input>
|
</el-form-item>
|
<el-form-item label="开始执行时间" prop="startExecutionTime">
|
<el-date-picker
|
v-model="dataForm.startExecutionTime"
|
type="datetime"
|
placeholder="开始执行时间"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="结束执行时间" prop="endExecutionTime">
|
<el-date-picker
|
v-model="dataForm.endExecutionTime"
|
type="datetime"
|
placeholder="结束执行时间"
|
value-format="yyyy-MM-dd HH:mm:ss"
|
>
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="品类" prop="category">
|
<el-select v-model="dataForm.category" placeholder="品类">
|
<el-option
|
v-for="item in materialCategoryTypeOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="循环周期" prop="cyclePeriod">
|
<el-input v-model="dataForm.cyclePeriod" placeholder="循环周期">
|
</el-input>
|
</el-form-item>
|
<el-form-item class="cycle-unit" label="" prop="cycleUnit">
|
<el-select v-model="dataForm.cycleUnit" placeholder="单位">
|
<el-option
|
v-for="item in testplanCycleUnitOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
type="textarea"
|
:autosize="{ minRows: 1, maxRows: 3 }"
|
v-model="dataForm.remark"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
<div class="testplan-detail">
|
<el-card class="testplan-card" shadow="never" style="">
|
<div slot="header" class="clearfix">
|
<div>
|
<span>关联检测标准</span>
|
</div>
|
</div>
|
<div>
|
<div style=" margin-left: 20px">
|
<el-button
|
type="text"
|
size="medium"
|
class="blue-but"
|
@click="addNode()"
|
>添加
|
</el-button>
|
</div>
|
<div style="display:flex;justify-content:space-between">
|
<div style="width:35%;">
|
<el-table
|
:data="testStandardData"
|
border
|
style="width: 100%"
|
@row-click="clickTestStandard"
|
highlight-current-row
|
height="665px"
|
>
|
<el-table-column
|
type="index"
|
label="序号"
|
align="center"
|
width="50"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="standardNo"
|
label="标准编号"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="standardName"
|
label="标准名称"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="inspectionType"
|
label="检测类型"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
align="center"
|
width="60px"
|
fixed="right"
|
>
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="small"
|
class="red-but"
|
@click.stop="delStandard(scope.row)"
|
>删除</el-button
|
>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div style="width:64%;">
|
<el-table
|
:data="testStandardParamData"
|
border
|
style="width: 100%"
|
height="665px"
|
>
|
<el-table-column
|
type="index"
|
label="序号"
|
align="center"
|
width="50"
|
>
|
</el-table-column>
|
<el-table-column prop="code" label="参数编号" align="center">
|
</el-table-column>
|
<el-table-column
|
prop="parameterItem"
|
label="参数项"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="referenceValue"
|
label="要求范围"
|
align="center"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column
|
prop="paramType"
|
label="检测类型"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column
|
prop="parameterFormat"
|
label="参数格式"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column prop="unit" label="单位" align="center">
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</div>
|
</el-card>
|
</div>
|
</div>
|
<testStandardDialog
|
:currshowlist.sync="showTestStandard"
|
@listenToSelectTestStandardEvent="selectTestStandard"
|
/>
|
</div>
|
</template>
|
<script>
|
import {
|
addObj,
|
putObj,
|
getObj,
|
addStandard,
|
getDtoById,
|
delStandard
|
} from '@/api/quality/testplan'
|
import { remote } from '@/api/admin/dict'
|
import testStandardDialog from '@/views/common/teststandardradio'
|
import { getTestStandardParams } from '@/api/quality/teststandard'
|
import { validatePositiveInteger } from '@/util/validate'
|
export default {
|
components: { testStandardDialog },
|
data() {
|
return {
|
dataForm: {
|
id: null,
|
testPlanNo: null,
|
testPlanName: null,
|
state: null,
|
startExecutionTime: null,
|
endExecutionTime: null,
|
cyclePeriod: null,
|
cycleUnit: null,
|
category: null,
|
remark: null
|
},
|
nodeList: [],
|
dataRule: {
|
testPlanName: [
|
{ required: true, message: '计划名称不能为空', trigger: 'blur' }
|
],
|
startExecutionTime: [
|
{ required: true, message: '开始执行时间不能为空', trigger: 'blur' }
|
],
|
endExecutionTime: [
|
{ required: true, message: '结束执行时间不能为空', trigger: 'blur' }
|
],
|
cyclePeriod: [
|
{ required: true, message: '循环周期不能为空', trigger: 'blur' },
|
{ validator: validatePositiveInteger, trigger: 'blur' }
|
],
|
category: [{ required: true, message: '品类不能为空', trigger: 'blur' }]
|
},
|
isSubmit: false,
|
testplanCycleUnitOptions: [],
|
materialCategoryTypeOptions: [],
|
testStandardData: [],
|
testStandardParamData: [],
|
showTestStandard: false
|
}
|
},
|
computed: {
|
editable: function() {
|
if (!this.dataForm.id) {
|
return true
|
}
|
return false
|
}
|
},
|
mounted() {
|
window.addEventListener(
|
'hashchange',
|
() => {
|
const currentPath = window.location.hash.slice(1)
|
if (this.$route.path !== currentPath) {
|
this.$router.push(currentPath)
|
}
|
},
|
false
|
)
|
},
|
created() {
|
const formId = this.$route.params.id
|
this.init(formId)
|
this.getTestplanCycleUnitOptions()
|
this.getMaterialCategoryTypeOptions()
|
},
|
methods: {
|
// 查询检测计划单位字典
|
getTestplanCycleUnitOptions() {
|
remote('testplan_cycle_unit').then((response) => {
|
if (response.data.code === 0) {
|
this.testplanCycleUnitOptions = response.data.data
|
} else {
|
this.testplanCycleUnitOptions = []
|
}
|
})
|
},
|
// 查询品类字典
|
getMaterialCategoryTypeOptions() {
|
remote('material_category_type').then((response) => {
|
if (response.data.code === 0) {
|
this.materialCategoryTypeOptions = response.data.data
|
} else {
|
this.materialCategoryTypeOptions = []
|
}
|
})
|
},
|
init(id) {
|
this.dataForm.id = id || 0
|
this.$nextTick(() => {
|
const formId = this.dataForm.id
|
this.initAllData()
|
if (formId) {
|
this.getTestPlanInfo(formId)
|
}
|
})
|
},
|
getTestPlanInfo(formId) {
|
getDtoById(formId).then((response) => {
|
const resCode = response.data.code
|
const resData = response.data.data
|
this.testStandardData = []
|
this.testStandardParamData = []
|
if (resCode === 0) {
|
this.dataForm.id = resData.id
|
this.dataForm.testPlanNo = resData.testPlanNo
|
this.dataForm.testPlanName = resData.testPlanName
|
this.dataForm.state = resData.state
|
this.dataForm.startExecutionTime = resData.startExecutionTime
|
this.dataForm.endExecutionTime = resData.endExecutionTime
|
this.dataForm.cyclePeriod = resData.cyclePeriod
|
this.dataForm.cycleUnit = resData.cycleUnit
|
this.dataForm.category = resData.category
|
this.dataForm.remark = resData.remark
|
this.testStandardData = resData.reliabilityTestPlanStandardList
|
}
|
})
|
},
|
initAllData() {
|
this.dataForm.id = null
|
this.dataForm.testPlanNo = null
|
this.dataForm.testPlanName = null
|
this.dataForm.state = null
|
this.dataForm.startExecutionTime = null
|
this.dataForm.endExecutionTime = null
|
this.dataForm.cyclePeriod = null
|
this.dataForm.cycleUnit = null
|
this.dataForm.category = null
|
this.dataForm.remark = null
|
this.nodeList = []
|
},
|
save() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
if (this.dataForm.id) {
|
putObj(this.dataForm).then((response) => {
|
var data = response.data
|
if (data.code === 0) {
|
this.$message.success('保存成功')
|
} else {
|
this.$message.error('保存失败')
|
}
|
this.isSubmit = false
|
})
|
} else {
|
if (this.dataForm.cycleUnit != null) {
|
addObj(this.dataForm).then((response) => {
|
var data = response.data
|
if (data.code === 0) {
|
this.dataForm.id = data.data
|
this.$message.success('保存成功')
|
} else {
|
this.$message.error('保存失败')
|
}
|
this.isSubmit = false
|
})
|
} else {
|
this.$message.error('请选择循环周期单位')
|
}
|
}
|
} else {
|
this.isSubmit = false
|
}
|
})
|
},
|
addNode() {
|
if (this.dataForm.id != null && this.dataForm.id) {
|
this.showTestStandard = true
|
} else {
|
this.$message.warning('请先保存检测计划信息')
|
}
|
},
|
selectTestStandard(param) {
|
if (param) {
|
const planAndStandard = []
|
planAndStandard.push({
|
standardId: param.id,
|
testPlanId: this.dataForm.id
|
})
|
this.testStandardData = []
|
this.testStandardParamData = []
|
addStandard(planAndStandard).then((res) => {
|
if (res.data.code === 0) {
|
const resData = res.data.data
|
this.testStandardData = resData
|
this.$message.success('关联检测标准成功')
|
}
|
})
|
}
|
},
|
// 检测标准的回调
|
clickTestStandard(row) {
|
this.getTestStandardParamData(row.standardId)
|
},
|
// 获取关联的检测标准参数信息
|
getTestStandardParamData(testStandardId) {
|
getTestStandardParams(
|
Object.assign({
|
testStandardId: testStandardId
|
})
|
).then((response) => {
|
this.testStandardParamData = response.data.data
|
})
|
},
|
// 删除子表
|
delStandard(row) {
|
console.log(row)
|
delStandard(row.id).then((res) => {
|
if (res.data.code === 0) {
|
this.getTestPlanInfo(this.dataForm.id)
|
this.$message.success('删除检测标准成功')
|
}
|
})
|
}
|
}
|
}
|
</script>
|
<style>
|
.testplan-basic {
|
background-color: #fff;
|
height: 100px;
|
display: flex;
|
padding: 20px 30px;
|
border: 1px solid #ddd;
|
}
|
.testplan-detail {
|
overflow: hidden;
|
width: 100%;
|
height: 760px;
|
padding: 10px 20px;
|
display: flex;
|
border: 1px solid #ddd;
|
background-color: #fff;
|
margin-top: 10px;
|
}
|
.testplan-detail .el-card__header {
|
padding: 0px 20px;
|
}
|
.testplan-card {
|
width: 100%;
|
border: 0px;
|
}
|
.testplan-card .el-card__header {
|
border-bottom: 0px;
|
}
|
.testplan-card .el-card__body {
|
padding-top: 0px;
|
}
|
.blue-but.is-disabled {
|
color: #aacfff;
|
}
|
|
.blue-but {
|
color: #006eff;
|
}
|
.red-but.is-disabled {
|
color: #fab6b6;
|
}
|
|
.red-but {
|
color: red;
|
}
|
.cycle-unit {
|
width: 40px;
|
}
|
</style>
|