Browse Source

联系人

zhaoxiaohai 2 years ago
parent
commit
54b52e1e6a

+ 37 - 6
packageA/setclient/modules/contacts/add/index.js

@@ -112,6 +112,9 @@ Page({
         }
     },
     onLoad(options) {
+        this.setData({
+            "content.sys_enterpriseid": options.sys_enterpriseid
+        });
         if (options.data) {
             let item = JSON.parse(options.data),
                 form = this.data.form.map(v => {
@@ -127,7 +130,7 @@ Page({
                 "disabled": false,
                 "content.contactsid": item.contactsid
             })
-        }
+        };
     },
     /* 提交数据 */
     submit() {
@@ -141,8 +144,6 @@ Page({
             "county": data.region[2] || "",
         };
         delete(content.region);
-        let pages = getCurrentPages();
-        content.sys_enterpriseid = pages[pages.length - 2].data.detail.sys_enterpriseid;
         _Http.basic({
             "id": "20221018141802",
             content
@@ -157,9 +158,39 @@ Page({
                 icon: "none"
             });
             setTimeout(() => {
-                let pages = getCurrentPages();
-                pages[pages.length - 2].partialRenewal(true);
-                wx.navigateBack();
+                getCurrentPages().forEach(v => {
+                    switch (v.__route__) {
+                        //详情界面更新数据
+                        case 'packageA/setclient/modules/contacts/detail/index':
+                            v.getDetail();
+                            break;
+                            //列表页更新数据
+                        case 'packageA/setclient/detail':
+                            let page = v.selectComponent("#Contacts"),
+                                list = page.data.list,
+                                index = list.findIndex(value => value.contactsid == res.data.contactsid);
+                            if (index != -1) {
+                                //列表中存在说明是编辑,返回上一级页面并更新数据
+                                list[index] = res.data;
+                                page.setData({
+                                    list
+                                });
+                                wx.navigateBack();
+                            } else {
+                                //列表中不存在说明是新增,返回上一级页面更新数据 并进入详情
+                                list.push(res.data);
+                                page.setData({
+                                    list,
+                                    "content.total": page.data.content.total + 1
+                                });
+                                wx.navigateBack();
+                                wx.navigateTo({
+                                    url: '/packageA/setclient/modules/contacts/detail/index?contactsid=' + res.data.contactsid
+                                })
+                            }
+                            break;
+                    }
+                });
             }, 500)
         });
     },

+ 22 - 4
packageA/setclient/modules/contacts/detail/index.js

@@ -1,5 +1,8 @@
+const _Http = getApp().globalData.http;
+
 Page({
     data: {
+        contactsid: 0,
         tabsActive: 0, //tabs 选中项
         tabsList: [{
             label: "详细信息",
@@ -13,8 +16,23 @@ Page({
         }],
     },
     onLoad(options) {
-        if (options.data) {
-            let item = JSON.parse(options.data)
+        if (options.contactsid) {
+            this.setData({
+                contactsid: options.contactsid
+            });
+            this.getDetail();
+        }
+    },
+    /* 获取详情信息 */
+    getDetail() {
+        _Http.basic({
+            "id": 20221026110602,
+            "content": {
+                "contactsid": this.data.contactsid
+            }
+        }).then(res => {
+            console.log("联系人详情", res)
+            const item = res.data;
             this.setData({
                 detail: item,
                 briefs: [{
@@ -52,8 +70,8 @@ Page({
                     label: "备注",
                     value: item.remarks
                 }]
-            })
-        }
+            });
+        })
     },
     onShareAppMessage() {}
 })

+ 4 - 5
packageA/setclient/modules/contacts/index.js

@@ -1,8 +1,6 @@
 const _Http = getApp().globalData.http;
 Component({
-    properties: {
-
-    },
+    properties: {},
     data: {
         list: [],
         content: {
@@ -12,7 +10,8 @@ Component({
             "pageTotal": 1,
             "total": null,
             "where": {
-                "condition": ""
+                "condition": "",
+                "workaddress": 0
             }
         },
     },
@@ -25,7 +24,7 @@ Component({
                 content.pageTotal = 1
             }
             _Http.basic({
-                "id": "20221018150602",
+                "id": "20221022165503",
                 content
             }).then(res => {
                 console.log("联系人", res)

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

@@ -6,7 +6,7 @@
         <navigator url="#" class="but">
             <van-icon name="search" />
         </navigator>
-        <navigator url="/packageA/setclient/modules/contacts/add/index" class="but">
+        <navigator url="/packageA/setclient/modules/contacts/add/index?sys_enterpriseid={{sys_enterpriseid}}" class="but">
             <van-icon name="plus" />
         </navigator>
     </view>

+ 14 - 5
packageA/setclient/modules/contacts/list/index.js

@@ -40,14 +40,23 @@ Component({
                                     title: res.data,
                                     icon: "none"
                                 });
-                                that.setData({
-                                    list: this.data.list.filter(v => v.contactsid != item.contactsid)
-                                });
+                                that.triggerEvent("changeTotal")
                                 wx.showToast({
                                     title: `删除成功!`,
                                     icon: "none"
                                 })
-                                that.triggerEvent("changeTotal")
+                                getCurrentPages().forEach(v => {
+                                    switch (v.__route__) {
+                                        case "packageA/setclient/detail":
+                                            that.setData({
+                                                list: this.data.list.filter(v => v.contactsid != item.contactsid)
+                                            });
+                                            break;
+                                        case "packageA/setclient/modules/contacts/detail/index":
+                                            wx.navigateBack()
+                                            break;
+                                    }
+                                })
                             })
                         }
                     })
@@ -64,7 +73,7 @@ Component({
                 item
             } = e.currentTarget.dataset;
             wx.navigateTo({
-                url: '/packageA/setclient/modules/contacts/detail/index?data=' + JSON.stringify(item)
+                url: '/packageA/setclient/modules/contacts/detail/index?contactsid=' + item.contactsid
             })
         },
     }