Просмотр исходного кода

Merge branch '绿色' into 配合官网应用跳转

xiaohaizhao 1 год назад
Родитель
Сommit
bc0b7d8401

+ 2 - 1
app.json

@@ -168,7 +168,8 @@
                 "contract/add/type4/select",
                 "expenseBreakdown/index",
                 "expenseBreakdown/insertion",
-                "expenseBreakdown/edit"
+                "expenseBreakdown/edit",
+                "contract/modules/contacts/quickly"
             ]
         }
     ],

+ 5 - 0
packageA/contract/detail.js

@@ -103,6 +103,11 @@ Page({
                         icon: "icon-tabchanpinleibie",
                         model: '#PiscountType'
                     }]);
+                    if (this.data.appAuth.options.some(v => v == 'IntermediaryContact')) tabsList.push({
+                        label: "联系人",
+                        icon: "icon-tablianxiren",
+                        model: "#Contacts"
+                    })
                     break;
                 case "项目":
                     data.type = data.typemx + '项目协议'

+ 1 - 0
packageA/contract/detail.json

@@ -5,6 +5,7 @@
         "Product": "./modules/product/index",
         "PiscountProduct": "./modules/discount/product/index",
         "PiscountType": "./modules/discount/type/index",
+        "Contacts": "./modules/contacts/index",
         "Work": "/packageA/public/work/index",
         "Objective": "./modules/objective/index",
         "Record": "/packageA/public/record/index"

+ 1 - 1
packageA/contract/detail.wxml

@@ -17,7 +17,7 @@
     <PiscountProduct wx:if="{{detail.type=='经销商合作协议'||detail.type=='直销客户合作协议'||detail.type=='居间协议'}}" isSync="{{detail.type=='居间协议'}}" slot='产品明细折扣' id='PiscountProduct' disabled="{{(isAdmin||isLeader)&&detail.status=='新建'}}" />
     <Product wx:else slot='{{detail.type=="工具使用(借用)协议"?  "工具清单": "产品明细折扣"}}' isSync="{{detail.type=='居间协议'}}" synchronous='{{(detail.type=="经销项目协议" || detail.type=="直销项目协议")  && isLeader && detail.status=="新建"}}' disabled="{{(isAdmin||isLeader)&&detail.status=='新建'}}" id='Product' />
     <PiscountType isSync="{{detail.type=='居间协议'}}" slot='产品类别折扣' id='PiscountType' synchronous='{{(detail.type=="经销项目协议" || detail.type=="直销项目协议") && isLeader && detail.status=="新建"}}' disabled="{{(isAdmin||isLeader)&&detail.status=='新建'}}" />
-
+    <Contacts slot='联系人' id='Contacts' />
     <Objective slot='业绩目标' id='Objective' disabled="{{(isAdmin||isLeader)&&detail.status=='新建'}}" />
     <Record slot="操作记录" id="Record" ownertable='sa_contract' ownerid='{{detail.sa_contractid}}' />
     <!-- <view slot='合同条款' /> -->

+ 52 - 0
packageA/contract/modules/contacts/index.js

@@ -0,0 +1,52 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        disabled: {type:Boolean}
+    },
+    data: {
+        "sa_contractid": 1,
+        "content": {
+            "nocache": true,
+            "sa_contractid": 1,
+            pageNumbe: 1,
+            pageTotal: 1,
+            total: null,
+            "where": {
+                "conditino": ""
+            }
+        }
+    },
+    methods: {
+        /* 获取地址列表 */
+        getList(id, init) {
+            let content = this.data.content;
+            content.sa_contractid = id;
+            if (init) content.pageNumber = 1
+            _Http.basic({
+                "id": "20240923153204",
+                content
+            }).then(res => {
+                console.log("关联联系人列表", res)
+                if (res.code != '1') 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.sa_contractid": id,
+                    "content.total": res.total,
+                    sa_contractid: id,
+                })
+            })
+        },
+        /* 修改总数 */
+        changeTotal() {
+            this.setData({
+                "content.total": this.data.content.total - 1
+            })
+        }
+    }
+})

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

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

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

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

+ 9 - 0
packageA/contract/modules/contacts/index.wxml

@@ -0,0 +1,9 @@
+<view class="head">
+	<view class="count">总共{{content.total}}个</view>
+	<view class="expand">
+		<navigator url="/packageA/contract/modules/contacts/quickly?id={{sa_contractid}}" class="but">
+			<van-icon name="plus" />
+		</navigator>
+	</view>
+</view>
+<List list='{{list}}' bindchangeTotal="changeTotal" />

+ 103 - 0
packageA/contract/modules/contacts/list/index.js

@@ -0,0 +1,103 @@
+const _Http = getApp().globalData.http;
+Component({
+    options: {
+        addGlobalClass: true
+    },
+    properties: {
+        list: {
+            type: Array
+        },
+        changeTotal: {
+            type: Function
+        },
+        disabled: {
+            type: Boolean
+        }
+    },
+    data: {
+        range: ['高层', '中层', '项目负责人']
+    },
+    methods: {
+        handleItem(e) {
+            const {
+                name,
+                item
+            } = e.target.dataset,
+                that = this;
+                console.log(item)
+            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": "20240923153104",
+                                "content": {
+                                    "sa_contractid": item.sa_contractid,
+                                    "sys_phonebookid": item.sys_phonebookid
+                                }
+                            }).then(res => {
+                                console.log("删除联系人", res)
+                                wx.showToast({
+                                    title: res.code == 1 ? `删除成功!` : res.data,
+                                    icon: "none"
+                                });
+                                getCurrentPages().forEach(v => {
+                                    if (v.selectComponent("#Contacts")) {
+                                        const page = v.selectComponent("#Contacts");
+                                        if (page.data.list.some(v => v.sys_phonebookid == item.sys_phonebookid)) {
+                                            page.setData({
+                                                list: page.data.list.filter(v => v.sys_phonebookid != item.sys_phonebookid)
+                                            });
+                                            page.changeTotal();
+                                        }
+                                    }
+                                })
+                            })
+                        }
+                    })
+                    break;
+                case "edit":
+                    wx.navigateTo({
+                        url: `/packageA/project/modules/contacts/add/index?data=${JSON.stringify(item)}`
+                    })
+                    break;
+            }
+        },
+        bindPickerChange(e) {
+            let item = e.currentTarget.dataset.item,
+                tag = this.data.range[e.detail.value];
+            if (item.tag == tag) return;
+            _Http.basic({
+                "id": 20221119103902,
+                "content": {
+                    "sa_project_contactsid": item.sa_project_contactsid,
+                    tag,
+                },
+            }).then(res => {
+                console.log("修改关联客户类型", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                this.setData({
+                    [`list[${this.data.list.findIndex(v=>v.sa_project_contactsid==item.sa_project_contactsid)}].tag[0]`]: tag
+                });
+                wx.showToast({
+                    title: `已更改“${item.name}”联系人类型为“${tag}”`,
+                    icon: "none"
+                })
+            })
+        },
+    }
+})

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

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

+ 102 - 0
packageA/contract/modules/contacts/list/index.scss

@@ -0,0 +1,102 @@
+.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 {
+                    width: 100%;
+                    height: 42rpx;
+                    line-height: 42rpx;
+                    font-size: 30rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #333333;
+
+                    text {
+                        margin-left: 10rpx;
+                        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;
+                }
+
+                .tag {
+                    display: inline-block;
+                    height: 36rpx;
+                    line-height: 36rpx;
+                    background: #FFEFD9;
+                    border-radius: 20rpx;
+                    color: #ffffff;
+                    padding: 0 10rpx;
+                    font-size: 20rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #FA8C16;
+                }
+            }
+        }
+
+
+    }
+
+    .editor {
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        width: 100%;
+        height: 60rpx;
+
+        .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;
+            }
+        }
+    }
+}
+
+.line-1 {
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}

+ 38 - 0
packageA/contract/modules/contacts/list/index.wxml

@@ -0,0 +1,38 @@
+<view class="item" wx:for="{{list}}" wx:key="changeuserid">
+    <navigator url="/packageA/contacts/detail?id={{item.sys_phonebookid}}&groupname=项目联系人" class="content">
+        <view class="user">
+            <view class="portrait">
+                {{item.name[0]}}
+            </view>
+            <view class="right">
+                <view class="title line-1">
+                    {{item.name}}<text>{{item.phonenumber}}</text><text>{{item.email}}</text>
+                </view>
+                <view class="tag" wx:if="{{item.tag[0]}}">{{item.tag[0]}}</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}}" wx:if="{{disabled}}" data-name="edit" class="iconfont icon-bianji" />
+            <navigator url="#" data-item="{{item}}" wx:if="{{disabled}}" data-name="change">
+                <picker bindchange="bindPickerChange" value="{{handle.getValue(item.tag[0],range)}}" data-item="{{item}}" range="{{range}}">
+                    <text class="iconfont icon-dibu-biangengchengjiaozhuangtai" />
+                </picker>
+            </navigator> -->
+            <navigator url="#" data-item="{{item}}" data-name="delete" class="iconfont icon-shanchu" />
+        </view>
+    </view>
+</view>
+<My_empty wx:if="{{list.length==0}}" />
+<wxs module="handle">
+    module.exports = {
+        getValue: function (name, list) {
+            var i = list.indexOf(name)
+            return i == -1 ? 0 : i
+        }
+    }
+</wxs>

+ 97 - 0
packageA/contract/modules/contacts/quickly.js

@@ -0,0 +1,97 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        content: {
+            loading: false,
+            sa_contractid: "",
+            nocache: true,
+            pageNumber: 1,
+            pageSize: 20,
+            pageTotal: 1,
+            total: 0,
+            where: {
+                "condition": "",
+            }
+        },
+        list: [],
+    },
+    getList(init = false) {
+        const content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            id: 20240923153304,
+            content
+        }).then(res => {
+            console.log("通讯录列表", res)
+            if (res.code != '1') return wx.showToast({
+                title: res.msg,
+                icon: "none"
+            });
+            content.pageNumber = res.pageNumber + 1;
+            content.pageTotal = res.pageTotal;
+            content.total = res.total;
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                content
+            })
+        })
+    },
+    onLoad(options) {
+        if (options.id) this.setData({
+            'content.sa_contractid': options.id
+        });
+        this.getList();
+    },
+    onClick(e) {
+        if (this.data.loading) return;
+        const {
+            item
+        } = e.currentTarget.dataset,
+            sa_contractid = this.data.content.sa_contractid;
+        this.data.loading = true;
+        _Http.basic({
+            "id": "20240923153004",
+            "content": {
+                sa_contractid,
+                "sys_phonebookid": item.sys_phonebookid
+            }
+        }).then(res => {
+            console.log("添加合同联系人", res)
+            this.data.loading = false;
+            wx.showToast({
+                title: res.code != '1' ? res.msg : '添加成功',
+                icon: "none",
+                mask: res.code == '1'
+            })
+            if (res.code == '1') setTimeout(() => {
+                wx.navigateBack()
+                getCurrentPages().forEach(v => {
+                    if (v.__route__ == 'packageA/contract/detail') {
+                        let page = v.selectComponent("#Contacts");
+                        page.getList(sa_contractid, true)
+                    }
+                });
+            }, 500)
+        })
+
+    },
+    onSearch({
+        detail
+    }) {
+        this.setData({
+            'content.where.condition': detail ? detail : ""
+        });
+        this.getList(true);
+    },
+    onClear() {
+        this.setData({
+            'content.where.condition': ""
+        });
+        this.getList(true);
+    },
+    onReachBottom() {
+        this.getList();
+    },
+})

+ 7 - 0
packageA/contract/modules/contacts/quickly.json

@@ -0,0 +1,7 @@
+{
+    "usingComponents": {
+        "van-radio": "@vant/weapp/radio/index",
+        "van-radio-group": "@vant/weapp/radio-group/index"
+    },
+    "navigationBarTitleText": "选择联系人"
+}

+ 59 - 0
packageA/contract/modules/contacts/quickly.scss

@@ -0,0 +1,59 @@
+.search {
+	border-top: 1rpx solid #ddd !important;
+}
+
+.box {
+	width: 100vw;
+	background-color: #fff;
+	box-sizing: border-box;
+
+	.item {
+			display: flex;
+			width: 100%;
+			padding-left: 30rpx;
+			box-sizing: border-box;
+
+			.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: 0;
+							flex: 1;
+							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;
+							}
+					}
+			}
+
+	}
+}

+ 27 - 0
packageA/contract/modules/contacts/quickly.wxml

@@ -0,0 +1,27 @@
+<view style="position: sticky; top: 0;">
+    <van-search custom-class='search' value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:search='onSearch' bind:clear='onClear' />
+</view>
+
+<view style="height: 20rpx;" />
+<view class="box">
+    <navigator url="#" class="item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" bindtap="onClick">
+        <view class="user">
+            <view class="portrait">
+                {{item.name[0]}}
+            </view>
+            <view class="exp">
+                <view class="line-1">
+                    {{item.name}}
+                    <text class="phone">{{item.enterprisename}}</text>
+                </view>
+                <view class="phone">
+                    {{item.position}}
+                    {{item.phonenumber}}
+                </view>
+            </view>
+        </view>
+    </navigator>
+</view>
+
+<My_empty wx:if="{{list.length==0}}" />
+<view style="height: 130rpx;" />

+ 6 - 0
utils/Http.js

@@ -44,6 +44,12 @@ class HTTP {
             fial: err => reject(err),
             complete: (res) => {
                 // if (loading) wx.hideLoading()
+                if (res.data.code != 1) {
+                    console.error("错误的请求", {
+                        request: data,
+                        result: res.data
+                    })
+                }
                 if (res.errMsg != 'request:ok') {
                     wx.showToast({
                         title: '网络异常,请重新进入',