Browse Source

称重恢复历史数据

Hello小健 3 weeks ago
parent
commit
7e9b9bd734
4 changed files with 165 additions and 69 deletions
  1. 21 1
      src/pages.json
  2. 79 0
      src/pages/weigh/instockLog.vue
  3. 65 66
      src/pages/weigh/weigh.vue
  4. 0 2
      src/utils/http.ts

+ 21 - 1
src/pages.json

@@ -68,7 +68,27 @@
     {
       "path": "pages/weigh/weigh",
       "style": {
-        "navigationBarTitleText": "称重"
+        "navigationBarTitleText": "称重",
+        "app-plus": {
+          "bounce": "none",
+          "titleNView": {
+            "buttons": [
+              {
+                "fontSize": "16px",
+                "text": "历史"
+              }
+            ],
+            "backButton": {
+              "background": "#00FF00"
+            }
+          }
+        }
+      }
+    },
+    {
+      "path": "pages/weigh/instockLog",
+      "style": {
+        "navigationBarTitleText": "录入历史"
       }
     },
     {

+ 79 - 0
src/pages/weigh/instockLog.vue

@@ -0,0 +1,79 @@
+<template>
+  <view class="history">
+    <view class="item" v-for="(item, i) in instockHistory" :key="i">
+      <text class="code" :style="{ color: item.status ? 'green' : '#666' }">
+        {{ item.orderNum }}
+        <text v-if="item.batch_text">批次号: {{ item.batch_text }}</text>
+        <text v-if="item.space">仓位编码: {{ item.space }}</text>
+        {{ item.type }}
+      </text>
+      <uni-icons
+        v-if="item.status"
+        type="checkmarkempty"
+        class="status"
+        size="16"
+        color="green"
+      ></uni-icons>
+      <text class="status fail" v-else>F</text>
+      <text style="margin-left: 10rpx; font-weight: 300">
+        {{ '\r\n' + item.createTime }}
+      </text>
+    </view>
+    <view v-if="instockHistory.length === 0" class="is-empty">暂无历史</view>
+  </view>
+</template>
+
+<script setup lang="ts">
+import { reactive, ref } from 'vue'
+import { onLoad } from '@dcloudio/uni-app'
+const instockHistory = ref([] as any[])
+const getHistory = () => {
+  instockHistory.value = uni.getStorageSync('instockHistory')
+}
+onLoad(() => {
+  getHistory()
+})
+</script>
+
+<style lang="scss" scoped>
+.history {
+  display: flex;
+  width: 100%;
+  flex-direction: column;
+  justify-items: start;
+
+  .title {
+    padding: 20rpx;
+    font-size: 24rpx;
+    font-weight: 600;
+  }
+  .type {
+    padding-right: 20rpx;
+    font-size: 24rpx;
+  }
+  .code {
+    font-weight: 600;
+  }
+
+  .item {
+    padding: 20rpx;
+    font-size: 20rpx;
+    color: #666;
+
+    .status {
+      padding-left: 20rpx;
+    }
+
+    .fail {
+      font-weight: 600;
+      color: #f00;
+    }
+  }
+
+  .is-empty {
+    text-align: center;
+    margin: 40px 0;
+    color: #999;
+  }
+}
+</style>

+ 65 - 66
src/pages/weigh/weigh.vue

@@ -394,8 +394,7 @@ onShow(async () => {
   focusType.value = true
   loading.value = false
   await _getWarehouseSpace()
-  await _getBindParams()
-  await _getPrinterList()
+  await Promise.all([_getBindParams(), _getPrinterList()])
 })
 onHide(() => {
   focusType.value = false
@@ -404,7 +403,7 @@ onHide(() => {
 onNavigationBarButtonTap((event: any) => {
   if (event.index === 0) {
     uni.navigateTo({
-      url: '/pages/instock/instockLog',
+      url: '/pages/weigh/instockLog',
     })
   }
 })
@@ -538,16 +537,16 @@ const instockScan = async (is_save_goods: number) => {
     messageText.value = res.msg
     message.value.open()
     //   console.log('res.data.data---', res.data.data)
-    //   const historyItem = {
-    //     orderNum: valiFormData.orderNum,
-    //     createTime: new Date(),
-    //     space: spaceRes.value,
-    //     type: '入库',
-    //     status: true,
-    //   }
-    //   instockHistory.value.unshift(historyItem)
-    //   uni.setStorageSync('instockHistory', instockHistory.value)
-    //   getHistory()
+    const historyItem = {
+      orderNum: valiFormData.orderNum,
+      createTime: new Date(),
+      space: spaceRes.value,
+      type: '入库',
+      status: true,
+    }
+    instockHistory.value.unshift(historyItem)
+    uni.setStorageSync('instockHistory', instockHistory.value)
+    getHistory()
     if (res.data.express_label) {
       //     console.log('有打印面单')
       selectPrinter.value = sendToPeinter.value.length > 0 ? printers.value[0].value : 0
@@ -562,16 +561,16 @@ const instockScan = async (is_save_goods: number) => {
     messageType.value = 'error'
     messageText.value = res.msg
     message.value.open()
-    //   const historyItem = {
-    //     orderNum: valiFormData.orderNum,
-    //     createTime: new Date(),
-    //     space: spaceRes.value,
-    //     type: '入库',
-    //     status: false,
-    //   }
-    //   instockHistory.value.unshift(historyItem)
-    //   uni.setStorageSync('instockHistory', instockHistory.value)
-    //   getHistory()
+    const historyItem = {
+      orderNum: valiFormData.orderNum,
+      createTime: new Date(),
+      space: spaceRes.value,
+      type: '入库',
+      status: false,
+    }
+    instockHistory.value.unshift(historyItem)
+    uni.setStorageSync('instockHistory', instockHistory.value)
+    getHistory()
     st = setTimeout(() => {
       reset()
       st && clearTimeout(st)
@@ -600,17 +599,17 @@ const scanOutstock = async () => {
     messageText.value = res.msg
     message.value.open()
 
-    // const historyItem = {
-    //   orderNum: valiFormData.orderNum,
-    //   batch_text: batchText(valiFormData.batch_number),
-    //   createTime: new Date(),
-    //   type: '出库',
-    //   status: true,
-    // }
-    // instockHistory.value.unshift(historyItem)
-    // instockHistory.value.length > 10 && (instockHistory.value.length = 10)
-    // uni.setStorageSync('instockHistory', instockHistory.value)
-    // getHistory()
+    const historyItem = {
+      orderNum: valiFormData.orderNum,
+      batch_text: batchText(valiFormData.batch_number),
+      createTime: new Date(),
+      type: '出库',
+      status: true,
+    }
+    instockHistory.value.unshift(historyItem)
+    instockHistory.value.length > 10 && (instockHistory.value.length = 10)
+    uni.setStorageSync('instockHistory', instockHistory.value)
+    getHistory()
     if (res.data.labels && res.data.labels.length > 0) {
       // console.log('有打印面单')
       selectPrinter.value = sendToPeinter.value.length > 0 ? printers.value[0].value : 0
@@ -628,17 +627,17 @@ const scanOutstock = async () => {
     messageText.value = res.msg
     message.value.open()
 
-    // const historyItem = {
-    //   orderNum: valiFormData.orderNum,
-    //   batch_text: batchText(valiFormData.batch_number),
-    //   createTime: new Date(),
-    //   type: '出库',
-    //   status: false,
-    // }
-    // instockHistory.value.unshift(historyItem)
-    // instockHistory.value.length > 10 && (instockHistory.value.length = 10)
-    // uni.setStorageSync('instockHistory', instockHistory.value)
-    // getHistory()
+    const historyItem = {
+      orderNum: valiFormData.orderNum,
+      batch_text: batchText(valiFormData.batch_number),
+      createTime: new Date(),
+      type: '出库',
+      status: false,
+    }
+    instockHistory.value.unshift(historyItem)
+    instockHistory.value.length > 10 && (instockHistory.value.length = 10)
+    uni.setStorageSync('instockHistory', instockHistory.value)
+    getHistory()
     st = setTimeout(() => {
       reset()
       st && clearTimeout(st)
@@ -658,30 +657,30 @@ const weighScan = async () => {
     messageType.value = 'success'
     messageText.value = res.msg
     message.value.open()
-    // const historyItem = {
-    //   orderNum: valiFormData.orderNum,
-    //   createTime: new Date(),
-    //   type: '称重',
-    //   status: true,
-    // }
-    // instockHistory.value.unshift(historyItem)
-    // instockHistory.value.length > 10 && (instockHistory.value.length = 10)
-    // uni.setStorageSync('instockHistory', instockHistory.value)
-    // getHistory()
+    const historyItem = {
+      orderNum: valiFormData.orderNum,
+      createTime: new Date(),
+      type: '称重',
+      status: true,
+    }
+    instockHistory.value.unshift(historyItem)
+    instockHistory.value.length > 10 && (instockHistory.value.length = 10)
+    uni.setStorageSync('instockHistory', instockHistory.value)
+    getHistory()
   } else {
     messageType.value = 'error'
     messageText.value = res.msg
     message.value.open()
-    // const historyItem = {
-    //   orderNum: valiFormData.orderNum,
-    //   createTime: new Date(),
-    //   type: '称重',
-    //   status: false,
-    // }
-    // instockHistory.value.unshift(historyItem)
-    // instockHistory.value.length > 10 && (instockHistory.value.length = 10)
-    // uni.setStorageSync('instockHistory', instockHistory.value)
-    // getHistory()
+    const historyItem = {
+      orderNum: valiFormData.orderNum,
+      createTime: new Date(),
+      type: '称重',
+      status: false,
+    }
+    instockHistory.value.unshift(historyItem)
+    instockHistory.value.length > 10 && (instockHistory.value.length = 10)
+    uni.setStorageSync('instockHistory', instockHistory.value)
+    getHistory()
   }
   st = setTimeout(() => {
     reset()
@@ -734,7 +733,7 @@ const onsubmit = () => {
     })
 }
 const getHistory = () => {
-  // this.instockHistory = uni.getStorageSync('history')
+  instockHistory.value = uni.getStorageSync('instockHistory')
 }
 const getImages = () => {
   const res = images.value.map((item: any) => {

+ 0 - 2
src/utils/http.ts

@@ -66,8 +66,6 @@ export const http = <T>(options: UniApp.RequestOptions) => {
       ...options,
       // 响应成功
       success(res) {
-        console.log('响应成功', res)
-
         // 状态码 2xx, axios 就是这样设计的
         if (res.statusCode >= 200 && res.statusCode < 300) {
           // 2.1 提取核心数据 res.data