Kaynağa Gözat

Merge branch 'zc-fix-bug' into lzw

Lzw 2 hafta önce
ebeveyn
işleme
d18c3f98f7

+ 27 - 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": "录入历史"
       }
     },
     {
@@ -89,6 +109,12 @@
         "navigationBarTitleText": "托盘/批次"
       }
     },
+    {
+      "path": "pages/scanLotno/waybillsList",
+      "style": {
+        "navigationBarTitleText": "运单列表"
+      }
+    },
     {
       "path": "pages/waybillNo/waybillNo",
       "style": {

+ 2 - 0
src/pages/login/login.vue

@@ -27,6 +27,8 @@ const loginSuccess = (profile: LoginResult) => {
   memberStore.setProfile(profile)
   // 成功提示
   uni.showToast({ icon: 'success', title: '登录成功' })
+  console.log('登录成功', profile)
+
   setTimeout(() => {
     // 页面跳转
     // uni.switchTab({ url: '/pages/my/my' })

+ 0 - 2
src/pages/printer/printer.vue

@@ -147,7 +147,6 @@ import { getPrinterList, printWaybillLabel, printCustomerLabel } from '@/service
 import type { Printers } from '@/types/printer'
 
 const valiFormRef = ref()
-const token = ref()
 const loading = ref(false)
 const hidePage = ref(false)
 const focusType = ref(true)
@@ -311,7 +310,6 @@ const onsubmit = async () => {
   if (!valiRes) {
     return
   }
-
   loading.value = true
   st && clearTimeout(st)
   selectPrinter.value = sendToPeinter.value.length > 0 ? printers.value[0].value : 0

+ 29 - 37
src/pages/scanLotno/scanLotno.vue

@@ -1,7 +1,7 @@
 <template>
   <view class="container">
     <uni-forms
-      ref="valiForm"
+      ref="valiFormRef"
       label-align="right"
       :label-width="80"
       :rules="rules"
@@ -28,7 +28,6 @@
         </uni-easyinput>
       </uni-forms-item>
       <!-- <text class='weight-tip'>复称重量作用是确保句惠完整,防止工作人员计费称車后进行的其他操作引起的物品丢失问题</text> -->
-      <!-- <uni-section title="绑定批托盘号" type="line" padding style="height: calc(100vh - 100px)"> -->
       <uni-forms-item label="绑定批次号" name="batchNum" class="select-item">
         <uni-data-select
           v-if="!editBatchNum"
@@ -48,20 +47,16 @@
           popup-title="绑定托盘号"
           :localdata="options.pallet"
           v-model="valiFormData.palletNum"
-          @change="onchange"
-          @nodeclick="onnodeclick"
-          @popupopened="onpopupopened"
-          @popupclosed="onpopupclosed"
+          :clear-icon="false"
         ></uni-data-picker>
 
         <uni-easyinput v-if="editPalletNum" :value="palletNum" :disabled="editPalletNum" />
         <button v-if="!editPalletNum" type="primary" @click="submitPalletNum">确认</button>
         <button v-if="editPalletNum" type="primary" @click="editPalletNum = false">修改</button>
       </uni-forms-item>
-      <!-- </uni-section> -->
     </uni-forms>
     <view class="button-group">
-      <button type="info" @click="reset">重置</button>
+      <button type="default" @click="reset">重置</button>
       <button type="default" @click="checkOrder" :loading="loading">
         <uni-icons v-if="!loading" type="search" size="18"></uni-icons>
         查看运单
@@ -117,7 +112,7 @@ import {
 import { checkPermission } from '@/utils'
 import { bindShipping, getBindParams, getWaybills } from '@/services/scanLotno'
 
-const token = ref()
+const valiFormRef = ref()
 const loading = ref(false)
 const hidePage = ref(false)
 const focusType = ref(true)
@@ -133,7 +128,7 @@ const valiFormData = ref({
   orderNum: '',
   weight: '',
   batchNum: '',
-  palletNum: '',
+  palletNum: '0',
 })
 
 const rules = reactive({
@@ -152,11 +147,6 @@ const options = reactive({
   pallet: [] as any,
 })
 
-const onnodeclick = () => {}
-const onpopupopened = () => {}
-const onpopupclosed = () => {}
-const onchange = () => {}
-
 const scanInput = async () => {
   // #ifdef APP-PLUS
   let status = await checkPermission()
@@ -233,7 +223,7 @@ const palletNum = computed(() => {
 
 const checkOrder = async () => {
   loading.value = true
-  // uni.setStorageSync('waybills', [])
+  uni.setStorageSync('waybills', [])
 
   const res = await getWaybills({
     order_no: valiFormData.value.orderNum,
@@ -244,17 +234,17 @@ const checkOrder = async () => {
   })
 
   loading.value = false
-  if (res.data.code == 1) {
+  if (res.code == 1) {
     messageType.value = 'success'
-    messageText.value = res.data.msg
+    messageText.value = res.msg
     messageRef.value.open()
-    // uni.setStorageSync('waybills', res.data.data.waybills)
+    uni.setStorageSync('waybills', res.data.waybills)
     uni.navigateTo({
       url: '/pages/scanLotno/waybillsList',
     })
   } else {
     messageType.value = 'error'
-    messageText.value = res.data.msg
+    messageText.value = res.msg
     messageRef.value.open()
   }
 }
@@ -289,12 +279,12 @@ const onsubmit = async () => {
   })
 
   loading.value = false
-  if (res.data.code == 1) {
+  if (res.code == 1) {
     messageType.value = 'success'
-    messageText.value = res.data.msg
+    messageText.value = res.msg
     messageRef.value.open()
 
-    if (res.data.data.labels && res.data.data.labels.length > 0) {
+    if (res.data.labels && res.data.labels.length > 0) {
       console.log('有打印面单')
       // res.data.data.labels.map((url: string) => {
       // 	let path = fullUrl(url);
@@ -313,7 +303,7 @@ const onsubmit = async () => {
     // getHistory()
   } else {
     messageType.value = 'error'
-    messageText.value = res.data.msg
+    messageText.value = res.msg
     messageRef.value.open()
     // const historyItem = {
     //   orderNum: valiFormData.value.orderNum,
@@ -332,11 +322,10 @@ const onsubmit = async () => {
   }, 1000)
 }
 
-const getHistory = () => {
-  lotnoLogHistory.value = uni.getStorageSync('lotnoLogHistory') || []
-}
+// const getHistory = () => {
+//   lotnoLogHistory.value = uni.getStorageSync('lotnoLogHistory') || []
+// }
 const keypress = (e: any) => {
-  console.log(e, '按键码')
   // 102  左侧    103  右侧   104  中间按键
   if (e.keyCode === 102 || e.keyCode === 103 || e.keyCode === 104) {
     //这里按键成功
@@ -387,9 +376,8 @@ onBackPress(() => {
 })
 onShow(() => {
   hidePage.value = false
-  token.value = uni.getStorageSync('token')
   _getBindParams()
-  getHistory()
+  // getHistory()
 })
 const setFocus = () => {
   if (hidePage.value) {
@@ -403,8 +391,8 @@ const setFocus = () => {
 const _getBindParams = async () => {
   const res = await getBindParams()
 
-  if (res.data.code === 1) {
-    options.batch = res.data.data.batch_number.map((item: any) => {
+  if (res.code === 1) {
+    options.batch = res.data.batch_number.map((item: any) => {
       return { text: item.name, value: item.id }
     })
     // eslint-disable-next-line no-inner-declarations
@@ -420,7 +408,9 @@ const _getBindParams = async () => {
         }
       })
     }
-    const shipping = transformData(res.data.data.shipping)
+    const shipping = transformData(res.data.shipping)
+    console.log('shipping', shipping)
+
     options.pallet = shipping
   }
 }
@@ -442,14 +432,16 @@ onNavigationBarButtonTap((event) => {
 
 .weight-right {
   padding-right: 10rpx;
-  font-size: 14rpx;
 }
 
 .weight-tip {
   color: gray;
   font-size: 12rpx;
 }
-
+:deep(.selected-area) {
+  flex: 0 1 auto;
+  height: auto;
+}
 .select-item {
   :deep(.uni-forms-item__content) {
     display: flex !important;
@@ -461,7 +453,7 @@ onNavigationBarButtonTap((event) => {
 
   button {
     height: 35px;
-    font-size: 16rpx;
+    font-size: 24rpx;
     margin-left: 10rpx;
   }
 }
@@ -479,7 +471,7 @@ onNavigationBarButtonTap((event) => {
     height: 35px;
     width: 50%;
     margin-left: 10px;
-    font-size: 16rpx;
+    font-size: 24rpx;
   }
 
   .uni-icons {

+ 79 - 0
src/pages/scanLotno/waybillsList.vue

@@ -0,0 +1,79 @@
+<template>
+  <view class="history">
+    <uni-section :title="'数量: ' + waybills.length"></uni-section>
+    <view class="item" v-for="(item, i) in waybills" :key="i">
+      <text class="code" :style="{ color: '#666' }">{{ item.order_box_no }}</text>
+      <text class="type">重量: {{ item.weight }}KG</text>
+      <view class="sub-items">
+        <view class="sub-item">
+          <text class="type">批次/船航/托盘</text>
+          <text class="type">{{ item.batch_shipping_pallet }}</text>
+        </view>
+        <view class="sub-item">
+          <text class="type">末公里运单号</text>
+          <text class="type">{{ item.tracking_number || '无' }}</text>
+        </view>
+      </view>
+    </view>
+    <view v-if="waybills.length === 0" class="is-empty">暂无运单</view>
+  </view>
+</template>
+
+<script setup lang="ts">
+import { reactive, ref } from 'vue'
+import { onLoad } from '@dcloudio/uni-app'
+
+const waybills = ref([] as any)
+const getHistory = () => {
+  waybills.value = uni.getStorageSync('waybills')
+}
+onLoad(() => {
+  getHistory()
+})
+</script>
+
+<style lang="scss" scoped>
+.history {
+  display: flex;
+  width: 100%;
+  flex-direction: column;
+  justify-items: start;
+
+  .type {
+    padding-right: 20rpx;
+    font-size: 24rpx;
+    margin-top: 10rpx;
+  }
+  .code {
+    font-weight: 600;
+  }
+
+  .item {
+    padding: 20rpx;
+    font-size: 24rpx;
+    color: #666;
+    border-radius: 10rpx;
+    border: #666 1rpx solid;
+    margin-bottom: 10rpx;
+    margin-left: 10rpx;
+    margin-right: 10rpx;
+    display: flex;
+    flex-direction: column;
+    .sub-items {
+      display: flex;
+      flex-direction: row;
+      .sub-item {
+        display: flex;
+        flex: 1;
+        flex-direction: column;
+      }
+    }
+  }
+
+  .is-empty {
+    text-align: center;
+    margin: 40px 0;
+    color: #999;
+  }
+}
+</style>

+ 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>

+ 67 - 68
src/pages/weigh/weigh.vue

@@ -390,12 +390,11 @@ const spaceRes = computed(() => {
     return ''
   }
 })
-onShow(() => {
+onShow(async () => {
   focusType.value = true
   loading.value = false
-  _getWarehouseSpace()
-  _getBindParams()
-  _getPrinterList()
+  await _getWarehouseSpace()
+  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) => {

+ 10 - 1
src/utils/http.ts

@@ -69,7 +69,16 @@ export const http = <T>(options: UniApp.RequestOptions) => {
         // 状态码 2xx, axios 就是这样设计的
         if (res.statusCode >= 200 && res.statusCode < 300) {
           // 2.1 提取核心数据 res.data
-          resolve(res.data as Data<T>)
+          const data = res.data as Data<T>
+          if (data.code === 302) {
+            // 401错误  -> 清理用户信息,跳转到登录页
+            const memberStore = useMemberStore()
+            memberStore.clearProfile()
+            uni.navigateTo({ url: '/pages/login/login' })
+            reject(res)
+          } else {
+            resolve(res.data as Data<T>)
+          }
         } else if (res.statusCode === 401) {
           // 401错误  -> 清理用户信息,跳转到登录页
           const memberStore = useMemberStore()