Prechádzať zdrojové kódy

作业票编辑功能

pm 1 rok pred
rodič
commit
40aeb38eb5

+ 5 - 1
src/App.vue

@@ -1,6 +1,10 @@
 <template>
   <div id="app">
-    <router-view />
+
+    <keep-alive>
+      <router-view />
+    </keep-alive>
+
   </div>
 </template>
 

+ 24 - 10
src/components/separationPoint/workshop.vue

@@ -80,6 +80,7 @@ export default {
       type: Array,
       default: () => [],
     },
+
   },
   data() {
     return {
@@ -124,7 +125,7 @@ export default {
     },
     jobProps: {
       handler(newVal, oldVal) {
-        console.log("jobProps 发生变化", newVal, oldVal);
+        console.log("jobProps 发生变化", newVal);
         // 在这里处理 jobProps 变化后的逻辑
         this.form.workShop = newVal[0].workshopId;
         this.form.producLine = newVal[0].workareaId;
@@ -138,30 +139,43 @@ export default {
           });
 
         // 这里是为了拿到sop模板里默认的隔离点选中的数据a
-        selectIsSopById(newVal[0].sopId).then((res) => {
-          console.log(res, "sop");
-          const selectSopPoints = res.data.pointDetailVOList.map((item) => {
+        if(!newVal[0].EditBool){
+          selectIsSopById(newVal[0].sopId).then((res) => {
+            console.log(res, "sop");
+            const selectSopPoints = res.data.pointDetailVOList.map((item) => {
+              return item.pointId;
+            });
+
+            // 调用 Vuex action 来存储 selectSopPoints
+            this.setSelectSopPoints(selectSopPoints);
+            this.setPointTableData(res.data)
+            this.setSopEdit(false)
+            console.log(selectSopPoints, "sop_selectePoints");
+          });
+        }else{
+          const selectSopPoints = newVal[0].spoint.map((item) => {
             return item.pointId;
           });
-
-          // 调用 Vuex action 来存储 selectSopPoints
           this.setSelectSopPoints(selectSopPoints);
-          this.setPointTableData(res.data)
-          this.setSopEdit(false)
-          console.log(selectSopPoints, "sop_selectePoints");
-        });
+          this.setPointTableData(newVal[0].spoint)
+          this.setSopEdit(true)
+        }
+
       },
       immediate: true, // 立即执行一次,确保在组件初始化时也能捕获到 jobProps 的值
     },
+
   },
   mounted() {
     this.getworkshopList();
+
   },
 
   methods: {
     ...mapActions('sopSelectPoints', [
       'setSelectSopPoints','setPointTableData','setSopEdit'
     ]),
+
     // 获取车间列表
     getworkshopList() {
       listAllWorkshop().then((response) => {

+ 4 - 2
src/router/index.js

@@ -116,7 +116,8 @@ export const dynamicRoutes = [
         path: 'NewSop',
         component: () => import('@/views/mes/sop/sopm/NewSop'),
         name: 'NewSop',
-        meta: { title: 'SOP管理-新建SOP', activeMenu: '/mes/sop/sopm/NewSop' }
+        meta: { title: 'SOP管理-新建SOP', activeMenu: '/mes/sop/sopm/NewSop' },
+
       },
 
     ]
@@ -131,7 +132,8 @@ export const dynamicRoutes = [
         path: 'NewOperations',
         component: () => import('@/views/mes/job/jobm/NewOperations'),
         name: 'NewOperations',
-        meta: { title: '作业管理-新建作业票', activeMenu: '/mes/job/jobm/NewOperations' }
+        meta: { title: '作业管理-新建作业票', activeMenu: '/mes/job/jobm/NewOperations' },
+
       },
       {
         path: 'LookJob',

+ 8 - 4
src/store/modules/sopSelectPoints.js

@@ -2,7 +2,8 @@
 const state = {
   selectSopPoints: [],
   PointTableData: [],
-  sopEdit:true
+  sopEdit:true,
+
 };
 
 const mutations = {
@@ -14,7 +15,8 @@ const mutations = {
   },
   setSopEdit(state, points){
     state.sopEdit = points;
-  }
+  },
+
 };
 
 const actions = {
@@ -26,13 +28,15 @@ const actions = {
   },
   setSopEdit({ commit }, points){
     commit('setSopEdit', points);
-  }
+  },
+
 };
 
 const getters = {
   getSelectSopPoints: state => state.selectSopPoints,
   getPointTableData: state => state.PointTableData,
-  getSopEdit: state => state.sopEdit
+  getSopEdit: state => state.sopEdit,
+
 };
 
 export default {

+ 387 - 204
src/views/mes/job/jobm/NewOperations.vue

@@ -14,6 +14,7 @@
         @product-line-selected="handleProductLineSelected"
         @work-shop-selected="handleWorkshopSelected"
         :jobProps="jobProps"
+
       ></WorkShop>
     </div>
     <div class="right">
@@ -24,7 +25,7 @@
             <span
               style="float: right; padding: 1px 0; font-size: 22px"
               type="text"
-              >×</span
+            >×</span
             >
           </div>
           <div class="text item">
@@ -89,7 +90,7 @@
                       type="primary"
                       class="workTicket_btn"
                       @click="nextStep('second')"
-                      >下一步
+                    >下一步
                     </el-button>
                   </el-form-item>
                 </el-form>
@@ -126,8 +127,8 @@
                       <el-table-column prop="pointName" label="已选隔离点">
                         <template slot-scope="scope">
                           <span style="color: #2a87ff">{{
-                            scope.row.pointName
-                          }}</span>
+                              scope.row.pointName
+                            }}</span>
                         </template>
                       </el-table-column>
                       <el-table-column prop="pointType" label="隔离点类型">
@@ -157,7 +158,7 @@
                       style="float: right; height: 30px; line-height: 10px"
                       type="primary"
                       @click="nextStep('third')"
-                      >下一步
+                    >下一步
                     </el-button>
                     <el-button
                       plain
@@ -169,7 +170,7 @@
                       "
                       type="primary"
                       @click="previousStep('first')"
-                      >上一步
+                    >上一步
                     </el-button>
                   </el-form-item>
                 </el-form>
@@ -193,6 +194,8 @@
                       />
                     </el-select>
                   </el-form-item>
+
+
                   <el-form-item label="共锁人" prop="coLocker">
                     <el-select
                       v-model="form.coLocker"
@@ -201,21 +204,24 @@
                       multiple
                       style="width: 100%"
                       @change="handleCoLockerChange"
+                      ref="coLockerSelect"
                     >
                       <el-option
-                        v-for="dict in this.form.ticketUserDTOList"
+                        v-for="dict in sortedTicketUserDTOList"
                         :key="dict.userId"
                         :label="dict.username"
                         :value="dict.username"
-                      />
+                      >
+                      </el-option>
                     </el-select>
+
                   </el-form-item>
                   <el-form-item label="共锁人" prop="coLocker">
                     <el-button type="primary" @click="addInside"
-                      >添加内部人员
+                    >添加内部人员
                     </el-button>
                     <el-button type="primary" @click="addOutside"
-                      >添加外部人员
+                    >添加外部人员
                     </el-button>
                   </el-form-item>
                   <el-form-item label="开始时间" prop="ticketStartTime">
@@ -226,6 +232,7 @@
                       align="right"
                       :picker-options="pickerOptions"
                       style="width: 100%"
+                      @change="ticketStartTimeChange"
                     >
                     </el-date-picker>
                   </el-form-item>
@@ -237,6 +244,7 @@
                       align="right"
                       :picker-options="pickerOptions"
                       style="width: 100%"
+                      @change="ticketEndTimeChange"
                     >
                     </el-date-picker>
                   </el-form-item>
@@ -245,7 +253,7 @@
                       style="float: right; height: 30px; line-height: 10px"
                       type="primary"
                       @click="confirm"
-                      >完 成
+                    >完 成
                     </el-button>
                   </el-form-item>
                 </el-form>
@@ -316,7 +324,7 @@
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="open = false">确认</el-button>
+        <el-button type="primary" @click="cancel">确认</el-button>
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
@@ -326,63 +334,64 @@
 
 
 <script>
-import SeparationPoint from "@/components/separationPoint/index.vue";
-import WorkShop from "@/components/separationPoint/workshop.vue";
+import SeparationPoint from '@/components/separationPoint/index.vue'
+import WorkShop from '@/components/separationPoint/workshop.vue'
 import {
   listJobTicket,
   getJobTicketInfo,
   addJobTicket,
   updateJobTicket,
   deleteIsJobTicket,
-  getworkareaList,
-} from "@/api/mes/job/job";
-import { listWorkshop } from "@/api/mes/md/workshop";
-import { listWorkarea } from "@/api/mes/wa/workarea";
-import { getIsSopPage } from "@/api/mes/sop/sopindex";
-import { listUser } from "@/api/system/user";
-import { listDept } from "@/api/system/dept";
-import IsolationLeftVue from "@/components/separationPoint/index.vue";
+  getworkareaList
+} from '@/api/mes/job/job'
+import { listWorkshop } from '@/api/mes/md/workshop'
+import { listWorkarea } from '@/api/mes/wa/workarea'
+import { getIsSopPage } from '@/api/mes/sop/sopindex'
+import { listUser } from '@/api/system/user'
+import { listDept } from '@/api/system/dept'
+import IsolationLeftVue from '@/components/separationPoint/index.vue'
 
-import { mapGetters } from "vuex";
+import { mapGetters,mapActions } from 'vuex'
 
 export default {
-  name: "addView",
-  dicts: ["ticket_type", "power_type", "point_type", "is_user_type"],
+  name: 'addView',
+  dicts: ['ticket_type', 'power_type', 'point_type', 'is_user_type'],
   components: {
     IsolationLeftVue,
     SeparationPoint,
-    WorkShop,
+    WorkShop
   },
   data() {
     return {
-      activeName: "first",
+      activeName: 'first',
       form: {
-        sopId: "",
-        pointIds: "",
-        ticketType: "",
-        ticketName: "",
-        ticketCode: "",
-        ticketContent: "",
-        workshopName: "", //车间名称
-        workline: "", //产线
+        sopId: '',
+        pointIds: '',
+        ticketId: '',
+        ticketType: '',
+        ticketName: '',
+        ticketCode: '',
+        ticketContent: '',
+        workshopName: '', //车间名称
+        workline: '', //产线
         spoint: [], //已选隔离点
-        locker: "", //上锁人
-        coLocker: "", //共锁人
-        ticketStartTime: "", //开始时间
-        ticketEndTime: "", //结束时间
+        locker: '', //上锁人
+        coLocker: '', //共锁人
+        ticketStartTime: '', //开始时间
+        ticketEndTime: '', //结束时间
         ticketUserDTOList: [
           // {
           //   userId: '',
           //   userName: '',
-          //   userRole: '',//作业票角色 暂时不传递
+          //   userRole: '',//作业票角色 暂时不传递 内部人还是外部人
           //   userType: ''//用户类型 上锁人或共锁人
           // }
-        ], //所选择的用户
+        ] //所选择的用户
       },
       dialogForm: {
-        deptId: "",
-        nickname: "",
-        username: "",
+        deptId: '',
+        nickName: '',
+        username: ''
       },
       listUserOption: null,
       listDeptOption: null,
@@ -391,52 +400,54 @@ export default {
       pickerOptions: {
         shortcuts: [
           {
-            text: "今天",
+            text: '今天',
             onClick(picker) {
-              picker.$emit("pick", new Date());
-            },
+              picker.$emit('pick', new Date())
+            }
           },
           {
-            text: "昨天",
+            text: '昨天',
             onClick(picker) {
-              const date = new Date();
-              date.setTime(date.getTime() - 3600 * 1000 * 24);
-              picker.$emit("pick", date);
-            },
+              const date = new Date()
+              date.setTime(date.getTime() - 3600 * 1000 * 24)
+              picker.$emit('pick', date)
+            }
           },
           {
-            text: "一周前",
+            text: '一周前',
             onClick(picker) {
-              const date = new Date();
-              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
-              picker.$emit("pick", date);
-            },
-          },
-        ],
+              const date = new Date()
+              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
+              picker.$emit('pick', date)
+            }
+          }
+        ]
       },
       // 是否显示弹出层
       open: false,
       // 弹出层标题
-      title: "",
+      title: '',
       // 弹框中显示的form表单内容
       insideMumber: false,
       outsideMumber: false,
       points: null, //逆向传递拿到隔离点的数据
       sopOptions: [], //sop下拉
       jobProps: [], //正向传递给车间components
+
       // 表单校验
       rules: {
         teamCode: [
-          { required: true, message: "班组编号不能为空", trigger: "blur" },
+          { required: true, message: '班组编号不能为空', trigger: 'blur' }
         ],
         teamName: [
-          { required: true, message: "班组名称不能为空", trigger: "blur" },
+          { required: true, message: '班组名称不能为空', trigger: 'blur' }
         ],
         calendarType: [
-          { required: true, message: "清选择班组类型", trigger: "blur" },
-        ],
+          { required: true, message: '清选择班组类型', trigger: 'blur' }
+        ]
       },
-    };
+      newticketUserDTOList:[],//为了上锁人单独传递数据
+    }
   },
   watch: {
     tableData: {
@@ -445,245 +456,371 @@ export default {
         if (newVal && newVal.length > 0) {
           this.form.pointIds = this.tableData
             .map((item) => item.pointId)
-            .join(",");
-          console.log(this.form.pointIds, this.tableData, "pointIds");
+            .join(',')
+          console.log(this.form.pointIds, this.tableData, 'pointIds')
         }
       },
-      deep: true,
+      deep: true
     },
+
+
   },
   computed: {
-    ...mapGetters("sopSelectPoints", ["getPointTableData"]),
+    ...mapGetters('sopSelectPoints', ['getPointTableData','getSelectSopPoints','getSopEdit']),
+    // 排序 ticketUserDTOList,将 userRole 为 0 的选项放在前面
+    sortedTicketUserDTOList() {
+      return this.form.ticketUserDTOList.sort((a, b) => Number(a.userRole) - Number(b.userRole))
+    }
   },
   mounted() {
-    this.getSopList();
-    this.getUser();
 
-    console.log(this.getPointTableData, "this.getPointTableData");
+    this.getSopList()
+    this.getUser()
+    if (this.$route.query.ticketId !== "null") {
+      this.getTicket();
+      this.form.ticketId=this.$route.query.ticketId
+    }
+    // console.log(this.getPointTableData, 'this.getPointTableData')
     if (this.getPointTableData) {
       this.tableData = this.getPointTableData.pointDetailVOList.map((item) => {
         return {
           pointId: item.pointId,
           pointName: item.pointName,
           pointType: item.pointType,
-          powerType: item.powerType,
-        };
-      });
+          powerType: item.powerType
+        }
+      })
     }
   },
   methods: {
+    // 编辑的时候给隔离点重新存储值
+    ...mapActions('sopSelectPoints',['setSelectSopPoints','setPointTableData','setSopEdit']),
     formatDateTime(date) {
-      const year = date.getFullYear().toString().padStart(2, "0");
-      const month = (date.getMonth() + 1).toString().padStart(2, "0");
-      const day = date.getDate().toString().padStart(2, "0");
-      const hours = date.getHours().toString().padStart(2, "0");
-      const minutes = date.getMinutes().toString().padStart(2, "0");
-      const seconds = date.getSeconds().toString().padStart(2, "0");
-
-      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+      const year = date.getFullYear().toString().padStart(2, '0')
+      const month = (date.getMonth() + 1).toString().padStart(2, '0')
+      const day = date.getDate().toString().padStart(2, '0')
+      const hours = date.getHours().toString().padStart(2, '0')
+      const minutes = date.getMinutes().toString().padStart(2, '0')
+      const seconds = date.getSeconds().toString().padStart(2, '0')
+
+      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
+    },
+    getTicket(){
+      const ticketId=this.$route.query.ticketId;
+      getJobTicketInfo(ticketId).then((response) => {
+        console.log(response,'编辑拿到路由参数')
+        this.form={
+          ...this.form,
+          workshopId:response.data.workshopId,
+          workareaId:response.data.workareaId,
+          sopId:response.data.sopId,
+          ticketCode:response.data.ticketCode,
+          ticketContent:response.data.ticketContent,
+          spoint:response.data.pointDetailVOList,
+          ticketUserDTOList:response.data.jobTicketUserList.map((item)=>{
+            return {
+              userName: item.userName,
+              userType: item.userType,
+              userRole: item.userRole,
+              userId:item.userId,
+            }
+          }),
+          locker: response.data.jobTicketUserList
+            .filter(item => item.userType == '0')
+            .map(item => item.userName),
+          coLocker: response.data.jobTicketUserList.map((item)=>{
+            return item.userType!=='0'?item.userName:null
+          }),
+          ticketStartTime:response.data.ticketStartTime,
+          ticketEndTime:response.data.ticketEndTime,
+          ticketId:response.data.ticketId,
+          ticketName:response.data.ticketName,
+          ticketStatus:response.data.ticketStatus,
+          ticketType:response.data.ticketType,
+          EditBool:true
+        }
+        this.jobProps=[this.form]
+        this.listUserOption=response.data.jobTicketUserList
+        console.log(this.form,'form')
+      });
     },
+
     getSopList() {
       const query = {
         current: 1,
-        size: 100000,
-      };
+        size: 100000
+      }
       getIsSopPage(query).then((res) => {
-        console.log(res, "sop列表接口");
-        this.sopOptions = res.data.records;
-      });
+        console.log(res, 'sop列表接口')
+        this.sopOptions = res.data.records
+      })
+
     },
     getUser() {
       const query = {
         pageNum: 1,
-        pageSize: 100000,
-      };
+        pageSize: 100000
+      }
       listUser(query).then((res) => {
-        console.log(res, "用户列表");
+        // console.log(res, '用户列表')
         this.listUserOption = res.rows.map((item) => {
           return {
             label: item.nickName,
-            value: item.userId,
-          };
-        });
+            value: item.userId
+          }
+        })
       }),
         listDept(query).then((res) => {
-          console.log(res, "部门列表");
+          // console.log(res, '部门列表')
           this.listDeptOption = res.data.map((item) => {
             return {
               label: item.deptName,
-              value: item.deptId,
-            };
-          });
-        });
+              value: item.deptId
+            }
+          })
+        })
+
     },
     // 添加内部人员 部门下拉的chage事件
     DeptChage(val) {
-      console.log(val, " 部门下拉");
+      console.log(val, ' 部门下拉')
       // 每次选中先清空用户下拉
-      this.listUserOption = [];
-      this.dialogForm.nickName = null;
+      this.listUserOption = []
+      this.dialogForm.nickName = null
       const query = {
         pageNum: 1,
         pageSize: 100000,
-        deptId: this.dialogForm.deptId,
-      };
+        deptId: this.dialogForm.deptId
+      }
       listUser(query).then((res) => {
-        console.log(res, "用户列表");
+        console.log(res, '用户列表')
         this.listUserOption = res.rows.map((item) => {
           return {
             label: item.nickName,
-            value: item.userId,
-          };
-        });
-      });
+            value: item.userId
+          }
+        })
+      })
+
     },
     // sop下拉change事件
     handleSelectSOP(value) {
-      this.jobProps = this.sopOptions.filter((item) => item.sopId == value);
-      console.log(this.jobProps, "父组件jobProps");
+      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.find((item) => item.value === val);
+      console.log(val, '上锁人chage')
+      const user = this.listUserOption.find((item) => item.value === val)
 
-      if (user && this.form.locker !== "") {
+      if (user && this.form.locker !== '') {
         const existingUser = this.form.ticketUserDTOList.find(
           (u) => u.userName === user.label
-        );
+        )
         if (!existingUser) {
-          this.form.ticketUserDTOList.push({
-            userName: user.label,
-            userId: user.value,
-            userType: 0,
-          });
-          console.log(this.form.ticketUserDTOList, "用户");
+          this.newticketUserDTOList.push({
+              userName: user.label,
+              userId: user.value,
+              userType: 0,
+              userRole: '0',
+          })
+          // this.form.ticketUserDTOList.push({
+          //   userName: user.label,
+          //   userId: user.value,
+          //   userType: 0,
+          //   userRole: '0',
+          // })
+          console.log(this.newticketUserDTOList, '用户')
         } else {
-          console.log("用户已存在", user.label);
+          // console.log('用户已存在', user.label)
         }
       }
+
+
     },
+
     // 添加内部人员的用户新增到ticketUserDTOList这个数据里
     changeInsideUser(values) {
-      this.form.coLocker = this.form.ticketUserDTOList;
       const usersinside = values
         .map((value) =>
           this.listUserOption.find((item) => item.value === value)
         )
-        .filter(Boolean);
+        .filter(Boolean)
       usersinside.forEach((user) => {
         const existingUser = this.form.ticketUserDTOList.find(
           (u) => u.userName === user.label
-        );
+        )
+        // console.log(usersinside, 'usersinside----67')
         if (!existingUser) {
           this.form.ticketUserDTOList.push({
             userName: user.label,
             userId: user.value,
             userType: 1,
-          });
+            userRole: 0,
+            bgColor: 'green'
+          })
+          console.log(this.form.ticketUserDTOList, '用户')
         } else {
-          console.log("用户已存在", user.label);
+          // console.log('用户已存在', user.label)
         }
-      });
-      this.updateCoLocker();
-      console.log(this.form.ticketUserDTOList, "用户");
+      })
+      this.updateCoLocker()
+
+      // console.log(this.form.ticketUserDTOList, '用户')
     },
-    // 添加外部人员 输入名称 userType==q userId==0
+    // 添加外部人员 输入名称 userType==1是共锁人 0是上锁人 userId==0
     outSideUserInput(value) {
-      console.log(value, "外部人员名称");
-      this.form.coLocker = [...this.dialogForm.username];
+      // console.log(value, '外部人员名称')
+
       const existingUser = this.form.ticketUserDTOList.find(
         (u) => u.userName === value
-      );
+      )
+
       if (!existingUser) {
         this.form.ticketUserDTOList.push({
           userName: value,
           userId: 0,
           userType: 1,
-        });
-        console.log(this.form.ticketUserDTOList, "用户");
+          userRole: 1,
+          bgColor: 'red'
+        })
+        console.log(this.form.ticketUserDTOList, '用户')
       } else {
-        console.log("用户已存在", value);
+        // console.log('用户已存在', value)
       }
-      this.updateCoLocker();
+      this.updateCoLocker()
+
     },
     // 更新界面中共锁人下拉框显示的内容
+    // 更新 coLocker 数据
     updateCoLocker() {
-      this.form.coLocker = this.form.ticketUserDTOList.map(
-        (user) => user.userName
-      );
+      // 获取现有的 coLocker 数据
+      const existingCoLocker = new Set(this.form.coLocker)
+      // console.log(existingCoLocker, 'existingCoLocker----1');
+
+      // 将 ticketUserDTOList 中的新用户名字添加到 existingCoLocker 中
+
+      this.form.ticketUserDTOList.forEach((user) => {
+          existingCoLocker.add(user.userName)
+      })
+      // console.log(this.form.ticketUserDTOList, 'this.form.ticketUserDTOList----2');
+
+      // 将 Set 转换回数组
+      this.form.coLocker = Array.from(existingCoLocker)
+      // console.log(this.form.coLocker, 'this.form.coLocker----3');
+
+      // 检查并补充 ticketUserDTOList 中缺少的用户
+      this.form.coLocker.forEach((name) => {
+        const existingUser = this.form.ticketUserDTOList.find(
+          (u) => u.userName === name
+        )
+
+        if (!existingUser) {
+          this.form.ticketUserDTOList.push({
+            userName: name,
+            userId: 0,
+            userType: 1,
+            userRole: 1,
+            bgColor: 'red'
+          })
+        }
+      })
+
+      console.log(this.form.ticketUserDTOList, '最终的 ticketUserDTOList')
     },
-    // 共锁人下拉框删除事件                                  
+    // 设置多选下拉框样式
+    // updateTagBackgrounds() {
+    //   this.$nextTick(() => {
+    //     const elTags = this.$refs.coLockerSelect.$el.querySelectorAll('.el-tag')
+    //
+    //     elTags.forEach(tag => {
+    //       const tagText = tag.textContent.trim()
+    //       const option = this.form.ticketUserDTOList.find(dict => dict.userName === tagText)
+    //
+    //       if (option) {
+    //         tag.style.backgroundColor = option.bgColor
+    //
+    //       }
+    //     })
+    //   })
+    // },
+    // 共锁人下拉框删除事件
     handleCoLockerChange(newValues) {
-      console.log(newValues, "ticketUserDTOList-newsValue");
+      console.log(newValues, 'ticketUserDTOList-newsValue')
 
       // 根据新值更新 this.form.ticketUserDTOList
       this.form.ticketUserDTOList = this.form.ticketUserDTOList.filter((user) =>
         newValues.includes(user.userName)
-      );
+      )
 
       // 更新 coLocker 显示的内容
-      this.updateCoLocker();
+      this.updateCoLocker()
+
     },
     handleClick(tab, event) {
       // console.log(tab, event);
+
     },
     previousStep(val) {
-      this.activeName = val;
+      this.activeName = val
+
     },
     nextStep(val) {
-      console.log(val, "nextStep");
-      this.activeName = val;
-      console.log("我点击了下一步");
+      console.log(val, 'nextStep')
+      this.activeName = val
+      console.log('我点击了下一步')
+
     },
     async getWorkareaId(query) {
       try {
-        const res = await listWorkarea(query);
-        console.log(res, "工作区域page");
-        return res.data.records[0].workareaId;
+        const res = await listWorkarea(query)
+        console.log(res, '工作区域page')
+        return res.data.records[0].workareaId
       } catch (error) {
-        console.error("获取工作区域ID失败", error);
-        throw error;
+        console.error('获取工作区域ID失败', error)
+        throw error
       }
+
     },
 
     async getWorkshopId(query) {
       try {
-        const res = await listWorkshop(query);
-        console.log(res, "车间id");
-        return res.rows[0].workshopId;
+        const res = await listWorkshop(query)
+        console.log(res, '车间id')
+        return res.rows[0].workshopId
       } catch (error) {
-        console.error("获取车间ID失败", error);
-        throw error;
+        console.error('获取车间ID失败', error)
+        throw error
       }
+
     },
 
     async confirm() {
       try {
         // 格式化时间
-        this.form.ticketStartTime = this.formatDateTime(
-          new Date(this.form.ticketStartTime)
-        );
-        this.form.ticketEndTime = this.formatDateTime(
-          new Date(this.form.ticketEndTime)
-        );
-        console.log(this.form, "拿到的所有参数确认");
+        this.form.ticketStartTime = this.formatDateTime(new Date(this.form.ticketStartTime));
+        this.form.ticketEndTime = this.formatDateTime(new Date(this.form.ticketEndTime));
+        console.log(this.form, '拿到的所有参数确认');
 
         const query = {
           current: 1,
           size: 100000,
-          workareaName: this.form.workline,
+          workareaName: this.form.workline
         };
 
         const query1 = {
           current: 1,
           size: 100000,
-          workshopName: this.form.workshopName,
+          workshopName: this.form.workshopName
         };
 
         const workareaId = await this.getWorkareaId(query);
         const workshopId = await this.getWorkshopId(query1);
 
+        // 合并 newticketUserDTOList 到 this.form.ticketUserDTOList
+        this.form.ticketUserDTOList.push(...this.newticketUserDTOList);
+
         const data = {
           pointIds: this.form.pointIds,
           sopId: this.form.sopId,
@@ -696,37 +833,66 @@ export default {
           ticketUserDTOList: this.form.ticketUserDTOList,
           workareaId: workareaId,
           workshopId: workshopId,
+
         };
+        const editdata={
+          pointIds: this.form.spoint.join(','),
+          sopId: this.form.sopId,
+          ticketCode: this.form.ticketCode,
+          ticketContent: this.form.ticketContent,
+          ticketId: this.form.ticketId,
+          ticketEndTime: this.form.ticketEndTime,
+          ticketName: this.form.ticketName,
+          ticketStartTime: this.form.ticketStartTime,
+          ticketType: this.form.ticketType,
+          ticketUserDTOList: this.form.ticketUserDTOList,
+          workareaId: workareaId,
+          workshopId: workshopId,
+        }
 
-        const res = await addJobTicket(data);
-        if (res.code === 200) {
-          this.$router.go(-1);
+        // 检查 route.query.ticketId 是否为 null
+        console.log(this.$route.query.ticketId,'this.$route.query.ticketId')
+        if (this.$route.query.ticketId!=='null') {
+          // 调用编辑接口
+          const res = await updateJobTicket(editdata);
+          if (res.code === 200) {
+            this.$router.go(-1);
+          } else {
+            console.error('编辑工单失败', res);
+          }
         } else {
-          console.error("提交工单失败", res);
+          // 调用新增接口
+          const res = await addJobTicket(data);
+          if (res.code === 200) {
+            this.$router.go(-1);
+          } else {
+            console.error('提交工单失败', res);
+          }
         }
       } catch (error) {
-        console.error("确认过程中发生错误", error);
+        console.error('确认过程中发生错误', error);
       }
 
-      console.log("确认");
+
+      console.log('确认');
     },
     // 子组件逆向传递选中的隔离点
 
     handleSelectPoint(points) {
-      console.log(points, "父组件接收逆向传递选中的隔离点");
+      console.log(points, '父组件接收逆向传递选中的隔离点')
 
       // 使用 Set 来存储传递过来的点值
-      const newValues = new Set(points.map((point) => point.pointId));
+      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) => {
         // 如果当前传递的点不在已有的点集中,则添加
@@ -735,56 +901,73 @@ export default {
             pointName: point.pointName, // 显示的名称
             pointId: point.pointId, // 对应的值
             pointType: point.pointType,
-            powerType: point.powerType,
-          });
+            powerType: point.powerType
+          })
           // 将新点值添加到 Set 中
-          existingValues.add(point.value);
+          existingValues.add(point.value)
         }
-      });
+      })
 
       // 更新 form.spoint 为最新选中的隔离点数组
-      this.form.spoint = points.map((point) => point.pointId);
+      this.form.spoint = points.map((point) => point.pointId)
+
     },
     // 车间你逆向传递拿到的隔离点数据产线
     handleProductLineSelected(selectedOption) {
       // console.log(selectedOption, '父组件接收到的 selectedOption');
-      this.points = selectedOption;
-      this.form.workline = selectedOption.label;
+      this.points = selectedOption
+      this.form.workline = selectedOption.label
+
     },
     // 车间子组件逆传递车间相关数据车间
     handleWorkshopSelected(selectedOption) {
-      console.log(selectedOption, "handleWorkshopSelected");
-      this.emitWorkShop = selectedOption;
-      this.form.workshopName = selectedOption.label;
+      console.log(selectedOption, 'handleWorkshopSelected')
+      this.emitWorkShop = selectedOption
+      this.form.workshopName = selectedOption.label
+
     },
     // 添加内部人员
     addInside() {
-      this.open = true;
-      this.title = "添加内部人员";
-      this.insideMumber = true;
-      this.outsideMumber = false;
-      this.form.ticketUserDTOList = [];
-      this.dialogForm.deptId = "";
-      this.dialogForm.nickname = "";
+      this.open = true
+      this.title = '添加内部人员'
+      this.insideMumber = true
+      this.outsideMumber = false
+      this.form.ticketUserDTOList = []
+      this.dialogForm.deptId = ''
+      this.dialogForm.nickName = ''
+
     },
     addOutside() {
-      this.open = true;
-      this.title = "添加外部人员";
-      this.insideMumber = false;
-      this.outsideMumber = true;
-      this.dialogForm.username = null;
+      this.open = true
+      this.title = '添加外部人员'
+      this.insideMumber = false
+      this.outsideMumber = true
+      this.dialogForm.username = null
+
     },
     // 取消按钮
     cancel() {
-      this.open = false;
-      this.reset();
+      this.open = false
+
     },
-  },
-};
+  //   时间选项
+    ticketStartTimeChange(){
+
+    },
+    ticketEndTimeChange(){
+
+    }
+  }
+}
 </script>
 
 
 <style scoped lang="scss">
+//::v-deep .el-tag.el-tag--info{
+//  background: green;
+//  color:white;
+//}
+
 .newOperations {
   width: 99%;
   height: 100%;

+ 7 - 4
src/views/mes/job/jobm/index.vue

@@ -173,6 +173,7 @@
       @selection-change="handleSelectionChange"
     >
       <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="作业票Id" prop="ticketId" width="75"></el-table-column>
       <el-table-column label="作业票编号" align="center" prop="ticketCode">
         <!-- <template slot-scope="scope">
           <el-button
@@ -253,7 +254,7 @@
 </template>
 
 <script>
-import { listJobTicket } from "@/api/mes/job/job";
+import { getJobTicketInfo, listJobTicket } from '@/api/mes/job/job'
 import {
   workshoplistAll,
   getIsWorkareaList,
@@ -366,6 +367,7 @@ export default {
         this.queryParams.endTime = this.formatDate(this.createTime[1]);
       }
       listJobTicket(this.queryParams).then((response) => {
+        console.log(response,'response--作业票列表')
         this.jobList = response.data.records;
         this.total = response.data.total;
         this.loading = false;
@@ -456,7 +458,7 @@ export default {
     handleAdd() {
       this.reset();
       this.open = true;
-      this.$router.push("/mes/job/jobm/NewOperations");
+      this.$router.push(`/mes/job/jobm/NewOperations?ticketId=null`);
       this.title = "添加隔离点";
       this.optType = "add";
     },
@@ -478,8 +480,9 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
-      const teamId = row.teamId || this.ids;
-      getTeam(teamId).then((response) => {
+      const teamId = row.ticketId || this.ids;
+      this.$router.push(`/mes/job/jobm/NewOperations?ticketId=${row.ticketId}`);
+      getJobTicketInfo(teamId).then((response) => {
         this.form = response.data;
         this.open = true;
         this.title = "修改隔离点信息";

+ 6 - 1
src/views/mes/sop/sopm/NewSop.vue

@@ -240,17 +240,22 @@ export default {
 
   methods: {
     ...mapActions('sopSelectPoints', [
-      'setSelectSopPoints','setPointTableData','setSopEdit'
+      'setSelectSopPoints','setPointTableData','setSopEdit','setWorkShop','setProductLine'
     ]),
     handleClick(tab, event) {
       // console.log(tab, event);
     },
     preStep() {
       this.activeName = "first";
+      this.tableData=[]
+      console.log(this.form,'sopform')
+
     },
+
     nextStep() {
       this.activeName = "second";
       // console.log("我点击了下一步");
+      console.log(this.form.workshopName,this.form.workline,'点击下一步拿到下拉框的数据');
     },
 
     // 详情数据

+ 2 - 1
src/views/mes/wa/workarea/MapData.vue

@@ -131,6 +131,7 @@ export default {
       //   { row: 12, col: 11 }, // E-17
       //   { row: 12, col: 13 }, // E-18
       // ];
+      console.log(this.parsedPoints,'this.parsedPoints')
       this.parsedPoints.forEach((pos, index) => {
         const x = pos.col * 50; // 每个单元格宽度为50
         const y = pos.row * 50; // 每个单元格高度为50
@@ -259,4 +260,4 @@ export default {
   height: 100%;
   // background: #000;
 }
-</style>
+</style>