浏览代码

新增关联客户

zhaoxiaohai 2 年之前
父节点
当前提交
9246c508e1

+ 138 - 0
packageA/project/modules/treaty/add/index.js

@@ -0,0 +1,138 @@
+const _Http = getApp().globalData.http,
+    getHeight = require("../../../../../utils/getRheRemainingHeight");
+
+Page({
+    data: {
+        result: [],
+        content: {
+            "nocache": true,
+            "pageNumber": 1,
+            "pageSize": 20,
+            "total": null,
+            "where": {
+                "condition": "",
+                "type": 5,
+                "sa_projectid": null
+            }
+        }
+    },
+    onLoad(options) {
+        if (options.sa_projectid) this.setData({
+            "content.where.sa_projectid": options.sa_projectid
+        })
+        this.getList();
+    },
+    submit() {
+        _Http.basic({
+            "id": 20221111102902,
+            "content": {
+                "sa_projectid": this.data.content.where.sa_projectid,
+                "sys_enterpriseids": this.data.result,
+                "remarks": ""
+            }
+        }).then(res => {
+            console.log("批量添加客户", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            wx.showToast({
+                title: '添加成功',
+                icon: "none"
+            })
+            setTimeout(() => {
+                getCurrentPages().forEach(v => {
+                    if (v.selectComponent('#Treaty')) {
+                        console.log(v.selectComponent('#Treaty'))
+                        v.selectComponent('#Treaty').getList(this.data.content.where.sa_projectid, true);
+                    }
+                });
+                wx.navigateBack();
+            }, 300)
+        })
+    },
+    /* 选中 */
+    changeResult(e) {
+        const {
+            id
+        } = e.currentTarget.dataset;
+        let result = this.data.result;
+        if (result.some(v => v == id)) {
+            result = result.filter(v => v != id);
+        } else {
+            result.push(id)
+        };
+        this.setData({
+            result
+        })
+    },
+    /* 获取列表 */
+    getList(init = false) {
+        //init 用于初始化分页
+        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": 20220920083901,
+            content
+        }).then(res => {
+            console.log("关联客户列表", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.getTags(res.data.map(v => v.sa_customersid));
+            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)
+            })
+        })
+    },
+    /* 开始搜索 */
+    startSearch({
+        detail
+    }) {
+        if (detail == this.data.content.where.condition) return;
+        this.setData({
+            'content.where.condition': detail
+        });
+        this.getList(true);
+    },
+    /* 取消搜索 */
+    onClear() {
+        this.setData({
+            'content.where.condition': ""
+        });
+        this.getList(true);
+    },
+    /* 获取标签 */
+    getTags(ownerids = []) {
+        _Http.basic({
+            "id": 20221018102001,
+            "content": {
+                "ownertable": "sa_customers",
+                ownerids
+            }
+        }).then(res => {
+            console.log("标签", res)
+            if (res.msg != '成功') return;
+            let list = this.data.list;
+            for (let key in res.data) {
+                let index = list.findIndex(v => v.sa_customersid == key);
+                if (index != -1) list[index].tags = res.data[key]
+            };
+            this.setData({
+                list
+            })
+        })
+    },
+    onReady() {
+        getHeight.getHeight('.search', this).then(res => this.setData({
+            listHeight: res
+        }));
+    },
+})

+ 4 - 0
packageA/project/modules/treaty/add/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "关联客户"
+}

+ 130 - 0
packageA/project/modules/treaty/add/index.scss

@@ -0,0 +1,130 @@
+page {
+    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;
+}
+
+.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;
+    }
+}
+
+.setclient-list-item {
+    width: 100vw;
+    padding-left: 30rpx;
+    background-color: #fff;
+    box-sizing: border-box;
+
+    .con {
+        display: flex;
+        width: 100%;
+        min-height: 136rpx;
+        border-bottom: 1px solid #EFEFEF;
+        box-sizing: border-box;
+        padding-top: 20rpx;
+
+        .portrait {
+            width: 96rpx;
+            height: 96rpx;
+            background: #E7EEFF;
+            border-radius: 16rpx;
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #3874F6;
+            padding: 16rpx 24rpx;
+            box-sizing: border-box;
+            margin-right: 20rpx;
+            flex-shrink: 0;
+        }
+
+        .min-portrait {
+            display: flex;
+            align-items: center;
+            padding: 0 !important;
+            justify-content: center;
+        }
+
+        .mian {
+            flex: 1;
+            width: 0;
+            padding-right: 20rpx;
+            box-sizing: border-box;
+
+            .label {
+                font-size: 28rpx;
+                font-family: PingFang SC-Bold, PingFang SC;
+                font-weight: bold;
+                color: #333333;
+                height: 40rpx;
+                line-height: 40rpx;
+            }
+
+            .tag-box {
+                margin-top: 10rpx;
+
+                .tag {
+                    height: 40rpx;
+                    font-size: 20rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    padding: 0 12rpx;
+                    margin-right: 10rpx;
+                }
+            }
+        }
+
+        .checkbox {
+            display: flex;
+            align-items: center;
+            margin-top: -20rpx;
+            margin-right: 10rpx;
+        }
+
+        .extend {
+            display: flex;
+            height: 116rpx;
+            width: 48rpx;
+            margin-right: 30rpx;
+            flex-shrink: 0;
+        }
+    }
+}
+
+.line-1 {
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}

+ 43 - 0
packageA/project/modules/treaty/add/index.wxml

@@ -0,0 +1,43 @@
+<van-search class="search" value="{{ content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<My_listBox id='ListBox' height="{{listHeight}}" bind:getlist='getList'>
+    <view class="total">共{{content.total}}个</view>
+    <navigator class="setclient-list-item" url="#" wx:for="{{list}}" wx:key="item.sys_enterpriseid" data-id="{{item.sys_enterpriseid}}" bindtap="changeResult">
+        <view class="con">
+            <view class="portrait {{item.enterprisename <=2?'min-portrait':''}}">
+                {{handle.getName(item.enterprisename)}}
+            </view>
+            <view class="mian">
+                <view class="label line-1">{{item.enterprisename}}</view>
+                <view class="tag-box">
+                    <van-tag custom-class='tag' color='#E7EEFF' wx:if="{{item.type}}" text-color='#3874F6' round>{{item.type}}</van-tag>
+                    <van-tag custom-class='tag' wx:for="{{item.tags.systemtag}}" wx:for-item='tag' wx:key="index" color='#E7EEFF' text-color='#3874F6' round>{{tag}}</van-tag>
+                    <van-tag custom-class='tag' wx:for="{{item.tags.datatag}}" wx:for-item='tag' wx:key="index" color='#FFEFD9' text-color='#FA8C16' round>{{tag}}</van-tag>
+                </view>
+            </view>
+            <view class="checkbox">
+                <van-checkbox value='{{handle.isCheck(item.sys_enterpriseid,result)}}' />
+            </view>
+        </view>
+    </navigator>
+    <My_empty wx:if="{{!list.length}}" />
+</My_listBox>
+
+<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="handle">
+    module.exports = {
+        getName: function (name) {
+            return name.substring(0, 4)
+        },
+        isCheck: function (id, list) {
+            return list.some(function (v) {
+                return v == id
+            });
+        },
+    }
+</wxs>