Browse Source

客户联系人

zhaoxiaohai 2 years ago
parent
commit
1e4a6cba30

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

@@ -0,0 +1,49 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        sa_projectid: String
+    },
+    data: {
+        "content": {
+            "sa_projectid": 1,
+            pageNumbe: 1,
+            pageTotal: 1,
+            total: null,
+            "where": {
+                "conditino": ""
+            }
+        }
+    },
+    methods: {
+        /* 获取地址列表 */
+        getList(id, init) {
+            let content = this.data.content;
+            content.sa_projectid = id;
+            if (init) content.pageNumber = 1
+            _Http.basic({
+                "id": "20221111131004",
+                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,
+                    sa_projectid: id
+                })
+            })
+        },
+        /* 修改总数 */
+        changeTotal() {
+            this.setData({
+                "content.total": this.data.content.total - 1
+            })
+        }
+    }
+})

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

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

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

@@ -0,0 +1 @@
+@import "../../../setclient/modules/address/head.scss";

+ 12 - 0
packageA/project/modules/contacts/index.wxml

@@ -0,0 +1,12 @@
+<view class="head">
+    <view class="count">总共{{content.total}}个</view>
+    <view class="expand">
+        <navigator url="/packageA/project/modules/contacts/search/index?sa_projectid={{sa_projectid}}" class="but" bindtap="toSearch">
+            <van-icon name="search" />
+        </navigator>
+        <navigator url="/packageA/project/modules/contacts/select/index?sa_projectid={{sa_projectid}}" class="but">
+            <van-icon name="plus" />
+        </navigator>
+    </view>
+</view>
+<List list='{{list}}' bindchangeTotal="changeTotal" />

+ 62 - 0
packageA/project/modules/contacts/search/index.js

@@ -0,0 +1,62 @@
+const _Http = getApp().globalData.http,
+    getHeight = require("../../../../../utils/getRheRemainingHeight");
+Page({
+    data: {
+        content: {
+            "sa_projectid": 1,
+            "pageNumber": 1,
+            "pageTotal": 1,
+            "pageSize": 20,
+            "where": {
+                "condition": ""
+            }
+        },
+    },
+    onLoad(options) {
+        console.log(options)
+    },
+    getList(init = false) {
+        if (init.detail != undefined) init = init.detail;
+        let content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            "id": 20221111131004,
+            content
+        }).then(res => {
+            console.log("项目联系人搜索", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                'content.pageNumber': res.pageNumber + 1,
+                'content.pageTotal': res.pageTotal,
+                'content.total': res.total,
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
+            })
+        })
+    },
+    /* 开始搜索 */
+    onSearch({
+        detail
+    }) {
+        if (this.data.content.where.condition == detail) return;
+        this.setData({
+            'content.where.condition': detail
+        });
+        this.getList(true)
+    },
+    onClear() {
+        this.setData({
+            'content.where.condition': ""
+        });
+        this.getList(true)
+    },
+    onReady() {
+        getHeight.getHeight('.total', this).then(res => this.setData({
+            listHeight: res
+        }));
+    },
+})

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

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

+ 4 - 0
packageA/project/modules/contacts/search/index.scss

@@ -0,0 +1,4 @@
+page {
+    overflow: hidden;
+    height: 100vh;
+}

+ 5 - 0
packageA/project/modules/contacts/search/index.wxml

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

+ 105 - 0
packageA/project/modules/contacts/select/index.js

@@ -0,0 +1,105 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        content: {
+            nocache: true,
+            sa_projectid: 1,
+            pageSize: 20,
+            pageNumber: 1,
+            pageTotal: 1,
+            "where": {
+                "condition": ""
+            }
+        },
+        list: [],
+        result: []
+    },
+    onLoad(options) {
+        this.setData({
+            "content.sa_projectid": options.sa_projectid
+        });
+        this.getList();
+    },
+    /* 提交 */
+    submit() {
+        _Http.basic({
+            "id": 20221111131104,
+            "content": {
+                "sa_project_contactsid": 0,
+                "contactsid": this.data.result,
+                "sa_projectid": this.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();
+                
+            }, 300)
+        })
+    },
+    /* 开始搜索 */
+    onSearch({
+        detail
+    }) {
+        if (this.data.content.where.condition == detail) return;
+        this.setData({
+            'content.where.condition': detail
+        });
+        this.getList(true)
+    },
+    onClear() {
+        this.setData({
+            'content.where.condition': ""
+        });
+        this.getList(true)
+    },
+    /* 选中 */
+    onChange(e) {
+        const contactsid = e.currentTarget.dataset.item.contactsid + "";
+        if (!contactsid) return;
+        let result = this.data.result;
+        if (result.some(v => v == contactsid)) {
+            result = result.filter(v => v != contactsid)
+        } else {
+            result.push(contactsid)
+        }
+        this.setData({
+            result
+        })
+    },
+    //获取列表
+    getList(init = false) {
+        let content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            "id": 20221111130704,
+            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.pageTotal": res.pageTotal,
+            })
+
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    }
+})

+ 4 - 0
packageA/project/modules/contacts/select/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "添加联系人"
+}

+ 92 - 0
packageA/project/modules/contacts/select/index.scss

@@ -0,0 +1,92 @@
+.box {
+    width: 100vw;
+    background-color: #fff;
+    box-sizing: border-box;
+
+    .item {
+        display: flex;
+        width: 100%;
+        padding-left: 30rpx;
+        box-sizing: border-box;
+
+        .checkbox {
+            display: flex;
+            align-items: center;
+            width: 58rpx;
+            height: 120rpx;
+        }
+
+        .user {
+            display: flex;
+            align-items: center;
+            width: 100%;
+            height: 120rpx;
+            border-bottom: 1px solid #ddd;
+            box-sizing: border-box;
+
+            .portrait {
+                width: 80rpx;
+                height: 80rpx;
+                background: #3874F6;
+                border-radius: 50%;
+                text-align: center;
+                line-height: 80rpx;
+                font-size: 28rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #FFFFFF;
+                flex-shrink: 0;
+            }
+
+            .exp {
+                width: 100%;
+                margin-left: 20rpx;
+
+                .line-1 {
+                    height: 42rpx;
+                    font-size: 30rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #333333;
+                }
+
+                .phone {
+                    font-size: 24rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #999999;
+                    margin-top: 4rpx;
+                }
+            }
+        }
+
+    }
+}
+
+.footer {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    padding: 0 30rpx;
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+    box-sizing: border-box;
+
+    .count {
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #333333;
+    }
+
+    .but {
+        width: 156rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 8rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+    }
+}

+ 42 - 0
packageA/project/modules/contacts/select/index.wxml

@@ -0,0 +1,42 @@
+<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">
+            <view class="checkbox">
+                <van-checkbox shape='square' icon-size='14' name="{{item.contactsid}}" />
+            </view>
+            <view class="user">
+                <view class="portrait">
+                    {{item.name[0]}}
+                </view>
+                <view class="exp">
+                    <view class="line-1">
+                        {{item.name}}
+                        <text class="phone">{{item.position}}</text>
+                    </view>
+                    <view class="phone">
+                        {{item.phonenumber}}
+                    </view>
+                </view>
+            </view>
+        </navigator>
+    </view>
+</van-checkbox-group>
+<My_empty wx:if="{{list.length==0}}" />
+<view style="height: 130rpx;" />
+<view class="footer">
+    <view class="count">
+        已选:{{result.length}}
+    </view>
+    <van-button custom-class='but' disabled='{{result.length==0}}' bind:click="submit">添加</van-button>
+</view>
+
+<wxs module="active">
+    module.exports.que = function (name, list) {
+        return list.some(function (v) {
+            return v === name
+        })
+    }
+</wxs>