优化问卷回答界面及功能

This commit is contained in:
zlwu committed 2025-06-27 11:47:00 +08:00
1 parent 1ab9f9c458
commit ed5eb9ca52
13 files changed
+6122 -86

No files matched your search

+56 -3
View File
@@ -1,6 +1,13 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SatSurveyVO, SatSurveyForm, SatSurveyQuery } from '@/api/hq/answerSurvey/types';
import {
SatSurveyVO,
SatSurveyForm,
SatSurveyQuery,
SubmitSurveyAnswerForm,
SatRecordVO,
SurveyStatisticsVO
} from '@/api/hq/answerSurvey/types';
/**
* 查询问卷列表
@@ -134,7 +141,7 @@ export const getUserSurveyAnswer = (surveyId: string | number): AxiosPromise<any
* 提交问卷答案
* @param data 答案数据
*/
export const submitSurveyAnswer = (data: any) => {
export const submitSurveyAnswer = (data: SubmitSurveyAnswerForm): AxiosPromise<SatRecordVO> => {
return request({
url: '/hq/satSurvey/answer/submit',
method: 'post',
@@ -146,10 +153,56 @@ export const submitSurveyAnswer = (data: any) => {
* 保存问卷答案草稿
* @param data 答案数据
*/
export const saveSurveyDraft = (data: any) => {
export const saveSurveyDraft = (data: SubmitSurveyAnswerForm): AxiosPromise<SatRecordVO> => {
return request({
url: '/hq/satSurvey/answer/draft',
method: 'post',
data: data
});
};
/**
* 获取问卷统计信息
* @param surveyId 问卷ID
*/
export const getSurveyStatistics = (surveyId: string | number): AxiosPromise<SurveyStatisticsVO> => {
return request({
url: '/hq/satSurvey/' + surveyId + '/statistics',
method: 'get'
});
};
/**
* 获取用户答题记录详情
* @param recordId 答题记录ID
*/
export const getAnswerRecord = (recordId: string | number): AxiosPromise<SatRecordVO> => {
return request({
url: '/hq/satSurvey/answer/record/' + recordId,
method: 'get'
});
};
/**
* 获取问卷的所有答题记录列表
* @param surveyId 问卷ID
* @param query 查询参数
*/
export const getSurveyAnswerRecords = (surveyId: string | number, query?: any): AxiosPromise<SatRecordVO[]> => {
return request({
url: '/hq/satSurvey/' + surveyId + '/records',
method: 'get',
params: query
});
};
/**
* 删除答题记录
* @param recordId 答题记录ID
*/
export const deleteAnswerRecord = (recordId: string | number) => {
return request({
url: '/hq/satSurvey/answer/record/' + recordId,
method: 'delete'
});
};
+274
View File
@@ -212,5 +212,279 @@ export interface SatSurveyQuery extends PageQuery {
params?: any;
}
// ==========================================
// 答题相关类型定义
// ==========================================
/**
* 答题答案VO
*/
export interface SatAnswerVO {
/**
* 主键ID
*/
id: string | number;
/**
* 答题记录ID
*/
recordId: string | number;
/**
* 题目ID
*/
questionId: string | number;
/**
* 题目类型(1单选题 2多选题 3问答题)
*/
questionType: string;
/**
* 选项ID(单选题、多选题用,问答题为NULL)
*/
optionId?: string | number;
/**
* 选项值(A、B、C、D等)
*/
optionValue?: string;
/**
* 选项文本内容
*/
optionText?: string;
/**
* 答案值(单选题存选项值,多选题存逗号分隔选项值,问答题存文本内容)
*/
answerValue: string;
/**
* 该答案得分
*/
answerScore: number;
/**
* 备注
*/
remark?: string;
}
/**
* 答题记录VO
*/
export interface SatRecordVO {
/**
* 主键ID
*/
id: string | number;
/**
* 问卷ID
*/
surveyId: string | number;
/**
* 答题人ID
*/
userId: string | number;
/**
* 答题人姓名
*/
userName?: string;
/**
* 答题开始时间
*/
startTime: string;
/**
* 答题结束时间
*/
endTime?: string;
/**
* 答题用时(秒)
*/
duration?: number;
/**
* 总得分
*/
totalScore: number;
/**
* 答题状态(0草稿 1已提交)
*/
status: string;
/**
* 是否匿名
*/
isAnonymous: number;
/**
* 备注
*/
remark?: string;
/**
* 答题详情列表
*/
answers?: SatAnswerVO[];
}
/**
* 提交答题的单个答案
*/
export interface SubmitAnswerItem {
/**
* 题目ID
*/
questionId: string | number;
/**
* 题目类型(1单选题 2多选题 3问答题)
*/
questionType: string;
/**
* 答案值
* - 单选题:选项值,如 "A"
* - 多选题:多个选项值,如 "A,C,D"
* - 问答题:用户输入的文本内容
*/
answerValue: string;
/**
* 选项详情(单选题和多选题需要)
*/
options?: Array<{
optionId: string | number;
optionValue: string;
optionText: string;
isSelected: boolean;
}>;
}
/**
* 提交答题请求数据
*/
export interface SubmitSurveyAnswerForm {
/**
* 问卷ID
*/
surveyId: string | number;
/**
* 答题开始时间
*/
startTime: string;
/**
* 答题结束时间
*/
endTime: string;
/**
* 是否匿名(1是 0否)
*/
isAnonymous: number;
/**
* 答案列表
*/
answers: SubmitAnswerItem[];
/**
* 备注
*/
remark?: string;
}
/**
* 答题统计信息
*/
export interface SurveyStatisticsVO {
/**
* 问卷ID
*/
surveyId: string | number;
/**
* 问卷标题
*/
surveyTitle: string;
/**
* 总参与人数
*/
totalParticipants: number;
/**
* 已完成人数
*/
completedCount: number;
/**
* 草稿数量
*/
draftCount: number;
/**
* 平均用时(秒)
*/
avgDuration: number;
/**
* 平均得分
*/
avgScore: number;
/**
* 题目统计详情
*/
questionStats?: QuestionStatItem[];
}
/**
* 题目统计项
*/
export interface QuestionStatItem {
/**
* 题目ID
*/
questionId: string | number;
/**
* 题目标题
*/
questionTitle: string;
/**
* 题目类型
*/
questionType: string;
/**
* 回答人数
*/
answerCount: number;
/**
* 选项统计(单选题、多选题)
*/
optionStats?: Array<{
optionId: string | number;
optionText: string;
selectCount: number;
selectRate: number;
}>;
/**
* 问答题统计
*/
textAnswers?: string[];
}
+13 -5
View File
@@ -127,7 +127,7 @@ const dynamicTenantEvent = async (tenantId: string) => {
if (companyName.value != null && companyName.value !== '') {
await dynamicTenant(tenantId);
dynamic.value = true;
await proxy?.$router.push('/');
await router.push('/');
await proxy?.$tab.closeAllPage();
await proxy?.$tab.refreshPage();
}
@@ -136,7 +136,7 @@ const dynamicTenantEvent = async (tenantId: string) => {
const dynamicClearEvent = async () => {
await dynamicClear();
dynamic.value = false;
await proxy?.$router.push('/');
await router.push('/');
await proxy?.$tab.closeAllPage();
await proxy?.$tab.refreshPage();
};
@@ -288,10 +288,18 @@ watch(
.user-avatar {
cursor: pointer;
width: 30px;
height: 30px;
border-radius: 8px;
width: 30px !important;
height: 30px !important;
min-width: 30px;
min-height: 30px;
max-width: 30px;
max-height: 30px;
border-radius: 6px;
margin-top: 10px;
object-fit: cover;
object-position: center;
display: block;
flex-shrink: 0;
}
i {
+11 -1
View File
@@ -153,6 +153,10 @@ service.interceptors.response.use(
} else if (code === HttpStatus.WARN) {
ElMessage({ message: msg, type: 'warning' });
return Promise.reject(new Error(msg));
} else if (code === 404) {
// 对404错误进行特殊处理,不显示错误提示
console.log('404错误被静默处理,不显示用户提示');
return Promise.reject(new Error('404'));
} else if (code !== HttpStatus.SUCCESS) {
ElNotification.error({ title: msg });
return Promise.reject('error');
@@ -167,7 +171,13 @@ service.interceptors.response.use(
} else if (message.includes('timeout')) {
message = '系统接口请求超时';
} else if (message.includes('Request failed with status code')) {
message = '系统接口' + message.substr(message.length - 3) + '异常';
const statusCode = message.substr(message.length - 3);
// 对404错误进行特殊处理,不显示错误提示
if (statusCode === '404') {
console.log('404错误被静默处理,不显示用户提示');
return Promise.reject(error);
}
message = '系统接口' + statusCode + '异常';
}
ElMessage({ message: message, type: 'error', duration: 5 * 1000 });
return Promise.reject(error);
File diff suppressed because it is too large. Load diff