Bläddra i källkod

领域只有一个时不显示筛选项目

xiaohaizhao 1 år sedan
förälder
incheckning
503c87bf6a
2 ändrade filer med 38 tillägg och 37 borttagningar
  1. 14 11
      packageA/orderForm/index.js
  2. 24 26
      pages/index/market/index.js

+ 14 - 11
packageA/orderForm/index.js

@@ -21,14 +21,6 @@ Page({
       }, {
         value: "特殊订单"
       }]
-    }, {
-      label: "领域",
-      index: null,
-      showName: "tradefield", //显示字段
-      valueKey: "tradefield", //返回Key
-      selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
-      value: "", //选中值
-      list: []
     }]
   },
   onLoad(options) {
@@ -162,9 +154,20 @@ Page({
       }
     }, false).then(res => {
       console.log("获取领域", res)
-      if (res.msg == '成功') this.setData({
-        "filtratelist[1].list": res.data
-      });
+      if (res.msg == '成功' && res.data.length > 1) {
+        this.data.filtratelist.push({
+          label: "领域",
+          index: null,
+          showName: "tradefield", //显示字段
+          valueKey: "tradefield", //返回Key
+          selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
+          value: "", //选中值
+          list: res.data
+        })
+        this.setData({
+          filtratelist: this.data.filtratelist
+        });
+      }
     })
   },
   /* 设置页面高度 */

+ 24 - 26
pages/index/market/index.js

@@ -18,29 +18,7 @@ Component({
     CustomBar: getApp().globalData.CustomBar,
     typeList: [],
     list: [],
-    filtratelist: [{
-      label: "领域",
-      index: 0,
-      showName: "tradefield", //显示字段
-      valueKey: "tradefield", //返回Key
-      selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
-      value: "", //选中值
-      list: [{
-        rowindex: 0,
-        subvalues: [],
-        sys_enterprise_tradefieldid: 0,
-        tradefield: "全部"
-      }]
-    }, {
-      label: "营销分类",
-      index: 0,
-      type: "multilevelClass",
-      showName: "itemclassname", //显示字段
-      valueKey: "itemclassid", //返回Key
-      selectKey: "itemclassid", //传参 代表选着字段 不传参返回整个选择对象
-      value: "", //选中值
-      list: []
-    }]
+    filtratelist: []
   },
   methods: {
     init() {
@@ -108,8 +86,18 @@ Component({
             itemclassname: "全部",
             subdep: []
           })
+          this.data.filtratelist.push({
+            label: "营销分类",
+            index: 0,
+            type: "multilevelClass",
+            showName: "itemclassname", //显示字段
+            valueKey: "itemclassid", //返回Key
+            selectKey: "itemclassid", //传参 代表选着字段 不传参返回整个选择对象
+            value: "", //选中值
+            list: res.data[0].ttemclass
+          })
           this.setData({
-            ['filtratelist[1].list']: res.data[0].ttemclass
+            filtratelist: this.data.filtratelist
           });
         }
         this.getList(true);
@@ -146,6 +134,7 @@ Component({
       content.where.condition = detail;
       this.getList(true)
     },
+
     /* 获取领域 */
     getTradefie() {
       _Http.basic({
@@ -160,15 +149,24 @@ Component({
         }
       }, false).then(res => {
         console.log("获取领域", res)
-        if (res.msg == '成功') {
+        if (res.msg == '成功' && res.data.length > 1) {
           res.data.unshift({
             rowindex: 0,
             subvalues: [],
             sys_enterprise_tradefieldid: 0,
             tradefield: "全部"
           })
+          this.data.filtratelist.unshift({
+            label: "领域",
+            index: 0,
+            showName: "tradefield", //显示字段
+            valueKey: "tradefield", //返回Key
+            selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
+            value: "", //选中值
+            list: res.data
+          })
           this.setData({
-            'filtratelist[0].list': res.data
+            filtratelist: this.data.filtratelist
           });
         }
       })