Browse Source

接口联调

htc 1 day ago
parent
commit
6aa15b3cd0

+ 25 - 9
components/CusTeamUser/index.vue

@@ -3,17 +3,19 @@
 		<view class="dialog-box">
 			<view class="dialog-box-title">{{title}}</view>
 			<image class="dialog-box-close" :src="imgBase+'remind_close.png'" @click="close"></image>
+			<view class="dialog-box-bottom" @click="addUser">添加人员</view>
 			<view class="dialog-box-list">
 				<view class="dialog-box-list-item" v-for="(item,index) in list" :key="index">
 					<view class="dialog-box-list-item-status" :class="{'wzd':item.status===0,'yzd':item.status===1}">{{statusCfg[item.status]}}</view>
 					<view class="dialog-box-list-item-name adfac">
-						<text>{{item.name}}</text>
-						<view class="type">{{typeCfg[item.type]}}</view>
+						<text>{{item.realName}}</text>
+						<view class="type">{{item.categoryName}}</view>
 					</view>
 					<view class="dialog-box-list-item-email">{{item.email}}</view>
 					<image class="dialog-box-list-item-delete" :src="imgBase+'icon_delete.png'" @click="deleteUser(item,index)" v-if="deluser"></image>
 				</view>
 			</view>
+			<view class="zt_btn" style="margin-top: 40rpx;" @click="handleConfirm">确定</view>
 		</view>
 	</view>
 </template>
@@ -40,11 +42,6 @@
 		},
 		data(){
 			return {
-				typeCfg:{
-					1:'赞助人Sponsor',
-					2:'团队Leader',
-					3:'利益相关者Stakeholder'
-				},
 				statusCfg:{
 					0:'未作答',
 					1:'已作答'
@@ -56,8 +53,14 @@
 				this.$emit('close')
 			},
 			deleteUser(item,index){
-				this.$emit('deleteUser')
-			}
+				this.$emit('deleteUser',{item,index})
+			},
+			addUser(){
+				this.$emit('addUser')
+			},
+			handleConfirm(){
+				this.$emit('handleConfirm')
+			},
 		}
 	}
 </script>
@@ -94,6 +97,19 @@
 				top: 30rpx;
 				right: 30rpx;
 			}
+			&-bottom{
+				width: 100%;
+				height: 88rpx;
+				background: rgba(25,156,156,0.1);
+				border-radius: 44rpx;
+				font-family: PingFang-SC, PingFang-SC;
+				font-weight: bold;
+				font-size: 32rpx;
+				color: #009191;
+				line-height: 88rpx;
+				text-align: center;
+				margin-top: 40rpx;
+			}
 			&-list{
 				height: 900rpx;
 				margin-top: 40rpx;

+ 65 - 29
pagesHome/components/createList.vue

@@ -18,7 +18,7 @@
 						</view>
 						<view class="bottom adfacjb">
 							<view class="bottom-left">截止时间:{{item.endTime}}</view>
-							<view class="bottom-right" v-if="item.status===0" @click.stop="handleAnswer(item)">立即作答</view>
+							<view class="bottom-right" v-if="item.status===0&&item.type==1" @click.stop="handleAnswer(item)">立即作答</view>
 							<view class="bottom-right" v-else-if="item.status===1&&!item.fileUrl" @click.stop="createReport(item)">生成报告</view>
 							<view class="bottom-right" v-else-if="item.status===1&&item.fileUrl" @click.stop="sendReport(item)">发送报告</view>
 						</view>
@@ -70,7 +70,8 @@
 				<div class="zt_btn" @click="alertShow=false">我知道了</div>
 			</div>
 		</div>
-		<cus-team-user :deluser="true" :show="teamUserShow" :list="teamUserList" @close="teamUserShow=false"></cus-team-user>
+		<cus-team-user :deluser="true" :show="teamUserShow" :list="teamUserList" 
+			@close="teamUserShow=false" @addUser="addUser" @handleConfirm="userConfirm" @deleteUser="deleteUser"></cus-team-user>
 	</view>
 </template>
 
@@ -124,34 +125,12 @@
 					}
 				],
 				menuListCopy:[],
-				teamUserList:[
-					// {
-					// 	name:'张三',
-					// 	email:'2233983769@qq.com',
-					// 	type:1,
-					// 	status:0
-					// },
-					// {
-					// 	name:'李四',
-					// 	email:'2233983769@qq.com',
-					// 	type:2,
-					// 	status:0
-					// },
-					// {
-					// 	name:'王五',
-					// 	email:'2233983769@qq.com',
-					// 	type:3,
-					// 	status:1
-					// },
-					// {
-					// 	name:'赵六',
-					// 	email:'2233983769@qq.com',
-					// 	type:1,
-					// 	status:1
-					// }
-				],
+				teamUserList:[],
+				originTeamUserList:[],
 				teamScaleData:[],
 				teamLevelData:[],
+				categoryData:[],
+				delMemberIds:[],
 			}
 		},
 		methods:{
@@ -182,11 +161,21 @@
 					})
 				})	
 			},
+			async getUserCategoryData(){
+				return new Promise((resolve,reject)=>{
+					this.$api.get('/getListByType/UserCategory').then(({data:res})=>{
+						if(res.code!==0) return this.$showToast(res.msg)
+						this.categoryData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
+						resolve()
+					})
+				})	
+			},
 			async handleMenuClick(item){
 				if(item.text==='编辑问卷'){
 					uni.navigateTo({
-						url:`/pagesHome/questionnaireEdit?teamQuestionnaireId=${this.dto.teamQuestionnaireId}&type=${this.dto.type}&questionnaireName=${this.dto.title}`
+						url:`/pagesHome/questionnaireEdit?teamQuestionnaireId=${this.dto.teamQuestionnaireId}&type=${this.dto.type}&questionnaireName=${this.dto.title}&isEdit=true`
 					})
+					this.show = false;
 				}else if(item.text==='分享问卷'){
 					
 				}else if(item.text==='团队信息'){
@@ -210,8 +199,14 @@
 					this.$showToast('复制成功')
 				}
 				else if(item.text==='团队人员'){
+					await this.getUserCategoryData()
 					this.$api.get(`/core/member/listByQueTeamId/${this.dto.teamQuestionnaireId}`).then(({data:res})=>{
 						if(res.code!==0) return this.$showToast(res.msg)
+						this.teamUserList = res.data;
+						this.originTeamUserList = res.data;
+						this.teamUserList.forEach(l=>{
+							l.categoryName = this.categoryData.find(c=>c.id==l.category)?.name;
+						})
 						this.teamUserShow = true
 					})
 				} 
@@ -242,6 +237,47 @@
 			sendReport(item){
 				
 			},
+			addUser(){
+				uni.navigateTo({
+					url:'/pagesMy/teamUser?type=select',
+					events:{
+						selectUserConfirm: data => {
+							data.forEach((d,i)=>(this.$set(data[i],'status',0)));
+							let newUser = this.filterUsers(this.teamUserList,data)
+							this.teamUserList = [...this.teamUserList,...newUser];
+						}
+					}
+				})
+			},
+			filterUsers(originArr,selectArr){
+				const aValuesToExclude = new Set(originArr.map(item => item.id));
+				return selectArr.filter(item => {
+				  return !aValuesToExclude.has(item.id);
+				});
+			},
+			userConfirm(){
+				if(this.teamUserList.length===0) return this.$showToast('至少保留一位团队人员');
+				this.$api.get('/core/team/questionnaire/'+this.dto.teamQuestionnaireId).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					let dto = res.data;
+					dto.coachId = JSON.parse(uni.getStorageSync('userInfo')).id;
+					dto.delMemberIds = [...new Set(this.delMemberIds)];
+					dto.memberList = this.teamUserList;
+					dto.type = 2;
+					delete dto.memberInfos;
+					this.$api.put('/core/team/questionnaire/updateMembers',dto).then(({data:resu})=>{
+						if(resu.code!==0) return this.$showToast(resu.msg)
+						this.$showToast('操作成功')
+						this.teamUserShow = false;
+						// this.show = false;
+					})
+				})
+			},
+			deleteUser(data){
+				let u = this.originTeamUserList.find(u=>u.id===data.item.id);
+				if(u) this.delMemberIds=[...this.delMemberIds,u.id]
+				this.teamUserList.splice(data.index,1);
+			}
 		}
 	}
 </script>

+ 8 - 2
pagesHome/questionnaire.vue

@@ -38,8 +38,14 @@
 				teamUserShow:false,
 			}
 		},
-		onLoad() {
-			this.getReceiveList();
+		onShow() {
+			if(this.tindex===0){
+				this.receiveList = [];
+				this.getReceiveList();
+			}else if(this.tindex===1){
+				this.createList = [];
+				this.getCreateList();
+			}
 		},
 		methods:{
 			changeTab(index){

+ 25 - 9
pagesHome/questionnaireEdit.vue

@@ -47,7 +47,7 @@
 				</view>
 			</view>
 		</view>
-		<view class="box" style="padding: 30rpx 24rpx 0;" v-if="type>1">
+		<!-- <view class="box" style="padding: 30rpx 24rpx 0;" v-if="type==2">
 			<view class="box-title adfacjb" style="margin-bottom: 21rpx;">
 				<text>团队人员</text>
 				<view class="box-add" @click="addTeamUser">+ 添加</view>
@@ -64,7 +64,7 @@
 					<image class="box-user-item-right" :src="imgBase+'icon_delete.png'" @click="deleteTeamUser(item,index)"></image>
 				</view>
 			</view>
-		</view>
+		</view> -->
 		<view class="bottom">
 			<view class="zt_btn" @click="confirmPublish">{{confirmText}}</view>
 		</view>
@@ -98,7 +98,8 @@
 				teamName:'请选择团队',
 				teamList:[],
 				minStartTime:new Date().getTime(),
-				minEndTime:''
+				minEndTime:new Date().getTime(),
+				isEdit:'',
 			}
 		},
 		onReady() {
@@ -110,10 +111,15 @@
 			this.questionnaireId = options.questionnaireId;
 			this.questionnaireName = options.questionnaireName;
 			this.type = options.type;
+			this.isEdit = options.isEdit;
 			if(this.type==2){
 				this.title = '发布问卷';
 				this.confirmText = '确认发布';
 				this.dto.answerSetting = 1;
+				if(this.isEdit){
+					this.title = '编辑问卷';
+					this.getDetail()
+				}
 			}else if(this.type==1) this.getDetail()
 		},
 		methods:{
@@ -132,7 +138,7 @@
 			valChange(e){
 				this.dto.answerSetting = e;
 			},
-			getDetail(){
+			async getDetail(){
 				this.$api.get('/core/team/questionnaire/'+this.teamQuestionnaireId).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
 					this.dto = {...this.dto,...res.data}
@@ -211,18 +217,28 @@
 				if(!params?.teamId) return this.$showToast('请选择团队')
 				if(!params?.startTime) return this.$showToast('请选择开始时间')
 				if(!params?.endTime) return this.$showToast('请选择结束时间')
-				if(params?.memberList.length==0) return this.$showToast('请选择团队人员')
+				if(params?.memberList.length==0&&!this.isEdit) return this.$showToast('请选择团队人员')
 				
 				let url = '/core/team/questionnaire';
+				let method = 'put';
 				if(this.type==2){
 					url = '/core/team/questionnaire/publish';
+					method = 'post'
 					params.questionnaireId = this.questionnaireId
+					if(this.isEdit){
+						url = '/core/team/questionnaire';
+						method = 'put';
+					}
 				}
-				this.$api[this.type==2?'post':'put'](url,params).then(({data:res})=>{
+				this.$api[method](url,params).then(({data:res})=>{
 					if(res.code!==0) return this.$showToast(res.msg)
-					if(this.type==2){
-						uni.navigateTo({ url:'/pagesPublish/publishResult?title='+this.questionnaireName })
-					}else uni.navigateBack()
+					this.$showToast('操作成功')
+					setTimeout(()=>{
+						if(this.type==2){
+							if(this.isEdit) return uni.navigateBack()
+							uni.navigateTo({ url:'/pagesPublish/publishResult?title='+this.questionnaireName })
+						}else uni.navigateBack()
+					},1500)
 				})
 			}
 		}