ソースを参照

1.修改token过期 2.物料流转增加功能。

jiaxiaoqiang 1 年間 前
コミット
e843907e5b
2 ファイル変更47 行追加18 行削除
  1. 14 12
      src/utils/request.ts
  2. 33 6
      src/views/material-flow/creatTask.vue

+ 14 - 12
src/utils/request.ts

@@ -1,4 +1,5 @@
 import axios, { AxiosResponse, InternalAxiosRequestConfig } from "axios";
+import { useUserStoreHook } from "@/store/modules/user";
 
 // 创建 axios 实例
 const service = axios.create({
@@ -34,18 +35,19 @@ service.interceptors.response.use(
     }
 
     // token 过期,重新登录
-    // if (code === "4106") {
-    //   ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
-    //     confirmButtonText: "确定",
-    //     cancelButtonText: "取消",
-    //     type: "warning",
-    //   }).then(() => {
-    //     const userStore = useUserStoreHook();
-    //     userStore.resetToken().then(() => {
-    //       location.reload();
-    //     });
-    //   });
-    // }
+    if (code === "4106") {
+      ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        const userStore = useUserStoreHook();
+        userStore.resetToken().then(() => {
+          location.reload();
+        });
+      });
+      return Promise.reject(new Error(msg || "Error"));
+    }
 
     ElMessage.error(msg || "系统出错");
 

+ 33 - 6
src/views/material-flow/creatTask.vue

@@ -37,9 +37,19 @@
                   <div class="spec">{{ item.spec }}</div>
                 </div>
                 <div class="bottom">
-                  <NumberInput v-model="item.num" />
+                  <NumberInput
+                    v-if="item.codeType === 'BATCH'"
+                    v-model="item.num"
+                  />
+                  <div v-else class="number" v-text="item.num"></div>
                   <span class="unit">{{ item.unitDictLabel }}</span>
                 </div>
+                <i-ep-delete
+                  class="delete"
+                  color="#ff4d4f"
+                  size="20px"
+                  @click="deleteMaterial(index)"
+                />
               </div>
             </div>
           </el-scrollbar>
@@ -110,7 +120,7 @@ const enterBox = () => {
 
 // 物料
 const scanCodeInput = ref("");
-const materialList = ref<any>([]);
+const materialList = ref<any[]>([]);
 
 const handleScanCodeInput = () => {
   getMaterialInfoByLabel(scanCodeInput.value).then((res) => {
@@ -122,15 +132,21 @@ const handleScanCodeInput = () => {
         currentMaterial.batchCode === res.data.batchCode &&
         currentMaterial.materialCode === res.data.materialCode
       ) {
-        materialList.value[i].num += res.data.num;
         hasMaterial = true;
-        break;
+        // SEQ/BATCH 如果是流转卡号数量只能唯1,序列号相加
+        if (currentMaterial.codeType === "BATCH") {
+          materialList.value[i].num += res.data.num;
+          break;
+        }
       }
     }
     !hasMaterial && materialList.value.push(res.data);
     scanCodeInput.value = "";
   });
 };
+const deleteMaterial = (index: number) => {
+  materialList.value.splice(index, 1);
+};
 // 流转终点
 const destinationList = ref<any>();
 const currentDestination = ref<any>({});
@@ -140,7 +156,7 @@ const selectStore = ref<any>({});
 const onEndBoxClick = (index: number, item: any) => {
   currentDestination.value = item;
   currentDestinationIndex.value = index;
-  // 如果是仓库,会根据仓库的no获取仓储的列表,存入map, 如果已经有数据了则不需要再次请求接口
+  // 如果是仓库,会根据仓库的no获取仓储的列表,存入map, 如果已经有数据了则不需要再次请求接口 =》 后来不需要展示了 就注释了
   // if (item.targetType === "stock") {
   //   if (!storeMap.has(item.houseNo)) {
   //     getStoreListByNo(item.houseNo).then((res) => {
@@ -153,7 +169,6 @@ const onEndBoxClick = (index: number, item: any) => {
 onMounted(() => {
   let wm = new WeakMap();
   getDestinationList(1).then((res) => {
-    console.log("destinationList", res);
     destinationList.value = res.data;
   });
 });
@@ -247,6 +262,7 @@ const createTask = () => {
     justify-content: space-between;
     align-items: start;
     padding: 30px 30px;
+    position: relative;
 
     .name {
       font-weight: 500;
@@ -274,6 +290,12 @@ const createTask = () => {
       text-align: left;
       margin-left: 5px;
     }
+
+    .delete {
+      position: absolute;
+      top: 20px;
+      right: 20px;
+    }
   }
 }
 
@@ -319,4 +341,9 @@ const createTask = () => {
   width: 100%;
   margin-top: 10px;
 }
+
+.number {
+  font-size: $f38;
+  font-weight: bolder;
+}
 </style>