|
@@ -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 = () => {
|