|
@@ -22,6 +22,14 @@
|
|
|
<van-col span="24"><span>IP:</span> {{ ipAddress || '获取中...' }}</van-col>
|
|
<van-col span="24"><span>IP:</span> {{ ipAddress || '获取中...' }}</van-col>
|
|
|
<van-col span="24"><span>MAC:</span> {{ mac }}</van-col>
|
|
<van-col span="24"><span>MAC:</span> {{ mac }}</van-col>
|
|
|
</van-row>
|
|
</van-row>
|
|
|
|
|
+ <van-row justify="center" :gutter="[0, 23]" style="margin-top: 23px">
|
|
|
|
|
+ <van-col span="24">
|
|
|
|
|
+ 错误数量:<span style="color: red">{{ errNum }}</span>
|
|
|
|
|
+ </van-col>
|
|
|
|
|
+ <van-col span="24">
|
|
|
|
|
+ <van-button style="width: 100px" v-if="errNum > 0" plain :loading="isOnePush" :disabled="isOnePush" loading-text="加载中..." type="danger" @click="_one_click_push">一键重传</van-button>
|
|
|
|
|
+ </van-col>
|
|
|
|
|
+ </van-row>
|
|
|
</van-col>
|
|
</van-col>
|
|
|
<van-col span="18" class="table-container">
|
|
<van-col span="18" class="table-container">
|
|
|
<van-cell-group class="custom-cell-group">
|
|
<van-cell-group class="custom-cell-group">
|
|
@@ -116,9 +124,9 @@
|
|
|
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
|
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
|
|
import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
|
|
|
import { scanSuccess, scanError } from '@/utils/android'
|
|
import { scanSuccess, scanError } from '@/utils/android'
|
|
|
-import { getVersionName, checkUpdate, saveUserId, getUserId, scanRepeat, saveMacAddress,
|
|
|
|
|
- readMacAddress, pageDelivery, addDelivery, updateDeliveryPushFail, markAsPushed } from '@/utils/androidPiece'
|
|
|
|
|
-import { showNotify } from 'vant'
|
|
|
|
|
|
|
+import { getVersionName, checkUpdate, saveUserId, getUserId, scanRepeat, saveMacAddress, listErrRecords,
|
|
|
|
|
+ readMacAddress, pageDelivery, addDelivery, updateDeliveryPushFail, markAsPushed, getErrRecordsCount } from '@/utils/androidPiece'
|
|
|
|
|
+import { showLoadingToast, showNotify } from 'vant'
|
|
|
import { getUserIdByCert, getUserNameById } from '@/api/login/index'
|
|
import { getUserIdByCert, getUserNameById } from '@/api/login/index'
|
|
|
import { receive } from '@/api/scan/index'
|
|
import { receive } from '@/api/scan/index'
|
|
|
import { formatDateTime } from '@/utils/date'
|
|
import { formatDateTime } from '@/utils/date'
|
|
@@ -139,6 +147,7 @@ const message = ref('')
|
|
|
const list = ref([])
|
|
const list = ref([])
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
const finished = ref(false)
|
|
const finished = ref(false)
|
|
|
|
|
+const errNum = ref(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
const isOnline = ref(navigator.onLine)
|
|
const isOnline = ref(navigator.onLine)
|
|
@@ -193,6 +202,8 @@ onMounted(() => {
|
|
|
}
|
|
}
|
|
|
// ip
|
|
// ip
|
|
|
fetchIP()
|
|
fetchIP()
|
|
|
|
|
+ // err数量
|
|
|
|
|
+ errNum.value = getErrNum()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@@ -271,6 +282,7 @@ const _handlerScan = (code) => {
|
|
|
scanError()
|
|
scanError()
|
|
|
updateDeliveryPushFail(code)
|
|
updateDeliveryPushFail(code)
|
|
|
list.value.unshift(dto)
|
|
list.value.unshift(dto)
|
|
|
|
|
+ errNum.value += 1
|
|
|
showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: `扫描失败!${err.message}` });
|
|
showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: `扫描失败!${err.message}` });
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -302,7 +314,12 @@ const debounce = (func, wait = 500) => {
|
|
|
// 修改后的推送函数
|
|
// 修改后的推送函数
|
|
|
const _rePush = (item) => {
|
|
const _rePush = (item) => {
|
|
|
if (!item || item.isPush === 1) return;
|
|
if (!item || item.isPush === 1) return;
|
|
|
-
|
|
|
|
|
|
|
+ let status = false
|
|
|
|
|
+ showLoadingToast({
|
|
|
|
|
+ message: '上传中...',
|
|
|
|
|
+ forbidClick: true,
|
|
|
|
|
+ closeToast: status
|
|
|
|
|
+ });
|
|
|
// 初始化当前单据的防抖状态
|
|
// 初始化当前单据的防抖状态
|
|
|
if (!debounceMap.has(item.deliveryNo)) {
|
|
if (!debounceMap.has(item.deliveryNo)) {
|
|
|
debounceMap.set(item.deliveryNo, {
|
|
debounceMap.set(item.deliveryNo, {
|
|
@@ -325,6 +342,8 @@ const _rePush = (item) => {
|
|
|
entry.isPushing = false; // 请求完成解锁
|
|
entry.isPushing = false; // 请求完成解锁
|
|
|
item.isPush = 1;
|
|
item.isPush = 1;
|
|
|
scanSuccess();
|
|
scanSuccess();
|
|
|
|
|
+ status = true
|
|
|
|
|
+ errNum.value -= 1
|
|
|
showNotify({
|
|
showNotify({
|
|
|
type: 'success',
|
|
type: 'success',
|
|
|
style: 'font-size: 30px !important;height:50px',
|
|
style: 'font-size: 30px !important;height:50px',
|
|
@@ -333,10 +352,11 @@ const _rePush = (item) => {
|
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
|
entry.isPushing = false; // 请求失败解锁
|
|
entry.isPushing = false; // 请求失败解锁
|
|
|
scanError();
|
|
scanError();
|
|
|
|
|
+ status = true
|
|
|
showNotify({
|
|
showNotify({
|
|
|
type: 'danger',
|
|
type: 'danger',
|
|
|
style: 'font-size: 30px !important;height:50px',
|
|
style: 'font-size: 30px !important;height:50px',
|
|
|
- message: `扫描失败!${err.message}`
|
|
|
|
|
|
|
+ message: `推单失败!${err.message}`
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
}, 500) // 500ms防抖时间
|
|
}, 500) // 500ms防抖时间
|
|
@@ -425,6 +445,10 @@ const fetchIP = async () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const getErrNum = () => {
|
|
|
|
|
+ return getErrRecordsCount()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const page = ref(1)
|
|
const page = ref(1)
|
|
|
const size = ref(10)
|
|
const size = ref(10)
|
|
|
// 模拟数据加载
|
|
// 模拟数据加载
|
|
@@ -453,6 +477,74 @@ const onRefresh = () => {
|
|
|
page.value = 1
|
|
page.value = 1
|
|
|
onLoad();
|
|
onLoad();
|
|
|
};
|
|
};
|
|
|
|
|
+const isOnePush = ref(false)
|
|
|
|
|
+const _one_click_push = () => {
|
|
|
|
|
+ isOnePush.value = true
|
|
|
|
|
+ const result = listErrRecords()
|
|
|
|
|
+ if (result && result != '[]') {
|
|
|
|
|
+ const records = JSON.parse(result);
|
|
|
|
|
+ const promises = []; // 收集所有请求的Promise
|
|
|
|
|
+
|
|
|
|
|
+ records.forEach(item => {
|
|
|
|
|
+ // 初始化当前单据的防抖状态
|
|
|
|
|
+ if (!debounceMap.has(item.deliveryNo)) {
|
|
|
|
|
+ const debounceEntry = {
|
|
|
|
|
+ isPushing: false,
|
|
|
|
|
+ debouncedFn: debounce(() => {
|
|
|
|
|
+ const entry = debounceMap.get(item.deliveryNo);
|
|
|
|
|
+ if (!entry || entry.isPushing) return;
|
|
|
|
|
+
|
|
|
|
|
+ entry.isPushing = true; // 加锁
|
|
|
|
|
+
|
|
|
|
|
+ const dto = {
|
|
|
|
|
+ deliveryNo: item.deliveryNo,
|
|
|
|
|
+ machine: item.machine,
|
|
|
|
|
+ operator: item.operator,
|
|
|
|
|
+ operationTime: item.operationTime
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 将请求包装成Promise并收集
|
|
|
|
|
+ const promise = receive(dto)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ const result = markAsPushed(item.deliveryNo);
|
|
|
|
|
+ list.value.filter(entry => entry.deliveryNo === item.deliveryNo).forEach(entry => {
|
|
|
|
|
+ entry.isPush = 1;
|
|
|
|
|
+ })
|
|
|
|
|
+ errNum.value -= 1
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ entry.isPushing = false; // 无论成功失败都解锁
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ promises.push(promise); // 添加到Promise数组
|
|
|
|
|
+ return promise;
|
|
|
|
|
+ }, 500)
|
|
|
|
|
+ };
|
|
|
|
|
+ debounceMap.set(item.deliveryNo, debounceEntry);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 立即执行防抖函数并收集Promise
|
|
|
|
|
+ const promise = debounceMap.get(item.deliveryNo).debouncedFn();
|
|
|
|
|
+ if (promise) promises.push(promise);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 所有请求完成后重置状态
|
|
|
|
|
+ Promise.allSettled(promises)
|
|
|
|
|
+ .then(_ => {
|
|
|
|
|
+ scanSuccess();
|
|
|
|
|
+ showNotify({ type: 'success', style: 'font-size: 30px !important;height:50px', message: '数据已推送!' });
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(_ => {
|
|
|
|
|
+ scanError();
|
|
|
|
|
+ showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '存在数据推送失败!' });
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ isOnePush.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '暂无异常数据!' });
|
|
|
|
|
+ isOnePush.value = false; // 没有数据时立即重置
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="sass">
|
|
<style scoped lang="sass">
|