GGDemo 1 개월 전
부모
커밋
caf1d8682f
2개의 변경된 파일71개의 추가작업 그리고 90개의 파일을 삭제
  1. 57 81
      src/pages/waybillNo/waybillNo.vue
  2. 14 9
      src/services/waybillNo.ts

+ 57 - 81
src/pages/waybillNo/waybillNo.vue

@@ -94,12 +94,8 @@ import {
   onNavigationBarButtonTap,
 } from '@dcloudio/uni-app'
 import { checkPermission } from '@/utils'
+import { addWaybillNo, waybillNoOptions } from '@/services/waybillNo'
 
-let waybillNoOptions = ''
-let addWaybillNoURL = ''
-let getWaybillsURL = ''
-
-const token = ref()
 const editSpaceNo = ref(false)
 const loading = ref(false)
 const hidePage = ref(false)
@@ -184,60 +180,51 @@ const findPalletNumIdByValue = (data: any, targetValue: any) => {
   return null
 }
 
-const onsubmit = () => {
+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 space = options.space.find((item: any) => item.value === valiFormData.value.space_id)
-        if (res.data.code == 1) {
-          messageType.value = 'success'
-          messageText.value = res.data.msg
-          messageRef.value.open()
-          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)
-      },
+    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) {
+      messageType.value = 'success'
+      messageText.value = res.data.msg
+      messageRef.value.open()
+      // 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)
   } else {
     if (!valiFormData.value.space_id) {
       messageType.value = 'error'
@@ -252,9 +239,9 @@ const onsubmit = () => {
   }
 }
 
-const getHistory = () => {
-  waybillNoHistory.value = uni.getStorageSync('waybillNoHistory') || []
-}
+// const getHistory = () => {
+//   waybillNoHistory.value = uni.getStorageSync('waybillNoHistory') || []
+// }
 const keypress = (e: any) => {
   console.log(e, '按键码')
   // 102  左侧    103  右侧   104  中间按键
@@ -307,33 +294,22 @@ onBackPress(() => {
 })
 onShow(() => {
   hidePage.value = false
-  token.value = uni.getStorageSync('token')
+  // token.value = uni.getStorageSync('token')
   getOptions()
-  getHistory()
+  // getHistory()
 })
 
-const getOptions = () => {
-  uni.request({
-    url: waybillNoOptions,
-    method: 'GET',
-    header: {
-      batoken: token.value,
-    },
-    success: (res: any) => {
-      console.log(res)
-      if (res.data.code === 1) {
-        for (let key in res.data.data.space_id) {
-          // eslint-disable-next-line no-prototype-builtins
-          if (res.data.data.space_id.hasOwnProperty(key)) {
-            options.space.push({ text: res.data.data.space_id[key], value: key })
-          }
-        }
+const getOptions = async () => {
+  const res = await waybillNoOptions()
+  console.log(res)
+  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 })
       }
-    },
-    fail(e) {
-      console.log('fail--', e)
-    },
-  })
+    }
+  }
 }
 
 const setFocus = () => {

+ 14 - 9
src/services/waybillNo.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 addWaybillNo = (data: { code: string; space_id: string }) => {
+  return http<any>({
+    method: 'POST',
+    url: '/admin/warehouse.waybillNo/add',
     data,
   })
 }