Browse Source

Merge branch 'dev' of https://e.coding.net/g-pheu9517/grt-iscs/ISCS_Ui_Admin_Base into dev

车车 1 year ago
parent
commit
639cd6d26d

+ 40 - 12
src/components/separationPoint/index.vue

@@ -4,7 +4,7 @@
 
 <script>
 import Konva from "konva";
-import { selectIsIsolationPointById } from "@/api/mes/spm/segregationPoint";
+import { selectIsIsolationPointById,getIsIsolationPointPage } from "@/api/mes/spm/segregationPoint";
 import { mapGetters } from "vuex";
 
 export default {
@@ -34,7 +34,7 @@ export default {
     console.log(
       this.getSelectSopPoints,
       this.getSopEdit,
-      "selectSopPoints in another page"
+      "getSopEdit - getSelectSopPoints"
     );
   },
   computed: {
@@ -110,6 +110,7 @@ export default {
 
       this.layer.draw();
     },
+
     renderGrid(imageSrc) {
       this.selectedStates = {}; // 用对象来存储选中状态,键为文字内容
       this.rects = {};
@@ -128,7 +129,7 @@ export default {
       if (isLocked && this.getSopEdit == true) {
         this.layer.on("click", (e) => {
           e.cancelBubble = true; // 阻止事件冒泡
-          e.stopPropagation(); // 阻止事件传播
+          // e.stopPropagation(); // 阻止事件传播
         });
       } else {
         this.layer.off("click"); // 移除全局点击事件监听器
@@ -150,8 +151,8 @@ export default {
             height: 50,
             draggable: false,
           });
-          // 添加点击事件,仅当 getSopEdit 为 true 时才允许点击
-          if (this.getSopEdit === true) {
+          // 添加点击事件,仅当 getSopEdit 为 true 时才允许点击a
+          if (this.getSopEdit == true) {
             knovaImage.on("click", () => {
               // 切换选中状态,基于文本内容
               this.selectedStates[labelText] = !this.selectedStates[labelText];
@@ -171,6 +172,7 @@ export default {
                 };
 
                 // 获取隔离点信息,并将选中的 labelText 推入数组
+
                 this.$nextTick(() => {
                   selectIsIsolationPointById(pos.pointId).then((res) => {
                     this.selectedText.push({
@@ -179,6 +181,7 @@ export default {
                       pointType: res.data.pointType,
                       powerType: res.data.powerType,
                     });
+                    console.log(this.selectedText,'$emit');
                     this.$emit("selection-changed", this.selectedText);
                   });
                 });
@@ -281,14 +284,39 @@ export default {
               knovaImage.image(selectedImage); // 更新图像
               this.layer.draw(); // 更新图层
             };
-
-            // 将选中的 labelText 推入数组
-            this.selectedText.push({
-              pointName: labelText,
-              pointId: pos.pointId,
-              pointType: pos.pointType,
-              powerType: pos.powerType,
+          // 将选中的 labelText 推入数组
+            this.$nextTick(() => {
+              getIsIsolationPointPage({ current: 1, size: 100 }).then((res) => {
+                const allPoints = res.data.records; // 假设返回的数据结构是 { records: [点数据] }
+
+                // 根据 pos.pointId 查找对应的 pointType 和 powerType
+                const pointInfo = allPoints.find(point => point.pointId == pos.pointId);
+
+                if (pointInfo) {
+                  this.selectedText.push({
+                    pointName: labelText,
+                    pointId: pos.pointId,
+                    pointType: pointInfo.pointType,
+                    powerType: pointInfo.powerType,
+                  });
+                } else {
+                  // 如果没有找到对应的点信息,可以处理这种情况
+                  console.warn(`未找到 pointId 为 ${pos.pointId} 的点信息`);
+                  this.selectedText.push({
+                    pointName: labelText,
+                    pointId: pos.pointId,
+                    pointType: '',
+                    powerType: '',
+                  });
+                }
+                // console.log(this.selectedText,'默认拿到的points')
+                // 触发父组件的 selection-changed 事件
+                this.$emit("selection-changed", this.selectedText);
+              }).catch((error) => {
+                console.error("获取隔离点信息失败", error);
+              });
             });
+
           }
 
           this.layer.draw();

+ 1 - 1
src/components/separationPoint/workshop.vue

@@ -137,7 +137,7 @@ export default {
             console.error("处理车间下拉失败", error);
           });
 
-        // 这里是为了拿到sop模板里默认的隔离点选中的数据
+        // 这里是为了拿到sop模板里默认的隔离点选中的数据a
         selectIsSopById(newVal[0].sopId).then((res) => {
           console.log(res, "sop");
           const selectSopPoints = res.data.pointDetailVOList.map((item) => {

+ 1 - 1
src/store/modules/sopSelectPoints.js

@@ -2,7 +2,7 @@
 const state = {
   selectSopPoints: [],
   PointTableData: [],
-  sopEdit:null
+  sopEdit:true
 };
 
 const mutations = {

+ 44 - 10
src/views/mes/job/jobm/NewOperations.vue

@@ -185,6 +185,7 @@
                       placeholder="上锁人"
                       clearable
                       style="width: 100%"
+                      @change="handlelockerChage"
                     >
                       <el-option
                         v-for="dict in this.listUserOption"
@@ -309,6 +310,22 @@
             />
           </el-select>
         </el-form-item>
+<!--        <el-form-item label="用户类型" prop="nickName" v-if="insideMumber">-->
+<!--          <el-select-->
+<!--            v-model="dialogForm.userType"-->
+<!--            placeholder="请选择人员"-->
+<!--            clearable-->
+<!--            style="width: 100%"-->
+<!--            multiple-->
+<!--          >-->
+<!--            <el-option-->
+<!--              v-for="dict in dict.type.is_user_type"-->
+<!--              :key="dict.value"-->
+<!--              :label="dict.label"-->
+<!--              :value="dict.value"-->
+<!--            />-->
+<!--          </el-select>-->
+<!--        </el-form-item>-->
         <el-form-item label="人员名称" prop="mumberId" v-if="outsideMumber">
           <el-input
             v-model="dialogForm.username"
@@ -349,7 +366,7 @@ import { mapGetters } from 'vuex'
 
 export default {
   name: 'addView',
-  dicts: ['ticket_type', 'power_type', 'point_type'],
+  dicts: ['ticket_type', 'power_type', 'point_type', 'is_user_type'],
   components: {
     IsolationLeftVue,
     SeparationPoint,
@@ -360,6 +377,7 @@ export default {
       activeName: 'first',
       form: {
         sopId: '',
+        pointIds: '',
         ticketType: '',
         ticketName: '',
         ticketCode: '',
@@ -369,8 +387,16 @@ export default {
         spoint: [], //已选隔离点
         locker: '', //上锁人
         coLocker: '', //共锁人
-        startTime: '', //开始时间
-        endTime: '' //结束时间
+        ticketStartTime: '', //开始时间
+        ticketendTime: '', //结束时间
+        ticketUserDTOList: [
+          {
+            userId: '',
+            userName: '',
+            userRole: '',//作业票角色 暂时不传递
+            userType: ''//用户类型 上锁人或共锁人
+          }
+        ]//所选择的用户
       },
       dialogForm: {
         deptId: '',
@@ -472,8 +498,8 @@ export default {
         this.listUserOption = res.rows.map((item) => {
           return {
             label: item.nickName,
-            value: item.deptId,
-            key: item.userId
+            value: item.userId,
+            key: item.deptId
           }
         })
       }),
@@ -489,12 +515,12 @@ export default {
         })
     },
     // 添加内部人员 部门下拉的chage事件
-    DeptChage(val){
-      console.log(val,' 部门下拉')
+    DeptChage(val) {
+      console.log(val, ' 部门下拉')
       const query = {
         pageNum: 1,
         pageSize: 100000,
-        deptId:this.dialogForm.deptId
+        deptId: this.dialogForm.deptId
       }
       listUser(query).then(res => {
         console.log(res, '用户列表')
@@ -511,8 +537,16 @@ export default {
     handleSelectSOP(value) {
       this.jobProps = this.sopOptions.filter((item) => item.sopId == value)
       console.log(this.jobProps, '父组件jobProps')
-    }
-    ,
+    },
+    // 上锁人下拉选择change事件
+    handlelockerChage(val){
+      console.log(val,'上锁人chage')
+      const user=this.listUserOption.filter((item) => {
+        return item.value == val
+      })
+      console.log(user,'用户')
+
+    },
     handleClick(tab, event) {
       // console.log(tab, event);
     }

+ 40 - 89
src/views/mes/sop/sopm/NewSop.vue

@@ -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');

+ 1 - 1
src/views/mes/sop/sopm/index.vue

@@ -429,7 +429,7 @@ export default {
       this.single = selection.length !== 1;
       this.multiple = !selection.length;
     },
-    /** 新增按钮操作 */
+    /** 新增按钮操作a */
     handleAdd() {
       this.reset();
       this.$router.push("/mes/sop/sopm/NewSop?sopId=null");