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