Browse Source

2024.12.11

Lzw 1 week ago
parent
commit
6b0d46dfed

+ 21 - 1
src/pages.json

@@ -118,7 +118,27 @@
     {
       "path": "pages/waybillNo/waybillNo",
       "style": {
-        "navigationBarTitleText": "库位绑定"
+        "navigationBarTitleText": "库位绑定",
+        "app-plus": {
+          "bounce": "none",
+          "titleNView": {
+            "buttons": [
+              {
+                "fontSize": "16px",
+                "text": "历史"
+              }
+            ],
+            "backButton": {
+              "background": "#00FF00"
+            }
+          }
+        }
+      }
+    },
+    {
+      "path": "pages/waybillNo/waybillNoHistory",
+      "style": {
+        "navigationBarTitleText": "库位历史"
       }
     },
     {

+ 69 - 63
src/pages/waybillNo/waybillNo.vue

@@ -73,6 +73,16 @@
       </view>
     </view>
 
+    <!-- <uni-popup ref="historypopup" type="bottom">
+      <view class="history">
+        <view class="title">历史</view>
+        <view class="item" v-for="(item, i) in waybillNoHistory" :key="i">
+          <view class="type">库位</view>
+          <view class="code">{{ item.space }}</view>
+        </view>
+      </view>
+    </uni-popup> -->
+
     <uni-popup ref="messageRef" type="message">
       <uni-popup-message
         :type="messageType"
@@ -104,6 +114,7 @@ const waybillNoHistory = ref([] as any)
 const messageRef = ref()
 const messageType = ref()
 const messageText = ref()
+const historyPopup = ref()
 let st: any
 
 const valiFormData = ref({
@@ -184,23 +195,17 @@ const onsubmit = async () => {
   if (valiFormData.value.space_id && valiFormData.value.code) {
     st && clearTimeout(st)
     loading.value = true
-    // uni.request({
-    //   url: addWaybillNoURL
-    //   method:'post',
-    //   header:{
-    //     batoken:token.value
-    //   },
-    //   data: {
-    //     code: valiFormData.value.code,
-    //     space_id: valiFormData.value.space_id,
-    //   },
-    // success: (res : any) => {
-
-    //     loading.value = false;
+    const res = await addWaybillNo({
+      code: valiFormData.value.code,
+      space_id: valiFormData.value.space_id,
+    })
+    loading.value = false
     const space = options.space.find((item: any) => item.value === valiFormData.value.space_id)
-    if (res.data.code == 1) {
+    console.log('res--', res)
+
+    if (res.code == 1) {
       messageType.value = 'success'
-      messageText.value = res.data.msg
+      messageText.value = res.msg
       messageRef.value.open()
       const historyItem = {
         code: valiFormData.value.code,
@@ -209,45 +214,30 @@ const onsubmit = async () => {
         space: space.text,
         status: true,
       }
-      const res = await addWaybillNo({
-        code: valiFormData.value.code,
-        space_id: valiFormData.value.space_id,
-      })
-      loading.value = false
-      // const space = options.space.find((item: any) => item.value === valiFormData.value.space_id)
-      if (res.data.code == 1) {
-        const historyItem = {
-          code: valiFormData.value.code,
-          createTime: new Date(),
-          type: '运单号',
-          space: space.text,
-          status: true,
-        }
-        waybillNoHistory.value.unshift(historyItem)
-        uni.setStorageSync('waybillNoHistory', waybillNoHistory.value)
-        getHistory()
-      } else {
-        messageType.value = 'error'
-        messageText.value = res.data.msg
-        messageRef.value.open()
-
-        // const historyItem = {
-        //   code: valiFormData.value.code,
-        //   createTime: new Date(),
-        //   type: '运单号',
-        //   space: space.text,
-        //   status: false,
-        // }
-        // waybillNoHistory.value.unshift(historyItem)
-        // uni.setStorageSync('waybillNoHistory', waybillNoHistory.value)
-        // getHistory()
-      }
-      st = setTimeout(() => {
-        reset()
-        setFocus()
-        st && clearTimeout(st)
-      }, 1000)
+      waybillNoHistory.value.unshift(historyItem)
+      uni.setStorageSync('waybillNoHistory', waybillNoHistory.value)
+      getHistory()
+    } else {
+      messageType.value = 'error'
+      messageText.value = res.msg
+      messageRef.value.open()
+
+      // const historyItem = {
+      //   code: valiFormData.value.code,
+      //   createTime: new Date(),
+      //   type: '运单号',
+      //   space: space.text,
+      //   status: false,
+      // }
+      // waybillNoHistory.value.unshift(historyItem)
+      // uni.setStorageSync('waybillNoHistory', waybillNoHistory.value)
+      // getHistory()
     }
+    st = setTimeout(() => {
+      reset()
+      setFocus()
+      st && clearTimeout(st)
+    }, 1000)
   } else {
     if (!valiFormData.value.space_id) {
       messageType.value = 'error'
@@ -319,12 +309,27 @@ onShow(() => {
   hidePage.value = false
   // token.value = uni.getStorageSync('token')
   getOptions()
-  // getHistory()
+  getHistory()
 })
 
-const getOptions = () => {
+// 获取选项
+const getOptions = async () => {
+  // 1 调用services定义的方法 获取选项数据
+  // 2 判断获取的数据是否成功,code === 1
+  // 3 如果成功,将数据赋值给options.space数组中
+
+  const res = await waybillNoOptions()
+  if (res.code === 1) {
+    for (let key in res.data.space_id) {
+      // eslint-disable-next-line no-prototype-builtins
+      if (res.data.space_id.hasOwnProperty(key)) {
+        options.space.push({ text: res.data.space_id[key], value: key })
+      }
+    }
+  }
+  /**
   uni.request({
-    url: waybillNoOptions,
+    url: 'url',
     method: 'GET',
     header: {
       // batoken: token.value,
@@ -344,6 +349,7 @@ const getOptions = () => {
       console.log('fail--', e)
     },
   })
+     */
 }
 
 const setFocus = () => {
@@ -359,7 +365,7 @@ const setFocus = () => {
 onNavigationBarButtonTap((event) => {
   if (event.index === 0) {
     uni.navigateTo({
-      url: '/pages/waybillNo/waybillNoLog',
+      url: '/pages/waybillNo/waybillNoHistory',
     })
   }
 })
@@ -424,10 +430,10 @@ button {
     font-weight: 600;
   }
 
-  .type {
-    padding-right: 20rpx;
-    font-size: 24rpx;
-  }
+  // .type {
+  //   padding-right: 20rpx;
+  //   font-size: 24rpx;
+  // }
 
   .code {
     font-weight: 600;
@@ -437,8 +443,8 @@ button {
     padding: 20rpx;
     font-size: 20rpx;
     color: #666;
-    display: flex;
-    flex-direction: row;
+    // display: flex;
+    // flex-direction: row;
 
     .status {
       padding-left: 20rpx;

+ 88 - 0
src/pages/waybillNo/waybillNoHistory.vue

@@ -0,0 +1,88 @@
+<template>
+  <view class="history">
+    <view class="item" v-for="(item, i) in waybillNoHistory" :key="i">
+      <text class="type">库位</text>
+      <text clsaa="code" :style="{ color: item.status ? 'green' : '#666' }">{{ item.space }}</text>
+      <view>
+        <text class="type">单号</text>
+        <text class="code" ;style="{color : item.status ? 'green' : '#666'}">{{ item.code }}</text>
+      </view>
+      <view class="space-time">
+        <text>
+          {{ item.createTime }}
+        </text>
+      </view>
+    </view>
+  </view>
+
+  <view v-if="waybillNoHistory.length === 0" class="is-empty">暂无历史</view>
+  <view class="history">
+    <view class="title">历史运单号</view>
+    <view v-for="(item, index) in waybillNoHistory" :key="index" class="item">
+      <view class="type">运单号:</view>
+      <view class="code">{{ item }}</view>
+      <view class="status">
+        <text class="fail">已失效</text>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script setup lang="ts">
+import { reactive, ref } from 'vue'
+import { onLoad } from '@dcloudio/uni-app'
+const waybillNoHistory = ref([] as any[])
+const getHistory = async () => {
+  waybillNoHistory.value = await uni.getStorageSync('waybillNoHistory')
+}
+onLoad(async () => {
+  await 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;
+    display: flex;
+    flex-direction: row;
+
+    .status {
+      padding-left: 20rpx;
+    }
+
+    .fail {
+      font-weight: 600;
+      color: #f00;
+    }
+  }
+
+  .is-empty {
+    text-align: center;
+    margin: 40px 0;
+    color: #999;
+  }
+}
+</style>

+ 1 - 0
src/pages/weigh/weigh.vue

@@ -900,6 +900,7 @@ const closePreview = () => {
     height: 35px;
     width: 50%;
     margin-left: 10px;
+    font-size: 16rpx;
   }
 
   .uni-icons {