소스 검색

Merge branch 'V0.0.2' of http://10.87.10.227:4000/jzyd_yyds/soc_app into V0.0.2

coys 2 년 전
부모
커밋
9a30c4cd08

+ 1 - 2
src/components/nfcPopup/gxmore.vue

@@ -27,7 +27,6 @@
           </div>
         </div>
       </div>
-      <input v-show="false" ref="upload"  type='file' accept="image/*"  capture="camera" @change="fileChange" @click="useCamera(1)"/>
 <!--      <input v-show="false" ref="upload"  type='file' accept="image/*" capture="camera" @change="fileChange"/>-->
     </van-popup>
   </div>
@@ -217,7 +216,7 @@ export default {
     nfcTakePhotos(){
       this.file = null;
       this.imageError = null;
-      this.$refs.upload.click();
+      this.useCamera(1);
     },
   }
 }

+ 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');

+ 170 - 158
src/components/upload/gxuploader.vue

@@ -1,186 +1,198 @@
 <template>
-    <div>
-        <van-uploader
-          ref="uploader"
-          v-bind="$attrs"
-          v-model="fileList"
-          :before-read="beforeRead"
-          :after-read="afterRead"
-          @click-upload="useCamera(1)"
-          capture="camera"
-          :max-count="maxCount"
-          @delete="deleteHandler"
-          :max-size="maxSize * 1024*1024"/>
+  <div>
+    <div id="upload-gx" style="float: left">
+      <van-uploader
+        ref="uploader"
+        v-bind="$attrs"
+        v-model="fileList"
+        :before-read="beforeRead"
+        :after-read="afterRead"
+        :max-count="maxCount"
+        @delete="deleteHandler"
+        :show-upload="false"
+        :max-size="maxSize * 1024*1024"/>
     </div>
+    <div  class="van-uploader__upload" @click="useCamera(1)">
+      <i class="van-icon van-icon-photograph van-uploader__upload-icon">
+      </i>
+    </div>
+  </div>
 </template>
 <script>
 import {upload, uploadBase64} from "@/api/public";
 import ImageCompressor from "js-image-compressor";
 import {imgUrl} from "@/utils";
-export default {
-    props:{
-      value:{
-        type: Array,
-      },
-      //最大上传数量
-      maxCount:{
-        type: Number,
-        default: 6,
-      },
-      //文件大小,单位MB
-      maxSize:{
-        type: Number,
-        default: 5,
-      },
 
+export default {
+  props: {
+    value: {
+      type: Array,
+    },
+    //最大上传数量
+    maxCount: {
+      type: Number,
+      default: 6,
     },
-    data() {
-      return {
-        //组件显示用
-        fileList:[],
-        //上传之后的图片列表,双向绑定之后覆盖fileList
-        imageList:[]
-      };
+    //文件大小,单位MB
+    maxSize: {
+      type: Number,
+      default: 5,
     },
 
-    mounted() {
+  },
+  data() {
+    return {
+      //组件显示用
+      fileList: [],
+      //上传之后的图片列表,双向绑定之后覆盖fileList
+      imageList: []
+    };
+  },
 
-    },
-    watch:{
-      value:{
-        handler(val){
-          if(!val || val.length === 0) {
-            this.imageList = [];
-            return
-          }
-          this.fileList = val.map(v=>{
-            v.url = imgUrl(v.imgPath);
-            return v
-          })
-          this.imageList = JSON.parse(JSON.stringify(this.fileList));
-        },
-        immediate:true
-      }
-    },
-    methods: {
-      openCameraCallBack(data){
-        let img =  JSON.parse(data);
-        this.content = data;
-        let params = {
-          extension:img.extension,
-          content:img.content,
+  mounted() {
 
+  },
+  watch: {
+    value: {
+      handler(val) {
+        if (!val || val.length === 0) {
+          this.imageList = [];
+          return
         }
-        uploadBase64(params).then(res=>{
-          /*上传成功*/
-          this.$toast.success('上传成功')
-          this.imageList.push({ name: res.data.name, url: imgUrl(res.data.url),imgPath:res.data.url});
-          this.$emit('input',this.imageList)
-        }).catch((err) => {
-          /*上传失败*/
-          this.$toast.fail('上传失败')
-          this.fileList.splice(this.fileList.length-1,1);
-        });
+        this.fileList = val.map(v => {
+          v.url = imgUrl(v.imgPath);
+          return v
+        })
+        this.imageList = JSON.parse(JSON.stringify(this.fileList));
       },
-      useCamera(actionType){
-        window.openCameraCallBack = null;
-        window.openCameraCallBack = this.openCameraCallBack;
-        let parms = {};
-        if(actionType){
-          parms.actionType = actionType;
-        }
-        let system = this.isAndroidOrIos();
-        if(system === 1){
-          //android
-          // 判断当前环境是是否存在 js桥 'sap'
-          const hasSap = window.hasOwnProperty('sap');
-          if (hasSap) {
-            // 判断是否存在方法 ?preview
-            const fun = sap.hasOwnProperty('openCamera');
-            if (fun) {
-              sap.openCamera(JSON.stringify(parms));
-            }
-          }
-        }
+      immediate: true
+    }
+  },
+  methods: {
+    openCameraCallBack(data) {
+      let img = JSON.parse(data);
+      this.content = data;
+      let params = {
+        extension: img.extension,
+        content: img.content,
 
-        if(system === 2){
-          //ios
-          // 判断 ios是否存在方法 preview
-          const preview = window.webkit.messageHandlers.hasOwnProperty('openCamera')
-          if (preview) {
-            window.webkit.messageHandlers.openCamera.postMessage(JSON.stringify(parms))
+      }
+      uploadBase64(params).then(res => {
+        /*上传成功*/
+        this.$toast.success('上传成功')
+        this.imageList.push({name: res.data.name, url: imgUrl(res.data.url), imgPath: res.data.url});
+        this.$emit('input', this.imageList)
+      }).catch((err) => {
+        /*上传失败*/
+        this.$toast.fail('上传失败')
+        this.fileList.splice(this.fileList.length - 1, 1);
+      });
+    },
+    useCamera(actionType) {
+      window.openCameraCallBack = null;
+      window.openCameraCallBack = this.openCameraCallBack;
+      let parms = {};
+      if (actionType) {
+        parms.actionType = actionType;
+      }
+      let system = this.isAndroidOrIos();
+      if (system === 1) {
+        //android
+        // 判断当前环境是是否存在 js桥 'sap'
+        const hasSap = window.hasOwnProperty('sap');
+        if (hasSap) {
+          // 判断是否存在方法 ?preview
+          const fun = sap.hasOwnProperty('openCamera');
+          if (fun) {
+            sap.openCamera(JSON.stringify(parms));
           }
         }
-      },
-      isAndroidOrIos(){
-        const urls = navigator.userAgent;
-        let isAndroid = urls.indexOf('Android') > -1 || urls.indexOf('Linux') > -1;
-        let isIos = !!urls.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
-        if(isAndroid){
-          return 1;
-        }
-        if(isIos){
-          return 2;
+      }
+
+      if (system === 2) {
+        //ios
+        // 判断 ios是否存在方法 preview
+        const preview = window.webkit.messageHandlers.hasOwnProperty('openCamera')
+        if (preview) {
+          window.webkit.messageHandlers.openCamera.postMessage(JSON.stringify(parms))
         }
-      },
-      //上传前压缩
-      beforeRead(file){
-        console.log(file,'图片压缩前')
-        return new Promise((resolve, reject) => {
-            new ImageCompressor({
-              file,
-              quality: 0.6,
-              success: (result) => {
-                //this.$toast('图片压缩成功')
-                console.log(result,'图片压缩后')
-                let imgFile = new File([result], result.name, {
-                  width: result.width,
-                  height: result.height,
-                  type: result.type,
-                });
-                console.log(imgFile,'后')
-                resolve(imgFile);
-              },
-              error: (e) => {
-                console.log('imageError:'+e);
-                this.$toast('图片压缩失败')
-                reject(e);
-              },
+      }
+    },
+    isAndroidOrIos() {
+      const urls = navigator.userAgent;
+      let isAndroid = urls.indexOf('Android') > -1 || urls.indexOf('Linux') > -1;
+      let isIos = !!urls.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
+      if (isAndroid) {
+        return 1;
+      }
+      if (isIos) {
+        return 2;
+      }
+    },
+    //上传前压缩
+    beforeRead(file) {
+      console.log(file, '图片压缩前')
+      return new Promise((resolve, reject) => {
+        new ImageCompressor({
+          file,
+          quality: 0.6,
+          success: (result) => {
+            //this.$toast('图片压缩成功')
+            console.log(result, '图片压缩后')
+            let imgFile = new File([result], result.name, {
+              width: result.width,
+              height: result.height,
+              type: result.type,
             });
+            console.log(imgFile, '后')
+            resolve(imgFile);
+          },
+          error: (e) => {
+            console.log('imageError:' + e);
+            this.$toast('图片压缩失败')
+            reject(e);
+          },
         });
-      },
-      //上传到服务器
-      afterRead(fileObj){
-        let formData = new FormData();
-        formData.append("file", fileObj.file);
-        upload(formData, "image").then((res) => {
-          /*上传成功*/
-          this.$toast.success('上传成功')
-          this.imageList.push({ name: res.data.name, url: imgUrl(res.data.url),imgPath:res.data.url});
-          this.$emit('input',this.imageList)
-        }).catch((err) => {
-          /*上传失败*/
-          this.$toast.fail('上传失败')
-          this.fileList.splice(this.fileList.length-1,1);
-        });
-      },
-      //删除
-      deleteHandler(){
-        let imageList=JSON.parse(JSON.stringify(this.fileList));
-        console.log(imageList,'imageList')
-        this.$emit('input',imageList)
-      }
+      });
     },
-    model:{
-      prop:'value',
-      event:'input'
+    //上传到服务器
+    afterRead(fileObj) {
+      let formData = new FormData();
+      formData.append("file", fileObj.file);
+      upload(formData, "image").then((res) => {
+        /*上传成功*/
+        this.$toast.success('上传成功')
+        this.imageList.push({name: res.data.name, url: imgUrl(res.data.url), imgPath: res.data.url});
+        this.$emit('input', this.imageList)
+      }).catch((err) => {
+        /*上传失败*/
+        this.$toast.fail('上传失败')
+        this.fileList.splice(this.fileList.length - 1, 1);
+      });
+    },
+    //删除
+    deleteHandler() {
+      let imageList = JSON.parse(JSON.stringify(this.fileList));
+      console.log(imageList, 'imageList')
+      this.$emit('input', imageList)
     }
+  },
+  model: {
+    prop: 'value',
+    event: 'input'
+  }
 };
 </script>
 <style lang="scss" scoped>
-  .upload-text{
-    font-size: 18px;
-    color: #999;
-    margin-top: 5px;
+.upload-text {
+  font-size: 18px;
+  color: #999;
+  margin-top: 5px;
+}
+#upload-gx{
+  .van-uploader{
+
   }
+
+}
 </style>

+ 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';

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

@@ -75,7 +75,7 @@
             <van-tab title="已扫描" name="a">
               <van-list finished-text="没有更多了" @load="onLoad">
                 <van-cell v-for="item in sheetYesList" :key="item.nfcCode"  :label="areasMap[item.areaId]" :title="item.nfcName">
-                  <span style="color: green">{{item.pointScan === 1?'必扫':'可选'}}</span>
+                  <span style="color: green">已完成</span>
                 </van-cell>
               </van-list>
             </van-tab>

+ 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>