zhaoxiaohai 3 سال پیش
والد
کامیت
4122894fc7

+ 4 - 3
packageA/setclient/modules/address/add/index.js

@@ -127,11 +127,12 @@ Page({
                                 "content.total": page.data.content.total + 1
                             });
                         }
-                        page.setData({
-                            radio: res.data.isdefault == 1 ? res.data.contactsid : page.data.radio
-                        })
+                        if (res.data.isdefault == 1) setTimeout(() => {
+                            page.selectComponent("#List").initRadio();
+                        }, 200)
                         wx.navigateBack();
                     };
+                    if ("packageA/setclient/modules/address/search/index" == v.__route__) v.getList(true);
                 })
             }, 300)
         })

+ 17 - 0
packageA/setclient/modules/address/index.js

@@ -54,6 +54,23 @@ Component({
                 }, 300)
 
             })
+        },
+
+        toSearch() {
+            wx.navigateTo({
+                url: '/packageA/setclient/modules/address/search/index?perams=' + JSON.stringify({
+                    sys_enterpriseid: this.data.sys_enterpriseid,
+                    "nacache": true,
+                    "pageNumber": 1,
+                    "pageSize": 20,
+                    "pageTotal": 1,
+                    "total": 0,
+                    "where": {
+                        "condition": "",
+                        "workaddress": 1
+                    }
+                }),
+            })
         }
     }
 })

+ 0 - 1
packageA/setclient/modules/address/index.json

@@ -1,7 +1,6 @@
 {
     "component": true,
     "usingComponents": {
-
         "List": "./list/index"
     }
 }

+ 1 - 1
packageA/setclient/modules/address/index.wxml

@@ -1,7 +1,7 @@
 <view class="head">
     <view class="count">总共{{content.total}}个</view>
     <view class="expand">
-        <navigator url="#" class="but">
+        <navigator url="#" class="but" bindtap="toSearch">
             <van-icon name="search" />
         </navigator>
         <navigator url="/packageA/setclient/modules/address/add/index?sys_enterpriseid={{sys_enterpriseid}}" class="but">

+ 45 - 11
packageA/setclient/modules/address/list/index.js

@@ -28,14 +28,36 @@ Component({
                     title: res.data,
                     icon: "none"
                 });
-                list = list.map((v, i) => {
-                    v.isdefault = v.contactsid == data.contactsid ? 1 : 0
-                    return v
+
+                getCurrentPages().forEach(v => {
+                    //更新列表
+                    if (["packageA/setclient/detail", "packageA/setclient/modules/contacts/detail/index"].includes(v.__route__)) {
+                        let page = v.selectComponent("#Address").selectComponent("#List");
+                        const lists = page.data.list.map(value => {
+                            value.isdefault = value.contactsid == data.contactsid ? 1 : 0
+                            return value
+                        });
+                        page.setData({
+                            list: lists
+                        })
+                        setTimeout(() => {
+                            page.initRadio();
+                        }, 200)
+                    };
+                    if (["packageA/setclient/modules/address/search/index"].includes(v.__route__)) {
+                        let page = v.selectComponent("#List");
+                        const lists = page.data.list.map(value => {
+                            value.isdefault = value.contactsid == data.contactsid ? 1 : 0
+                            return value
+                        });
+                        page.setData({
+                            list: lists
+                        })
+                        setTimeout(() => {
+                            page.initRadio();
+                        }, 200)
+                    };
                 })
-                this.setData({
-                    list
-                })
-                console.log(list)
             })
         }, //处理操作
         handleItem(e) {
@@ -83,11 +105,23 @@ Component({
                                     wx.showToast({
                                         title: `删除成功!`,
                                         icon: "none"
-                                    })
-                                    that.setData({
-                                        list: that.data.list.filter(v => v.contactsid != item.contactsid)
                                     });
-                                    that.triggerEvent("changeTotal")
+                                    getCurrentPages().forEach(v => {
+                                        switch (v.__route__) {
+                                            case "packageA/setclient/detail":
+                                                let model = v.selectComponent("#Address");
+                                                model.setData({
+                                                    list: model.data.list.filter(value => value.contactsid != item.contactsid)
+                                                });
+                                                that.triggerEvent("changeTotal")
+                                                break;
+                                            case "packageA/setclient/modules/address/search/index":
+                                                v.setData({
+                                                    list: v.data.list.filter(value => value.contactsid != item.contactsid)
+                                                });
+                                                break;
+                                        }
+                                    })
                                 })
                             }
                         }

+ 56 - 0
packageA/setclient/modules/address/search/index.js

@@ -0,0 +1,56 @@
+const _Http = getApp().globalData.http;
+Page({
+    data: {
+
+    },
+    onLoad(options) {
+        this.setData({
+            content: JSON.parse(options.perams)
+        })
+        this.getList();
+    },
+    /* 开始搜索 */
+    startSearch({
+        detail
+    }) {
+        this.setData({
+            "content.where.condition": detail
+        });
+        this.getList(true);
+    },
+    onClear() {
+        this.setData({
+            "content.where.condition": ""
+        });
+        this.getList(true);
+    },
+    /* 获取地址列表 */
+    getList(init) {
+        let content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            "id": "20221022165503",
+            content
+        }).then(res => {
+            console.log("地址列表", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                "content.pageNumber": res.pageNumber + 1,
+                "content.pageSize": res.pageSize,
+                "content.pageTotal": res.pageTotal,
+                "content.total": res.total
+            })
+            setTimeout(() => {
+                this.selectComponent("#List").initRadio();
+            }, 300)
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    },
+})

+ 6 - 0
packageA/setclient/modules/address/search/index.json

@@ -0,0 +1,6 @@
+{
+    "usingComponents": {
+        "List": "../list/index"
+    },
+    "navigationBarTitleText": "搜索地址"
+}

+ 1 - 0
packageA/setclient/modules/address/search/index.scss

@@ -0,0 +1 @@
+/* packageA/setclient/modules/address/search/index.wxss */

+ 3 - 0
packageA/setclient/modules/address/search/index.wxml

@@ -0,0 +1,3 @@
+<van-search value="{{ content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<view style="height: 20rpx;" />
+<List id='List' list='{{list}}' />