From 1e84774c0c0752c61e60592e7f7fc1c0d25a1dab Mon Sep 17 00:00:00 2001
From: hanbaoshan <hanbaoshan@aiotlink.com>
Date: 星期二, 27 十月 2020 16:38:48 +0800
Subject: [PATCH] 首页加入算法

---
 src/components/subComponents/CardItem.vue |  120 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 69 insertions(+), 51 deletions(-)

diff --git a/src/components/subComponents/CardItem.vue b/src/components/subComponents/CardItem.vue
index 3c9791c..df55282 100644
--- a/src/components/subComponents/CardItem.vue
+++ b/src/components/subComponents/CardItem.vue
@@ -37,7 +37,7 @@
             background: getUrl(data.baseInfo[initialIndex].bwType)
           }"
         >
-          <b>{{ `${data.baseInfo[initialIndex].compareScore}%` }}</b>
+          <b>{{ data.baseInfo[initialIndex].compareScore | percentage }}</b>
         </div>
       </div>
     </div>
@@ -87,12 +87,8 @@
         @mouseenter="cardMouseenter($event)"
         @mouseleave="cardMouseleave($event)"
       >
-        <!-- <p :title="data.baseInfo[0].compareScore" class="score">
-          <span v-if="data.id">{{ data.compareScore }}%</span>
-          <span v-else>{{ data.baseInfo[0].compareScore }}%</span>
-        </p>-->
         <p>
-          <span class="fontStyle color222">{{ data.picDate }}</span>
+          <span class="fontStyle color222">{{ data.picDate | formatTime}}</span>
         </p>
         <p style="margin-bottom: 8px;">
           <span class="fontStyle color222">{{ data.cameraAddr }}</span>
@@ -137,7 +133,7 @@
               <span
                 class="fontStyle"
                 v-if="data.baseInfo[initialIndex].labels"
-              >/&nbsp;{{ data.baseInfo[initialIndex].labels.split("/")[1] }}</span>&nbsp;
+              >/&nbsp;{{ data.baseInfo[initialIndex].labels | idCard}}</span>&nbsp;
               <span
                 class="fontStyle"
                 v-if="data.baseInfo[initialIndex].monitorLevel"
@@ -163,7 +159,7 @@
               <span
                 class="fontStyle"
                 v-if="data.baseInfo[initialIndex].labels"
-              >/&nbsp;{{ data.baseInfo[initialIndex].labels.split("/")[1] }}</span>&nbsp;
+              >/&nbsp;{{ data.baseInfo[initialIndex].labels | idCard}}</span>&nbsp;
               <span
                 class="fontStyle"
                 v-if="data.baseInfo[initialIndex].monitorLevel"
@@ -200,7 +196,7 @@
           class="score"
           style="font-family: PingFangSC-Medium;font-size: 20px;color: #3D68E1;letter-spacing: 0.4px;"
         >
-          <span>{{ data.baseInfo[0].compareScore }}%</span>
+          <span>{{ data.baseInfo[0].compareScore | percentage}}</span>
         </p>
         <p
           :style="data.baseInfo[0].bwType == '0' ? 'font-size:12px;line-height:20px' : 'color:red;font-size:12px;line-height:20px'"
@@ -209,7 +205,7 @@
           <span>{{ data.baseInfo[0].targetName }}</span>&nbsp;&nbsp;
           <span
             v-if="data.baseInfo[0].labels"
-          >/&nbsp;{{ data.baseInfo[0].labels.split("/")[1] }}</span>
+          >/&nbsp;{{ data.baseInfo[0].labels | idCard}}</span>
         </p>
       </div>
       <div class="card-icon-box">
@@ -230,7 +226,7 @@
         @mouseleave="cardMouseleave($event)"
       >
         <p :title="data.picDate">
-          <span class="fontStyle color222">{{ data.picDate }}</span>
+          <span class="fontStyle color222">{{ data.picDate | formatTime }}</span>
         </p>
         <p :title="data.cameraAddr" style="margin-bottom: 8px;">
           <span class="fontStyle color222">{{ data.cameraAddr }}</span>
@@ -316,11 +312,11 @@
           v-if="VideoPhotoData.uploadType"
           style="font-family: PingFangSC-Medium;font-size: 20px;color: #3D68E1;letter-spacing: 0.4px;"
         >
-          <span v-if="data.id">{{ data.compareScore }}%</span>
-          <span v-else>{{ data.baseInfo[0].compareScore }}%</span>
+          <span v-if="data.id">{{ data.compareScore | percentage}}</span>
+          <span v-else>{{ data.baseInfo[0].compareScore | percentage}}</span>
         </p>
         <p :title="data.picDate">
-          <span class="fontStyle color222">{{ data.picDate }}</span>
+          <span class="fontStyle color222">{{ data.picDate | formatTime }}</span>
         </p>
         <p :title="data.cameraAddr" style="margin-bottom: 8px;">
           <span class="fontStyle color222">{{ data.cameraAddr }}</span>
@@ -362,15 +358,12 @@
           <div slot="content">
             <p v-for="(item,index) in data.baseInfo" :key="index+'base1'">
               <span class="fontStyle">{{item.tableName}}</span>&nbsp;
-              <span class="fontStyle" v-if="item.targetName !== ''">/&nbsp;{{item.targetName}}</span>&nbsp;
+              <span class="fontStyle" v-if="item.targetName.length">/&nbsp;{{item.targetName}}</span>&nbsp;
               <span
                 class="fontStyle"
-                v-if="item.labels !== '' && item.labels.split('/')[1] !== ''"
-              >/&nbsp;{{item.labels.split("/")[1]}}</span>&nbsp;
-              <span
-                class="fontStyle"
-                v-if="item.labels !== '' && item.labels.split('/')[0] !== ''"
-              >/&nbsp;{{item.labels.split("/")[0]}}</span>
+                v-if="item.labels.length"
+              >/&nbsp;{{item.labels | idCard}}</span>&nbsp;
+              <span class="fontStyle" v-if="item.labels.length">/&nbsp;{{item.labels | sex}}</span>
             </p>
           </div>
           <el-button
@@ -382,15 +375,12 @@
               :style="item.bwType == '1' ? 'color:red;font-size:12px;line-height:20px':'font-size:12px;line-height:20px'"
             >
               <span class="fontStyle">{{item.tableName}}</span>&nbsp;
-              <span class="fontStyle" v-if="item.targetName !== ''">/&nbsp;{{item.targetName}}</span>&nbsp;
+              <span class="fontStyle" v-if="item.targetName.length">/&nbsp;{{item.targetName}}</span>&nbsp;
               <span
                 class="fontStyle"
-                v-if="item.labels !== '' && item.labels.split('/')[1] !== ''"
-              >/&nbsp;{{item.labels.split("/")[1]}}</span>&nbsp;
-              <span
-                class="fontStyle"
-                v-if="item.labels !== '' && item.labels.split('/')[0] !== ''"
-              >/&nbsp;{{item.labels.split("/")[0]}}</span>
+                v-if="item.labels.length"
+              >/&nbsp;{{item.labels | idCard}}</span>&nbsp;
+              <span class="fontStyle" v-if="item.labels.length">/&nbsp;{{item.labels |sex }}</span>
             </span>
           </el-button>
         </el-tooltip>
@@ -469,7 +459,7 @@
         >
           <div>
             <p :title="data.picDate">
-              <span class="fontStyle color222">{{ data.picDate }}</span>
+              <span class="fontStyle color222">{{ data.picDate | formatTime }}</span>
             </p>
             <p :title="data.cameraAddr" style="margin-bottom: 8px;">
               <span class="fontStyle color222">{{ data.cameraAddr }}</span>
@@ -488,6 +478,22 @@
 </template>
 
 <script>
+Date.prototype.Format = function (fmt) {
+  var o = {
+    "M+": this.getMonth() + 1, //鏈堜唤 
+    "d+": this.getDate(), //鏃� 
+    "H+": this.getHours(), //灏忔椂 
+    "m+": this.getMinutes(), //鍒� 
+    "s+": this.getSeconds(), //绉� 
+    "q+": Math.floor((this.getMonth() + 3) / 3), //瀛e害 
+    "S": this.getMilliseconds() //姣 
+  };
+  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+  for (var k in o)
+    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+  return fmt;
+}
+
 export default {
   mounted() {
     window.addEventListener("resize", this.watchWindow);
@@ -502,19 +508,34 @@
       default: "search"
     }
   },
-  watch: {
-    data: {
-      handler(val, oldVal) {
-        console.log('鏁版嵁鍙戠敓鍙樺寲')
-        this.$forceUpdate()
-      },
-      deep: true
-    }
-  },
   computed: {
     isId() {
       return this.data.id
     }
+  },
+  filters: {
+    formatTime(t) {
+      return new Date(t).Format("yyyy-MM-dd HH:mm:ss")
+    },
+    percentage(score) {
+      return score.toFixed(2) + "%"
+    },
+    idCard(v) {
+      try {
+        let obj = JSON.parse(v)
+        return obj.idCard
+      } catch (error) {
+        return v.split("/")[1]
+      }
+    },
+    sex(v) {
+      try {
+        let obj = JSON.parse(v)
+        return obj.sex
+      } catch (error) {
+        return v.split("/")[0]
+      }
+    },
   },
   data() {
     return {
@@ -525,17 +546,15 @@
       overflowState: true
     };
   },
+  watch: {
+    data: {
+      handler(val, oldVal) {
+        this.$forceUpdate()
+      },
+      deep: true
+    }
+  },
   methods: {
-    watchWindow() {
-      // console.log('height')
-      // this.$nextTick(() => {
-      //   document.querySelectorAll('.compareScore111').forEach(ele => {
-      //     ele.style.bottom = this.getBottom()
-      //     console.log("鍏冪礌鐨勬牱寮忓�硷細",ele.style.bottom)
-      //   }); 
-      //   this.$forceUpdate()
-      // })
-    },
     getBottom() {
       // let imgDom = document.getElementById(str)
       let imgDom = this.$refs.firstImg
@@ -568,7 +587,6 @@
       this.$emit("detailsClick", ev);
     },
     toAdd(item) {
-      console.log("瑙﹀彂鍔犲叆搴曞簱")
       this.$emit("addToBase", item);
     },
     tosearch(item) {
@@ -578,9 +596,9 @@
       if (!item.id || item.id == "") {
         compType = 0 // 鏁版嵁鏉ヨ嚜浜庡簳搴�
       }
-      // window.open(href + '?showType=findByPic&targetId=' + captureId + '&picSmUrl=' + url + '&compType=' + compType)
 
-      let message = 'toSearch?showType=findByPic&targetId=' + captureId + '&picSmUrl=' + imgUrl + '&compType=' + compType;
+      let message = 'toSearch?showType=findByPic&targetId=' + captureId + '&picSmUrl=' + imgUrl + '&compType=' + compType + '&timestamp=' + new Date().getTime();
+      //let message = 'toSearch?showType=findByPic&targetId=' + captureId + '&picSmUrl=' + imgUrl + '&compType=' + compType;
       window.parent.postMessage({
         msg: message
       }, "*")

--
Gitblit v1.8.0