Browse Source

feature/入库页面&&预期套bug修复

dy 1 year ago
parent
commit
d12c39f803

+ 1 - 1
.env.development

@@ -13,7 +13,7 @@ VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 # 线上接口地址
 # VITE_APP_API_URL = http://vapi.youlai.tech
 # 开发接口地址
-VITE_APP_API_URL = 'http://192.168.101.188:8079'
+VITE_APP_API_URL = 'http://192.168.101.4:8079'
 # Websocket地址
 VITE_WEBSOCKET_URL = 'ws://192.168.101.4:8079'
 ``

+ 1 - 1
.gitignore

@@ -1,6 +1,6 @@
 node_modules
 .DS_Store
-dist
+docker/dist
 dist-ssr
 *.local
 .history

+ 36 - 0
src/api/storage/in.ts

@@ -0,0 +1,36 @@
+import request from "@/utils/request";
+
+// 获取料箱列表
+export function getStorageBoxesList(data: any) {
+  return request({
+    url: "/api/v1/stock/queryVehicleList",
+    method: "post",
+    data,
+  });
+}
+
+// 出库
+export function toOutBox(data: object) {
+  return request({
+    url: "/api/v1/wmsOrder/outBox",
+    method: "post",
+    data,
+  });
+}
+
+// 返库
+export function backToStorageAPI(data: object) {
+  return request({
+    url: "/api/v1/wmsOrder/inBox",
+    method: "post",
+    data,
+  });
+}
+//
+export function inBoxAPI(data: object) {
+  return request({
+    url: "/api/v1/wmsOrder/inBox",
+    method: "post",
+    data,
+  });
+}

+ 1 - 1
src/views/prepare-complete-suit/components/second.vue

@@ -1,5 +1,5 @@
 <template>
-  <div><input /></div>
+  <div></div>
 </template>
 
 <script lang="ts" setup></script>

+ 58 - 24
src/views/prepare-complete-suit/firstPopUpView/bindingScan.vue

@@ -70,7 +70,8 @@
 
       <div class="bottomBtn">
         <el-button class="leftBtn" @click="handleClose">取消</el-button>
-        <el-button class="rightBtn" :disabled="scanItemArray.length<1" @click="handleSubmit" type="primary">绑定</el-button>
+        <el-button class="rightBtn" :disabled="scanItemArray.length < 1" @click="handleSubmit"
+          type="primary">绑定</el-button>
       </div>
     </div>
   </div>
@@ -113,35 +114,68 @@ const showRecordArray = computed(() => {
 const scanItemArray = computed(() => {
   let materialCodeArray = [];
   let resArray = [];
-  recordArray.value.forEach((item) => {
-    if (!materialCodeArray.includes(item.materialCode)) {
-      materialCodeArray.push(item.materialCode);
+  // recordArray.value.forEach((item) => {
+  //   if (!materialCodeArray.includes(item.materialCode)) {
+  //     materialCodeArray.push(item.materialCode);
+  //     resArray.push({
+  //       materialCode: item.materialCode,
+  //       materialName: item.materialName,
+  //       num: item.num,
+  //       spec: item.spec,
+  //       batchCode: item.batchCode,
+  //     });
+  //   } else {
+  //     resArray.forEach((res) => {
+  //       if (
+  //         res.materialCode == item.materialCode &&
+  //         res.batchCode == item.batchCode
+  //       ) {
+  //         res.num = Number(res.num) + Number(item.num);
+  //       } else {
+  //         resArray.push({
+  //           materialCode: item.materialCode,
+  //           materialName: item.materialName,
+  //           num: item.num,
+  //           spec: item.spec,
+  //           batchCode: item.batchCode,
+  //         });
+  //       }
+  //     });
+  //   }
+  // });
+  for (let i = 0; i < recordArray.value.length; i++) {
+    if (!materialCodeArray.includes(recordArray.value[i].materialCode)) {
+      materialCodeArray.push(recordArray.value[i].materialCode);
       resArray.push({
-        materialCode: item.materialCode,
-        materialName: item.materialName,
-        num: item.num,
-        spec: item.spec,
-        batchCode: item.batchCode,
+        materialCode: recordArray.value[i].materialCode,
+        materialName: recordArray.value[i].materialName,
+        num: recordArray.value[i].num,
+        spec: recordArray.value[i].spec,
+        batchCode: recordArray.value[i].batchCode,
       });
     } else {
-      resArray.forEach((res) => {
+      let status = false;
+      for (let b = 0; b < resArray.length; b++) {
         if (
-          res.materialCode == item.materialCode &&
-          res.batchCode == item.batchCode
+          resArray[b].materialCode == recordArray.value[i].materialCode &&
+          resArray[b].batchCode == recordArray.value[i].batchCode
         ) {
-          res.num = Number(res.num) + Number(item.num);
-        } else {
-          resArray.push({
-            materialCode: item.materialCode,
-            materialName: item.materialName,
-            num: item.num,
-            spec: item.spec,
-            batchCode: item.batchCode,
-          });
+          resArray[b].num =
+            Number(resArray[b].num) + Number(recordArray.value[i].num);
+          status = true;
         }
-      });
+      }
+      if (status == false) {
+        resArray.push({
+          materialCode: recordArray.value[i].materialCode,
+          materialName: recordArray.value[i].materialName,
+          num: recordArray.value[i].num,
+          spec: recordArray.value[i].spec,
+          batchCode: recordArray.value[i].batchCode,
+        });
+      }
     }
-  });
+  }
   return resArray;
 });
 //清空操作
@@ -168,7 +202,7 @@ const enterfnc = async () => {
     recordArray.value.unshift(obj);
     scanCode.value = "";
     scanAllNum.value = scanAllNum.value + 1;
-    ElMessage.success('扫描成功!')
+    ElMessage.success("扫描成功!");
   }
 };
 const addTableSum = computed((code) => {

+ 3 - 2
src/views/prepare-complete-suit/index.vue

@@ -16,9 +16,9 @@
           <StorageOut />
         </div>
       </el-tab-pane>
-      <el-tab-pane label="Third" name="third">
+      <el-tab-pane label="入库" name="third">
         <div class="contentBox">
-          <Third />
+          <StorageIn />
         </div>
       </el-tab-pane>
     </el-tabs>
@@ -28,6 +28,7 @@
 <script lang="ts" setup>
 import First from "./components/first.vue";
 import StorageOut from "@/views/storage-out/index.vue";
+import StorageIn from "@/views/storage-in/index.vue";
 import Third from "./components/third.vue";
 import { TabsPaneContext } from "element-plus";
 

+ 365 - 0
src/views/storage-in/index.vue

@@ -0,0 +1,365 @@
+<template>
+  <div>
+    <el-row :gutter="20">
+      <el-col :span="8">
+        <div class="type-title">载具入库</div>
+        <ScanCodeInput v-model="boxSearch" :clearable="true" :showSuffix="true" placeholder="请扫描或输入料箱编号"
+          @keyup.enter="enterBox" />
+        <el-scrollbar class="boxes-container base-container">
+          <div v-for="(item, index) in boxesList" :key="index" :class="{ 'box-selected': index === currentBoxIndex }"
+            class="box-item" @click="clickBox(item, index)">
+            <div class="box-name">{{ item.vehicleNo }}</div>
+            <div v-for="(material, index) in item.list" :key="index" class="box-info">
+              <div>{{ material.materialName }}</div>
+              <div>{{ material.num }}</div>
+            </div>
+          </div>
+        </el-scrollbar>
+        <el-button class="sureBtn" type="primary" @click="sureToOut">出库
+        </el-button>
+      </el-col>
+      <el-col :span="8">
+        <div class="type-title">盒内原有物料</div>
+        <el-scrollbar class="outing-container">
+          <div v-for="(material, index) in outingMaterials" :key="index" class="outing-box">
+            <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>
+              <div>{{ material.num }}</div>
+            </div>
+          </div>
+        </el-scrollbar>
+        <el-button class="sureBtn" type="info" @click="backToStorage">返库
+        </el-button>
+      </el-col>
+      <el-col :span="8">
+        <div class="type-title">请扫码物料</div>
+        <ScanCodeInput v-model="scanCodeInput" placeholder="请扫描或输入物料编码" @keyup.enter="handleScanCodeInput" />
+        <el-scrollbar class="base-container">
+          <div class="list-container">
+            <div v-for="(item, index) in materialList" :key="index" class="list-box">
+              <div>
+                <div class="name">{{ item.materialName }}</div>
+                <div class="spec">{{ item.spec }}</div>
+              </div>
+              <div class="bottom">
+                <NumberInput v-model="item.num" />
+                <span class="unit">{{ item.unitDictLabel }}</span>
+              </div>
+            </div>
+          </div>
+        </el-scrollbar>
+        <el-button class="sureBtn" type="primary" @click="sureToAdd">确认添加
+        </el-button>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script lang="ts" setup>
+//料箱
+import {
+  getDestinationList,
+  getMaterialInfoByLabel,
+} from "@/api/process/materialFlow";
+import {
+  backToStorageAPI,
+  getStorageBoxesList,
+  toOutBox,
+  inBoxAPI,
+} from "@/api/storage/in";
+
+const boxSearch = ref("");
+//盒内原有物料data
+const boxesList = ref<any[]>([]);
+//选中的item
+const currentBox = ref<any>({});
+const currentBoxIndex = ref(-1);
+//出库
+const enterBox = () => {
+  boxSearch.value = boxSearch.value.trim();
+  getStorageBoxesList({}).then((res) => {
+    boxesList.value = res.data;
+  });
+};
+const clickBox = (box: any, index: number) => {
+  currentBox.value = box;
+  currentBoxIndex.value = index;
+};
+//出库操作
+const sureToOut = async () => {
+  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 = [];
+  }
+};
+
+let outingRawBoxList: any[] = []; //确认添加的时候会对比捡料位和扫描的数量,多次点击会导致捡料位的数字一直改变,所以用一个变量来保存原始的捡料位数据
+const outingBox = ref<any>({});
+const outingMaterials = ref<any[]>([]);
+const backToStorage = async () => {
+  console.log("back to storage");
+  await backToStorageAPI({
+    vehicleCode: outingBox.value.vehicleNo,
+    houseNo: outingBox.value.houseNo,
+    detailsList: outingMaterials.value,
+  });
+  outingBox.value = {};
+  outingMaterials.value = [];
+  ElMessage.success("返库成功");
+  currentBox.value = {};
+  currentBoxIndex.value = -1;
+  boxSearch.value = "";
+  getStorageBoxesList({}).then((res) => {
+    boxesList.value = res.data;
+  });
+};
+
+// 物料
+const scanCodeInput = ref("");
+//扫码后的array
+const materialList = ref<any>([]);
+// 扫码料码
+const handleScanCodeInput = () => {
+  getMaterialInfoByLabel(scanCodeInput.value).then((res) => {
+    if (res.data.codeType == "SEQ") {
+      res.data.seqNo = scanCodeInput.value;
+    } else {
+      res.data.seqNo = "";
+    }
+    materialList.value.push({ ...res.data });
+    scanCodeInput.value = "";
+  });
+};
+//确认添加:只是页面静态添加 不做接口发送
+const sureToAdd = () => {
+  outingMaterials.value = JSON.parse(JSON.stringify(outingRawBoxList));
+  for (let i = 0; i < materialList.value.length; i++) {
+    let status = false;
+    for (let b = 0; b < outingMaterials.value.length; b++) {
+      if (materialList.value[i].seqNo != "") {
+        outingMaterials.value.push({
+          ...materialList.value[i],
+          materialNo: materialList.value[i].materialCode,
+          unit: materialList.value[i].unitDictValue,
+        });
+      } else {
+        if (
+          materialList.value[i].materialCode ==
+          outingMaterials.value[b].materialNo &&
+          materialList.value[i].batchCode == outingMaterials.value[b].batchCode
+        ) {
+          outingMaterials.value[i].num =
+            outingMaterials.value[i].num + materialList.value[i].num;
+          status = true;
+        }
+      }
+    }
+    if (status == false) {
+      outingMaterials.value.push({
+        ...materialList.value[i],
+        materialNo: materialList.value[i].materialCode,
+        unit: materialList.value[i].unitDictValue,
+      });
+    }
+  }
+  ElMessage.success("添加成功!");
+};
+// 流转终点
+const destinationList = ref([]);
+onMounted(() => {
+  getDestinationList().then((res) => {
+    destinationList.value = res.data;
+  });
+  getStorageBoxesList({}).then((res) => {
+    boxesList.value = res.data;
+  });
+});
+</script>
+
+<style lang="scss" scoped>
+.type-title {
+  font-weight: 500;
+  font-size: 30px;
+  color: rgba(0, 0, 0, 0.9);
+  text-align: left;
+  margin-bottom: 15px;
+}
+
+.base-container {
+  width: 100%;
+  margin-top: 15px;
+  height: calc(100vh - 420px);
+}
+
+.boxes-container {
+  .box-item {
+    background: #fff;
+    border-radius: 16px;
+    margin-bottom: 15px;
+    padding: 10px 8px;
+  }
+
+  .box-selected {
+    border: 2px solid #0a59f7;
+  }
+
+  .box-name {
+    font-size: 20px;
+    line-height: 40px;
+  }
+
+  .box-info {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    font-weight: bolder;
+    font-size: 24px;
+  }
+}
+
+.outing-container {
+  height: calc(100vh - 354px);
+
+  .outing-box {
+    background: #fff;
+    border-radius: 16px;
+    margin-bottom: 15px;
+    padding: 10px 8px;
+  }
+
+  .material-title {
+    font-weight: bolder;
+    font-size: 24px;
+    text-align: left;
+  }
+
+  .material-info {
+    font-size: 20px;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+  }
+
+  .batchCode {
+    max-width: 60%;
+    flex-shrink: 0;
+    overflow: hidden;
+    text-overflow: ellipsis;
+  }
+}
+
+.list-container {
+  width: 100%;
+  display: grid;
+  /*行间距*/
+  grid-row-gap: 24px;
+  /*列间距*/
+  //grid-column-gap: 24px;
+
+  grid-template-columns: 1fr;
+
+  .list-box {
+    height: 210px;
+    background: #fff;
+    border-radius: 16px 16px 16px 16px;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    align-items: start;
+    padding: 30px 30px;
+
+    .name {
+      font-weight: 500;
+      font-size: 24px;
+      color: rgba(0, 0, 0, 0.9);
+      text-align: left;
+    }
+
+    .spec {
+      font-size: 20px;
+      color: rgba(0, 0, 0, 0.6);
+      text-align: left;
+    }
+
+    .bottom {
+      display: flex;
+      justify-content: start;
+      align-items: end;
+    }
+
+    .unit {
+      font-weight: 500;
+      font-size: 24px;
+      color: rgba(0, 0, 0, 0.6);
+      text-align: left;
+      margin-left: 5px;
+    }
+  }
+}
+
+.destination {
+  height: calc(100vh - 350px);
+  margin-top: 15px;
+
+  .end-box {
+    height: 80px;
+    background: #ffffff;
+    border-radius: 40px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    font-weight: 500;
+    font-size: 24px;
+    color: rgba(0, 0, 0, 0.9);
+    display: flex;
+    justify-content: space-evenly;
+    align-items: center;
+  }
+
+  .end-box:not(:last-child) {
+    margin-bottom: 15px;
+  }
+
+  .selected {
+    border-radius: 40px;
+    border: 2px solid rgba(10, 89, 247, 1);
+  }
+
+  .name {
+    font-weight: 500;
+    font-size: 24px;
+    color: rgba(0, 0, 0, 0.9);
+  }
+}
+
+.sureBtn {
+  height: 80px;
+  font-size: 24px;
+  //background: #0a59f7;
+  border-radius: 76px 76px 76px 76px;
+  width: 100%;
+  margin-top: 10px;
+}
+</style>