<template>
|
<div>
|
<div style="display:flex;justify-content:space-around;">
|
<div style="width:32%">
|
<el-card class="document-params-template">
|
<div slot="header">
|
<span>检测标准</span>
|
<div style="float: right;">
|
<el-button
|
style="padding: 3px 0"
|
type="text"
|
size="medium"
|
v-if="editable && dataFormId && routingOperationId"
|
@click="openTestStandardDialog"
|
>添加
|
</el-button>
|
</div>
|
</div>
|
<el-table
|
ref="operationTestStandardTable"
|
:data="operationTestStandardList"
|
class="l-mes"
|
highlight-current-row
|
@row-click="testStandardRowClick"
|
height="400px"
|
>
|
<el-table-column
|
label="标准编号"
|
prop="standardNo"
|
align="center"
|
show-overflow-tooltip
|
/>
|
<el-table-column
|
label="标准名称"
|
prop="standardName"
|
align="center"
|
show-overflow-tooltip
|
/>
|
</el-table>
|
</el-card>
|
</div>
|
<div style="width:64%">
|
<el-card class="document-template-rule">
|
<div slot="header">
|
<span>标准参数</span>
|
<div style="float: right;">
|
<el-button
|
style="padding: 3px 0"
|
type="text"
|
size="medium"
|
@click="dataFormTestStandardParam()"
|
v-if="editable && currentOperationTestStandardId"
|
>提交参数
|
</el-button>
|
<el-button
|
style="padding: 3px 0"
|
type="text"
|
size="medium"
|
v-if="editable && currentOperationTestStandardId"
|
@click="relateOperationParam()"
|
>添加
|
</el-button>
|
</div>
|
</div>
|
<el-table
|
:data="operationTestStandardParamList"
|
id="testStandardParamTable"
|
ref="testStandardParam"
|
:default-sort="{ prop: 'index' }"
|
highlight-current-row
|
height="400px"
|
style="width: 100%"
|
>
|
<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"
|
show-overflow-tooltip
|
>
|
</el-table-column>
|
<el-table-column label="检测类型" prop="paramType" align="center">
|
<template slot-scope="scope">
|
<span>{{
|
scope.row.paramType
|
? paramTypeOptions.find((item) => {
|
return item.value === scope.row.paramType
|
}).label
|
: ''
|
}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="参数格式"
|
prop="parameterFormat"
|
align="center"
|
>
|
</el-table-column>
|
<el-table-column label="单位" prop="unit" align="center" />
|
</el-table>
|
</el-card>
|
</div>
|
</div>
|
<testStandardDialog
|
:currshowlist.sync="showTestStandard"
|
@handleSelectionTestStandardChange="selectTestStandard"
|
/>
|
<!-- 弹窗, 基础参数选择 -->
|
<!--<ParamDialog
|
:currshowlist.sync="showParam"
|
@handleSelectionChange="getJoinData"
|
:paramSelArr="paramSelArr"
|
:paramSelCol="paramSelCol"
|
></ParamDialog>-->
|
<edit-order-param-form
|
v-if="editOrderParamVisible"
|
ref="editOrderParam"
|
@refreshOrderParamList="refreshOrderParamList"
|
></edit-order-param-form>
|
</div>
|
</template>
|
<style lang="scss" scoped>
|
.document-params-template >>> .el-card__body {
|
padding: 0px 0px 5px;
|
}
|
.document-template-rule >>> .el-card__body {
|
padding: 0px 0px 5px;
|
}
|
</style>
|
<script>
|
import {
|
addRoutingTestStandard,
|
getRoutingTestStandardList,
|
deleteRoutingTestStandard,
|
getOperationTestStandardParam,
|
addOperationTestStandardParam
|
} from '@/api/plan/moteststandard'
|
import { getTestStandardParams } from '@/api/quality/teststandard'
|
import testStandardDialog from '@/views/common/teststandard'
|
import EditOrderParamForm from './editparamform'
|
import ParamDialog from '@/views/common/param.vue'
|
import { remote } from '../../../api/admin/dict'
|
|
export default {
|
props: {
|
editable: {
|
type: Boolean,
|
default: false
|
},
|
dataFormId: {
|
type: Number,
|
default: 0
|
},
|
routingOperationId: {
|
type: Number,
|
default: 0
|
},
|
paramTypeOptions: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
},
|
operationTestStandardList: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
data() {
|
return {
|
addCustomizeTestStandardVisible: false,
|
showTestStandard: false,
|
operationTestStandardParamList: [],
|
currentOperationTestStandardId: 0,
|
paramSelArr: [],
|
paramSelCol: 'code',
|
showParam: false,
|
insertIndex: null,
|
last: true,
|
editOrderParamVisible: false
|
}
|
},
|
components: {
|
testStandardDialog,
|
EditOrderParamForm
|
},
|
mounted() {
|
// this.rowDrop()
|
},
|
created() {
|
// this.initDirParamType()
|
},
|
methods: {
|
initDirParamType() {
|
remote('quality_param_type').then((response) => {
|
if (response.data.code === 0) {
|
this.paramTypeOptions = response.data.data
|
}
|
})
|
},
|
selectLastTestStandard() {
|
if (
|
this.operationTestStandardList &&
|
this.operationTestStandardList.length > 0
|
) {
|
const lastTestStandard = this.operationTestStandardList[
|
this.operationTestStandardList.length - 1
|
]
|
this.$refs.operationTestStandardTable.setCurrentRow(lastTestStandard)
|
this.getOperationTestStandardParam(lastTestStandard.id)
|
}
|
},
|
// 根据制造订单id和工艺工序id查询检测标准
|
getRoutingTestStandard(param) {
|
getRoutingTestStandardList(param).then((response) => {
|
const resData = response.data
|
if (resData.code === 0) {
|
this.currentOperationTestStandardId = 0
|
this.operationTestStandardList = resData.data
|
if (this.operationTestStandardList) {
|
this.$refs.operationTestStandardTable.setCurrentRow(
|
this.operationTestStandardList[0]
|
)
|
this.testStandardRowClick(this.operationTestStandardList[0])
|
}
|
this.operationTestStandardParamList = []
|
} else {
|
this.currentOperationTestStandardId = 0
|
this.operationTestStandardList = []
|
this.operationTestStandardParamList = []
|
this.$message.error('检测标准请求异常')
|
}
|
})
|
},
|
// 弹出基础检测标准选择列表
|
openTestStandardDialog() {
|
this.showTestStandard = true
|
},
|
// 检测标准的选中结果返回
|
selectTestStandard(param) {
|
if (param.length > 0) {
|
// 进行urlencoding
|
// debugger;
|
for (var i = 0; i < param.length; i++) {
|
// 遍历数组
|
if (param[i].judgeFormula) {
|
var reg = new RegExp('&', 'g')
|
// var newstr = str.replace( reg , '天朝' );
|
param[i].judgeFormula = param[i].judgeFormula.replace(reg, '&')
|
}
|
}
|
|
const mo = {
|
id: this.dataFormId,
|
routingOperationId: this.routingOperationId,
|
moTestStandardList: param
|
}
|
addRoutingTestStandard(mo).then((response) => {
|
const data = response.data
|
if (data.code === 0) {
|
const newTestStandardList = response.data.data
|
for (let i = 0; i < newTestStandardList.length; i++) {
|
this.operationTestStandardList.push(newTestStandardList[i])
|
}
|
this.$message.success('检测标准添加成功')
|
// 选中最后一个检测标准
|
this.selectLastTestStandard()
|
} else {
|
this.$message.error('检测标准添加失败')
|
}
|
})
|
}
|
},
|
// 删除检测标准
|
handleTestStandardDelete(row, index) {
|
deleteRoutingTestStandard(row.id).then((response) => {
|
const data = response.data
|
if (data.code === 0) {
|
// 清空参数、删除当前行、清空选中、清空当前的routingTemplateId
|
this.operationTestStandardList.splice(index, 1)
|
this.operationTestStandardParamList = []
|
this.currentOperationTestStandardId = null
|
this.$refs.operationTestStandardTable.setCurrentRow()
|
this.$message.success('删除成功')
|
} else {
|
this.$message.error('删除失败')
|
}
|
})
|
},
|
// 检测标准点击事件,显示检测标准参数
|
testStandardRowClick(row) {
|
this.getOperationTestStandardParam(row.standardId)
|
},
|
// 根据工艺工序id、模板id去获取模板下的参数
|
getOperationTestStandardParam(standardId) {
|
this.currentOperationTestStandardId = standardId
|
getTestStandardParams(
|
Object.assign({
|
testStandardId: standardId
|
})
|
).then((response) => {
|
this.operationTestStandardParamList = response.data.data
|
})
|
},
|
|
rowDrop() {
|
const that = this
|
const tbody = document.querySelector(
|
'#testStandardParamTable .el-table__body-wrapper tbody'
|
)
|
Sortable.create(tbody, {
|
// 结束拖拽
|
onEnd({ newIndex, oldIndex }) {
|
if (newIndex > oldIndex) {
|
// 下移
|
that.operationTestStandardParamList
|
.filter((e) => e.index === oldIndex + 1)
|
.forEach((e) => (e.index = 'x'))
|
that.operationTestStandardParamList
|
.filter((e) => e.index > oldIndex + 1 && e.index <= newIndex + 1)
|
.forEach((e) => (e.index = e.index - 1))
|
that.operationTestStandardParamList
|
.filter((e) => e.index === 'x')
|
.forEach((e) => (e.index = newIndex + 1))
|
} else if (oldIndex > newIndex) {
|
// 上移
|
that.operationTestStandardParamList
|
.filter((e) => e.index === oldIndex + 1)
|
.forEach((e) => (e.index = 'x'))
|
that.operationTestStandardParamList
|
.filter((e) => e.index < oldIndex + 1 && e.index >= newIndex + 1)
|
.forEach((e) => (e.index = e.index + 1))
|
that.operationTestStandardParamList
|
.filter((e) => e.index === 'x')
|
.forEach((e) => (e.index = newIndex + 1))
|
}
|
}
|
})
|
},
|
// 提交检测标准参数
|
dataFormTestStandardParam() {
|
if (this.operationTestStandardParamList.length > 0) {
|
addOperationTestStandardParam(this.operationTestStandardParamList).then(
|
(response) => {
|
this.$message.success('检测标准参数保存成功')
|
}
|
)
|
} else {
|
this.$message.warning('请先添加参数')
|
}
|
},
|
editTestStandardParam(row) {
|
this.editOrderParamVisible = true
|
this.$nextTick(() => {
|
this.$refs.editOrderParam.init(row)
|
})
|
},
|
deleteTestStandardParam(row) {
|
this.$confirm('是否确认删除参数编号为:' + row.code, {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then((data) => {
|
this.operationTestStandardParamList.splice(
|
this.operationTestStandardParamList.findIndex(
|
(item) => item.index === row.index
|
),
|
1
|
)
|
this.operationTestStandardParamList
|
.filter((e) => e.index >= row.index)
|
.forEach((e) => (e.index = e.index - 1))
|
this.$message.success('删除参数成功')
|
})
|
},
|
// 选择基础参数(添加)
|
relateOperationParam() {
|
if (this.currentOperationTestStandardId !== 0) {
|
this.selectedParamCode()
|
this.showParam = true
|
} else {
|
this.$message.error('请选择检测标准')
|
}
|
},
|
// 选择基础参数(插入)
|
insertOperationParam(row) {
|
this.selectedParamCode()
|
this.showParam = true
|
this.last = false
|
this.insertIndex = row.index
|
},
|
selectedParamCode() {
|
// 筛选出当前页面已有的参数
|
this.paramSelArr = []
|
if (this.operationTestStandardParamList.length > 0) {
|
this.operationTestStandardParamList.forEach((ele) => {
|
if (ele.code != null && ele.code !== '') {
|
this.paramSelArr.push(ele.code)
|
}
|
})
|
}
|
},
|
refreshOrderParamList() {
|
getOperationTestStandardParam(
|
Object.assign({
|
moTestStandardId: this.currentOperationTestStandardId
|
})
|
).then((response) => {
|
this.operationTestStandardParamList = response.data.data
|
})
|
},
|
// 选中的基础参数信息
|
getJoinData(param) {
|
const newDataList = this.operationTestStandardParamList
|
this.operationTestStandardParamList = []
|
this.$nextTick(() => {
|
this.operationTestStandardParamList = newDataList
|
for (let i = 0, len = param.length; i < len; i++) {
|
if (this.last) {
|
this.operationTestStandardParamList.push(
|
Object.assign({
|
moTestStandardId: this.currentOperationTestStandardId,
|
code: param[i].code,
|
parameterItem: param[i].parameterItem,
|
type: param[i].type,
|
unit: param[i].unit,
|
parameterFormat: param[i].parameterFormat,
|
referenceValue: null,
|
index: this.operationTestStandardParamList.length + 1
|
})
|
)
|
} else {
|
this.operationTestStandardParamList
|
.filter((e) => e.index >= this.insertIndex)
|
.forEach((e) => (e.index = e.index + 1))
|
this.operationTestStandardParamList.push(
|
Object.assign({
|
moTestStandardId: this.currentOperationTestStandardId,
|
code: param[i].code,
|
parameterItem: param[i].parameterItem,
|
type: param[i].type,
|
unit: param[i].unit,
|
parameterFormat: param[i].parameterFormat,
|
referenceValue: null,
|
index: this.insertIndex
|
})
|
)
|
}
|
}
|
})
|
}
|
},
|
watch: {
|
operationTestStandardList: {
|
handler(newValue, oldValue) {
|
this.operationTestStandardParamList = []
|
},
|
deep: true
|
}
|
}
|
}
|
</script>
|