<template>
|
<basic-container>
|
<el-row>
|
<el-col :span="12">
|
<ttable
|
:table="table"
|
@handleSelectionChange="handleSelectionChange"
|
@currentChange="handleCurrentChange"
|
@shoudonggouxuan="handleCurrentChange"
|
:uploadInfo="uploadInfo"
|
:prelang="prelang"
|
:options="options"
|
:ajaxFun="ajaxFun"
|
:paramObj="paramObj"
|
:bottomOffset="100"
|
ref="selectTestStandardTable"
|
>
|
<template #toolbar></template>
|
</ttable>
|
</el-col>
|
<el-col :span="12" style="padding-left: 10px">
|
<div style="float: right;margin-bottom: 8px;" v-if="editable && currentRow&¤tRow.id">
|
<el-button
|
style="padding: 3px 0"
|
type="text"
|
size="medium"
|
@click="saveAllParamChange"
|
>保存
|
</el-button>
|
<!-- <el-button
|
style="padding: 3px 0"
|
type="text"
|
size="medium"
|
@click="openTempalteParamDialog"
|
>添加
|
</el-button> -->
|
</div>
|
<el-table
|
:data="testStandardParams"
|
id="testStandardParamTable"
|
ref="testStandardParam"
|
:default-sort="{ prop: 'index' }"
|
highlight-current-row
|
max-height="500"
|
style="width: 100%;overflow-x: auto;"
|
>
|
<el-table-column
|
prop="index"
|
label="序号"
|
align="center"
|
width="50"
|
/>
|
<el-table-column label="参数编号" prop="code" align="center" />
|
<el-table-column label="参数项" prop="parameterItem" align="center" />
|
<el-table-column
|
label="要求值"
|
prop="referenceValue"
|
align="center"
|
width="120px"
|
>
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.referenceValue"
|
placeholder="值"
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="单位" prop="unit" align="center" width="120px">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.unit"
|
placeholder="单位"
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="测试方法" prop="method" align="center">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.method"
|
placeholder=""
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="测试目的" prop="purpose" align="center">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.purpose"
|
placeholder=""
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" fixed="right">
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="mini"
|
v-if="editable && currentRow&¤tRow.id"
|
@click.stop="handleParamDelete(scope.row, scope.$index)"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-col>
|
</el-row>
|
<qualityStandardDialog
|
:currshowlist.sync="showQualityStandard"
|
:paramTemplateObj="qualityStandardParamObj"
|
@listenToSelectTestStandardEvent="selectQualityStandard"
|
/></basic-container>
|
</template>
|
<script>
|
//import { getTestStandardParams } from '@/api/quality/teststandard'
|
import ttable from '@/views/common/ztt-table.vue'
|
import { mapGetters } from 'vuex'
|
import {
|
deleteTestStandard,
|
getTestStand,
|
saveTestStandard,
|
getTestStandardParams,
|
deleteTestStandardParam,
|
saveTestStandardParam,
|
} from '@/api/technology/document'
|
import qualityStandardDialog from '@/views/common/teststandardradio.vue'
|
|
export default {
|
props: {
|
documentId: {
|
type: Number,
|
default: 0
|
},
|
editable: {
|
type: Boolean,
|
default: true
|
}
|
},
|
data() {
|
return {
|
paramObj: {documentId : this.documentId},
|
showQualityStandard: false,
|
testStandardParams: [],
|
ajaxFun: getTestStand,
|
currentRow: null,
|
innerVisible: false,
|
multipleSelection: [],
|
isShowQuery: false,
|
uploadInfo: {
|
// 是否展示上传EXCEL以及对应的url
|
isShow: false,
|
url: ''
|
},
|
prelang: 'operationParamTemplate',
|
options: {
|
height: 300, // 默认高度-为了表头固定
|
stripe: true, // 是否为斑马纹 table
|
highlightCurrentRow: false, // 是否要高亮当前行
|
border: true, // 是否有纵向边框
|
lazy: false, // 是否需要懒加载
|
fit: true, // 列的宽度是否自撑开
|
multiSelect: true, //
|
seqNo: true,
|
isShowHide: true, // 是否显示显影按钮
|
isSearch: true, // 高级查询按钮
|
defaultOrderBy: { column: 'standardNo', direction: 'desc' }
|
},
|
table: {
|
total: 0,
|
currentPage: 1,
|
pageSize: 20,
|
data: [],
|
// 标题
|
column: [
|
{
|
minWidth: 'code',
|
prop: 'standardNo',
|
label: '标准编号',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '120',
|
prop: 'standardName',
|
label: '标准名称',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
},
|
{
|
minWidth: '120',
|
prop: 'remark',
|
label: '备注',
|
sort: true,
|
isTrue: true,
|
isSearch: true,
|
searchInfoType: 'text'
|
}
|
],
|
toolbar: [],
|
operator: null,
|
operatorConfig: {
|
fixed: 'right',
|
label: '操作',
|
width: 100,
|
minWidth: 100
|
}
|
},
|
qualityStandardParamObj: null
|
}
|
},
|
components: {
|
ttable,
|
qualityStandardDialog
|
},
|
watch: {
|
editable: {
|
immediate: true,
|
handler() {
|
if (this.editable) {
|
this.table.toolbar = [
|
{
|
text: '新增',
|
type: 'primary',
|
fun: this.addOrUpdateHandle,
|
disabled: false
|
}
|
]
|
this.table.operator = [
|
{
|
text: '删除',
|
type: 'text',
|
size: 'small',
|
fun: this.deleteHandle
|
}
|
]
|
} else {
|
this.table.toolbar = []
|
this.table.operator = null
|
}
|
}
|
}
|
},
|
computed: {
|
...mapGetters(['permissions'])
|
},
|
created() {
|
this.$nextTick(()=>{
|
getTestStand(this.paramObj)
|
})
|
},
|
mounted(){
|
this.$nextTick(()=>{
|
getTestStand(this.paramObj)
|
})
|
},
|
methods: {
|
// 获取数据列表
|
getData() {
|
this.$refs.selectTestStandardTable.getDataList()
|
},
|
addOrUpdateHandle() {
|
if (this.documentId) {
|
if (this.editable) {
|
this.qualityStandardParamObj = {
|
state: '02accepted'
|
}
|
this.showQualityStandard = true
|
} else {
|
this.$message.error('该状态下的工艺文件不可新增成品检测')
|
}
|
} else {
|
this.$message.error('请先填写主表信息')
|
}
|
},
|
selectQualityStandard(row) {
|
if (row != null) {
|
// 保存检测标准,查询检测项
|
var qualityStandardObj = {
|
documentId: this.documentId,
|
testStandardId: row.id
|
}
|
const qualityStandards = []
|
qualityStandards.push(qualityStandardObj)
|
saveTestStandard(qualityStandards).then((response) => {
|
const data = response.data
|
if (data.code === 0) {
|
this.$message.success('添加检测标准成功')
|
this.getData()
|
} else {
|
this.$message.error('添加检测标准失败')
|
}
|
})
|
}
|
},
|
deleteHandle(row) {
|
if (this.editable) {
|
this.$confirm('确定删除检测标准?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
closeOnClickModal: false,
|
type: 'warning'
|
})
|
.then(() => {
|
var qualityStandardObj = {
|
documentId: this.documentId,
|
testStandardId: row.id
|
}
|
deleteTestStandard(qualityStandardObj).then((response) => {
|
const data = response.data
|
if (data.code === 0) {
|
this.$message.success('删除检测标准成功')
|
this.getData()
|
this.testStandardParams = []
|
} else {
|
this.$message.error('删除检测标准失败')
|
}
|
})
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
})
|
})
|
} else {
|
this.$message.error('该状态下的工艺文件不可删除成品检测')
|
}
|
},
|
handleCurrentChange(row) {
|
this.testStandardParams = []
|
this.currentRow = row
|
if (row && row.id) {
|
this.getTestStandardParamData(row.id)
|
}
|
},
|
// 获取关联的检测标准参数信息
|
getTestStandardParamData(testStandardId) {
|
getTestStandardParams(
|
Object.assign({
|
testStandardId: testStandardId
|
})
|
).then((response) => {
|
this.testStandardParams = response.data.data
|
})
|
},
|
handleSelectionChange(val) {
|
// 多行选中
|
this.multipleSelection = val
|
},
|
saveAllParamChange(){
|
this.testStandardParams.forEach(e=>{
|
if(e.referenceValue!=null){
|
e.referenceValue=e.referenceValue.replace(',',',').replace('(','(').replace(')',')')
|
if (!isNaN(e.referenceValue)) {
|
e.referenceValue='='+e.referenceValue
|
}
|
}
|
})
|
saveTestStandardParam(this.testStandardParams).then((response) => {
|
const data = response.data
|
if (data.code == 0) {
|
this.$message.success('保存成功')
|
this.getTestStandardParamData(this.currentRow.id)
|
} else {
|
this.$message.error('保存失败')
|
}
|
})
|
},
|
openTempalteParamDialog(){},
|
handleParamDelete(row, index){
|
this.$confirm('是否确认删除参数项为' + row.parameterItem, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(function() {
|
return deleteTestStandardParam(row.id)
|
})
|
.then((response) => {
|
const data = response.data
|
if (data.code == 0) {
|
// 删除当前行
|
this.testStandardParams.splice(index, 1)
|
this.$message.success('删除成功')
|
} else {
|
this.$message.error('删除失败')
|
}
|
})
|
}
|
}
|
}
|
</script>
|