Explorar el Código

1.出库修改。

jiaxiaoqiang hace 1 año
padre
commit
7c6ff10d92

+ 9 - 0
src/api/storage/out.ts

@@ -18,6 +18,15 @@ export function toOutBox(data: object) {
   });
 }
 
+// 捡料位 获取出入库料单信息
+export function getStorageOrderInfo(data: object) {
+  return request({
+    url: "/api/v1/wms/order/get",
+    method: "post",
+    data,
+  });
+}
+
 // 返库
 export function backToStorageAPI(data: object) {
   return request({

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

@@ -8,6 +8,7 @@ export const useCommonStore = defineStore("commonStore", {
     tableType: 1,
     tableTitle: "",
     loadingMap: new Map(),
+    orderId: 68, // 出库后在检料位使用,派发后重置。
   }),
   actions: {
     // 获取当前时间格式的函数

+ 0 - 1
src/views/pro-steps/components/duomeiticaiji.vue

@@ -153,4 +153,3 @@ const clickDeleteAll = () => {
   }
 }
 </style>
-@/api/prosteps/medias

+ 81 - 25
src/views/storage-out/index.vue

@@ -36,6 +36,7 @@
       <el-col :span="6">
         <div class="type-title">捡料位</div>
         <el-scrollbar class="outing-container">
+          <div class="boxHeader">载具:{{ outingBox?.vehicleCode }}</div>
           <div
             v-for="(material, index) in outingMaterials"
             :key="index"
@@ -44,16 +45,16 @@
             <div class="material-title">
               {{ material.materialName }} | {{ material.materialNo }}
             </div>
-            <div class="material-info">
-              <div>批次号</div>
-              <el-tooltip :content="material.batchCode" placement="top">
-                <div class="batchCode">{{ material.batchCode }}</div>
-              </el-tooltip>
-            </div>
-            <div class="material-info">
-              <div>位置</div>
-              <div>{{ material.locationNo }}</div>
-            </div>
+            <!--            <div class="material-info">-->
+            <!--              <div>批次号</div>-->
+            <!--              <el-tooltip :content="material.batchCode" placement="top">-->
+            <!--                <div class="batchCode">{{ material.batchCode }}</div>-->
+            <!--              </el-tooltip>-->
+            <!--            </div>-->
+            <!--            <div class="material-info">-->
+            <!--              <div>位置</div>-->
+            <!--              <div>{{ material.locationNo }}</div>-->
+            <!--            </div>-->
             <div class="material-info">
               <div>数量</div>
               <div>{{ material.num }}</div>
@@ -86,6 +87,12 @@
                 <NumberInput v-model="item.num" />
                 <span class="unit">{{ item.unitDictLabel }}</span>
               </div>
+              <i-ep-delete
+                class="delete-btn"
+                color="#ff4d4f"
+                size="20px"
+                @click="deleteMaterial(index)"
+              />
             </div>
           </div>
         </el-scrollbar>
@@ -126,8 +133,12 @@ import {
 import {
   backToStorageAPI,
   getStorageBoxesList,
+  getStorageOrderInfo,
   toOutBox,
 } from "@/api/storage/out";
+import { useCommonStoreHook } from "@/store";
+
+const commonS = useCommonStoreHook();
 
 const boxSearch = ref("");
 const boxesList = ref<any[]>([]);
@@ -135,7 +146,7 @@ const currentBox = ref<any>({});
 const currentBoxIndex = ref(-1);
 const enterBox = () => {
   boxSearch.value = boxSearch.value.trim();
-  getStorageBoxesList({}).then((res) => {
+  getStorageBoxesList({}).then((res: any) => {
     boxesList.value = res.data;
   });
 };
@@ -145,25 +156,49 @@ const clickBox = (box: any, index: number) => {
   currentBoxIndex.value = index;
 };
 const sureToOut = async () => {
-  await toOutBox({
+  let res: any = await toOutBox({
     vehicleNo: currentBox.value.vehicleNo,
     houseNo: currentBox.value.houseNo,
   });
-  ElMessage.success("出库成功");
-  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 = [];
-  }
+  commonS.orderId = res.data.orderId;
+  ElMessage.success("出库成功,等待料箱到达捡料位置");
+  checkHasOuting();
 };
 
 //捡料位
 let outingRawBoxList: any[] = []; //确认添加的时候会对比捡料位和扫描的数量,多次点击会导致捡料位的数字一直改变,所以用一个变量来保存原始的捡料位数据
 const outingBox = ref<any>({});
 const outingMaterials = ref<any[]>([]);
+let outInterval: number = -1;
+const checkHasOuting = () => {
+  //   点击出库之后,需要在其他地方(机器)确实已经到达检料位置,才能进行捡料
+  //   接口需要传入出库outBox接口返回的orderId转为id传上去, 如果有这个orderId就开始轮询
+  // 如果没有数据则停止轮询。数据返回的state是1处理中2启用3处理异常4已完成, 当为3或者4的时候停止轮询,并且在派发后清空oderid。
+  if (commonS.orderId != -1) {
+    outInterval = setInterval(() => {
+      getStorageOrderInfo({ id: commonS.orderId }).then((res: any) => {
+        if (res.data) {
+          if (res.data.state === 3 || res.data.state === 4) {
+            clearInterval(outInterval);
+            outingBox.value = { ...res.data };
+            console.log(outingBox.value);
+            if (res.data.detailsList.length > 0) {
+              outingMaterials.value = outingBox.value.detailsList;
+              outingRawBoxList = JSON.parse(
+                JSON.stringify(outingBox.value.detailsList)
+              );
+            } else {
+              outingRawBoxList = [];
+              outingMaterials.value = [];
+            }
+          }
+        } else {
+          clearInterval(outInterval);
+        }
+      });
+    }, 1000);
+  }
+};
 const backToStorage = async () => {
   console.log("back to storage");
   await backToStorageAPI({
@@ -177,7 +212,7 @@ const backToStorage = async () => {
   currentBox.value = {};
   currentBoxIndex.value = -1;
   boxSearch.value = "";
-  getStorageBoxesList({}).then((res) => {
+  getStorageBoxesList({}).then((res: any) => {
     boxesList.value = res.data;
   });
 };
@@ -187,7 +222,7 @@ const scanCodeInput = ref("");
 const materialList = ref<any[]>([]);
 
 const handleScanCodeInput = () => {
-  getMaterialInfoByLabel(scanCodeInput.value).then((res) => {
+  getMaterialInfoByLabel(scanCodeInput.value).then((res: any) => {
     // 扫描之后要先查看数组中是否有这个物料,有的话就数量相加,没有的话就添加到数组中
     let hasMaterial = false;
     for (let i = 0; i < materialList.value.length; i++) {
@@ -223,6 +258,11 @@ const sureToAdd = () => {
     }
   }
 };
+
+const deleteMaterial = (index: number) => {
+  materialList.value.splice(index, 1);
+};
+
 // 出库终点
 const destinationList = ref<any>();
 const currentDestination = ref<any>({});
@@ -235,12 +275,13 @@ const onEndBoxClick = (index: number, item: any) => {
 
 onMounted(() => {
   let wm = new WeakMap();
-  getDestinationList(0).then((res) => {
+  getDestinationList(0).then((res: any) => {
     destinationList.value = res.data;
   });
   getStorageBoxesList({}).then((res) => {
     boxesList.value = res.data;
   });
+  checkHasOuting();
 });
 
 const createTask = () => {
@@ -251,7 +292,7 @@ const createTask = () => {
     // locationNo: "",
     stationId: currentDestination.value.id,
     targetType: currentDestination.value.targetType,
-    vehicleCode: outingBox.value.vehicleNo,
+    vehicleCode: outingBox.value.vehicleCode,
     vehicleId: outingBox.value.vehicleId,
     vehicleName: outingBox.value.vehicleName,
   };
@@ -266,6 +307,7 @@ const createTask = () => {
     materialList.value = [];
     currentDestination.value = {};
     currentDestinationIndex.value = -1;
+    commonS.orderId = -1;
   });
 };
 </script>
@@ -314,11 +356,18 @@ const createTask = () => {
 .outing-container {
   height: calc(100vh - 354px);
 
+  .boxHeader {
+    font-weight: bolder;
+    font-size: 24px;
+    text-align: left;
+  }
+
   .outing-box {
     background: #fff;
     border-radius: 16px;
     margin-bottom: 15px;
     padding: 10px 8px;
+    position: relative;
   }
 
   .material-title {
@@ -361,6 +410,13 @@ const createTask = () => {
     justify-content: space-between;
     align-items: start;
     padding: 30px 30px;
+    position: relative;
+
+    .delete-btn {
+      position: absolute;
+      top: 15px;
+      right: 15px;
+    }
 
     .name {
       font-weight: 500;