GGDemo 1 month ago
parent
commit
42e50cb352

+ 100 - 127
src/pages/scanLotno/scanLotno.vue

@@ -115,10 +115,7 @@ import {
   onNavigationBarButtonTap,
 } from '@dcloudio/uni-app'
 import { checkPermission } from '@/utils'
-
-let getBindParamsURL = ''
-let bindShippingURL = ''
-let getWaybillsURL = ''
+import { bindShipping, getBindParams, getWaybills } from '@/services/scanLotno'
 
 const token = ref()
 const loading = ref(false)
@@ -234,39 +231,32 @@ const palletNum = computed(() => {
   return textPath
 })
 
-const checkOrder = () => {
+const checkOrder = async () => {
   loading.value = true
-  uni.setStorageSync('waybills', [])
-  uni.request({
-    url: getWaybillsURL,
-    method: 'POST',
-    header: {
-      batoken: token.value,
-    },
-    data: {
-      order_no: valiFormData.value.orderNum,
-      batch_number: valiFormData.value.batchNum,
-      pallet_number: valiFormData.value.palletNum
-        ? findPalletNumIdByValue(options.pallet, valiFormData.value.palletNum)
-        : '',
-    },
-    success: (res: any) => {
-      loading.value = false
-      if (res.data.code == 1) {
-        messageType.value = 'success'
-        messageText.value = res.data.msg
-        messageRef.value.open()
-        uni.setStorageSync('waybills', res.data.data.waybills)
-        uni.navigateTo({
-          url: '/pages/scanLotno/waybillsList',
-        })
-      } else {
-        messageType.value = 'error'
-        messageText.value = res.data.msg
-        messageRef.value.open()
-      }
-    },
+  // uni.setStorageSync('waybills', [])
+
+  const res = await getWaybills({
+    order_no: valiFormData.value.orderNum,
+    batch_number: valiFormData.value.batchNum,
+    pallet_number: valiFormData.value.palletNum
+      ? findPalletNumIdByValue(options.pallet, valiFormData.value.palletNum)
+      : '',
   })
+
+  loading.value = false
+  if (res.data.code == 1) {
+    messageType.value = 'success'
+    messageText.value = res.data.msg
+    messageRef.value.open()
+    // uni.setStorageSync('waybills', res.data.data.waybills)
+    uni.navigateTo({
+      url: '/pages/scanLotno/waybillsList',
+    })
+  } else {
+    messageType.value = 'error'
+    messageText.value = res.data.msg
+    messageRef.value.open()
+  }
 }
 
 const findPalletNumIdByValue = (data: any, targetValue: any) => {
@@ -285,68 +275,61 @@ const findPalletNumIdByValue = (data: any, targetValue: any) => {
   return null
 }
 
-const onsubmit = () => {
+const onsubmit = async () => {
   st && clearTimeout(st)
   loading.value = true
-  uni.request({
-    url: bindShippingURL,
-    method: 'POST',
-    header: {
-      batoken: token.value,
-    },
-    data: {
-      order_no: valiFormData.value.orderNum,
-      reweighting: valiFormData.value.weight,
-      batch_number: valiFormData.value.batchNum,
-      pallet_number: valiFormData.value.palletNum
-        ? findPalletNumIdByValue(options.pallet, valiFormData.value.palletNum)
-        : '',
-    },
-    success: (res: any) => {
-      loading.value = false
-      if (res.data.code == 1) {
-        messageType.value = 'success'
-        messageText.value = res.data.msg
-        messageRef.value.open()
-
-        if (res.data.data.labels && res.data.data.labels.length > 0) {
-          console.log('有打印面单')
-          // res.data.data.labels.map((url: string) => {
-          // 	let path = fullUrl(url);
-          // 	window.open(path, '_blank');
-          // });
-        }
-        const historyItem = {
-          orderNum: valiFormData.value.orderNum,
-          createTime: new Date(),
-          type: valiFormData.value.batchNum ? '绑定批次' : '绑定托盘',
-          status: true,
-        }
-        console.log('lotnoLogHistory--', lotnoLogHistory)
-        lotnoLogHistory.value.unshift(historyItem)
-        uni.setStorageSync('lotnoLogHistory', lotnoLogHistory.value)
-        getHistory()
-      } else {
-        messageType.value = 'error'
-        messageText.value = res.data.msg
-        messageRef.value.open()
-        const historyItem = {
-          orderNum: valiFormData.value.orderNum,
-          createTime: new Date(),
-          type: valiFormData.value.batchNum ? '绑定批次' : '绑定托盘',
-          status: false,
-        }
-        lotnoLogHistory.value.unshift(historyItem)
-        uni.setStorageSync('lotnoLogHistory', lotnoLogHistory.value)
-        getHistory()
-      }
-      st = setTimeout(() => {
-        reset()
-        setFocus()
-        st && clearTimeout(st)
-      }, 1000)
-    },
+
+  const res = await bindShipping({
+    order_no: valiFormData.value.orderNum,
+    reweighting: valiFormData.value.weight,
+    batch_number: valiFormData.value.batchNum,
+    pallet_number: valiFormData.value.palletNum
+      ? findPalletNumIdByValue(options.pallet, valiFormData.value.palletNum)
+      : '',
   })
+
+  loading.value = false
+  if (res.data.code == 1) {
+    messageType.value = 'success'
+    messageText.value = res.data.msg
+    messageRef.value.open()
+
+    if (res.data.data.labels && res.data.data.labels.length > 0) {
+      console.log('有打印面单')
+      // res.data.data.labels.map((url: string) => {
+      // 	let path = fullUrl(url);
+      // 	window.open(path, '_blank');
+      // });
+    }
+    // const historyItem = {
+    //   orderNum: valiFormData.value.orderNum,
+    //   createTime: new Date(),
+    //   type: valiFormData.value.batchNum ? '绑定批次' : '绑定托盘',
+    //   status: true,
+    // }
+    // console.log('lotnoLogHistory--', lotnoLogHistory)
+    // lotnoLogHistory.value.unshift(historyItem)
+    // uni.setStorageSync('lotnoLogHistory', lotnoLogHistory.value)
+    // getHistory()
+  } else {
+    messageType.value = 'error'
+    messageText.value = res.data.msg
+    messageRef.value.open()
+    // const historyItem = {
+    //   orderNum: valiFormData.value.orderNum,
+    //   createTime: new Date(),
+    //   type: valiFormData.value.batchNum ? '绑定批次' : '绑定托盘',
+    //   status: false,
+    // }
+    // lotnoLogHistory.value.unshift(historyItem)
+    // uni.setStorageSync('lotnoLogHistory', lotnoLogHistory.value)
+    // getHistory()
+  }
+  st = setTimeout(() => {
+    reset()
+    setFocus()
+    st && clearTimeout(st)
+  }, 1000)
 }
 
 const getHistory = () => {
@@ -405,7 +388,7 @@ onBackPress(() => {
 onShow(() => {
   hidePage.value = false
   token.value = uni.getStorageSync('token')
-  getBindParams()
+  _getBindParams()
   getHistory()
 })
 const setFocus = () => {
@@ -417,39 +400,29 @@ const setFocus = () => {
     focusType.value = true
   })
 }
-const getBindParams = () => {
-  uni.request({
-    url: getBindParamsURL,
-    method: 'GET',
-    header: {
-      batoken: token.value,
-    },
-    success: (res: any) => {
-      if (res.data.code === 1) {
-        options.batch = res.data.data.batch_number.map((item: any) => {
-          return { text: item.name, value: item.id }
-        })
-        // eslint-disable-next-line no-inner-declarations
-        function transformData(data: any) {
-          return data.map((item: any) => {
-            const { id, value, label, ...rest } = item
-            return {
-              id: id || value,
-              value: value,
-              text: label,
-              ...rest,
-              children: item.children ? transformData(item.children) : [],
-            }
-          })
+const _getBindParams = async () => {
+  const res = await getBindParams()
+
+  if (res.data.code === 1) {
+    options.batch = res.data.data.batch_number.map((item: any) => {
+      return { text: item.name, value: item.id }
+    })
+    // eslint-disable-next-line no-inner-declarations
+    function transformData(data: any) {
+      return data.map((item: any) => {
+        const { id, value, label, ...rest } = item
+        return {
+          id: id || value,
+          value: value,
+          text: label,
+          ...rest,
+          children: item.children ? transformData(item.children) : [],
         }
-        const shipping = transformData(res.data.data.shipping)
-        options.pallet = shipping
-      }
-    },
-    fail(e) {
-      console.log('fail--', e)
-    },
-  })
+      })
+    }
+    const shipping = transformData(res.data.data.shipping)
+    options.pallet = shipping
+  }
 }
 
 onNavigationBarButtonTap((event) => {

+ 41 - 52
src/pages/warehouseScan/warehouseScan.vue

@@ -69,8 +69,8 @@ import {
   onNavigationBarButtonTap,
 } from '@dcloudio/uni-app'
 import { checkPermission } from '@/utils'
+import { warehouseScan } from '@/services/warehouseScan'
 
-const token = ref()
 const loading = ref(false)
 const hidePage = ref(false)
 const focusType = ref(true)
@@ -80,8 +80,6 @@ const messageType = ref()
 const messageText = ref()
 let st: number
 
-let warehouseScanURL = ''
-
 const valiFormData = ref({
   order_code: '',
 })
@@ -128,59 +126,51 @@ const setfocus = () => {
   })
 }
 
-const onsubmit = () => {
+const onsubmit = async () => {
   st && clearTimeout(st)
   loading.value = true
-  uni.request({
-    url: warehouseScanURL,
-    method: 'POST',
-    header: {
-      batoken: token.value,
-    },
-    data: {
-      order_code: valiFormData.value.order_code,
-    },
-    success: (res: any) => {
-      loading.value = false
-      if (res.data.code == 1) {
-        messageType.value = 'success'
-        messageText.value = res.data.msg
-        messageRef.value.open()
 
-        const historyItem = {
-          order_code: valiFormData.value.order_code,
-          createTime: new Date(),
-          type: '单据扫描',
-          status: true,
-        }
-        warehouseLogHistory.value.unshift(historyItem)
-        uni.setStorageSync('warehouseLogHistory', warehouseLogHistory.value)
-        getHistory()
-      } else {
-        messageType.value = 'error'
-        messageText.value = res.data.msg
-        messageRef.value.open()
-        const historyItem = {
-          order_code: valiFormData.value.order_code,
-          createTime: new Date(),
-          type: '单据扫描',
-          status: false,
-        }
-        warehouseLogHistory.value.unshift(historyItem)
-        uni.setStorageSync('warehouseLogHistory', warehouseLogHistory.value)
-        getHistory()
-      }
-      st = setTimeout(() => {
-        reset()
-        st && clearTimeout(st)
-      }, 1000)
-    },
+  const res = await warehouseScan({
+    order_code: valiFormData.value.order_code,
   })
-}
+  loading.value = false
+  if (res.data.code == 1) {
+    messageType.value = 'success'
+    messageText.value = res.data.msg
+    messageRef.value.open()
 
-const getHistory = () => {
-  warehouseLogHistory.value = uni.getStorageSync('warehouseLogHistory') || []
+    // const historyItem = {
+    //   order_code: valiFormData.value.order_code,
+    //   createTime: new Date(),
+    //   type: '单据扫描',
+    //   status: true,
+    // }
+    // warehouseLogHistory.value.unshift(historyItem)
+    // uni.setStorageSync('warehouseLogHistory', warehouseLogHistory.value)
+    // getHistory()
+  } else {
+    messageType.value = 'error'
+    messageText.value = res.data.msg
+    messageRef.value.open()
+    // const historyItem = {
+    //   order_code: valiFormData.value.order_code,
+    //   createTime: new Date(),
+    //   type: '单据扫描',
+    //   status: false,
+    // }
+    // warehouseLogHistory.value.unshift(historyItem)
+    // uni.setStorageSync('warehouseLogHistory', warehouseLogHistory.value)
+    // getHistory()
+  }
+  st = setTimeout(() => {
+    reset()
+    st && clearTimeout(st)
+  }, 1000)
 }
+
+// const getHistory = () => {
+//   warehouseLogHistory.value = uni.getStorageSync('warehouseLogHistory') || []
+// }
 const keypress = (e: any) => {
   console.log(e, '按键码')
   // 102  左侧    103  右侧   104  中间按键
@@ -233,9 +223,8 @@ onBackPress(() => {
 })
 
 onShow(() => {
-  token.value = uni.getStorageSync('token')
   hidePage.value = false
-  getHistory()
+  // getHistory()
 })
 
 onNavigationBarButtonTap((event) => {

+ 33 - 9
src/services/scanLotno.ts

@@ -1,17 +1,41 @@
 import { http } from '@/utils/http'
-import type { PageParams } from '@/types/global'
-import type { HotResult } from '@/types/hot'
 
-type HotParams = PageParams & { subType?: string }
 /**
- * 通用热门推荐类型
- * @param url 请求地址
- * @param data 请求参数
+ * 获取 扫描 托盘号、批次号
  */
-export const getHotRecommendAPI = (url: string, data?: HotParams) => {
-  return http<HotResult>({
+export const getBindParams = () => {
+  return http<any>({
     method: 'GET',
-    url,
+    url: '/admin/order.scanOrder/getBindParams',
+  })
+}
+
+/**
+ * 扫描托盘
+ */
+export const bindShipping = (data: {
+  order_no: string
+  reweighting: string
+  batch_number: string
+  pallet_number: string
+}) => {
+  return http<any>({
+    method: 'POST',
+    url: '/admin/order.scanOrder/bindShipping',
+    data,
+  })
+}
+/**
+ * 扫描托盘
+ */
+export const getWaybills = (data: {
+  order_no: string
+  batch_number: string
+  pallet_number: string
+}) => {
+  return http<any>({
+    method: 'POST',
+    url: '/admin/order.scanOrder/getWaybills',
     data,
   })
 }

+ 14 - 9
src/services/warehouseScan.ts

@@ -1,17 +1,22 @@
 import { http } from '@/utils/http'
-import type { PageParams } from '@/types/global'
-import type { HotResult } from '@/types/hot'
 
-type HotParams = PageParams & { subType?: string }
 /**
- * 通用热门推荐类型
- * @param url 请求地址
- * @param data 请求参数
+ * 临时单据--字段选项
  */
-export const getHotRecommendAPI = (url: string, data?: HotParams) => {
-  return http<HotResult>({
+export const waybillNoOptions = () => {
+  return http<any>({
     method: 'GET',
-    url,
+    url: '/admin/warehouse.waybillNo/getOptions',
+  })
+}
+
+/**
+ * 面单 仓库扫描
+ */
+export const warehouseScan = (data: { order_code: string }) => {
+  return http<any>({
+    method: 'POST',
+    url: '/admin/order.sheetOrder/warehouseScan',
     data,
   })
 }