duy hace 4 meses
padre
commit
0ebc0654b3
Se han modificado 2 ficheros con 98 adiciones y 32 borrados
  1. 21 0
      httpApi/modules/storage.js
  2. 77 32
      pages/putStorage/putStorage.vue

+ 21 - 0
httpApi/modules/storage.js

@@ -0,0 +1,21 @@
+import { httpApi } from '../request/httpApi'
+import website from "@/config/index";
+
+export default {
+//开始扫描
+    async getSelectRfidListById(form) {
+        return httpApi({
+            url: '/api/blade-business/entrustinfo/selectRfidListById',
+            method: 'get',
+            params: form,
+        })
+    },
+    //一键入库
+    async update(form) {
+        return httpApi({
+            url: '/api/blade-business/entrustinfo/update',
+            method: 'post',
+            data: form,
+        })
+    },
+}

+ 77 - 32
pages/putStorage/putStorage.vue

@@ -12,13 +12,13 @@
 									<template v-slot:body>
 										<view class="ml-6" style="font-size: 14px;">
 										    <view class="name">
-										      {{item}}
+										      {{item.materialName}}
 										    </view>
 										    <view>
-										        {{item}}
+										        {{item.specificationNumber}}
 										    </view>
 										    <view>
-										        {{item}}
+										        {{item.proposedPosition}}
 										    </view>
 										</view>
 									</template>
@@ -30,7 +30,7 @@
 				</scroll-view>
               <view class="button-container" v-if="type==1">
 
-                   <button class="btn"  type="default" @click='startScan' v-if="isShowStartBtn" :loading="scanLoad">
+                   <button class="btn"  type="default" @click='startScan(1)' v-if="isShowStartBtn" :loading="scanLoad">
                        <uni-icons type="scan"></uni-icons>
 
                        开始扫描
@@ -40,12 +40,12 @@
                         <uni-icons type="circle-filled"></uni-icons>
 
                         停止扫描</button>
-                    <button class="btn"  type="default" @click="toStorageClick">
+                    <button class="btn"  type="default" @click="toStorageClick" :loading="manualStorageLoading">
                           <uni-icons type="upload-filled"></uni-icons>
                         一键入库</button>
               </view>
               <view class="button-container"  v-if="type==2">
-                   <button class="btn"  type="default" @click='startScan' v-if="isShowStartBtn" :loading="scanLoad">
+                   <button class="btn"  type="default" @click='startScan(2)' v-if="isShowStartBtn" :loading="scanLoad">
                         <uni-icons type="scan"></uni-icons>
                        开始扫描</button>
                     <button class="btn"  type="default" @click='stopScan' v-if="!isShowStartBtn">
@@ -55,29 +55,29 @@
                          <uni-icons type="upload"></uni-icons>
                         一键生成报告</button>
              </view>
-              <LottieAnimation :animationData="animationData" v-if="!isShowStartBtn" />
+
 	</view>
 </template>
 
 <script setup>
-    import LottieAnimation from './LottieAnimation.vue';
-    import animationData from '/static/lotte/circle.json'; // 导入你的动画 JSON 数据
-    import {
-        onMounted,
-        ref,
-        watch
-    } from "vue";
+
+import {
+    onMounted,
+    ref,
+    watch
+} from "vue";
 import {onLoad, onReady, onUnload} from '@dcloudio/uni-app'
 import {getArrValue} from "js-fast-way";
+import mainApi from '~api/storage.js';
 
 
 // 获取 module
-// const rfidModule = uni.requireNativePlugin("DeviceModule_RFID");
+const rfidModule = uni.requireNativePlugin("DeviceModule_RFID");
 
 //渲染完成
 onReady(() => {
     // #ifdef APP-PLUS
-    // rfidModuleInit()
+    rfidModuleInit()
     // #endif
 })
 
@@ -139,8 +139,11 @@ const keyListener = ({keyCode}) => {
 }
 
 //开始扫描
+//开始扫描
+const isShowStartBtn=ref(true)
+const scanLoad=ref(false)
 const isScan = ref(false)
-const startScan = () => {
+const startScan = (type) => {
  isShowStartBtn.value=false
     if (isRfidInit.value) return
     isScan.value = true
@@ -151,14 +154,15 @@ const startScan = () => {
                 title: '开启扫描成功'
             })
         } else if (res.code === 1) {
-            startScanData(res.data)
+            startScanData(res.data,type)
         }
     })
 }
 
 //扫描结果处理
+const codeIds=ref('')
 const scanDatas = ref([])
-const startScanData = async (data) => {
+const startScanData = async (data,type) => {
     const arr = getArrValue(data)
     let epcs = scanDatas.value
     for (let i = 0; i < arr.length; i++) {
@@ -168,10 +172,27 @@ const startScanData = async (data) => {
         }
     }
     scanDatas.value = epcs
-    console.log(scanDatas.value,'scanDatas.value');
-    listArr.value=scanDatas.value
+    codeIds.value=epcs.join(',')
+    getResult(type)
+
 }
+//获取扫描结果
+const getResult=async(type)=>{
+    console.log('发请求');
+      const { response,error, code, data } = await mainApi.getSelectRfidListById({
+         rids:codeIds.value,
+         state:type
+      });
+      //处理数据
+      if (!error && code === 200) {
+          console.log( listArr.value,' listArr.value');
+         listArr.value = getArrValue(data);
+
+      } else {
+          listArr.value = [];
 
+      }
+}
 //停止扫描
 const stopScan = () => {
 
@@ -199,30 +220,53 @@ onUnload(()=>{
     rfidModule.free();
     // #endif
 })
-const listArr=ref([
-    {name:' 水泥(42.5级散装)',num:'SN20015678',postion:'路基、路面、桥梁、隧道'},
-    {name:' 水泥(42.5级散装)',num:'SN20015678',postion:'路基、路面、桥梁、隧道'},
-
-])
-//开始扫描
-const isShowStartBtn=ref(true)
-const scanLoad=ref(false)
+const listArr=ref([])
 
-const toStorageClick=()=>{
+//一键入库
+const manualStorageLoading=ref(false)
+const toStorageClick=async()=>{
     if(!isShowStartBtn.value){
         uni.showToast({
            title: '请先停止扫描',
            icon: 'none',
            duration: 3000
         })
+        return;
     }
+       manualStorageLoading.value = true;
+       console.log(codeIds.value,'codeIds.value');
+       if(codeIds.value.length<1){
+           return;
+       }
+        const { error, code, msg,response } = await mainApi.update({
+            id: codeIds.value,
+            sampleStatus: 2,
+        });
+        console.log(response,'response');
+        manualStorageLoading.value = false;
+        if (!error && code === 200) {
+         uni.showToast({
+             title:'操作成功',
+             duration: 2000,
+             mask: true
+         });
+             getResult().then();
+        } else {
+           uni.showToast({
+               title:'操作失败',
+               duration: 2000,
+               mask: true
+           });
+        }
 }
 const clearItem=(item,index)=>{
     listArr.value.splice(index,1)
 }
-//一键入库
-const storageLoad=ref(false)
+
+
 //一键生成报告
+
+
 const toReport=()=>{
     if(!isShowStartBtn.value){
         uni.showToast({
@@ -230,6 +274,7 @@ const toReport=()=>{
            icon: 'none',
            duration: 3000
         })
+           return;
     }
 }
 </script>