From 155f2b80f2a9b6f900c73f6e4461e9cebb7cd028 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期二, 10 十月 2023 17:12:20 +0800
Subject: [PATCH] #

---
 pages/business/cstmr/cstmrDetails.vue |  203 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 189 insertions(+), 14 deletions(-)

diff --git a/pages/business/cstmr/cstmrDetails.vue b/pages/business/cstmr/cstmrDetails.vue
index 6f27b5e..18c3a20 100644
--- a/pages/business/cstmr/cstmrDetails.vue
+++ b/pages/business/cstmr/cstmrDetails.vue
@@ -30,12 +30,30 @@
 				<view class="list-item1">淇敼鏃堕棿</view><view class="list-item2 color-main">{{cstmr.updateTime$}}</view>
 			</view>
 			<view class="container">
-				<view><y-title title="璺熻繘浜�"></y-title></view><view></view><view><uni-icons type="plus" size="20" color="#55aaff"></uni-icons></view>
+				<view><y-title title="璺熻繘浜�"></y-title></view><view></view><view><uni-icons @click="addPerson()" type="plus" size="20" color="#55aaff"></uni-icons></view>
+				<view class="list" v-for="(item,index) in followers" :key="index">
+					<view class="list-left">{{item.userName}}</view>
+					<view class="list-right"><button size="mini" style="float: right;" type="warn" @click="removeFollowers(item.userId)">绉婚櫎</button></view>
+				</view>
+				<view class="list-none" v-show="followers.length == 0">
+					<text>鏆傛棤璺熻繘浜�</text>
+				</view>
 			</view>
 			
 		</scroll-view>
 		<view class="foot">
-			<button>鍒犻櫎</button>
+			<button  size="mini" type="warn" @click="del(id)">鍒犻櫎</button>
+		</view>
+		
+		<view>
+			<!-- 杈撳叆妗嗙ず渚� -->
+			<uni-popup ref="inputDialog" type="dialog">
+				<uni-popup-dialog ref="inputClose" mode="input" title="娣诲姞璺熻繘浜�" value="瀵硅瘽妗嗛缃彁绀哄唴瀹�!"
+					placeholder="璇疯緭鍏ュ唴瀹�" @confirm="confirm">
+						<uni-combox :candidates="addFollower.followers" placeholder="璇烽�夋嫨"
+						v-model="addFollower.follower" @input="autoLoad('follower',addFollower.follower)"></uni-combox>
+				</uni-popup-dialog>
+			</uni-popup>
 		</view>
 	</view>
 </template>
@@ -44,20 +62,30 @@
 	export default {
 		data() {
 			return {
-				id: '',
-				baseUrl: '',
+				id: 0,
 				cstmr: {
-					name: '娌冲寳鍚涢偊涔充笟鏈夐檺鍏徃',
-					tel: '15067665399',
-					addr: '娌冲寳鐪侀偗閮稿競鍚涢偊涔充笟鏈夐檺鍏徃',
-					cstman: '鏈辨槑蹇�'
-				}
+					id: '',
+					name: '',
+					tel: '',
+					addr: '',
+					cstman: ''
+				},
+				addFollower: {
+					follower: '',
+					followers: '',
+					followerList: []
+				},
+				followers: [],
+				cstmrId: ''
 			}
 		},
 		onLoad(option) { 
 			this.id = option.id
-			this.baseUrl = uni.getStorageSync('baseUrl')
 			this.init()
+			this.autoLoad('follower','')
+			setTimeout(()=>{
+				this.getFollowers()
+			},500)
 		},
 		methods: {
 			init() {
@@ -69,7 +97,120 @@
 					success(res) {
 						res = res.data
 						that.cstmr = res.data
+						that.cstmrId = that.cstmr.id
+					}
+				})
+			},
+			del(e) {
+				let that = this
+				e = Number(e)
+				uni.request({
+					url: that.baseUrl + '/cstmr/delete/one/' + e,
+					header: {'token' : uni.getStorageSync('token'),
+					},
+					method: 'GET',
+					
+					success(res) {
 						console.log(res);
+						res = res.data
+						if (res.code === 200) {
+							uni.navigateBack()
+						} else if (res.code === 403) {
+							uni.showToast({title: res.msg, icon: "none", position: 'top'})
+							setTimeout(() => {
+								uni.reLaunch({
+									url: '../../login/login'
+								});
+							}, 1000);
+						} else {
+							uni.showToast({title: res.msg, icon: "none",position: 'top'})
+						}
+					}
+				})
+			},
+			addPerson() {
+				this.$refs.inputDialog.open()
+			},
+			// 纭閫夋嫨宸ヤ綔浜�
+			confirm() {
+				let that = this
+				var followerId
+				var followerList = that.addFollower.followerList
+				for (var i = 0;i < followerList.length; i++) {
+					if (followerList[i].name == this.addFollower.follower) {
+						followerId =followerList[i].value
+					}
+				}
+				uni.request({
+					url: that.baseUrl + '/cstmr/followers/add/json',
+					header:{'token':uni.getStorageSync('token'),
+						// 'content-type':'application/x-www-form-urlencoded',
+						},
+					data: {
+						cstmrId: that.cstmrId,
+						followerIds:followerId},
+					method: 'POST',
+					success(result) {
+						var res = result.data
+						that.getFollowers()
+					}
+				})
+				this.addFollower.follower = ''
+			},
+			// 宸ヤ綔浜哄垪琛�
+			autoLoad(type,condition) {
+				let that = this
+				that.addFollower.followers = []
+				that.addFollower.followerList = []
+				uni.request({
+					url: that.baseUrl + '/user/all/get/kv',
+					header:{'token':uni.getStorageSync('token')},
+					data: {condition:condition},
+					method: 'POST',
+					success(result) {
+						var res = result.data
+						if (res.code === 200) {
+							var element;
+							if (type == 'follower') {
+								for(element of res.data) {
+									that.addFollower.followers.push(element.name)
+									that.addFollower.followerList.push(element)
+								}
+								return
+							}
+						}
+					}
+				})
+			},
+			getFollowers() {
+				let that = this
+				uni.request({
+					url: that.baseUrl + '/cstmr/followers/table/auth',
+					header:{'token':uni.getStorageSync('token')},
+					data: {cstmrId:that.cstmrId},
+					method:'GET',
+					success(res) {
+						res = res.data
+						that.followers = res.data
+					}
+				})
+			},
+			removeFollowers(userId) {
+				let that = this
+				uni.request({
+					url: that.baseUrl + '/cstmr/followers/remove/auth',
+					header:{
+						'token':uni.getStorageSync('token'),
+						'content-type': 'application/x-www-form-urlencoded'
+					},
+					data: {
+						cstmrId:that.cstmrId,
+						userId: userId
+						},
+					method:'POST',
+					success(res) {
+						res = res.data
+						that.getFollowers()
 					}
 				})
 			}
@@ -81,7 +222,7 @@
 	.header {
 		width: auto;
 		min-height: 110rpx;
-		background-color: #f8f8f8;
+		background-color: #fff;
 		padding: 30px 20px 10px 20px;
 	}
 	.cstmr-name {
@@ -105,13 +246,13 @@
 	.container {
 		margin-top: 10px;
 		padding: 10rpx 20rpx 0 20rpx;
-		background-color: #f8f8f8;
+		background-color: #fff;
 		display: grid;
 		grid-template-columns: 1fr 3fr;
 	}
 	.container:last-child {
 		grid-template-columns: 5fr 5fr 2fr;
-		margin-bottom: 100rpx;
+		margin-bottom: 120rpx;
 	}
 	.list-item1 {
 		min-height: 45rpx;
@@ -129,9 +270,43 @@
 	}
 	.foot {
 		position: fixed;
-		/* display: flex; */
+		width: 100%;
 		min-height: 100rpx;
 		bottom: 0;
 		margin-bottom: 0;
+		background-color: #fff;
+		border-top: 1px solid #efefef;
+		display: flex;
+		align-items: center;
+	}
+	.list {
+		min-height: 60rpx;
+		margin-top: 20rpx;
+		grid-column: 1 / 10;
+		display: grid;
+		grid-template-columns: 1fr 1fr;
+		position: relative;
+	}
+	.list-left {
+		min-height: 60rpx;
+		line-height: 60rpx;
+		padding-left: 20rpx;
+		color: #55aaff
+	}
+	.list-right {
+		min-height: 60rpx;
+		line-height: 60rpx;
+		/* background-color: #222; */
+		padding-right: 30rpx;
+	}
+	.list-none {
+		min-height: 60rpx;
+		margin-top: 20rpx;
+		text-align: center;
+		/* background-color: #303133; */
+		color: #b1b3b8;
+		grid-column: 1 / 10;
+		display: grid;
+		position: relative;
 	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.1