<template>
|
<div>
|
<el-card class="productorder-params-template">
|
<div slot="header">
|
<span>检测标准</span>
|
<div style="float: right;">
|
<el-button
|
style="padding: 3px 0;color:#909399"
|
type="text"
|
size="medium"
|
v-if="editable && dataFormId && moRoutingOperationId"
|
@click="openCustomizeTestStandardDialog"
|
>自定义
|
</el-button>
|
<el-button
|
style="padding: 3px 0"
|
type="text"
|
size="medium"
|
v-if="editable && dataFormId && moRoutingOperationId"
|
@click="openTestStandardDialog"
|
>添加
|
</el-button>
|
</div>
|
</div>
|
<el-table
|
ref="operationTestStandardTable"
|
:data="operationTestStandardList"
|
class="l-mes"
|
highlight-current-row
|
@row-click="testStandardRowClick"
|
>
|
<el-table-column
|
label="标准编号"
|
prop="standardNo"
|
align="center"
|
show-overflow-tooltip
|
/>
|
<el-table-column
|
label="标准名称"
|
prop="standardName"
|
align="center"
|
show-overflow-tooltip
|
/>
|
<el-table-column label="检测类型" prop="inspectionType" align="center">
|
<template slot-scope="scope">
|
<span>{{
|
inspectionTypeOptions.find((item) => {
|
return item.value === scope.row.inspectionType
|
})
|
? inspectionTypeOptions.find((item) => {
|
return item.value === scope.row.inspectionType
|
}).label
|
: ''
|
}}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="备注"
|
prop="remark"
|
align="center"
|
show-overflow-tooltip
|
/>
|
<el-table-column label="操作" align="center">
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="mini"
|
v-if="editable && dataFormId && moRoutingOperationId != null"
|
@click.stop="editTestStandard(scope.row)"
|
>编辑
|
</el-button>
|
<el-button
|
type="text"
|
size="mini"
|
v-if="editable && dataFormId && moRoutingOperationId != null"
|
@click.stop="handleTestStandardDelete(scope.row, scope.$index)"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-card>
|
<el-card class="productorder-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="100%"
|
style="width: 100%"
|
>
|
<el-table-column prop="index" label="序号" align="center" width="50" />
|
<el-table-column label="线芯" prop="wireCore" align="center" />
|
<el-table-column
|
prop="isCheck"
|
label="抽检"
|
align="center"
|
:formatter="isCheckFormatter"
|
/>
|
<el-table-column label="参数编号" prop="code" align="center" />
|
<el-table-column label="参数项" prop="parameterItem" align="center" />
|
<el-table-column label="检测范围" prop="referenceValue" align="center">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.referenceValue"
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="默认值" prop="defaultValue" align="center">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.defaultValue"
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="参数项类型" prop="paramType" align="center">
|
<template slot-scope="scope">
|
<el-select
|
v-model="scope.row.paramType"
|
placeholder="请选择"
|
style="width: 100%;"
|
>
|
<el-option
|
v-for="(item, index) in paramTypeOptions"
|
:key="index"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</template>
|
</el-table-column>
|
<el-table-column label="参数格式" prop="parameterFormat" align="center">
|
<template slot-scope="scope">
|
<el-input
|
v-model="scope.row.parameterFormat"
|
:disabled="!editable"
|
></el-input>
|
</template>
|
</el-table-column>
|
<el-table-column label="通道" prop="aisle" align="center" />
|
<el-table-column label="部位" prop="position" align="center" />
|
<el-table-column label="单位" prop="unit" align="center" />
|
<el-table-column
|
prop="extendsRoutingNo"
|
label="继承工艺路线"
|
align="center"
|
/>
|
<el-table-column
|
prop="extendsOperationNo"
|
label="继承工序"
|
align="center"
|
/>
|
<el-table-column
|
prop="extendsTestStandardNo"
|
label="继承标准"
|
align="center"
|
/>
|
<el-table-column
|
prop="extendsTestStandardParamNo"
|
label="继承标准参数"
|
align="center"
|
/>
|
<el-table-column label="操作" align="center" width="118">
|
<template slot-scope="scope">
|
<el-button
|
type="text"
|
size="mini"
|
@click.stop="insertOperationParam(scope.row)"
|
>插入
|
</el-button>
|
<el-button
|
type="text"
|
size="mini"
|
@click.stop="editTestStandardParam(scope.row)"
|
>公式
|
</el-button>
|
<el-button
|
type="text"
|
size="mini"
|
@click.stop="deleteTestStandardParam(scope.row)"
|
>删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-card>
|
<testStandardDialog
|
:currshowlist.sync="showTestStandard"
|
@handleSelectionTestStandardChange="selectTestStandard"
|
/>
|
<StandardParamForm
|
v-if="standardParamVisible"
|
ref="addOrUpdateStandardParam"
|
@refreshDataList="refreshJoinData"
|
/>
|
<standardForm
|
v-if="standardVisible"
|
ref="addOrUpdateStandard"
|
@refreshDataList="addCustomizeTestStandard"
|
></standardForm>
|
<!-- 弹窗, 基础参数选择 -->
|
<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>
|
.productorder-template-rule .el-card__body {
|
height: 570px;
|
}
|
</style>
|
<script>
|
import {
|
addRoutingTestStandard,
|
getRoutingTestStandardList,
|
deleteRoutingTestStandard,
|
getOperationTestStandardParam,
|
addOperationTestStandardParam
|
} from '@/api/plan/moteststandard'
|
import testStandardDialog from '@/views/common/teststandard'
|
import StandardParamForm from './standardparamform'
|
import StandardForm from './standardform'
|
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
|
},
|
moRoutingOperationId: {
|
type: Number,
|
default: 0
|
}
|
},
|
data() {
|
return {
|
paramTypeOptions: [],
|
inspectionTypeOptions: [],
|
addCustomizeTestStandardVisible: false,
|
showTestStandard: false,
|
operationTestStandardList: [],
|
operationTestStandardParamList: [],
|
currentOperationTestStandardId: 0,
|
standardParamVisible: false,
|
standardVisible: false,
|
paramSelArr: [],
|
paramSelCol: 'code',
|
showParam: false,
|
insertIndex: null,
|
last: true,
|
editOrderParamVisible: false
|
}
|
},
|
components: {
|
testStandardDialog,
|
StandardParamForm,
|
StandardForm,
|
ParamDialog,
|
EditOrderParamForm
|
},
|
mounted() {
|
this.rowDrop()
|
},
|
created() {
|
this.initDirParamType()
|
this.initDirInspectionType()
|
},
|
methods: {
|
// 弹出自定义检测标准对话框
|
openCustomizeTestStandardDialog() {
|
this.standardVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdateStandard.init(
|
this.dataFormId,
|
this.moRoutingOperationId,
|
null
|
)
|
})
|
},
|
// 弹出检测标准修改的对话框
|
editTestStandard(row) {
|
this.standardVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdateStandard.init(null, null, row.id)
|
})
|
},
|
// 获取数据列表
|
addCustomizeTestStandard(testStandard) {
|
let flag = true
|
for (let i = 0; i < this.operationTestStandardList.length; i++) {
|
if (testStandard.id === this.operationTestStandardList[i].id) {
|
this.$set(this.operationTestStandardList, i, testStandard)
|
flag = false
|
this.$refs.operationTestStandardTable.setCurrentRow(
|
this.operationTestStandardList[i]
|
)
|
this.getOperationTestStandardParam(testStandard.id)
|
break
|
}
|
}
|
if (flag) {
|
this.operationTestStandardList.push(testStandard)
|
// 选中最后一个检测标准
|
this.selectLastTestStandard()
|
}
|
},
|
initDirParamType() {
|
remote('quality_param_type').then((response) => {
|
if (response.data.code === 0) {
|
this.paramTypeOptions = response.data.data
|
}
|
})
|
},
|
initDirInspectionType() {
|
remote('apply_report_type').then((response) => {
|
if (response.data.code === 0) {
|
this.inspectionTypeOptions = 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.operationTestStandardList.length > 0
|
) {
|
this.$refs.operationTestStandardTable.setCurrentRow(
|
this.operationTestStandardList[0]
|
)
|
this.testStandardRowClick(this.operationTestStandardList[0])
|
} else {
|
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,
|
moRoutingOperationId: this.moRoutingOperationId,
|
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()
|
// 刷新抽检规则
|
this.$emit('refreshTestStandardInfo')
|
} 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.id)
|
},
|
// 根据工艺工序id、模板id去获取模板下的参数
|
getOperationTestStandardParam(rowId) {
|
this.currentOperationTestStandardId = rowId
|
getOperationTestStandardParam(
|
Object.assign({
|
moTestStandardId: rowId
|
})
|
).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))
|
}
|
}
|
})
|
},
|
// 添加
|
addTestStandardParam(row, index) {
|
if (this.currentOperationTestStandardId !== 0) {
|
this.standardParamVisible = true
|
this.$nextTick(() => {
|
this.$refs.addOrUpdateStandardParam.init(row, index)
|
})
|
} else {
|
this.$message.warning('请选择检测标准')
|
}
|
},
|
// 提交检测标准参数
|
dataFormTestStandardParam() {
|
if (this.operationTestStandardParamList.length > 0) {
|
addOperationTestStandardParam(this.operationTestStandardParamList).then(
|
(response) => {
|
this.$message.success('检测标准参数保存成功')
|
}
|
)
|
} else {
|
this.$message.warning('请先添加参数')
|
}
|
},
|
// 添加/插入操作后更新参数信息
|
refreshJoinData(param) {
|
const newDataList = this.operationTestStandardParamList
|
this.operationTestStandardParamList = []
|
this.$nextTick(() => {
|
this.operationTestStandardParamList = newDataList
|
this.operationTestStandardParamList
|
.filter((e) => e.index >= param.index)
|
.forEach((e) => (e.index = e.index + 1))
|
this.operationTestStandardParamList.push(
|
Object.assign(
|
{
|
moTestStandardId: this.currentOperationTestStandardId
|
},
|
param
|
)
|
)
|
})
|
},
|
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,
|
defaultValue: null,
|
aisle: null,
|
position: null,
|
index: this.operationTestStandardParamList.length + 1,
|
wireCore: null
|
})
|
)
|
} 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,
|
defaultValue: null,
|
aisle: null,
|
position: null,
|
index: this.insertIndex,
|
wireCore: null
|
})
|
)
|
}
|
}
|
})
|
},
|
isCheckFormatter(row) {
|
let isCheckStr = ''
|
if (row.isCheck != null) {
|
if (row.isCheck) {
|
isCheckStr = '是'
|
} else {
|
isCheckStr = '否'
|
}
|
}
|
return isCheckStr
|
}
|
}
|
}
|
</script>
|