Jelajahi Sumber

Merge branch 'master' of http://192.168.101.4:3000/jiaxiaoqiang/JG-CLIENT-TEMP

jiaxiaoqiang 11 bulan lalu
induk
melakukan
ef784fed08

+ 2 - 0
src/api/auth/types.ts

@@ -28,6 +28,8 @@ export interface LoginData {
   proCode?: string; //产线
 
   stationId?: string; //工位
+
+  stationType?: string; //工位类型
 }
 
 /**

+ 4 - 0
src/api/user/types.ts

@@ -11,6 +11,7 @@ export interface UserInfo {
   roles: string[];
   perms: string[];
   deptId?: string;
+  stationType?: string;
 }
 
 /**
@@ -22,6 +23,7 @@ export interface UserQuery extends PageQuery {
   deptId?: number;
   startTime?: string;
   endTime?: string;
+  stationType?: string;
 }
 
 /**
@@ -72,6 +74,7 @@ export interface UserPageVO {
    * 用户名
    */
   username?: string;
+  stationType?: string;
 }
 
 /**
@@ -115,4 +118,5 @@ export interface UserForm {
    * 用户名
    */
   username?: string;
+  stationType?: string;
 }

File diff ditekan karena terlalu besar
+ 1 - 0
src/assets/icons/MachineryLoading.svg


+ 79 - 0
src/components/MachineryLoading/index.vue

@@ -0,0 +1,79 @@
+<template>
+  <div class="body">
+    <div class="canvasBox">
+      <div class="spinnerSexBox p1"></div>
+      <div class="spinnerSexBox p2"></div>
+      <div class="spinnerSexBox p3"></div>
+      <div class="spinnerSexBox p4"></div>
+      <div class="p5 iconBox">
+        <img class="icon" src="@/assets/icons/MachineryLoading.svg" />
+      </div>
+    </div>
+    <div class="textInfo">正在操作载具请稍后...</div>
+  </div>
+</template>
+
+<script lang="ts" setup></script>
+
+<style lang="scss" scoped>
+.body {
+  display: flex;
+  flex-direction: column;
+  width: 100%;
+  min-height: 400px;
+}
+.icon {
+  height: 140px !important;
+  width: 140px !important;
+}
+.iconBox {
+  padding: 0px;
+}
+.textInfo {
+  text-align: center;
+  font-size: $f24;
+}
+.canvasBox {
+  @include flex;
+  width: 100%;
+  height: 100%;
+
+  .spinnerSexBox {
+    background: #1296db;
+    border-radius: 50%;
+    height: 10px;
+    margin: 10px;
+    width: 10px;
+  }
+
+  .p1 {
+    animation: fall 1.5s linear 0.375s infinite;
+  }
+
+  .p2 {
+    animation: fall 1.5s linear 0.25s infinite;
+  }
+
+  .p3 {
+    animation: fall 1.5s linear 0.125s infinite;
+  }
+
+  .p4 {
+    animation: fall 1.5s linear infinite;
+  }
+  @keyframes fall {
+    0% {
+      transform: translateY(0px);
+    }
+    25% {
+      transform: translateY(25px);
+    }
+    75% {
+      transform: translateY(25px);
+    }
+    100% {
+      transform: translateY(0px);
+    }
+  }
+}
+</style>

+ 10 - 0
src/router/modules/prepare.ts

@@ -1,3 +1,4 @@
+import { useUserStore } from "@/store/modules/user";
 const Layout = () => import("@/layout/index.vue");
 export default {
   path: "/prepare",
@@ -15,4 +16,13 @@ export default {
       },
     },
   ],
+  beforeEnter: (to, from, next) => {
+    const store = useUserStore();
+    console.log(store.user.stationType);
+    if (store.user.stationType == "5") {
+      next();
+    } else {
+      next({ path: "/" });
+    }
+  },
 };

+ 11 - 1
src/router/modules/process.ts

@@ -1,5 +1,6 @@
-const Layout = () => import("@/layout/index.vue");
+import { useUserStore } from "@/store/modules/user";
 
+const Layout = () => import("@/layout/index.vue");
 export default {
   path: "/",
   name: "/",
@@ -161,4 +162,13 @@ export default {
       },
     },
   ],
+  beforeEnter: (to, from, next) => {
+    const store = useUserStore();
+    console.log(store.user.stationType, "222");
+    if (store.user.stationType == "5") {
+      next({ path: "/prepare" });
+    } else {
+      next();
+    }
+  },
 };

+ 2 - 0
src/store/modules/common.ts

@@ -11,6 +11,8 @@ export const useCommonStore = defineStore("commonStore", {
     storageInOrderId: -1, // 入库界面的出库使用
     orderId: -1, // 出库后在检料位使用,派发后重置。
     changeBoxType: 1, // 1: 入库,2:出库
+    orderInId: -1, //入库时使用
+    changeBoxInType: 1, // 1: 入库,2:出库
   }),
   actions: {
     // 获取当前时间格式的函数

+ 4 - 3
src/store/modules/user.ts

@@ -25,8 +25,8 @@ export const useUserStore = defineStore(
     function login(loginData: LoginData) {
       return new Promise<void>((resolve, reject) => {
         loginApi(loginData)
-          .then((response) => {
-            getUserInfo();
+          .then(async (response) => {
+            await getUserInfo();
             // const { tokenType, accessToken } = response.data;
             // localStorage.setItem("token", tokenType + " " + accessToken); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx
             localStorage.setItem("token", response.data + "");
@@ -53,7 +53,7 @@ export const useUserStore = defineStore(
             user.value.username = data.userName;
             user.value.roles = data.roles;
             user.value.deptId = data.deptId;
-
+            user.value.stationType = data.stationType;
             isGetAuth.value = true;
 
             user.value.perms = data.permissions ?? [];
@@ -73,6 +73,7 @@ export const useUserStore = defineStore(
           .then(() => {
             localStorage.setItem("token", "");
             location.reload(); // 清空路由
+            user.value = { roles: [], perms: [] };
             resolve();
           })
           .catch((error) => {

+ 4 - 0
src/views/login/index.vue

@@ -245,6 +245,7 @@ const onStationChange = (val: any) => {
   });
   stationType = stationArray[0].stationDictValue;
   stationName = stationArray[0].name;
+  loginData.value.stationType = stationArray[0].stationDictValue;
 };
 
 /**
@@ -281,6 +282,7 @@ function handleLogin() {
         orgId: loginData.value.orgId,
         jobNumber: loginData.value.jobNumber,
         stationId: loginData.value.stationId,
+        stationType: loginData.value.stationType,
       };
 
       let acountP = {
@@ -289,6 +291,7 @@ function handleLogin() {
         proCode: loginData.value.proCode,
         orgId: loginData.value.orgId,
         stationId: loginData.value.stationId,
+        stationType: loginData.value.stationType,
       };
 
       userStore
@@ -346,6 +349,7 @@ watch(
           loginData.value.stationId = stationList.value[0].id;
           stationType = stationList.value[0].stationDictValue;
           stationName = stationList.value[0].name;
+          loginData.value.stationType = stationList.value[0].stationDictValue;
         }
       });
     }

+ 1 - 1
src/views/pro-operation/drawing/index.vue

@@ -5,7 +5,7 @@
         <div class="pdf-box">
           <PDFView
             :need-to-show-pdf="true"
-            :pdf-source="baseUrl + box.drawingPath"
+            :pdf-source="baseUrl + box.pdfPath"
           />
         </div>
         <div class="suit-title">{{ box?.drawingTitle }}</div>

+ 3 - 2
src/views/pro-steps/components/wuliaocaiji.vue

@@ -71,17 +71,18 @@ const showInfo = ref({});
 const scanData = ref([]);
 provide("scanData", scanData);
 const enterfnc = async () => {
+  let str = scanCode.value;
+  scanCode.value = "";
   const { code, data } = await searchMaterial({
     operationId: store.odersData.operationId,
     processId: store.scanInfo.id,
     seqNo: store.scanInfo.seqNo,
-    scanCode: scanCode.value,
+    scanCode: str,
     workOrderCode: store.odersData.workOrderCode,
   });
   if (code == "200") {
     scanData.value = data;
     showCJ.value = true;
-    // scanCode.value = "";
   }
 };
 const opCompentDataList = ref([]);

+ 122 - 27
src/views/storage-in/index.vue

@@ -39,7 +39,7 @@
         <el-button
           class="sureBtn"
           type="primary"
-          :disabled="outStatus || addStatus"
+          :disabled="outStatus || addStatus || Machinery"
           @click="sureToOut"
           >出库
         </el-button>
@@ -47,10 +47,14 @@
       <el-col :span="8">
         <div class="type-title">盒内原有物料</div>
         <el-scrollbar class="outing-container">
+          <div style="height: 300px" v-if="Machinery">
+            <MachineryLoading />
+          </div>
           <div v-if="!outStatus">
             <div class="addbox" v-if="addSuccessStatus">
               扫码的盒子编码:{{ addBoxInfo.code }}
             </div>
+
             <ScanCodeInput
               v-if="addStatus && addSuccessStatus == false"
               v-model="addBoxSearch"
@@ -63,6 +67,8 @@
               class="sureBtn"
               :type="addStatus ? 'info' : 'primary'"
               @click="changeAddStatus"
+              :disabled="Machinery"
+              style="margin-bottom: 20px"
               >{{ addStatus ? "取消" : "入库新载具" }}
             </el-button>
           </div>
@@ -75,12 +81,18 @@
               <div class="material-title">
                 {{ material.materialName }} | {{ material.materialNo }}
               </div>
-              <div
-                @click="deleteIndexOld(index)"
+              <!-- <div
+                @click=""
                 class="material-title deleteSty"
               >
                 删除
-              </div>
+              </div> -->
+              <i-ep-delete
+                class="delete-btn"
+                color="#ff4d4f"
+                size="20px"
+                @click="deleteIndexOld(index)"
+              />
             </div>
             <div class="material-info">
               <div>批次号/序列号</div>
@@ -98,7 +110,11 @@
             </div>
           </div>
         </el-scrollbar>
-        <el-button class="sureBtn" type="info" @click="backToStorage"
+        <el-button
+          class="sureBtn"
+          type="info"
+          @click="backToStorage"
+          :disabled="Machinery || !boxStatus"
           >入库
         </el-button>
       </el-col>
@@ -127,17 +143,27 @@
                     <span class="unit">{{ item.unitDictLabel }}</span>
                   </div>
                 </div>
-                <div
+                <!-- <div
                   @click="deleteIndexScanAdd(index)"
                   class="list-box-delete deleteSty"
                 >
                   删除
-                </div>
+                </div> -->
+                <i-ep-delete
+                  class="delete-btn"
+                  color="#ff4d4f"
+                  size="20px"
+                  @click="deleteIndexScanAdd(index)"
+                />
               </div>
             </div>
           </div>
         </el-scrollbar>
-        <el-button class="sureBtn" type="primary" @click="sureToAdd"
+        <el-button
+          class="sureBtn"
+          type="primary"
+          @click="sureToAdd"
+          :disabled="Machinery || materialList.length < 1 || !boxStatus"
           >确认添加
         </el-button>
       </el-col>
@@ -158,6 +184,10 @@ import {
   toOutBox,
   inBoxAPI,
 } from "@/api/storage/in";
+import { getStorageOrderInfo } from "@/api/storage/out";
+import { useCommonStoreHook } from "@/store";
+
+const commonS = useCommonStoreHook();
 
 const boxSearch = ref("");
 const deleteIndexOld = (index: any) => {
@@ -169,16 +199,25 @@ const deleteIndexScanAdd = (index: any) => {
   materialList.value.splice(index, 1);
   ElMessage.success("操作成功!");
 };
-
+//硬件操作期间的状态:false 表示未有操作 true表示硬件在操作中
+const Machinery = ref(false);
 //盒内原有物料data
 const boxesList = ref<any[]>([]);
+//新加载具的开起状态
 const addStatus = ref(false);
+//新加载具的成功状态
 const addSuccessStatus = ref(false);
+//新加载具的内容
 const addBoxInfo = ref();
-//选中的item
+//库中选中的item
 const currentBox = ref<any>({});
+//绑定当前盒子的状态
+const boxStatus = ref(false);
 const currentBoxIndex = ref(-1);
+//库中选中的状态
 const outStatus = ref(false);
+//新扫时候的input值
+const addBoxSearch = ref("");
 const resetData = () => {
   addSuccessStatus.value = false;
   addBoxInfo.value = null;
@@ -192,6 +231,7 @@ const resetData = () => {
   boxSearch.value = "";
   addStatus.value = false;
   outStatus.value = false;
+  boxStatus.value = false;
 };
 const changeAddStatus = () => {
   if (addStatus.value == true) {
@@ -200,7 +240,7 @@ const changeAddStatus = () => {
     addStatus.value = !addStatus.value;
   }
 };
-const addBoxSearch = ref("");
+
 //扫盒子
 const addenterBox = () => {
   addBoxSearch.value = addBoxSearch.value.trim();
@@ -211,6 +251,7 @@ const addenterBox = () => {
     outingBox.value.vehicleId = addBoxInfo.value.id;
     outingBox.value.houseNo = "1";
     ElMessage.success("扫码成功!");
+    boxStatus.value = true;
   });
 };
 //出库
@@ -220,6 +261,7 @@ const enterBox = () => {
     boxSearch.value ? { vehicleCode: boxSearch.value } : {}
   ).then((res) => {
     boxesList.value = res.data;
+    commonS.orderInId = res.data.orderId;
   });
 };
 const clickBox = (box: any, index: number) => {
@@ -228,38 +270,90 @@ const clickBox = (box: any, index: number) => {
 };
 //出库操作
 const sureToOut = async () => {
-  await toOutBox({
+  let res = await toOutBox({
     vehicleNo: currentBox.value.vehicleNo,
     houseNo: currentBox.value.houseNo,
   });
-  ElMessage.success("出库成功");
+  ElMessage.success("出库成功,等待料箱到达捡料位置");
+
+  commonS.orderInId = res.data.orderId;
+  commonS.changeBoxType = 1;
+  Machinery.value = true;
+  checkHasOuting();
   outStatus.value = true;
-  outingBox.value = currentBox.value;
-  if (outingBox.value.list.length > 0) {
-    outingMaterials.value = outingBox.value.list;
-    outingRawBoxList = JSON.parse(JSON.stringify(outingBox.value.list));
-  } else {
-    outingRawBoxList = [];
-    outingMaterials.value = [];
+};
+//定时器任务
+let outInterval: number = -1;
+const checkHasOuting = () => {
+  //   点击出库之后,需要在其他地方(机器)确实已经到达检料位置,才能进行捡料
+  //   接口需要传入出库outBox接口返回的orderId转为id传上去, 如果有这个orderId就开始轮询
+  // 如果没有数据则停止轮询。数据返回的state是1处理中2启用3处理异常4已完成, 当为3或者4的时候停止轮询,并且在派发后清空oderid。
+  if (commonS.orderInId != -1) {
+    outInterval = setInterval(() => {
+      getStorageOrderInfo({ id: commonS.orderInId })
+        .then((res: any) => {
+          if (res.data) {
+            if (res.data.state === 3 || res.data.state === 4) {
+              clearInterval(outInterval);
+              commonS.orderInId = -1;
+              if (commonS.changeBoxType === 1) {
+                outingBox.value = currentBox.value;
+                if (outingBox.value.list.length > 0) {
+                  outingMaterials.value = outingBox.value.list;
+                  outingRawBoxList = JSON.parse(
+                    JSON.stringify(outingBox.value.list)
+                  );
+                } else {
+                  outingRawBoxList = [];
+                  outingMaterials.value = [];
+                }
+                getStorageBoxesList({}).then((res: any) => {
+                  boxesList.value = res.data;
+                });
+                currentBoxIndex.value = -1;
+                ElMessage.success("料箱已到达");
+                Machinery.value = false;
+                boxStatus.value = true;
+              } else {
+                resetData();
+                getStorageBoxesList({}).then((res) => {
+                  boxesList.value = res.data;
+                });
+                ElMessage.success("料箱入库成功");
+                Machinery.value = false;
+              }
+            } else {
+              outStatus.value = false;
+              ElMessage.error(res.msg);
+            }
+          } else {
+            clearInterval(outInterval);
+          }
+        })
+        .catch(() => {
+          clearInterval(outInterval);
+          commonS.orderInId = -1;
+          Machinery.value = false;
+        });
+    }, 5000);
   }
 };
-
 let outingRawBoxList: any[] = []; //确认添加的时候会对比捡料位和扫描的数量,多次点击会导致捡料位的数字一直改变,所以用一个变量来保存原始的捡料位数据
 const outingBox = ref<any>({});
 const outingMaterials = ref<any[]>([]);
 const backToStorage = async () => {
-  await backToStorageAPI({
+  const { data } = await backToStorageAPI({
     vehicleCode: outingBox.value.vehicleNo,
     houseNo: outingBox.value.houseNo,
     detailsList: outingMaterials.value,
   });
   outingBox.value = {};
   outingMaterials.value = [];
-  ElMessage.success("返库成功");
-  resetData();
-  getStorageBoxesList({}).then((res) => {
-    boxesList.value = res.data;
-  });
+  ElMessage.success("返库操作成功,等待料箱到达");
+  commonS.changeBoxType = 2;
+  commonS.orderInId = data.orderId;
+  Machinery.value = true;
+  checkHasOuting();
 };
 
 // 物料
@@ -326,6 +420,7 @@ onMounted(() => {
   getStorageBoxesList({}).then((res) => {
     boxesList.value = res.data;
   });
+  checkHasOuting();
 });
 </script>