gaoxiong před 2 roky
rodič
revize
fb21da2780

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

@@ -27,7 +27,7 @@
           </div>
         </div>
       </div>
-      <input v-show="false" ref="upload"  type='file' accept="image/*" capture="camera" @click="useCamera(1)"/>
+      <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>

+ 3 - 0
src/components/upload/gxuploader.vue

@@ -4,7 +4,10 @@
           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"/>

+ 111 - 82
src/views/menu/resumption/detail.vue

@@ -16,11 +16,11 @@
                 </div>
               </van-col>
               <van-col span="12">
-                <div class="total_panel" @click="showDetail()">
+                <div class="total_panel" @click="showDetail(1)">
                   <div class="title">NFC</div>
                   <div class="content">
-                    <span class="con_num ok">已扫 {{ resumptionData.yesNFCNums }}</span>
-                    <span class="con_num no">未扫 {{ resumptionData.noNFCNums }}</span>
+                    <span class="con_num ok">已扫 {{ yesList.length }}</span>
+                    <span class="con_num no">未扫 {{ noList.length}}</span>
                   </div>
                 </div>
               </van-col>
@@ -32,11 +32,11 @@
         <van-progress
           :percentage="
             (
-              ((resumptionData.yesPointNums + resumptionData.yesNFCNums) /
+              ((resumptionData.yesPointNums + yesList.length) /
                 (resumptionData.yesPointNums +
                   resumptionData.noPointNums +
-                  resumptionData.yesNFCNums +
-                  resumptionData.noNFCNums)) *
+                  yesList.length +
+                  noList.length)) *
               100
             ).toFixed(2)
           "
@@ -64,18 +64,18 @@
       <van-action-sheet v-model="total_show">
         <div class="content">
           <van-tabs>
-            <van-tab title="已扫描" name="a">
+            <van-tab title="未扫描" name="b">
               <van-list finished-text="没有更多了" @load="onLoad">
-                <van-cell v-for="item in yesList" :key="item.nfcCode" :title="item.nfcName">
-                  <span>{{item.pointScan === 1?'必扫':'可选'}}</span>
+                <van-cell v-for="item in sheetNoList" :key="item.nfcCode" :label="areasMap[item.areaId] " :title="item.nfcName">
+                  <!-- <img :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon"/>-->
+                  <span style="color: red">{{item.pointScan === 1?'必扫':'非必扫'}}</span>
                 </van-cell>
               </van-list>
             </van-tab>
-            <van-tab title="未扫描" name="b">
+            <van-tab title="已扫描" name="a">
               <van-list finished-text="没有更多了" @load="onLoad">
-                <van-cell v-for="item in noList" :key="item.nfcCode" :title="item.nfcName">
-                  <!-- <img :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon"/>-->
-                  <span>{{item.pointScan === 1?'必扫':'可选'}}</span>
+                <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>
                 </van-cell>
               </van-list>
             </van-tab>
@@ -86,15 +86,17 @@
       <div class="card">
         <van-row>
           <van-col span="16">
-            <van-cell>
+            <van-cell @click="showDetail(0)">
               <template #title>
                 <span>NFC</span>
               </template>
               <template #extra>
-                <span style="display: inline-block; color: #26850c">{{ yesNFCnums }}</span>
-                <span style="display: inline-block; color: #0e0e0e">/</span>
-                <span style="display: inline-block; color: #0e0e0e">{{ NFCnums }}</span>
-                <img :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon" @click="clickNFC" />
+                <div>
+                  <span style="display: inline-block; color: #26850c">{{ areaYesList.length }}</span>
+                  <span style="display: inline-block; color: #0e0e0e">/</span>
+                  <span style="display: inline-block; color: #0e0e0e">{{ areaNoList.length }}</span>
+                </div>
+                <img :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon"  />
               </template>
             </van-cell>
           </van-col>
@@ -213,10 +215,13 @@
 
       <div class="bottomClass" v-if="enable">
         <van-row>
-          <van-col span="12">
+          <van-col span="8">
+            <van-button type="primary" @click="clickNFC">扫描NFC</van-button>
+          </van-col>
+          <van-col span="8">
             <van-button type="default" @click="resumptionDataSave">保存</van-button>
           </van-col>
-          <van-col span="12">
+          <van-col span="8">
             <van-button type="info" @click="submitResumptionData">提交</van-button>
           </van-col>
         </van-row>
@@ -266,6 +271,7 @@ export default {
       areaId: null,
       resumptionData: {},
       areas: [],
+      areasMap: {},
       checks: [],
       nfcs: [],
       selectRadio: 0,
@@ -275,6 +281,10 @@ export default {
       dayList: [15, 30, 90, 180],
       yesList: [],
       noList: [],
+      areaYesList:[],
+      areaNoList:[],
+      sheetYesList: [],
+      sheetNoList: [],
       loading: false,
       finished: false,
       selectArea: null,
@@ -356,12 +366,8 @@ export default {
           checkOk = true;
         }
       });
-
-      if(checkOk){
-        this.yesNFCnums++
-        this.resumptionData.yesNFCNums++
-        this.resumptionData.noNFCNums--
-      }else{
+      this.updateNFC(1,nfcCode);
+      if(!checkOk){
         this.$toast.fail(nfcCode + ",不在本次履职范围内!");
       }
       this.validateArea(areaId)
@@ -441,11 +447,17 @@ export default {
         this.checks = res.data.checks
         this.nfcs = res.data.nfcs
         this.areas = res.data.areas
+        let obj = {};
+        res.data.areas.forEach(function(v,i){
+          obj[v.areaId] = v.areaName;
+        });
+        this.areasMap = obj;
         this.activeArea(this.areas[0], 0)
 
         if (!this.enable) {
           this.openCollapseItems()
         }
+        this.updateNFC(0);
       })
     },
     openCollapseItems() {
@@ -480,7 +492,6 @@ export default {
       let yes = 0
       this.checks.forEach(item => {
         let pointList = item.points
-
         pointList.forEach(point => {
           if (item.areaId === areaId) {
             total++
@@ -490,15 +501,10 @@ export default {
           }
         })
       })
-
-      let noNfc = this.nfcs.filter((item, index) => {
-        return item.areaId === areaId && item.status === 0
-      })
-
       let areaStatus = '0'
-      if (total === yes && noNfc.length === 0) {
+      if (total === yes && this.areaNoList.length === 0) {
         areaStatus = '1'
-      } else if (yes === 0 && noNfc.length === this.NFCnums) {
+      } else if (yes === 0 && this.areaNoList.length === this.NFCnums) {
         areaStatus = '0'
       } else {
         areaStatus = '2'
@@ -527,58 +533,80 @@ export default {
       }
     },
     cancelImg(imgItem) {
-      let areaId = null
-      this.nfcs.forEach(v => {
-        if (v.nfcCode === imgItem.nfcCode) {
-          areaId = v.areaId
-          v.img = imgItem.url
-          v.status = 0
-          v.scanMethod = null
-        }
-      })
-      let now = this.currentImgNFC.filter(v => {
-        return v.nfcCode !== imgItem.nfcCode
-      })
-      this.currentImgNFC = now
-
-      this.yesNFCnums--
-      this.resumptionData.yesNFCNums--
-      this.resumptionData.noNFCNums++
-      this.validateArea(areaId)
+      this.updateNFC(2,imgItem.nfcCode,imgItem);
+      this.validateArea(this.areaId)
     },
     changeNfcImg(imgItem) {
-      let areaId = null
-      this.nfcs.forEach(v => {
-        if (v.nfcCode === imgItem.nfcCode) {
-          areaId = v.areaId
-          v.img = imgItem.url
-          v.status = 1
-          v.scanMethod = 1
-          v.submitTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
-          v.submitBy = this.id
-          this.currentImgNFC.push(v)
+      this.updateNFC(1,imgItem.nfcCode,imgItem);
+      this.validateArea(this.areaId);
+    },
+    updateNFC(type,nfcCode,imgItem){
+      //type 1 表示新增加扫描的数据,2 表示新增未扫描的数量,0 未做任何操作
+      //nfcCode 代表扫描和减少的nfc数据。
+      //更新全局nfc已扫描 和未扫描
+      this.yesList = [];
+      this.noList = [];
+      this.areaYesList = [];
+      this.areaNoList = [];
+      this.nfcs.forEach(item => {
+        if(type === 1){
+          //新增扫描到的标签
+          if(nfcCode === item.nfcCode){
+            item.status = 1
+            item.scanMethod = 1
+            item.submitTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
+            item.submitBy = this.id
+            if(imgItem){
+              //拍照NFC特殊处理
+              item.img = imgItem.url
+              this.currentImgNFC.push(item)
+            }
+          }
         }
-      })
-      this.yesNFCnums++
-      this.resumptionData.yesNFCNums++
-      this.resumptionData.noNFCNums--
-      this.validateArea(areaId)
+        if(type === 2){
+          //新增未扫描的标签
+          if(nfcCode === item.nfcCode){
+            item.status = 0
+            item.scanMethod = null
+            item.submitTime = null
+            item.submitBy = null
+            if(item.img){
+              //拍照NFC特殊处理
+              item.img = null;
+              this.currentImgNFC = this.currentImgNFC.filter(v => {
+                return v.nfcCode !== item.nfcCode
+              })
+            }
+          }
+        }
+        //扫描到nfc
+        if(item.status === 1){
+          this.yesList.push(item);
+          if(this.areaId === item.areaId){
+            this.areaYesList.push(item);
+          }
+        }else{
+          this.noList.push(item);
+          if(this.areaId === item.areaId){
+            this.areaNoList.push(item);
+          }
+        }
+
+      });
+
     },
-    showDetail() {
+    showDetail(data) {
+      if(data === 1){
+        this.sheetYesList = this.yesList;
+        this.sheetNoList = this.noList;
+      }else{
+        this.sheetNoList = this.areaNoList;
+        this.sheetYesList = this.areaYesList;
+      }
       this.total_show = true
     },
     onLoad() {
-      // 异步更新数据
-      // setTimeout 仅做示例,真实场景中一般为 ajax 请求
-      this.yesList = []
-      this.noList = []
-      this.nfcs.forEach((item, index) => {
-        if (item.status === 1) {
-          this.yesList.push(item)
-        } else {
-          this.noList.push(item)
-        }
-      })
+
     },
     //点击区域
     clickArea(area, index) {
@@ -588,6 +616,7 @@ export default {
     activeArea(area, index) {
       //获取当前选中区域
       this.areaId = area.areaId
+      this.updateNFC(0);
       //设置选中样式
       this.$nextTick(() => {
         let doms = document.getElementsByClassName('check-area')
@@ -597,15 +626,15 @@ export default {
         doms[index].classList.add('active')
       })
       let nfcs = 0
-      let yesNfc = 0
       let current = []
+      let yesNum = 0;
       for (let i = 0; i < this.nfcs.length; i++) {
         let nfc = this.nfcs[i]
         let areaId = nfc.areaId
         if (areaId === area.areaId) {
           nfcs++
           if (nfc.status === 1) {
-            yesNfc++
+            yesNum++;
           }
           if (nfc.img) {
             current.push(nfc)
@@ -613,7 +642,7 @@ export default {
         }
       }
       this.currentImgNFC = current
-      this.yesNFCnums = yesNfc
+      this.yesNFCnums = yesNum;
       this.NFCnums = nfcs
       this.selectArea = area
     },

+ 4 - 0
src/views/menu/resumption/list.vue

@@ -261,6 +261,10 @@ export default {
       this.date = val;
       this.getDatalist();
     },
+  },
+  destroyed(){
+    window.openCameraCallBack = null;
+    window.openNFCScanCallBack = null;
   }
 }
 </script>