Browse Source

项目关联客户

zhaoxiaohai 2 years ago
parent
commit
e7d4872c5a
2 changed files with 58 additions and 13 deletions
  1. 57 12
      packageA/project/modules/treaty/index.js
  2. 1 1
      packageA/project/modules/treaty/index.wxml

+ 57 - 12
packageA/project/modules/treaty/index.js

@@ -6,15 +6,14 @@ Component({
     },
     data: {
         "sa_projectid": null,
-        "content": {
-            "nocache": true,
-            "pageNumber": 1,
-            "pageTotal": 1,
-            "pageSize": 20,
-            "total": null,
-            "where": {
-                "condition": "",
-                "type": 4
+        content: {
+            nocache: true,
+            pageNumber: 1,
+            pageTotal: 1,
+            pageSize: 10,
+            total: null,
+            where: {
+                condition: "",
             }
         },
     },
@@ -22,13 +21,13 @@ Component({
         /* 获取地址列表 */
         getList(id, init) {
             let content = this.data.content;
-            content.where.sa_projectid = id;
+            content.sa_projectid = id;
             if (init) {
                 content.pageNumber = 1
                 content.pageTotal = 1
             }
             _Http.basic({
-                "id": "20220920083901",
+                "id": "20221027143702",
                 content
             }).then(res => {
                 console.log("关联客户列表", res)
@@ -60,12 +59,58 @@ Component({
                 let list = this.data.list;
                 for (let key in res.data) {
                     let index = list.findIndex(v => v.sa_customersid == key);
-                    list[index].tags = res.data[key]
+                    if (index != -1) list[index].tags = res.data[key]
                 };
                 this.setData({
                     list
                 })
             })
         },
+        /* 去搜索 */
+        toSearch() {
+            wx.navigateTo({
+                url: '/packageA/project/modules/treaty/search?data=' + JSON.stringify(this.data.content),
+            })
+        },
+        fastCallBack({
+            detail
+        }) {
+            console.log(detail.name, detail.item)
+            const that = this;
+            switch (detail.name) {
+                case 'delete':
+                    wx.showModal({
+                        title: '提示',
+                        content: `是否确认取消关联"${detail.item.enterprisename}"?`,
+                        complete: ({
+                            confirm
+                        }) => {
+                            if (confirm) _Http.basic({
+                                "id": 20221027143802,
+                                "content": {
+                                    "sa_project_partiesids": [detail.item.sa_project_partiesid]
+                                },
+                            }).then(res => {
+                                if (res.msg != '成功') return wx.showToast({
+                                    title: res.data,
+                                    icon: "none"
+                                });
+                                that.setData({
+                                    list: that.data.list.filter(v => v.sa_project_partiesid != detail.item.sa_project_partiesid),
+                                    'content.total': that.data.content.total - 1
+                                });
+                                wx.showToast({
+                                    title: `已取消关联"${detail.item.enterprisename}"`,
+                                    icon: "none"
+                                })
+                            })
+                        }
+                    })
+                    break;
+
+                default:
+                    break;
+            }
+        }
     }
 })

+ 1 - 1
packageA/project/modules/treaty/index.wxml

@@ -9,4 +9,4 @@
         </navigator>
     </view>
 </view>
-<List list='{{list}}' />
+<List list='{{list}}' fast bindfastCallBack='fastCallBack' />