Browse Source

打印历史修复

Hello小健 2 weeks ago
parent
commit
e1eb4c3abb
4 changed files with 121 additions and 25 deletions
  1. 21 1
      src/pages.json
  2. 76 0
      src/pages/printer/logList.vue
  3. 23 23
      src/pages/printer/printer.vue
  4. 1 1
      src/pages/warehouseScan/logList.vue

+ 21 - 1
src/pages.json

@@ -120,7 +120,27 @@
     {
       "path": "pages/printer/printer",
       "style": {
-        "navigationBarTitleText": "打印"
+        "navigationBarTitleText": "打印",
+        "app-plus": {
+          "bounce": "none",
+          "titleNView": {
+            "buttons": [
+              {
+                "fontSize": "16px",
+                "text": "历史"
+              }
+            ],
+            "backButton": {
+              "background": "#00FF00"
+            }
+          }
+        }
+      }
+    },
+    {
+      "path": "pages/printer/logList",
+      "style": {
+        "navigationBarTitleText": "录入历史"
       }
     },
     {

+ 76 - 0
src/pages/printer/logList.vue

@@ -0,0 +1,76 @@
+<template>
+  <view class="history">
+    <view class="item" v-for="(item, i) in printLogHistory" :key="i">
+      <text class="code" :style="{ color: item.status ? 'green' : '#666' }"
+        >{{ item.type }} {{ item.order_code }}</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="printLogHistory.length === 0" class="is-empty">暂无历史</view>
+  </view>
+</template>
+
+<script setup lang="ts">
+import { reactive, ref } from 'vue'
+import { onLoad } from '@dcloudio/uni-app'
+const printLogHistory = ref([] as any)
+const getHistory = () => {
+  printLogHistory.value = uni.getStorageSync('printLogHistory')
+}
+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>

+ 23 - 23
src/pages/printer/printer.vue

@@ -264,30 +264,30 @@ const printConfirm = async () => {
     messageText.value = res.msg
     messageRef.value.open()
 
-    // const historyItem = {
-    //   order_code: valiFormData.value.order_code,
-    //   createTime: new Date(),
-    //   type: type,
-    //   status: res.data.code,
-    // }
-    // printLogHistory.value.unshift(historyItem)
-    // uni.setStorageSync('printLogHistory', printLogHistory.value)
-    // getHistory()
+    const historyItem = {
+      order_code: valiFormData.value.order_code,
+      createTime: new Date(),
+      type: type,
+      status: res.code,
+    }
+    printLogHistory.value.unshift(historyItem)
+    uni.setStorageSync('printLogHistory', printLogHistory.value)
+    getHistory()
     close()
   } else {
     subLoading.value = false
     messageType.value = 'error'
     messageText.value = '打印失败'
     messageRef.value.open()
-    // const historyItem = {
-    //   order_code: valiFormData.value.order_code,
-    //   createTime: new Date(),
-    //   type: type,
-    //   status: false,
-    // }
-    // printLogHistory.value.unshift(historyItem)
-    // uni.setStorageSync('printLogHistory', printLogHistory.value)
-    // getHistory()
+    const historyItem = {
+      order_code: valiFormData.value.order_code,
+      createTime: new Date(),
+      type: type,
+      status: false,
+    }
+    printLogHistory.value.unshift(historyItem)
+    uni.setStorageSync('printLogHistory', printLogHistory.value)
+    getHistory()
     close()
   }
 }
@@ -317,9 +317,9 @@ const onsubmit = async () => {
   loading.value = false
 }
 
-// const getHistory = () => {
-//   printLogHistory.value = uni.getStorageSync('printLogHistory') || []
-// }
+const getHistory = () => {
+  printLogHistory.value = uni.getStorageSync('printLogHistory') || []
+}
 const keypress = (e: any) => {
   // 102  左侧    103  右侧   104  中间按键
   if (e.keyCode === 102 || e.keyCode === 103 || e.keyCode === 104) {
@@ -372,14 +372,14 @@ onBackPress(() => {
 
 onShow(() => {
   hidePage.value = false
-  // getHistory()
+  getHistory()
   _getPrinterList()
 })
 
 onNavigationBarButtonTap((event) => {
   if (event.index === 0) {
     uni.navigateTo({
-      url: '/pages/warehouseScan/warehouseLog',
+      url: '/pages/printer/logList',
     })
   }
 })

+ 1 - 1
src/pages/warehouseScan/logList.vue

@@ -24,7 +24,7 @@
 <script setup lang="ts">
 import { reactive, ref } from 'vue'
 import { onLoad } from '@dcloudio/uni-app'
-const warehouseLogHistory = ref([])
+const warehouseLogHistory = ref([] as any)
 const getHistory = () => {
   warehouseLogHistory.value = uni.getStorageSync('warehouseLogHistory')
 }