ソースを参照

选择产品添加筛选

zhaoxiaohai 2 年 前
コミット
748a5d8c91

+ 143 - 1
packageA/select/product/select.js

@@ -8,6 +8,33 @@ Page({
         radio: false, //是否为单选
         idname: "itemid", //idkey
         showName: "itemname", //表单用 显示名称
+        filtrate: false,
+        filtratelist: [{
+            label: "品牌",
+            index: null,
+            showName: "brandname", //显示字段
+            valueKey: "sa_brandid", //返回Key
+            selectKey: "sa_brandid", //传参 代表选着字段 不传参返回整个选择对象
+            value: "", //选中值
+            interrupt: true,
+            list: null
+        }, {
+            label: "标准",
+            index: null,
+            showName: "value", //显示字段
+            valueKey: "value", //返回Key
+            selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
+            value: "", //选中值
+            list: null
+        }, {
+            label: "领域",
+            index: null,
+            showName: "tradefield", //显示字段
+            valueKey: "tradefield", //返回Key
+            selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
+            value: "", //选中值
+            list: null
+        }]
     },
     onLoad(options) {
         if (options.params) {
@@ -135,5 +162,120 @@ Page({
     onUnload() {
         //回收数据
         getApp().globalData.handleSelect = null;
-    }
+    },
+    async openFiltrate() {
+        if (this.data.filtratelist[0].list == null) {
+            let res = await Promise.all([this.getBrand(), this.getitemstandards(), this.gettradefields()]);
+            console.log(res)
+            res.forEach((v, i) => this.data.filtratelist[i].list = v.data);
+            this.setData({
+                filtratelist: this.data.filtratelist,
+                filtrate: true
+            })
+        } else {
+            this.setData({
+                filtrate: true
+            })
+        }
+    },
+    /* 处理筛选 */
+    handleFilter(e) {
+        this.data.params.content.where.itemclassid = e.detail.itemclassid || "";
+        this.data.params.content.where.sa_brandid = e.detail.sa_brandid || "";
+        this.data.params.content.where.tradefield = e.detail.tradefield || "";
+        this.getList(true)
+    },
+    /* 获取品牌列表 */
+    getBrand() {
+        return _Http.basic({
+            "id": "20220922085103",
+            "version": 1,
+            "content": {
+                "where": {
+                    "condition": ""
+                }
+            }
+        })
+    },
+    /* 获取标准列表 */
+    getitemstandards() {
+        return _Http.basic({
+            "classname": "sysmanage.develop.optiontype.optiontype",
+            "method": "optiontypeselect",
+            "content": {
+                nocache: true,
+                "pageNumber": 1,
+                "pageSize": 999,
+                "typename": "itemstandards",
+                "parameter": {
+                    "siteid": wx.getStorageSync('siteP').siteid
+                }
+            }
+        })
+
+    },
+    /* 获取标准列表 */
+    getitemstandards() {
+        return _Http.basic({
+            "classname": "sysmanage.develop.optiontype.optiontype",
+            "method": "optiontypeselect",
+            "content": {
+                nocache: true,
+                "pageNumber": 1,
+                "pageSize": 999,
+                "typename": "itemstandards",
+                "parameter": {
+                    "siteid": wx.getStorageSync('siteP').siteid
+                }
+            }
+        })
+    },
+    /* 获取领域列表 */
+    gettradefields() {
+        return _Http.basic({
+            "id": 20221223141802,
+            "content": {
+                "pageNumber": 1,
+                "pageSize": 99999,
+                "where": {
+                    "condition": ""
+                }
+            }
+        })
+    },
+    /* 打断 */
+    interrupt(e) {
+        let {
+            name,
+            index,
+            item,
+            list
+        } = e.detail;
+        if (name == "sa_brandid") _Http.basic({
+            "id": "20220922110403",
+            "content": {
+                nocache: true,
+                "sa_brandid": item.sa_brandid,
+            }
+        }).then(res => {
+            console.log("分类列表", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            })
+            if (!res.data[0].ttemclass) return;
+            list[3] = {
+                label: "分类",
+                index: null,
+                showName: "itemclassname", //显示字段
+                valueKey: "itemclassid", //返回Key
+                selectKey: "itemclassid", //传参 代表选着字段 不传参返回整个选择对象
+                value: "", //选中值
+                list: res.data[0].ttemclass
+            }
+            this.setData({
+                filtratelist: list
+            })
+        })
+    },
 })

+ 7 - 0
packageA/select/product/select.scss

@@ -138,4 +138,11 @@ page {
         font-weight: bold;
         color: #FFFFFF;
     }
+}
+
+.iconfont {
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+    padding: 0 10rpx;
 }

+ 8 - 4
packageA/select/product/select.wxml

@@ -1,5 +1,8 @@
-<van-search class="search" value="{{ params.content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
-
+<van-search value="{{ params.content.where.condition }}" shape='round' placeholder="请输入搜索关键词" use-action-slot bind:clear='onClear' bind:search="startSearch">
+    <navigator url="#" slot="action" class="iconfont icon-shaixuan" bindtap="openFiltrate">
+        筛选
+    </navigator>
+</van-search>
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
     <view class="total">共{{params.content.total}}个</view>
     <navigator class="setclient-list-item" url="#" wx:for="{{list}}" wx:key="{{idname}}" data-id="{{item[idname]}}" bindtap="changeResult">
@@ -34,7 +37,6 @@
     <view wx:if="{{!radio}}" style="height: 230rpx;" />
     <My_empty wx:if="{{!list.length}}" />
 </Yl_ListBox>
-
 <view style="height: 130rpx;" />
 <block wx:if="{{!radio}}">
     <view class="footer">
@@ -52,4 +54,6 @@
             },
         }
     </wxs>
-</block>
+</block>
+
+<Yl_Filtrate1 show='{{filtrate}}' list="{{filtratelist}}" bindhandle="handleFilter" bindinterrupt='interrupt' />