Kaynağa Gözat

修复nfc管理bug,添加字段

凉纪 2 yıl önce
ebeveyn
işleme
938152f762

+ 15 - 1
src/components/nfcPopup/more.vue

@@ -69,10 +69,24 @@ export default {
       }
     }
   },
+  mounted(){
+    window.openNFCScanCallBack = this.openNFCScanCallBack;
+  },
   methods:{
+    openNFCScanCallBack(data){
+      alert(data)
+      if(!data) {
+        this.$toast('扫描失败');
+        return
+      }
+      let code = JSON.parse(data).content;
+      this.$emit('NFCCode',code);
+      this.$toast('扫描成功');
+    },
     //nfc扫描
     nfcCheck(){
-      this.$emit('checkNFC');
+      this.useNFC();
+
     },
     onConfirm(){
       if(!this.selectNFC) return this.$toast('请选择NFC');

+ 39 - 16
src/views/menu/NFCmanage/index.vue

@@ -11,13 +11,14 @@
         <p class="card-title blue">{{disable?'标签信息':'新增标签'}}</p>
         <van-cell-group v-if="!disable" :border="false">
           <van-cell title="NFC编码" :value="formData.code" />
-<!--          <van-cell title="所属机构" value="内容" is-link/>-->
+          <van-field required label="标签名称" v-model="formData.labelName" placeholder="请输入" />
           <van-cell required title="选择所属机构" :label="formData.orgName" is-link  @click="clickItem"/>
           <select-cell required :disabled="areaList.length == 0" v-model="formData.areaId" title="选择区域" :border="true" :prop="props" :dataList="areaList"></select-cell>
           <select-cell required :disabled="pointList.length == 0" v-model="formData.checkId" title="选择采集点" :prop="checkProps" :dataList="pointList"></select-cell>
         </van-cell-group>
         <van-cell-group v-else :border="false">
           <van-cell title="NFC编码" :value="nfcInfo.code" />
+          <van-cell title="标签名称" :value="nfcInfo.labelName" />
           <van-cell title="所属机构" :value="nfcInfo.orgName" />
           <van-cell title="区域名称" :value="nfcInfo.areaName" />
           <van-cell title="采集点名称" :value="nfcInfo.collectionAreaName" />
@@ -69,11 +70,13 @@ export default {
       pointList:[],
       nfcInfo:{
         code:null,
+        labelName:'无',
         orgName: '无',
         areaName:'无',
         collectionAreaName:'无',
       },
       formData:{
+        labelName:'',
         orgName:'',
         code:null,
         orgId: null,
@@ -83,8 +86,8 @@ export default {
       flag:false,
     }
   },
-  mounted() {
-    window.openNFCScanCallBack = this.openNFCScanCallBack;
+  destroyed(){
+    window.openNFCScanCallBack = null;
   },
   computed:{
     ...mapGetters(['orgId']),
@@ -95,19 +98,22 @@ export default {
       //alert(data)
       this.nfcMsg = '读取中...';
       if(!data) {
-        this.nfcMsg = '点击扫描';
         this.$toast('扫描失败');
         //this.showPopup = false;
         return
       }
       let code = JSON.parse(data).content;
       this.$toast('扫描成功');
+      this.nfcInfo = {};
+      this.formData = {};
       nfcDetails(code).then(res=>{
-        console.log(res,'res')
+        //console.log(res,'res')
+        //alert(JSON.stringify(res))
         //this.showPopup = false;
-        setTimeout(()=>{this.nfcMsg = '点击扫描';},500);
+        setTimeout(()=>{this.nfcMsg = '将NFC贴至手机背部'},500);
         if(res.data){
           this.nfcInfo = res.data;
+          this.disable = true;
         }else {
           this.$toast('未查询到NFC相关信息');
           this.formData.code = code;
@@ -158,8 +164,13 @@ export default {
       })
     },
     getNfc(){
-     if(this.nfcMsg === '扫描中...') return;
-     this.useNFC();
+      window.openNFCScanCallBack = this.openNFCScanCallBack;
+      if(this.nfcMsg === '将NFC贴至手机背部'){
+        this.nfcMsg = '点击扫描';
+        window.openNFCScanCallBack = null;
+        return
+      }
+      this.useNFC();
     },
     changeOrg(selected){
       this.showPicker = false;
@@ -170,11 +181,16 @@ export default {
       this.getCheckList();
     },
     cancelPicker(){
+      if(this.nfcMsg === '将NFC贴至手机背部') return;
       this.showPicker = false;
     },
     checkData(){
       if(!this.formData.code){
-        this.$toast('请先扫描NFC标签');
+        this.$toast('先扫描NFC标签');
+        return false;
+      }
+      if(!this.formData.labelName){
+        this.$toast('请输入标签名称');
         return false;
       }
       if(!this.formData.orgId){
@@ -198,10 +214,14 @@ export default {
     useNFC(){
       let system = this.isAndroidOrIos();
       console.log(system,'system')
-      if(system === 3) return this.$toast('当前环境不支持');
+      if(system === 3){
+        this.$toast('当前环境不支持');
+        return
+      }
       const parms = {
         "iOS_SessionType":"0"
       };
+      this.nfcMsg = '将NFC贴至手机背部';
       if(system === 1){
         //android
         // 判断当前环境是是否存在 js桥 'sap'
@@ -215,13 +235,17 @@ export default {
           }
         }else {
           this.$toast('当前环境不支持');
+          this.nfcMsg = '点击扫描';
         }
       }
-
       if(system === 2){
         //ios
         // 判断 ios是否存在方法 preview
-        if(!window.webkit) return this.$toast('当前环境不支持');
+        if(!window.webkit) {
+          this.nfcMsg = '点击扫描';
+          this.$toast('当前环境不支持');
+          return;
+        }
         const fun = window.webkit.messageHandlers.hasOwnProperty('openNFCScan')
         if (fun) {
           window.webkit.messageHandlers.openNFCScan.postMessage(JSON.stringify(parms))
@@ -236,7 +260,6 @@ export default {
   .nfc-container{
     padding:0 20px 20px 20px;
     height: calc(100vh - 192px);
-    -border: 1px solid red;
     overflow: auto;
   }
   .card-title{
@@ -252,8 +275,8 @@ export default {
     padding:0 20px;
     margin-top:24px;
     >div{
-      width: 400px;
-      height: 400px;
+      width: 360px;
+      height: 360px;
       border-radius: 50%;
       display: flex;
       justify-content: center;
@@ -277,7 +300,7 @@ export default {
   }
 
   .nfc-btn {
-    margin: 50px;
+    margin: 40px;
     width: 32%;
     height: 48vh;
     background: linear-gradient(-45deg, #dae, #3c9, #09f, #66f);

+ 1 - 1
src/views/menu/problemItem/detail.vue

@@ -170,7 +170,7 @@
 import NavBar from '@/components/NavBar';
 import SelectCell from '@/components/selectCell';
 import DateCell from '@/components/dateCell';
-import Uploader from '@/components/upload/uploader';
+import Uploader from '@/components/upload/gxuploader.vue';
 import {taskDetails,confirm, confirmDissent, reform,} from "./api";
 import {formatDate} from "@/filters/filter";
 import { ImagePreview } from 'vant';

+ 92 - 10
src/views/menu/securityCheckRegister/detail.vue

@@ -39,7 +39,7 @@
                   </template>
                   <template #right-icon>
                     <img
-                      v-if="enable && item.nfcList && item.nfcList.length > 0"
+                      v-if="enable && nfcState(item)"
                       :src="require('../../../assets/svg/NFC.svg')"
                       class="nfc-icon"
                       @click="clickNFC(item.nfcList)"
@@ -123,7 +123,8 @@
     <!--    </van-image-preview>-->
 
     <!--  nfc弹窗  -->
-    <nfc-popup v-if="enable" ref="NfcPopup" @change="changeNfcImg"></nfc-popup>
+    <nfc-popup v-if="enable" ref="NfcPopup" @NFCCode="getCode" @change="changeNfcImg"></nfc-popup>
+    <nfc-popup v-if="enable" ref="NfcPopup" @checkNFC="checkNFC" @change="changeNfcImg"></nfc-popup>
   </div>
 
   <!--  添加检查内容  -->
@@ -134,8 +135,8 @@
 import NavBar from '@/components/NavBar'
 import SelectCell from '@/components/selectCell'
 import DateCell from '@/components/dateCell'
-import Uploader from '@/components/upload/uploader'
-import NfcPopup from '@/components/nfcPopup/more'
+import Uploader from '@/components/upload/gxuploader'
+import NfcPopup from '@/components/nfcPopup/gxmore'
 import AddCheck from './addCheck'
 import { registerDetail, registerSubmit } from './api'
 import { imgUrl } from '@/utils'
@@ -151,6 +152,7 @@ export default {
       activeNames: ['1'],
       //基本信息
       taskInfo: [],
+      //选中的nfc列表
       NFCList: [],
       //区域下检查内容列表
       checkList: [],
@@ -188,12 +190,93 @@ export default {
     this.id = this.$route.query.id
     this.getData()
   },
+  destroyed(){
+    window.openCameraCallBack = null;
+    window.openNFCScanCallBack = null;
+  },
   methods: {
+    checkNFC(){
+      this.useNFC();
+      this.$toast.loading({
+        duration: 0, // 持续展示 toast
+        position: 'top',
+        forbidClick: true,
+        message: '请靠近NFC标签,进行扫描!',
+      });
+
+      let second = 30;
+      this.timer = setInterval(() => {
+        second--;
+        if(!second){
+          this.$toast.clear();
+          clearInterval(this.timer);
+          this.$toast.fail({
+            message: '未扫描到任何信息!',
+          });
+        }
+      }, 1000);
+
+    },
+
+    openNFCScanCallBack(nfcStr){
+      clearInterval(this.timer);
+      let nfc = JSON.parse(nfcStr);
+      let nfcCode =  nfc.content;
+      this.checkNfcFilter(nfcCode);
+    },
+    checkNfcFilter(nfcCode){
+      let areaId = null;
+      let checkOk =  false;
+      this.nfcs.forEach(v => {
+        if(v.nfcCode === nfcCode){
+          areaId = v.areaId;
+          this.switchArea(areaId);
+          if(v.status === 1){
+            this.$toast.fail('NFC点位:' + v.nfcName + '已扫描,请勿重复扫描!');
+            throw new Error('NFC点位:' + v.nfcName + '已扫描,请勿重复扫描!');
+          }
+          v.status = 1
+          v.scanMethod = 2
+          v.submitTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
+          v.submitBy = this.id
+          this.$toast.success('NFC点位:' + v.nfcName + '扫描成功!');
+          checkOk = true;
+        }
+      });
+
+      if(checkOk){
+        this.yesNFCnums++
+        this.resumptionData.yesNFCNums++
+        this.resumptionData.noNFCNums--
+      }else{
+        this.$toast.fail(nfcCode + ",不在本次履职范围内!");
+      }
+      this.validateArea(areaId)
+    },
+    switchArea(areaId){
+      this.areas.forEach((area, i) => {
+        if (areaId === area.areaId) {
+          this.activeArea(area, i)
+        }
+      })
+    },
+
+
+    //是否显示nfc图标
+    nfcState(item){
+      if(item.nfcList && item.nfcList.length > 0){
+        return item.nfcList.some(v=>{
+          return v.status === 0
+        })
+      }
+      return false
+    },
     //格式化时间范围
     formatTime(start,end,format){
       format = format || 'YYYY-MM-DD'
       return `${this.dayjs(start).format(format)} ~ ${this.dayjs(end).format(format)}`;
     },
+    //插入检查项
     addItem(val) {
       console.log(val, 'list')
       if (!val) return
@@ -334,11 +417,9 @@ export default {
     },
     //点击NFC图标
     clickNFC(arr) {
-      //if(arr.length === 0) return;
-      // let arr = this.selectArea.nfclist.filter(item=>{
-      //   return item.status == 0;
-      // })
-      this.$refs.NfcPopup.show(arr)
+      this.NFCList = arr;
+      console.log(this.NFCList,'NFCList')
+      this.$refs.NfcPopup.show(arr);
     },
     //清空数据
     clearData() {
@@ -368,7 +449,8 @@ export default {
         }
       })
       console.log(this.selectArea.nfclist, this.nfcImage, 'nfcObj')
-    }
+    },
+
   }
 }
 </script>