zhaoxiaohai před 2 roky
rodič
revize
401f799069

+ 1 - 0
packageA/project/modules/contacts/index.js

@@ -5,6 +5,7 @@ Component({
     },
     data: {
         "content": {
+            "nocache": true,
             "sa_projectid": 1,
             pageNumbe: 1,
             pageTotal: 1,

+ 1 - 1
packageA/project/modules/contacts/index.json

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

+ 77 - 0
packageA/project/modules/contacts/list/index.js

@@ -0,0 +1,77 @@
+const _Http = getApp().globalData.http;
+Component({
+    options: {
+        addGlobalClass: true
+    },
+    properties: {
+        list: Array,
+        changeTotal: Function
+    },
+    data: {},
+    methods: {
+        handleItem(e) {
+            const {
+                name,
+                item
+            } = e.target.dataset,
+                that = this;
+            switch (name) {
+                case "call":
+                    if (!item.phonenumber) return wx.showToast({
+                        title: '该用户手机号为空',
+                        icon: "none"
+                    })
+                    wx.makePhoneCall({
+                        phoneNumber: item.phonenumber,
+                    })
+                    break;
+                case "delete":
+                    wx.showModal({
+                        title: '提示',
+                        content: `是否确认删除"${item.name}"`,
+                        complete: (res) => {
+                            if (res.confirm) _Http.basic({
+                                "id": "20221111130904",
+                                "content": {
+                                    sa_project_contactsids: [item.sa_project_contactsid],
+                                }
+                            }).then(res => {
+                                console.log("删除联系人", res)
+                                if (res.msg != '成功') return wx.showToast({
+                                    title: res.data,
+                                    icon: "none"
+                                });
+                                wx.showToast({
+                                    title: `删除成功!`,
+                                    icon: "none"
+                                })
+                                getCurrentPages().forEach(v => {
+                                    if (v.selectComponent("#Contacts")) {
+                                        const page = v.selectComponent("#Contacts");
+                                        page.setData({
+                                            list: page.data.list.filter(v => v.contactsid != item.contactsid)
+                                        });
+                                        page.changeTotal();
+                                    } else if (v.__route__ == "packageA/project/modules/contacts/search/index") {
+                                        v.setData({
+                                            list: v.data.list.filter(v => v.contactsid != item.contactsid),
+                                            'content.total': v.data.content.total - 1
+                                        });
+                                    } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
+                                        wx.navigateBack()
+                                    }
+                                })
+                            })
+                        }
+                    })
+                    break;
+                case "edit":
+                    wx.navigateTo({
+                        url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
+                    })
+                    break;
+            }
+        },
+
+    }
+})

+ 6 - 0
packageA/project/modules/contacts/list/index.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-action-sheet": "@vant/weapp/action-sheet/index"
+    }
+}

+ 82 - 0
packageA/project/modules/contacts/list/index.scss

@@ -0,0 +1,82 @@
+.item {
+    width: 100vw;
+    background-color: #ffffff;
+    margin-bottom: 20rpx;
+
+    .content {
+        padding: 20rpx 0;
+        padding-left: 30rpx;
+        border-bottom: 1px solid #DDD;
+        box-sizing: border-box;
+
+        .user {
+            display: flex;
+            width: 100%;
+
+            .portrait {
+                width: 64rpx;
+                height: 64rpx;
+                text-align: center;
+                line-height: 64rpx;
+                background: #3874F6;
+                border-radius: 50%;
+                margin-top: 12rpx;
+                margin-right: 16rpx;
+                flex-shrink: 0;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #FFFFFF;
+            }
+
+            .right {
+                flex: 1;
+
+                .title {
+                    height: 42rpx;
+                    line-height: 42rpx;
+                    font-size: 30rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #333333;
+
+                    text {
+                        margin-left: 20rpx;
+                        font-size: 24rpx;
+                        font-family: PingFang SC-Regular, PingFang SC;
+                        color: #999999;
+                    }
+                }
+
+                .exp {
+                    font-size: 24rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #333333;
+                }
+            }
+        }
+
+
+    }
+
+    .editor {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        width: 100%;
+        height: 80rpx;
+
+        .icon-but {
+            padding-right: 30rpx;
+
+            navigator {
+                display: inline-block;
+                width: 60rpx;
+                height: 60rpx;
+                line-height: 60rpx;
+                text-align: center;
+                margin-left: 30rpx;
+                width: 32px;
+                color: #707070;
+            }
+        }
+    }
+}

+ 24 - 0
packageA/project/modules/contacts/list/index.wxml

@@ -0,0 +1,24 @@
+<view class="item" wx:for="{{list}}" wx:key="item.changeuserid">
+    <navigator url="/packageA/setclient/modules/contacts/detail/index?contactsid={{item.contactsid}}" class="content">
+        <view class="user">
+            <view class="portrait">
+                {{item.name[0]}}
+            </view>
+            <view class="right">
+                <view class="title">
+                    {{item.name}}<text>{{item.phonenumber}}</text>
+                </view>
+                <view class="exp" style="margin-top: 10rpx;">{{item.enterprisename}} <text>{{item.position}}</text></view>
+            </view>
+        </view>
+    </navigator>
+    <view class="editor">
+        <view />
+        <view class="icon-but" bindtap="handleItem">
+            <navigator url="#" data-item="{{item}}" data-name="call" class="iconfont icon-bodadianhua" />
+            <navigator url="#" data-item="{{item}}" data-name="edit" class="iconfont icon-bianji" />
+            <navigator url="#" data-item="{{item}}" data-name="delete" class="iconfont icon-shanchu" />
+        </view>
+    </view>
+</view>
+<My_empty wx:if="{{list.length==0}}" />

+ 7 - 2
packageA/project/modules/contacts/search/index.js

@@ -3,17 +3,22 @@ const _Http = getApp().globalData.http,
 Page({
     data: {
         content: {
+            nocache: true,
             "sa_projectid": 1,
             "pageNumber": 1,
             "pageTotal": 1,
             "pageSize": 20,
+            total: null,
             "where": {
                 "condition": ""
             }
         },
     },
     onLoad(options) {
-        console.log(options)
+        this.setData({
+            "content.sa_projectid": options.sa_projectid
+        })
+        this.getList();
     },
     getList(init = false) {
         if (init.detail != undefined) init = init.detail;
@@ -55,7 +60,7 @@ Page({
         this.getList(true)
     },
     onReady() {
-        getHeight.getHeight('.total', this).then(res => this.setData({
+        getHeight.getHeight('.search', this).then(res => this.setData({
             listHeight: res
         }));
     },

+ 1 - 1
packageA/project/modules/contacts/search/index.json

@@ -1,6 +1,6 @@
 {
     "usingComponents": {
-        "List": "../../../../setclient/modules/contacts/list/index"
+        "List": "../list/index"
     },
     "navigationBarTitleText": "搜索联系人"
 }

+ 10 - 1
packageA/project/modules/contacts/search/index.scss

@@ -1,4 +1,13 @@
 page {
-    overflow: hidden;
     height: 100vh;
+    overflow: hidden;
+}
+
+.total {
+    height: 60rpx;
+    line-height: 60rpx;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #666666;
+    padding-left: 30rpx;
 }

+ 2 - 1
packageA/project/modules/contacts/search/index.wxml

@@ -1,5 +1,6 @@
-<van-search class="total" value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:search='onSearch' bind:clear='onClear' />
+<van-search class="search" value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:search='onSearch' bind:clear='onClear' />
 <My_listBox id='ListBox' height="{{listHeight}}" bind:getlist='getList'>
+    <view class="total">共{{content.total}}位</view>
     <List list='{{list}}' />
     <view style="height: 250rpx;" />
 </My_listBox>

+ 34 - 21
packageA/project/modules/contacts/select/index.js

@@ -23,29 +23,42 @@ Page({
     },
     /* 提交 */
     submit() {
-        _Http.basic({
-            "id": 20221111131104,
-            "content": {
-                "sa_project_contactsid": 0,
-                "contactsid": this.data.result,
-                "sa_projectid": this.data.content.sa_projectid,
-                "remarks": ""
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: '是否确认添加联系人',
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) {
+                    _Http.basic({
+                        "id": 20221111131104,
+                        "content": {
+                            "sa_project_contactsid": 0,
+                            "contactsids": that.data.result,
+                            "sa_projectid": that.data.content.sa_projectid,
+                            "remarks": ""
+                        }
+                    }).then(res => {
+                        console.log("项目添加联系人", res)
+                        if (res.msg != '成功') return wx.showToast({
+                            title: res.data,
+                            icon: "none"
+                        });
+                        wx.showToast({
+                            title: '添加成功',
+                            icon: "none"
+                        });
+                        setTimeout(() => {
+                            wx.navigateBack();
+                            let pages = getCurrentPages();
+                            pages[pages.length - 2].partialRenewal(true);
+                        }, 300)
+                    })
+                }
             }
-        }).then(res => {
-            console.log("项目添加联系人", res)
-            if (res.msg != '成功') return wx.showToast({
-                title: res.data,
-                icon: "none"
-            });
-            wx.showToast({
-                title: '添加成功',
-                icon: "none"
-            });
-            setTimeout(() => {
-                wx.navigateBack();
-                
-            }, 300)
         })
+
     },
     /* 开始搜索 */
     onSearch({

+ 2 - 2
packageA/project/modules/contacts/select/index.wxml

@@ -1,6 +1,5 @@
 <van-search value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:search='onSearch' bind:clear='onClear' />
 <view style="height: 20rpx;" />
-
 <van-checkbox-group value="{{ result }}">
     <view class="box">
         <navigator url="#" class="item" wx:for="{{list}}" wx:key="item.contactsid" data-item="{{item}}" bindtap="onChange">
@@ -14,9 +13,10 @@
                 <view class="exp">
                     <view class="line-1">
                         {{item.name}}
-                        <text class="phone">{{item.position}}</text>
+                        <text class="phone">{{item.enterprisename}}</text>
                     </view>
                     <view class="phone">
+                        {{item.position}} 
                         {{item.phonenumber}}
                     </view>
                 </view>

+ 30 - 30
packageA/setclient/modules/contacts/add/index.js

@@ -181,38 +181,38 @@ Page({
             });
             setTimeout(() => {
                 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;
+                    if (v.__route__ == 'packageA/setclient/modules/contacts/detail/index') {
+                        v.getDetail();
+                    } else if (v.selectComponent("#Contacts")) {
+                        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
+                            });
+                        } else {
+                            //列表中不存在说明是新增,返回上一级页面更新数据 并进入详情
+                            list.push(res.data);
+                            page.setData({
+                                list,
+                                "content.total": page.data.content.total + 1
+                            });
+                            wx.navigateTo({
+                                url: '/packageA/setclient/modules/contacts/detail/index?contactsid=' + res.data.contactsid
+                            })
+                        }
+                    } else if (v.__route__ == 'packageA/project/modules/contacts/search/index') {
+                        let index = v.data.list.findIndex(value => value.contactsid == res.data.contactsid);
+                        console.log(index)
+                        if (index != -1) v.setData({
+                            [`list[${index}]`]: res.data
+                        })
                     }
                 });
+                wx.navigateBack();
             }, 500)
         });
     },