Explorar el Código

计件宝记录上一个上传成功数据

zh hace 10 meses
padre
commit
c0e7035441
Se han modificado 1 ficheros con 31 adiciones y 2 borrados
  1. 31 2
      src/views/piece/dashboard/index.vue

+ 31 - 2
src/views/piece/dashboard/index.vue

@@ -170,6 +170,7 @@ const list = ref([])
 const loading = ref(false)
 const finished = ref(false)
 const errNum = ref(0)
+const preDeliveryNo = ref('')
 
 // 小青蛙位置属性
 const frogPosition = ref({
@@ -272,6 +273,8 @@ const _openScan = () => {
     scanInit(_handlerScan)
   },300)
 }
+
+const pushing = ref(false)
 const _handlerScan = (code) => {
   code = fixDuplicateText(code)
   // 校验扫描的是否为登录二维码
@@ -279,7 +282,6 @@ const _handlerScan = (code) => {
   if (code !== null && regex.test(code)) {
     const match = regex.exec(code)
     const sign = match[1]
-    const [userId, token] = sign.split('#');
     const identity = match[2]
     getUserIdByCert({sign: sign, identity: identity}).then(res => {
       if (res && res.data) {
@@ -320,8 +322,31 @@ const _handlerScan = (code) => {
       showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '该快递单已扫描!' });
       return
     }
+
+    if (pushing.value) {
+      scanError()
+      showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '正在提交中,请稍后扫描!' });
+      return
+    }
+    pushing.value =  true  // 请求状态锁
+    let status = false
+    showLoadingToast({
+      message: '上传中...',
+      forbidClick: true,
+      closeToast: status
+    });
+
     message.value = ''
-    const dto = { deliveryNo: code, machine: mac.value, operator: userInfo.value.userId, operationTime: currentTime, operatorName: userInfo.value.name, isPush: 1, version: versionName.value }
+    const dto = {
+      deliveryNo: code,
+      machine: mac.value,
+      operator: userInfo.value.userId,
+      operationTime: currentTime,
+      operatorName: userInfo.value.name,
+      isPush: 1,
+      preDeliveryNo: preDeliveryNo.value,
+      version: versionName.value }
+
     receive(dto).then(res => {
       if (res && res.code === 200) {
         const result = addDelivery(mac.value, code, userInfo.value.userId, userInfo.value.name)
@@ -336,6 +361,7 @@ const _handlerScan = (code) => {
           showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '添加失败,请联系开发人员!' });
           return
         }
+        preDeliveryNo.value = code
         scanSuccess()
         list.value.unshift(dto)
         showNotify({ type: 'success', style: 'font-size: 30px !important;height:50px', message: '扫描成功!' });
@@ -348,6 +374,9 @@ const _handlerScan = (code) => {
         scanError()
       }
       showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: `扫描失败!${err.message}` });
+    }).finally(() => {
+      status = true
+      pushing.value = false
     })
   }
 }