zhaoxiaohai 2 年之前
父節點
當前提交
81ff5257d9

+ 42 - 79
packageA/group/index.js

@@ -1,99 +1,62 @@
 const _Http = getApp().globalData.http;
-
 Page({
     data: {
-        radio: false, //是否为单选
-        content: {
-            "ownertable": "sa_itemgroup",
-            "ownerid": 11,
-            pageSize: 20,
-            pageNumber: 1,
-            pageTotal: 1,
-            "where": {
-                "condition": ""
-            }
-        },
-        list: [],
-        result: [],
+        ownertable: null,
+        ownerid: null,
+        active: 0,
+        copyTeams: [], //用来本地搜索
+        keyword: "", //搜索关键字
     },
     onLoad(options) {
-        //是否为单选
-        if (options.radio) this.setData({
-            radio: true
-        })
-        if (options.ownertable) {
+        if (options.item) {
+            let item = JSON.parse(options.item);
             this.setData({
-                "content.ownertable": options.ownertable,
-                "content.ownerid": options.ownerid,
+                ...item
             });
-            this.getList();
-            console.log(this.data.content)
-        };
+            this.getList()
+        }
+    },
+    onInput({
+        detail
+    }) {
+        let list = this.data.copyTeams[this.data.active];
+        if (detail.value) list = list.filter(v => v.position.includes(detail.value) || v.name.includes(detail.value));
+        this.setData({
+            [`teams[${this.data.active}].team`]: list
+        })
+    },
+    /* 取消搜索 */
+    cancelTheSearch() {
+        this.setData({
+            keyword: "",
+            [`teams[${this.data.active}].team`]: this.data.copyTeams[this.data.active]
+        })
     },
-    submit() {
-        let result = this.data.result;
-        if (result.length == 0) return;
-        console.log(result)
+    /* 切换tabs */
+    onChange({
+        detail
+    }) {
+        this.setData({
+            active: detail.index
+        })
+    },
+    //获取列表
+    getList() {
         _Http.basic({
-            "id": 20220930103601,
+            "id": 20220930103501,
             "content": {
-                "ownertable": this.data.content.ownertable,
-                "ownerid": this.data.content.ownerid,
-                "userids": result
+                "ownertable": this.data.ownertable,
+                "ownerid": this.data.ownerid
             }
         }).then(res => {
+            console.log("团队成员列表", res)
             if (res.msg != '成功') return wx.showToast({
                 title: res.data,
                 icon: "none"
-            });
-            wx.showToast({
-                title: '保存成功',
-                icon: "none"
-            });
-            setTimeout(() => {
-                const pages = getCurrentPages();
-                pages[pages.length - 2].selectComponent("#Group").getList();
-                wx.navigateBack();
-            }, 300)
-        })
-    },
-    /* 选中 */
-    onChange(e) {
-        const userid = e.currentTarget.dataset.item.userid + "";
-        if (!userid) return;
-        if (this.data.radio) {
-            this.setData({
-                result: [userid]
-            })
-        } else {
-            let result = this.data.result;
-            if (result.some(v => v == userid)) {
-                result = result.filter(v => v != userid)
-            } else {
-                result.push(userid)
-            }
-            this.setData({
-                result
             })
-        }
-    },
-    //获取列表
-    getList(init = false) {
-        let content = this.data.content;
-        if (init) {
-            content.pageTotal = 1
-            content.pageNumber = 1
-        }
-        if (content.pageNumber > content.pageTotal) return;
-        _Http.basic({
-            "id": 20221018122201,
-            content
-        }).then(res => {
-            console.log("数据团队列表", res)
             this.setData({
-                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
-                "content.pageTotal": res.pageTotal,
-                "content.pageNumber": res.pageNumber + 1,
+                teams: res.data,
+                copyTeams: res.data.map(v => v.team)
             })
         })
     },

+ 3 - 1
packageA/group/index.json

@@ -1,4 +1,6 @@
 {
-    "usingComponents": {},
+    "usingComponents": {
+        "List": "./modules/list/index"
+    },
     "navigationBarTitleText": "团队"
 }

+ 37 - 76
packageA/group/index.scss

@@ -1,92 +1,53 @@
-.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;
-                }
-            }
-        }
-
-    }
+.tab-active-class {
+    font-size: 28rpx;
+    font-family: PingFang SC-Bold, PingFang SC;
+    font-weight: bold !important;
+    color: #3874F6 !important;
 }
 
-.footer {
+.head {
     display: flex;
-    justify-content: space-between;
+    width: 100vw;
+    height: 98rpx;
     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 {
+        flex: 1;
         font-size: 28rpx;
         font-family: PingFang SC-Regular, PingFang SC;
         color: #333333;
+        flex-shrink: 0;
+    }
+
+    .search {
+        display: flex;
+        align-items: center;
+        width: 360rpx;
+        height: 58rpx;
+        background: #FFFFFF;
+        border-radius: 29rpx;
+        box-sizing: border-box;
+        padding: 0 15rpx;
+
+        input {
+            flex: 1;
+            font-size: 28rpx;
+            padding: 0 10rpx;
+        }
     }
 
-    .but {
-        width: 156rpx;
-        height: 90rpx;
-        background: #3874F6;
+    .add {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        width: 58rpx;
+        height: 58rpx;
+        background: #FFFFFF;
         border-radius: 8rpx;
-        font-size: 28rpx;
-        font-family: PingFang SC-Bold, PingFang SC;
-        font-weight: bold;
-        color: #FFFFFF;
+        border: 2rpx solid #CCCCCC;
+        margin-left: 32rpx;
+        color: #666666;
     }
 }

+ 16 - 37
packageA/group/index.wxml

@@ -1,39 +1,18 @@
-<van-search value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:change='onInput' />
-<view style="height: 20rpx;" />
-<van-checkbox-group value="{{ result }}">
-    <view class="box">
-        <navigator url="#" class="item" wx:for="{{list}}" wx:key="item.userid" data-item="{{item}}" bindtap="onChange">
-            <view class="checkbox">
-                <van-checkbox shape='square' icon-size='14' name="{{item.userid}}" />
+<van-tabs active="{{ active }}" tab-active-class='tab-active-class' color='#3874F6' bind:change="onChange">
+    <van-tab wx:for="{{teams}}" title="{{item.teamname+'团队'}}" wx:key="index">
+        <view class="head">
+            <view class="count">
+                总计:{{item.team.length}}个
             </view>
-            <view class="user">
-                <view class="portrait">
-                    {{item.name[0]}}
-                </view>
-                <view class="exp">
-                    <view class="line-1">
-                        {{item.name}}
-                    </view>
-                    <view class="phone">
-                        {{item.phonenumber}}
-                    </view>
-                </view>
+            <view class="search">
+                <van-icon name="search" />
+                <input type="text" placeholder="搜索关键字" bindinput='onInput' value="{{keyword}}" />
+                <van-icon name="close" bindtap="cancelTheSearch" />
             </view>
-        </navigator>
-    </view>
-</van-checkbox-group>
-<view style="height: 130rpx;" />
-<view class="footer">
-    <view class="count">
-        已选:{{result.length}}
-    </view>
-    <van-button custom-class='but' disabled='{{result.length==0}}' bindtap="submit">确定</van-button>
-</view>
-
-<wxs module="active">
-    module.exports.que = function (name, list) {
-        return list.some(function (v) {
-            return v === name
-        })
-    }
-</wxs>
+            <navigator url="#" class="add">
+                <van-icon name="plus" />
+            </navigator>
+        </view>
+        <List list='{{item.team}}' />
+    </van-tab>
+</van-tabs>

+ 14 - 6
packageA/group/modules/Yl-group/index.js

@@ -14,23 +14,31 @@ Component({
                 "id": 20220930103501,
                 "content": {
                     ownertable: this.data.ownertable,
-                    ownerid: this.data.ownerid,
-                    pageSize: 5
+                    ownerid: this.data.ownerid
                 }
             }).then(res => {
-                console.log("团队", res)
+                console.log("团队列表", res)
                 if (res.msg != '成功') return wx.showToast({
                     title: res.data,
                     icon: "none"
                 });
+                if (res.data.length == 0) return;
+                let list = res.data.map(v => v.team);
+                const newArr = function (arr) {
+                    return arr.reduce((pre, cur) => pre.concat(Array.isArray(cur) ? newArr(cur) : cur), [])
+                }
+                list = newArr(list).slice(0, 5);
                 this.setData({
-                    list: res.data
+                    list
                 })
-            })
+            });
         },
         addUser() {
             wx.navigateTo({
-                url: '/packageA/group/index?ownertable=' + this.data.ownertable + '&ownerid=' + this.data.ownerid,
+                url: '/packageA/group/index?item=' + JSON.stringify({
+                    ownertable: this.data.ownertable,
+                    ownerid: this.data.ownerid
+                })
             })
         },
     }

+ 34 - 0
packageA/group/modules/list/index.js

@@ -0,0 +1,34 @@
+const _Http = getApp().globalData.http;
+Component({
+    properties: {
+        list: Array
+    },
+    options: {
+        addGlobalClass: true
+    },
+    data: {
+
+    },
+    methods: {
+        /* 处理删除 */
+        handleDelete(e) {
+            const {
+                item
+            } = e.currentTarget.dataset;
+            console.log(item)
+            wx.showModal({
+                title: '提示',
+                content: `是否确认移除${item.name}?`,
+                complete: ({
+                    confirm
+                }) => {
+                    if (confirm) {
+                        wx.showToast({
+                          title: '移除成功!',
+                        })
+                    }
+                }
+            })
+        },
+    }
+})

+ 4 - 0
packageA/group/modules/list/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 74 - 0
packageA/group/modules/list/index.scss

@@ -0,0 +1,74 @@
+.group-item {
+    height: 124rpx;
+    width: 100vw;
+    background-color: #ffffff;
+    padding-left: 30rpx;
+    box-sizing: border-box;
+
+    .main {
+        display: flex;
+        width: 100%;
+        height: 100%;
+        border-bottom: 1px solid #ddd;
+        padding: 20rpx 0rpx;
+        box-sizing: border-box;
+
+        .portrait {
+            width: 80rpx;
+            height: 80rpx;
+            border-radius: 50%;
+            overflow: hidden;
+            font-size: 0;
+            flex-shrink: 0;
+            margin-right: 30rpx;
+
+            image,
+            .alt {
+                width: 100%;
+                height: 100%;
+            }
+
+            .alt {
+                line-height: 80rpx;
+                text-align: center;
+                font-size: 28rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #FFFFFF;
+                background: #3874F6;
+            }
+        }
+
+        .content {
+            flex: 1;
+            width: 0;
+
+            .title {
+                width: 100%;
+                height: 42rpx;
+                line-height: 42rpx;
+                font-size: 30rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #333333;
+            }
+
+            .role {
+                width: 100%;
+                height: 34rpx;
+                line-height: 34rpx;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #999999;
+                margin-top: 8rpx;
+            }
+        }
+
+        .delete-box {
+            flex-shrink: 0;
+            color: #999999;
+            font-size: 32rpx;
+            padding: 0 30rpx;
+        }
+    }
+
+
+}

+ 22 - 0
packageA/group/modules/list/index.wxml

@@ -0,0 +1,22 @@
+<navigator class="group-item" url="#" wx:for="{{list}}" wx:key="item.changeuserid">
+    <view class="main">
+        <view class="portrait">
+            <image wx:if="{{item.headpic}}" src="{{item.headpic}}" mode="aspectFill" />
+            <view class="alt">
+                {{item.name[0]}}
+            </view>
+        </view>
+        <view class="content">
+            <view class="title line-1">
+                {{item.name}}
+            </view>
+            <view class="role line-1">
+                职位:{{item.position}}
+            </view>
+        </view>
+        <view class="delete-box" bindtap="handleDelete" data-item="{{item}}">
+            <text class="iconfont icon-shanchu" />
+        </view>
+    </view>
+</navigator>
+<My_empty wx:if="{{list.length==0}}" />

+ 103 - 0
packageA/group/select.js

@@ -0,0 +1,103 @@
+const _Http = getApp().globalData.http;
+
+Page({
+    data: {
+        radio: false, //是否为单选
+        content: {
+            "ownertable": "sa_itemgroup",
+            "ownerid": 11,
+            pageSize: 20,
+            pageNumber: 1,
+            pageTotal: 1,
+            "where": {
+                "condition": ""
+            }
+        },
+        list: [],
+        result: []
+    },
+    onLoad(options) {
+        //是否为单选
+        if (options.radio) this.setData({
+            radio: true
+        })
+        if (options.ownertable) {
+            this.setData({
+                "content.ownertable": options.ownertable,
+                "content.ownerid": options.ownerid,
+            });
+            this.getList();
+            console.log(this.data.content)
+        };
+    },
+    submit() {
+        let result = this.data.result;
+        if (result.length == 0) return;
+        console.log(result)
+        _Http.basic({
+            "id": 20220930103601,
+            "content": {
+                "ownertable": this.data.content.ownertable,
+                "ownerid": this.data.content.ownerid,
+                "userids": result
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            wx.showToast({
+                title: '保存成功',
+                icon: "none"
+            });
+            setTimeout(() => {
+                const pages = getCurrentPages();
+                pages[pages.length - 2].selectComponent("#Group").getList();
+                wx.navigateBack();
+            }, 300)
+        })
+    },
+    /* 选中 */
+    onChange(e) {
+        const userid = e.currentTarget.dataset.item.userid + "";
+        if (!userid) return;
+        if (this.data.radio) {
+            this.setData({
+                result: [userid]
+            })
+        } else {
+            let result = this.data.result;
+            if (result.some(v => v == userid)) {
+                result = result.filter(v => v != userid)
+            } else {
+                result.push(userid)
+            }
+            this.setData({
+                result
+            })
+        }
+    },
+    //获取列表
+    getList(init = false) {
+        let content = this.data.content;
+        if (init) {
+            content.pageTotal = 1
+            content.pageNumber = 1
+        }
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            "id": 20221018122201,
+            content
+        }).then(res => {
+            console.log("数据团队列表", res)
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                "content.pageTotal": res.pageTotal,
+                "content.pageNumber": res.pageNumber + 1,
+            })
+        })
+    },
+    onReachBottom() {
+        this.getList();
+    }
+})

+ 4 - 0
packageA/group/select.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "团队"
+}

+ 92 - 0
packageA/group/select.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;
+    }
+}

+ 39 - 0
packageA/group/select.wxml

@@ -0,0 +1,39 @@
+<van-search value="{{ value }}" shape="round" background="#fff" placeholder="搜索姓名、手机号" bind:change='onInput' />
+<view style="height: 20rpx;" />
+<van-checkbox-group value="{{ result }}">
+    <view class="box">
+        <navigator url="#" class="item" wx:for="{{list}}" wx:key="item.userid" data-item="{{item}}" bindtap="onChange">
+            <view class="checkbox">
+                <van-checkbox shape='square' icon-size='14' name="{{item.userid}}" />
+            </view>
+            <view class="user">
+                <view class="portrait">
+                    {{item.name[0]}}
+                </view>
+                <view class="exp">
+                    <view class="line-1">
+                        {{item.name}}
+                    </view>
+                    <view class="phone">
+                        {{item.phonenumber}}
+                    </view>
+                </view>
+            </view>
+        </navigator>
+    </view>
+</van-checkbox-group>
+<view style="height: 130rpx;" />
+<view class="footer">
+    <view class="count">
+        已选:{{result.length}}
+    </view>
+    <van-button custom-class='but' disabled='{{result.length==0}}' bindtap="submit">确定</van-button>
+</view>
+
+<wxs module="active">
+    module.exports.que = function (name, list) {
+        return list.some(function (v) {
+            return v === name
+        })
+    }
+</wxs>