Browse Source

新版本团队列表

xiaohaizhao 2 years ago
parent
commit
51752a03ef

+ 186 - 0
Universal/dataTeam/index.js

@@ -0,0 +1,186 @@
+const _Http = getApp().globalData.http;
+let ownertable = '',
+    ownerid = '',
+    id = "1";
+
+Page({
+    data: {
+        isleader: false,
+        manage: "管理",
+        result: []
+    },
+    onLoad(options) {
+        ownertable = options.ownertable;
+        ownerid = options.ownerid;
+        if (options.ownertable == "sa_workorder") id = "3";
+        this.getList();
+    },
+    getList() {
+        _Http.basic({
+            "id": 2022093010350 + id,
+            content: {
+                ownertable,
+                ownerid,
+                nocache: true
+            }
+        }).then(res => {
+            console.log(`数据团队${ownertable+ownerid}`, res)
+            if (res.msg != '成功') {
+                wx.showToast({
+                    title: res.msg,
+                    icon: "none",
+                    mask: true
+                });
+                return setTimeout(wx.navigateBack, 1500);
+            } else {
+                this.setData({
+                    list: res.data[0].team,
+                    isleader: res.data[0].teamleader[0].userid == wx.getStorageSync('userMsg').userid
+                })
+            }
+        })
+    },
+    /* 添加成员 */
+    insert() {
+        let params = id == 3 ? {
+            "id": "20230213143003",
+            "version": 1,
+            "content": {
+                nocache: true,
+                "where": {
+                    "condition": "",
+                    "isleader": 0
+                }
+            }
+        } : {
+            "id": 20221018122201,
+            "content": {
+                "ownertable": ownertable,
+                "ownerid": ownerid,
+                nocache: true,
+                "where": {
+                    "condition": "",
+                    "withoutselect": 1
+                }
+            }
+        };
+        wx.navigateTo({
+            url: `/select/contacts/index?params=${JSON.stringify(params)}`,
+        })
+        getApp().globalData.handleSelect = this.insertUser.bind(this);
+    },
+    insertUser({
+        value
+    }) {
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确认添加${value[0]+value[0].length}位成员`,
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) _Http.basic({
+                    "accesstoken": "7eb155cb0a9ed5895056afc151af7d7f",
+                    "id": 20220930103601,
+                    "content": {
+                        ownertable,
+                        ownerid,
+                        "userids": value[1],
+                        "justuserids": 1
+                    }
+                }).then(res => {
+                    console.log("添加成员", res)
+                    wx.showToast({
+                        title: res.msg == '成功' ? '添加成功' : res.msg,
+                        icon: "none",
+                        mask: true
+                    });
+                    if (res.msg == '成功') {
+                        that.getList()
+                        setTimeout(wx.navigateBack, 1000)
+                    }
+                })
+            }
+        })
+    },
+    /* 设置负责人 */
+    setLeader(e) {
+        const {
+            item
+        } = e.currentTarget.dataset,
+            that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确认将负责人转让到“${item.name}”`,
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) _Http.basic({
+                    "id": 2022093010370 + id,
+                    "content": {
+                        ownertable,
+                        ownerid,
+                        "userid": item.userid
+                    }
+                }).then(res => {
+                    wx.showToast({
+                        title: res.msg == '成功' ? '转让成功' : res.msg,
+                        icon: "none",
+                        mask: true
+                    });
+                    if (res.msg == '成功') that.getList()
+                })
+            }
+        })
+    },
+    /* 开启设置 */
+    setTeam() {
+        this.setData({
+            manage: this.data.manage == '管理' ? '取消' : "管理"
+        })
+    },
+    /* 选中成员 */
+    toggle(event) {
+        const {
+            name
+        } = event.currentTarget.dataset;
+        let result = this.data.result;
+        result.some(v => v == name) ? result = result.filter(v => v != name) : result.push(name);
+        this.setData({
+            result
+        })
+    },
+    /* 移除成员 */
+    onRemove() {
+        let result = this.data.result,
+            that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确认移除${result.length}位成员`,
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) _Http.basic({
+                    "id": 2022093010380 + id,
+                    "content": {
+                        ownertable,
+                        ownerid,
+                        "userids": result
+                    }
+                }).then(res => {
+                    wx.showToast({
+                        title: res.msg == '成功' ? '移除成功' : res.msg,
+                        icon: "none",
+                        mask: true
+                    });
+                    if (res.msg == '成功') {
+                        that.setData({
+                            result: []
+                        });
+                        that.getList()
+                    }
+                })
+            }
+        })
+    }
+})

+ 5 - 0
Universal/dataTeam/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "van-tag": "@vant/weapp/tag/index"
+  }
+}

+ 81 - 0
Universal/dataTeam/index.scss

@@ -0,0 +1,81 @@
+.user-box {
+	width: 100vw;
+	background-color: #fff;
+	box-sizing: border-box;
+	padding: 20rpx 0 0 30rpx;
+
+	.user {
+		display: flex;
+		border-bottom: 1px solid #ddd;
+		padding-bottom: 20rpx;
+
+		.profile {
+			height: 84rpx;
+			width: 84rpx;
+			text-align: center;
+			overflow: hidden;
+			border-radius: 50%;
+			flex-shrink: 0;
+			margin-right: 20rpx;
+
+			.text {
+				line-height: 84rpx;
+				text-align: center;
+				background-color: #3874F6;
+				color: #fff;
+			}
+		}
+
+		.content {
+			flex: 1;
+			height: 84rpx;
+			width: 0;
+
+			.name {
+				font-size: 28rpx;
+				margin-bottom: 4rpx;
+			}
+		}
+
+		.set {
+			display: flex;
+			align-items: center;
+			flex-shrink: 0;
+			height: 84rpxrpx;
+			margin-right: 30rpx;
+		}
+	}
+}
+
+.search {
+	position: relative;
+	box-shadow: rgba(50, 50, 93, 0.1) 0px 6px 12px -2px, rgba(0, 0, 0, 0.05) 0px 3px 7px -3px;
+	z-index: 9;
+	position: sticky;
+	top: 0;
+	z-index: 999;
+	width: 100vw;
+}
+
+.footer {
+	display: flex;
+	justify-content: center;
+	position: fixed;
+	bottom: 0;
+	width: 100vw;
+	min-height: 130rpx;
+	background-color: #fff;
+	box-shadow: rgba(0, 0, 0, 0.15) 0px 5rpx 15rpx 0px;
+	z-index: 999999999999999;
+
+	.but {
+		width: 690rpx;
+		height: 90rpx;
+		background: #FA8C16;
+		border-radius: 16rpx;
+		font-size: 28rpx;
+		font-weight: 600;
+		color: #FFFFFF;
+		margin-top: 10rpx;
+	}
+}

+ 42 - 0
Universal/dataTeam/index.wxml

@@ -0,0 +1,42 @@
+<van-search custom-class="search" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' use-action-slot bind:clear='onClear'>
+	<view slot="action" wx:if="{{isleader}}" style="color: #333;" catchtap="setTeam">
+		<van-icon name="setting" /> {{manage}}
+	</view>
+</van-search>
+
+<view style="height: 20rpx;" />
+<view hover-class="{{manage=='管理'?'none':'navigator-hover'}}" class="user-box" wx:for="{{list}}" data-name="{{item.userid}}" bind:tap="{{manage=='管理'?'':'toggle'}}" wx:key="userid">
+	<view class="user">
+		<view class="profile">
+			<van-image wx:if="{{item.headpic}}" width="42" height="42" round src="{{item.headpic}}" lazy-load />
+			<view wx:else class="text">
+				{{item.name[0]}}
+			</view>
+		</view>
+		<view class="content">
+			<view class="name line-1">
+				{{item.name}}
+			</view>
+			<view class="tags">
+				<van-tag wx:if="{{item.isleader}}" style="margin-right: 10rpx;" type="danger">负责人</van-tag>
+				<van-tag type="primary">{{item.position}}</van-tag>
+			</view>
+		</view>
+		<view class="set" wx:if="{{isleader && item.isleader==0}}">
+			<van-button wx:if="{{manage=='管理'}}" type="primary" size="mini" data-item="{{item}}" bindclick='setLeader'>转让负责人</van-button>
+			<van-checkbox wx:else custom-class='checkbox' icon-size='18' value='{{wqp.query(result,item.userid)}}' name="{{item.userid}}" />
+		</view>
+	</view>
+</view>
+<view style="height: 34rpx;" />
+<Yl_Empty wx:if="{{list.length==0}}" />
+<Yl_FloatingButton wx:if="{{isleader && manage=='管理'}}" bindtap="insert" />
+
+<block wx:if="{{manage!='管理'}}">
+	<!-- 底部 -->
+	<view style="height: 100rpx;" />
+	<view class="footer">
+		<van-button custom-class='but' disabled='{{!result.length}}' bindclick="onRemove">移除({{result.length}})</van-button>
+	</view>
+</block>
+<wxs src="../../utils/wxmlQueryPer.wxs" module="wqp" />