Prechádzať zdrojové kódy

器件选型类型筛选做降序。

ouxq 8 rokov pred
rodič
commit
970de15f9e
1 zmenil súbory, kde vykonal 14 pridanie a 16 odobranie
  1. 14 16
      components/product/CategoryProperty.vue

+ 14 - 16
components/product/CategoryProperty.vue

@@ -82,6 +82,19 @@
 </template>
 
 <script>
+  function compare (propertyName) {
+    return function (object1, object2) {
+      var value1 = object1[propertyName]
+      var value2 = object2[propertyName]
+      if (value1 > value2) {
+        return 1
+      } else if (value1 < value2) {
+        return -1
+      } else {
+        return 0
+      }
+    }
+  }
   export default {
     layout: 'main',
     data () {
@@ -104,11 +117,6 @@
 //        console.log(id)
 //      }
     },
-    filters: {
-      sortText: function (text) {
-        return text.sort()
-      }
-    },
     computed: {
       kind () {
         return this.$store.state.product.kind.kindsParentWithBother.data[this.$store.state.product.kind.kindsParentWithBother.data.length - 1]
@@ -128,17 +136,6 @@
       }
     },
     methods: {
-      triggerOnMouseEnter (id) {
-        console.log(id)
-        let toggles = document.getElementsByClassName('x-split-dropdown-toggle')
-        for (let i in toggles) {
-          console.log(toggles[i])
-          let toggleId = toggles[i].getAttribute('split-dropdown-toggle')
-          if (toggleId === id) {
-            console.log(toggles[i])
-          }
-        }
-      },
       selectBrand (item) {
         this.selectedBrand = item
         console.log(this.JSONObj)
@@ -176,6 +173,7 @@
       },
       use_exp_list: function (pro, index) {
         this.selectedProperties = pro
+        this.selectedProperties.values.sort(compare('value'))
         let dom = document.getElementsByClassName('drop-down-list')[0]
         let list = document.getElementsByClassName('list-menu')[index]
         let content = document.getElementsByClassName('container')[0]