Quellcode durchsuchen

fix: update questionnaire report menu and preview

Developer vor 2 Wochen
Ursprung
Commit
b3cda449d5

+ 68 - 37
pagesHome/components/createList.vue

@@ -99,7 +99,16 @@
 			@addUser="addUser"
 			@handleConfirm="userConfirm"
 			@deleteUser="deleteUser"
-		></cus-team-user>
+		></cus-team-user>
+		<cus-select-team-user
+			ref="sendTeamUserSelect"
+			:show="sendTeamUserShow"
+			:list="sendTeamUserList"
+			@close="handleSendTeamUserClose"
+			@changeAll="changeSendAll"
+			@handleSelectUser="handleSendUserSelect"
+			@handleConfirm="confirmSendReport"
+		></cus-select-team-user>
 		<view class="kind-reminder adffcacjc" v-if="testShow">
 			<view class="kr-box adffcac">
 				<view class="kr-title">温馨提示</view>
@@ -114,6 +123,7 @@
 import PageEmpty from '@/components/pageEmpty/index.vue'
 import CusTeamUser from '@/components/CusTeamUser/index.vue'
 import CusTeamInfoFill from '@/components/CusTeamInfoFill/index.vue'
+import CusSelectTeamUser from '@/components/CusSelectTeamUser/index.vue'
 import backgroundSurveyRules from '@/utils/backgroundSurvey.js'
 const { backgroundIntroUrl } = backgroundSurveyRules
 
@@ -138,7 +148,7 @@ function extractReportId(payload) {
 }
 
 export default {
-	components:{ PageEmpty, CusTeamUser, CusTeamInfoFill },
+	components:{ PageEmpty, CusTeamUser, CusTeamInfoFill, CusSelectTeamUser },
 	props:{
 		list:{
 			typeof:Array,
@@ -150,16 +160,13 @@ export default {
 			show:false,
 			teamInfoShow:false,
 			teamUserShow:false,
+			sendTeamUserShow:false,
 			alertShow:false,
 			dto:null,
 			menuList:[
 				{
 					img:this.$imgBase+'questionnaire_edit.png',
-					text:'编辑问卷(一)'
-				},
-				{
-					img:this.$imgBase+'questionnaire_edit.png',
-					text:'编辑问卷(二)'
+					text:'编辑问卷'
 				},
 				{
 					img:this.$imgBase+'questionnaire_share.png',
@@ -169,10 +176,6 @@ export default {
 					img:this.$imgBase+'questionnaire_info.png',
 					text:'团队信息'
 				},
-				{
-					img:this.$imgBase+'questionnaire_copy.png',
-					text:'复制链接'
-				},
 				{
 					img:this.$imgBase+'questionnaire_users.png',
 					text:'团队人员'
@@ -180,6 +183,10 @@ export default {
 				{
 					img:this.$imgBase+'questionnaire_report.png',
 					text:'生成报告'
+				},
+				{
+					img:this.$imgBase+'questionnaire_report.png',
+					text:'发送报告'
 				}
 			],
 			menuListCopy:[],
@@ -188,6 +195,8 @@ export default {
 			teamScaleData:[],
 			teamLevelData:[],
 			categoryData:[],
+			sendReportId:null,
+			sendTeamUserList:[],
 			delMemberIds:[],
 			testShow:false,
 			tipText:'',
@@ -255,12 +264,7 @@ export default {
 			})
 		},
 		async handleMenuClick(item){
-			if(item.text==='编辑问卷(一)'){
-				uni.navigateTo({
-					url:`/pagesPublish/backgroundSurvey?mode=coach&teamQuestionnaireId=${encodeURIComponent(this.dto.teamQuestionnaireId)}`
-				})
-				this.show = false;
-			}else if(item.text==='编辑问卷(二)'){
+			if(item.text==='编辑问卷'){
 				uni.navigateTo({
 					url:`/pagesHome/questionnaireEdit?teamQuestionnaireId=${this.dto.teamQuestionnaireId}&type=${this.dto.type}&questionnaireName=${this.dto.title}&isEdit=true`
 				})
@@ -284,27 +288,12 @@ export default {
 					this.$refs.teamRef.teamLevelText = this.teamLevelData.find(d=>d.id==res.data.hierarchy).name;
 				})
 			}
-			else if(item.text==='复制链接') {
-				let shareUserId = JSON.parse(uni.getStorageSync('userInfo')).id;
-				let res = await this.$api.post('/wx/genInviteLink',{
-					'path': '',
-					'query': `shareTQId=${this.dto.teamQuestionnaireId}&shareUserId=${shareUserId}&shareType=Questionnaire`,
-					'env_version': 'trial'//默认"release",正式版"release",体验版"trial",开发版"develop"
-				});
-				if(res.data.code!==0) return this.$showToast(res.data.msg)
-				uni.setClipboardData({
-					data:res.data.data.openlink,
-					success: () => {
-						this.$showToast('复制成功')
-					},
-					fail: () => {
-						this.$showToast('复制失败')
-					}
-				})
-			}
 			else if(item.text==='团队人员'){
 				this.showTeamUser(this.dto);
 			}
+			else if(item.text==='发送报告'){
+				this.sendReport(this.dto);
+			}
 			else if(item.text==='生成报告'){
 				if(this.dto.status==0) return this.$showToast('问卷未完成,全部团队人员作答后才能生成报告')
 				this.createReportConfirm(this.dto.teamQuestionnaireId)
@@ -390,8 +379,50 @@ export default {
 				})
 			})
 		},
-		sendReport(item){
-
+		async sendReport(item){
+			const reports = await this.$api.get('/core/report/generatedReportList',{page:1,limit:100,teamName:''})
+			if(reports.data.code!==0) return this.$showToast(reports.data.msg)
+			const report = (reports.data.data.list||[])
+				.filter(report => String(report.teamQueId) === String(item.teamQuestionnaireId) && report.state !== '-1' && report.state !== -1)
+				.sort((a,b) => String(b.createDate||'').localeCompare(String(a.createDate||'')))[0]
+			if(!report || !report.reportId) return this.$showToast('该问卷尚未生成可发送的报告')
+			this.sendReportId = report.reportId
+			await this.getUserCategoryData()
+			const members = await this.$api.get(`/core/member/listByQueTeamId/${item.teamQuestionnaireId}`)
+			if(members.data.code!==0) return this.$showToast(members.data.msg)
+			this.sendTeamUserList = (members.data.data||[]).map(member => ({
+				...member,
+				categoryName:this.categoryData.find(category => category.id==member.category)?.name,
+				select:false
+			}))
+			if(!this.sendTeamUserList.length) return this.$showToast('暂无可发送的团队成员')
+			this.$refs.sendTeamUserSelect.selectNums = 0
+			this.$refs.sendTeamUserSelect.selectAll = false
+			this.sendTeamUserShow = true
+		},
+		handleSendTeamUserClose(){
+			this.sendTeamUserShow = false
+		},
+		changeSendAll(selected){
+			this.sendTeamUserList.forEach((member,index) => this.$set(this.sendTeamUserList[index],'select',selected))
+			this.$refs.sendTeamUserSelect.selectNums = selected ? this.sendTeamUserList.length : 0
+		},
+		handleSendUserSelect(index){
+			this.$set(this.sendTeamUserList[index],'select',!this.sendTeamUserList[index].select)
+			const selected = this.sendTeamUserList.filter(member => member.select).length
+			this.$refs.sendTeamUserSelect.selectNums = selected
+			this.$refs.sendTeamUserSelect.selectAll = selected === this.sendTeamUserList.length
+		},
+		async confirmSendReport(){
+			const selected = this.sendTeamUserList.filter(member => member.select)
+			if(!selected.length) return this.$showToast('请选择要发送的用户')
+			const result = await this.$api.post('/core/report/sendReport',{
+				reportId:this.sendReportId,
+				memberList:selected.map(member => ({id:member.id,mobile:member.mobile,category:member.category}))
+			})
+			if(result.data.code!==0) return this.$showToast(result.data.msg)
+			this.sendTeamUserShow = false
+			uni.navigateTo({url:'/pagesHome/sendResult?result='+result.data.code})
 		},
 		addUser(){
 			uni.navigateTo({

+ 1 - 1
pagesPublish/backgroundSurvey.vue

@@ -9,7 +9,7 @@
 			<view class="survey-progress">
 				<view class="survey-progress-row adfacjb">
 					<text>答题进度</text>
-					<text><span>{{currentIndex + 1}}</span>/{{survey.questionCount}}</text>
+					<text>{{currentIndex + 1}}/{{survey.questionCount}}</text>
 				</view>
 				<view class="survey-progress-track">
 					<view class="survey-progress-current" :style="{width:progressPercent+'%'}"></view>

+ 5 - 3
pagesPublish/questionnairePreview.vue

@@ -68,7 +68,7 @@
 		onLoad(options) {
 			this.type = options.type;
 			this.questionnaireName = options.questionnaireName;
-			if(this.type==2) this.getData2(options.questionnaireId, options.backgroundSurveyId)
+			if(this.type==2) this.getData2(options.questionnaireId, options.backgroundSurveyId, options.teamQuestionnaireId)
 			else this.getData(options.teamQuestionnaireId)
 		},
 		methods:{
@@ -83,11 +83,13 @@
 					this.isLoading = false;
 				})
 			},
-			async getData2(id, backgroundSurveyId){
+			async getData2(id, backgroundSurveyId, teamQuestionnaireId){
 				this.isLoading = true;
 				try {
 					const requests = [this.$api.get(`/core/questionnaire/${id}`)]
-					if(backgroundSurveyId){
+					if(teamQuestionnaireId){
+						requests.push(this.$api.get(`/core/background/survey/member/team-questionnaire/${teamQuestionnaireId}`))
+					}else if(backgroundSurveyId){
 						requests.push(this.$api.get(`/core/background/survey/${backgroundSurveyId}`))
 					}
 					const responses = await Promise.all(requests)