spc/src/views/spc-basic/components/productList-four-content.vue

328 lines
11 KiB
Vue
Raw Normal View History

2022-09-01 15:46:47 +08:00
<!--
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
2023-04-10 15:49:11 +08:00
* @LastEditTime: 2023-04-10 15:44:28
2022-09-01 15:46:47 +08:00
* @Description:
-->
<template>
2023-04-10 15:49:11 +08:00
<div class="baseTable">
2022-09-09 16:50:02 +08:00
<div v-if="workingProcedure.length && productFeaturesOptions.length">
<el-tabs @tab-click="tabClick">
2023-01-06 15:49:40 +08:00
<el-tab-pane
v-loading="loading"
element-loading-text="保存中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)"
label="控制矩阵"
>
2022-09-09 16:50:02 +08:00
<el-button style="float:right" size="small" type="primary" @click="deleteFeatures()">
<svg class="icon-svg"><use xlink:href="#icon-新建"></use></svg>
保存
</el-button>
<el-table
:data="productFeaturesList"
v-loading="dataListLoading"
border
style="width: 50%;"
2022-09-01 15:46:47 +08:00
>
2022-12-13 16:41:37 +08:00
<el-table-column prop="name" align="center"> </el-table-column>
2022-09-09 16:50:02 +08:00
<el-table-column
v-for="(item, index) in workingProcedure"
:key="item.id"
:label="item.workingProcedureName"
>
<template slot-scope="scope">
<el-checkbox
@change="
(checked) => CheckboxChange(checked, scope.row.id, item.workingProcedureId)
"
:checked="scope.row['checked' + index]"
>
</el-checkbox>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
2022-12-13 16:41:37 +08:00
<el-tab-pane label="特性列表" align="center">
2022-09-09 16:50:02 +08:00
<el-table
:data="dataList"
:header-cell-style="{
2023-04-10 15:49:11 +08:00
background: '#F2F4F9',
2022-09-09 16:50:02 +08:00
color: '#606266',
}"
style="width: 100%;"
2022-09-01 15:46:47 +08:00
>
2022-09-09 16:50:02 +08:00
<el-table-column
type="index"
header-align="center"
align="center"
label="序号"
width="50"
>
</el-table-column>
2022-12-13 16:41:37 +08:00
<el-table-column prop="code" align="center" label="编号"> </el-table-column>
<el-table-column prop="name" align="center" label="名称"></el-table-column>
<el-table-column prop="type" align="center" label="特性类型">
2022-09-09 16:50:02 +08:00
<template slot-scope="scope">
<span>{{ scope.row.type === 2 ? "计数" : "计量" }}</span>
</template>
</el-table-column>
2022-12-13 16:41:37 +08:00
<el-table-column prop="defectLevel" align="center" label="缺陷等级">
2022-09-09 16:50:02 +08:00
<template slot-scope="scope">
<span>{{
scope.row.defectLevel === 1
? "致命缺陷"
: scope.row.defectLevel === 2
? "严重缺陷"
: "轻微缺陷"
}}</span>
</template>
</el-table-column>
2022-12-13 16:41:37 +08:00
<el-table-column prop="measureToolName" align="center" label="量具"></el-table-column>
<el-table-column prop="isSpc" align="center" label="SPC">
2022-09-09 16:50:02 +08:00
<template slot-scope="scope">
<span>{{ scope.row.isSpc === 1 ? "是" : "否" }}</span>
</template>
</el-table-column>
2023-01-06 15:49:40 +08:00
<el-table-column
prop="controlGraphName"
align="center"
label="分析图形"
></el-table-column>
2022-12-13 16:41:37 +08:00
<el-table-column prop="sampleSize" align="center" label="样本大小"></el-table-column>
2023-01-06 15:49:40 +08:00
<el-table-column
prop="samplingFrequency"
align="center"
label="抽样频率"
></el-table-column>
2022-12-13 16:41:37 +08:00
<el-table-column prop="unitName" align="center" label="单位"></el-table-column>
<el-table-column prop="decimalPlaces" align="center" label="小数位数"></el-table-column>
<el-table-column prop="specifications" align="center" label="规格"></el-table-column>
<el-table-column prop="lsl" align="center" label="LSL"></el-table-column>
<el-table-column prop="sl" align="center" label="SL"></el-table-column>
<el-table-column prop="usl" align="center" label="USL"></el-table-column>
<el-table-column prop="targetCpk" align="center" label="目标CPK"></el-table-column>
<el-table-column prop="targetPpk" align="center" label="目标PPK"></el-table-column>
<el-table-column prop="remark" align="center" label="备注"></el-table-column>
2022-09-09 16:50:02 +08:00
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
2023-06-21 16:41:40 +08:00
:label="$t('handle')"
2022-09-09 16:50:02 +08:00
>
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">
<el-tooltip class="item" effect="dark" content="修改" placement="top">
<svg class="icon-svg aui-sidebar__menu-icon">
<use xlink:href="#icon-编辑"></use>
</svg>
</el-tooltip>
</el-button>
<el-button type="text" size="small" @click="productFeaturesHis(scope.row.id)">
<el-tooltip class="item" effect="dark" content="历史记录" placement="top">
<svg class="icon-svg aui-sidebar__menu-icon">
<use xlink:href="#历史记录"></use>
</svg>
</el-tooltip>
</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</div>
<el-empty
v-else
description="该产品没有配置产品特性或工序,暂时不能分配过程控制特性"
></el-empty>
2022-09-01 15:46:47 +08:00
<four-add-or-update
v-if="fourAddOrUpdateVisible"
ref="fourAddOrUpdate"
@refreshFourDataList="getFourDataList"
></four-add-or-update>
2023-01-06 15:49:40 +08:00
<four-history v-if="productFeaturesHisVisible" ref="productFeaturesHisRef"></four-history>
2022-09-01 15:46:47 +08:00
</div>
</template>
<script>
import fourAddOrUpdate from "./productList-four-add";
2022-09-09 16:50:02 +08:00
import fourHistory from "./productList-four-history";
2022-09-01 15:46:47 +08:00
export default {
props: {
productFeaturesOptions: {
type: Array,
default: () => {
return [];
},
},
2022-09-09 16:50:02 +08:00
workingProcedure: {
type: Array,
default: () => {
return [];
},
},
productId: {
type: String,
},
2022-09-01 15:46:47 +08:00
},
data() {
return {
fourAddOrUpdateVisible: false,
2022-09-09 16:50:02 +08:00
productFeaturesList: [],
2022-09-01 15:46:47 +08:00
dataList: [],
2022-09-09 16:50:02 +08:00
setBatchInsert: [],
inspectionStage: 0,
dataListLoading: false,
2023-01-06 15:49:40 +08:00
loading: false,
productFeaturesHisVisible: false,
2022-09-01 15:46:47 +08:00
};
},
components: {
fourAddOrUpdate,
2022-09-09 16:50:02 +08:00
fourHistory,
2022-09-01 15:46:47 +08:00
},
methods: {
2022-09-09 16:50:02 +08:00
init(index) {
this.dataListLoading = false;
2023-01-06 15:49:40 +08:00
this.loading = false;
2022-12-13 16:41:37 +08:00
this.inspectionStage = parseInt(index);
2022-09-09 16:50:02 +08:00
this.productFeaturesList.splice(0, this.productFeaturesList.length);
2022-09-01 15:46:47 +08:00
this.$nextTick(() => {
2022-09-09 16:50:02 +08:00
this.getSelection();
if (this.productId) {
2022-09-01 15:46:47 +08:00
}
});
},
2022-09-09 16:50:02 +08:00
getSelection() {
this.setBatchInsert.splice(0, this.setBatchInsert.length);
this.dataListLoading = true;
this.$http
.post(
`/basic/productFeatures/getFeaturesByStageProcedure?inspectionStage=${this.inspectionStage}&productId=${this.productId}`
)
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
2022-09-01 15:46:47 +08:00
}
2022-09-09 16:50:02 +08:00
this.productFeaturesList = this.productFeaturesOptions.map((item) => {
const obj = Object.assign({}, item);
this.workingProcedure.forEach((item1, index) => {
res.data.forEach((item2) => {
if (item2.productFeaturesId === item.id) {
if (item2.workingProcedureId === item1.workingProcedureId) {
Object.assign(obj, { ["checked" + index]: true });
this.CheckboxChange(true, item2.productFeaturesId, item2.workingProcedureId);
}
}
});
});
return obj;
});
this.dataListLoading = false;
})
.catch((e) => {
console.log(e);
this.dataListLoading = false;
2022-09-01 15:46:47 +08:00
});
2022-09-09 16:50:02 +08:00
},
tabClick(val) {
if (val.label === "特性列表") {
this.getFourDataList();
2022-09-01 15:46:47 +08:00
}
},
// 新增 / 修改
addOrUpdateHandle(id) {
this.fourAddOrUpdateVisible = true;
this.$nextTick(() => {
2022-09-09 16:50:02 +08:00
this.$refs.fourAddOrUpdate.init(id, this.productId);
2022-09-01 15:46:47 +08:00
});
},
2022-09-09 16:50:02 +08:00
deleteFeatures() {
2023-01-06 15:49:40 +08:00
this.loading = true;
2022-09-09 16:50:02 +08:00
this.workingProcedure.forEach((item, index) => {
this.$http
2023-01-06 15:49:40 +08:00
.delete(
`/basic/featuresStageProcedureRelation/deleteByStageProcedure?inspectionStage=${this.inspectionStage}&productId=${this.productId}&workingProcedureId=${item.workingProcedureId}`
)
2022-09-09 16:50:02 +08:00
.then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg);
}
if (index === this.workingProcedure.length - 1) {
this.addFeatures();
}
})
.catch(() => {});
});
},
addFeatures() {
2022-09-01 15:46:47 +08:00
this.$http
2022-09-09 16:50:02 +08:00
.post("/basic/featuresStageProcedureRelation/batchInsert", [...this.setBatchInsert])
.then(({ data: res }) => {
2023-01-06 15:49:40 +08:00
this.loading = false;
2022-09-09 16:50:02 +08:00
if (res.code !== 0) {
return this.$message.error(res.msg);
}
2022-09-01 15:46:47 +08:00
})
2022-09-09 16:50:02 +08:00
.catch(() => {});
},
CheckboxChange(checked, productFeaturesId, workingProcedureId) {
this.setBatchInsert = [...this.setBatchInsert];
if (checked) {
const obj = {
inspectionStage: parseInt(this.inspectionStage),
productFeaturesId: productFeaturesId,
workingProcedureId: workingProcedureId,
};
this.setBatchInsert.push(obj);
} else {
const id1 = this.setBatchInsert.findIndex((item) => {
if (
item.productFeaturesId === productFeaturesId &&
item.workingProcedureId === workingProcedureId
) {
return true;
}
});
this.setBatchInsert.splice(id1, 1);
}
},
getFourDataList() {
this.$http
.post(
`/basic/productFeatures/getFeaturesList?inspectionStage=${this.inspectionStage}&productId=${this.productId}`
)
2022-09-01 15:46:47 +08:00
.then(({ data: res }) => {
if (res.code !== 0) {
2022-09-09 16:50:02 +08:00
this.dataList = [];
2022-09-01 15:46:47 +08:00
return this.$message.error(res.msg);
}
2022-09-09 16:50:02 +08:00
this.dataList = res.data;
this.tabClick();
2022-09-01 15:46:47 +08:00
})
.catch(() => {});
},
2023-01-06 15:49:40 +08:00
productFeaturesHis(id) {
this.productFeaturesHisVisible = true;
this.$nextTick(() => {
this.$refs.productFeaturesHisRef.init(id);
});
2022-09-09 16:50:02 +08:00
},
2022-09-01 15:46:47 +08:00
// 表单提交
dataFormSubmit() {},
},
};
</script>
2023-04-10 15:49:11 +08:00
<style>
.baseTable .el-table__body tr.current-row > td.el-table__cell {
background-color: #eaf1fc;
}
.baseTable .el-table .el-table__cell {
padding: 0;
height: 35px;
}
</style>