fix(Survey): 优化移动端问卷模板保存校验
- 更新了错误提示信息,增加了对逻辑设置的提及 - 增加了对问卷逻辑的校验,只允许自动填写类型的逻辑
This commit is contained in:
@@ -81,7 +81,7 @@ async function saveTemplate(item: SurveyItem) {
|
|||||||
if (!(await validateSurvey(data))) {
|
if (!(await validateSurvey(data))) {
|
||||||
showDialog({
|
showDialog({
|
||||||
title: '无法保存模板',
|
title: '无法保存模板',
|
||||||
message: '问卷内包含移动端暂未兼容题型,请至PC端编辑后重新保存。'
|
message: '问卷内包含移动端暂未兼容题型/逻辑设置,请至PC端编辑后重新保存。'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -98,19 +98,29 @@ async function saveTemplate(item: SurveyItem) {
|
|||||||
function clearSurveys() {
|
function clearSurveys() {
|
||||||
survey.value = [];
|
survey.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验问卷是否可以保存为模板
|
* 校验问卷是否可以保存为模板
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
async function validateSurvey(survey: SurveyItem): Promise<boolean> {
|
async function validateSurvey(survey: SurveyItem): Promise<boolean> {
|
||||||
const { data } = await getQuestionList(survey.sn);
|
const { data } = await getQuestionList(survey.sn);
|
||||||
const questions = data.data.questions;
|
const { questions, logics } = data.data;
|
||||||
return questions.every((question: any) => {
|
const questionValid = questions.every((question: any) => {
|
||||||
if (!questionTypeMap.has(question.question_type)) {
|
if (!questionTypeMap.has(question.question_type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
// 2 自动填写, 3 是逻辑配额
|
||||||
|
const logicValid = logics.every((logic: any) => {
|
||||||
|
if (![2].includes(logic.skip_type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(questionValid, logicValid);
|
||||||
|
|
||||||
|
return questionValid && logicValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
Reference in New Issue
Block a user