|
|
@@ -175,6 +175,7 @@ import {
|
|
|
updateIsSop,
|
|
|
selectIsSopById,
|
|
|
} from "@/api/mes/sop/sopindex";
|
|
|
+import { mapActions, mapGetters } from 'vuex'
|
|
|
export default {
|
|
|
name: "addView",
|
|
|
dicts: ["power_type", "point_type", "sop_type"],
|
|
|
@@ -229,12 +230,18 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
+
|
|
|
if (this.$route.query.sopId !== "null") {
|
|
|
// console.log(this.$route.query.sopId, "接受路由参数");
|
|
|
this.getSopInfo();
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
methods: {
|
|
|
+ ...mapActions('sopSelectPoints', [
|
|
|
+ 'setSelectSopPoints','setPointTableData','setSopEdit'
|
|
|
+ ]),
|
|
|
handleClick(tab, event) {
|
|
|
// console.log(tab, event);
|
|
|
},
|
|
|
@@ -251,7 +258,7 @@ export default {
|
|
|
const sopId = this.$route.query.sopId;
|
|
|
console.log(this.$route.query.sopId, "接受路由参数");
|
|
|
|
|
|
- if (sopId) {
|
|
|
+ if (sopId!==null) {
|
|
|
selectIsSopById(sopId).then((response) => {
|
|
|
console.log(response, "详细内容");
|
|
|
this.form = response.data;
|
|
|
@@ -261,6 +268,10 @@ export default {
|
|
|
});
|
|
|
} else {
|
|
|
this.title = "新增隔离点信息";
|
|
|
+ this.setSopEdit(true)
|
|
|
+ this.setSelectSopPoints([])
|
|
|
+ this.setPointTableData([])
|
|
|
+ this.tableData = null;
|
|
|
this.form = {
|
|
|
spoint: [],
|
|
|
sopContent: "",
|
|
|
@@ -296,7 +307,8 @@ export default {
|
|
|
};
|
|
|
|
|
|
// 编辑模式
|
|
|
- if (this.$route.query.sopId) {
|
|
|
+ if (this.$route.query.sopId!=='null') {
|
|
|
+ console.log(this.$route.query.sopId,'sopIdaaa');
|
|
|
// 确保 sopId 存在
|
|
|
if (!this.form.sopId) {
|
|
|
console.error("隔离点id不可为空!");
|
|
|
@@ -366,102 +378,41 @@ export default {
|
|
|
// }
|
|
|
// },
|
|
|
|
|
|
- // 子组件逆向传递选中的隔离点
|
|
|
- handleSelectPoint(points) {
|
|
|
- console.log(points, "父组件接收逆向传递选中的隔离点");
|
|
|
|
|
|
- // 使用 Map 存储所有新选中的点,pointId 作为 key
|
|
|
- const newPointsMap = new Map(
|
|
|
- points.map((point) => [point.pointId, point])
|
|
|
- );
|
|
|
+ // 子组件选中的隔离点逆传递拿到的数据
|
|
|
+ handleSelectPoint(points) {
|
|
|
+ // console.log(points, "父组件接收逆向传递选中的隔离点");
|
|
|
|
|
|
- // 1. 保留原有的隔离点,更新其数据,如果新选中点中有对应的点,更新 pointType 和 powerType
|
|
|
- this.tableData = this.tableData.map((existingPoint) => {
|
|
|
- if (newPointsMap.has(existingPoint.pointId)) {
|
|
|
- const newPoint = newPointsMap.get(existingPoint.pointId);
|
|
|
- const updatedPoint = { ...existingPoint, ...newPoint };
|
|
|
+ // 使用 Set 来存储传递过来的点值
|
|
|
+ const newValues = new Set(points.map((point) => point.pointId));
|
|
|
|
|
|
- // 删除 undefined 的 pointType 和 powerType
|
|
|
- if (updatedPoint.pointType === undefined) {
|
|
|
- delete updatedPoint.pointType;
|
|
|
- }
|
|
|
- if (updatedPoint.powerType === undefined) {
|
|
|
- delete updatedPoint.powerType;
|
|
|
- }
|
|
|
+ // 1. 删除取消选中的点
|
|
|
+ this.tableData = this.tableData.filter((item) =>
|
|
|
+ newValues.has(item.pointId)
|
|
|
+ );
|
|
|
|
|
|
- return updatedPoint;
|
|
|
- }
|
|
|
- return existingPoint; // 如果没有新数据,则保留原点
|
|
|
- });
|
|
|
+ // 2. 确保新增点不会重复
|
|
|
+ const existingValues = new Set(
|
|
|
+ this.tableData.map((item) => item.pointId)
|
|
|
+ );
|
|
|
|
|
|
- // 2. 添加新点到 tableData 中,如果它不存在并且 pointType 和 powerType 不为 undefined
|
|
|
- points.forEach((newPoint) => {
|
|
|
- const exists = this.tableData.some(
|
|
|
- (item) => item.pointId === newPoint.pointId
|
|
|
- );
|
|
|
-
|
|
|
- // 确保 pointType 和 powerType 都存在,才添加
|
|
|
- if (
|
|
|
- !exists &&
|
|
|
- newPoint.pointType !== undefined &&
|
|
|
- newPoint.powerType !== undefined
|
|
|
- ) {
|
|
|
- const newPointData = {
|
|
|
- pointName: newPoint.pointName,
|
|
|
- pointId: newPoint.pointId,
|
|
|
- pointType: newPoint.pointType,
|
|
|
- powerType: newPoint.powerType,
|
|
|
- };
|
|
|
-
|
|
|
- this.tableData.push(newPointData);
|
|
|
+ points.forEach((point) => {
|
|
|
+ // 如果当前传递的点不在已有的点集中,则添加
|
|
|
+ if (!existingValues.has(point.pointId)) {
|
|
|
+ this.tableData.push({
|
|
|
+ pointName: point.pointName, // 显示的名称
|
|
|
+ pointId: point.pointId, // 对应的值
|
|
|
+ pointType: point.pointType,
|
|
|
+ powerType: point.powerType,
|
|
|
+ });
|
|
|
+ // 将新点值添加到 Set 中
|
|
|
+ existingValues.add(point.value);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // 3. 过滤掉 tableData 中不包含 pointType 或 powerType 的数据
|
|
|
- this.tableData = this.tableData.filter(
|
|
|
- (item) => item.pointType !== undefined && item.powerType !== undefined
|
|
|
- );
|
|
|
-
|
|
|
- // 更新 form.spoint 为最新选中的点的 pointId 数组
|
|
|
- this.form.spoint = this.tableData.map((point) => point.pointId);
|
|
|
-
|
|
|
- // 触发其他可能的更新逻辑,比如向父组件发送更新事件
|
|
|
- this.$emit("selection-changed", this.tableData);
|
|
|
+ // 更新 form.spoint 为最新选中的隔离点数组
|
|
|
+ this.form.spoint = points.map((point) => point.pointId);
|
|
|
},
|
|
|
-
|
|
|
- // handleSelectPoint(points) {
|
|
|
- // console.log(points, "父组件接收逆向传递选中的隔离点");
|
|
|
-
|
|
|
- // // 使用 Set 来存储传递过来的点值
|
|
|
- // const newValues = new Set(points.map((point) => point.pointId));
|
|
|
-
|
|
|
- // // 1. 删除取消选中的点
|
|
|
- // this.tableData = this.tableData.filter((item) =>
|
|
|
- // newValues.has(item.pointId)
|
|
|
- // );
|
|
|
-
|
|
|
- // // 2. 确保新增点不会重复
|
|
|
- // const existingValues = new Set(
|
|
|
- // this.tableData.map((item) => item.pointId)
|
|
|
- // );
|
|
|
-
|
|
|
- // points.forEach((point) => {
|
|
|
- // // 如果当前传递的点不在已有的点集中,则添加
|
|
|
- // if (!existingValues.has(point.pointId)) {
|
|
|
- // this.tableData.push({
|
|
|
- // pointName: point.pointName, // 显示的名称
|
|
|
- // pointId: point.pointId, // 对应的值
|
|
|
- // pointType: point.pointType,
|
|
|
- // powerType: point.powerType,
|
|
|
- // });
|
|
|
- // // 将新点值添加到 Set 中
|
|
|
- // existingValues.add(point.value);
|
|
|
- // }
|
|
|
- // });
|
|
|
-
|
|
|
- // // 更新 form.spoint 为最新选中的隔离点数组
|
|
|
- // this.form.spoint = points.map((point) => point.pointId);
|
|
|
- // },
|
|
|
// 车间你逆向传递拿到的隔离点数据产线
|
|
|
handleProductLineSelected(selectedOption) {
|
|
|
// console.log(selectedOption, '父组件接收到的 selectedOption');
|