diff --git a/src/views/Design/Index.vue b/src/views/Design/Index.vue
index 769e5ea..e3e12b0 100644
--- a/src/views/Design/Index.vue
+++ b/src/views/Design/Index.vue
@@ -418,27 +418,29 @@ const actionFun = {
// emit 事件
const saveQueItem = (logics, questions, survey) => {
+ if (route.query.sn) {
+ saveQuestion({
+ sn: route.query.sn,
+ data: {
+ logics: logics || [],
+ questions: questions || [],
+ survey: {
+ local_pages: [],
+ ...survey,
+ pages: getPages(
+ questionInfo.value.questions,
+ questionInfo.value.survey.is_one_page_one_question
+ ),
+ version: Base64.encode(`${new Date().getTime()}`)
+ }
+ }
+ }).then(() => {
+ sync({ sn: route.query.sn });
+ });
+ }
// questions.map((item, index) => {
// item.title = index + 1;
// });
- saveQuestion({
- sn: route.query.sn,
- data: {
- logics: logics || [],
- questions: questions || [],
- survey: {
- local_pages: [],
- ...survey,
- pages: getPages(
- questionInfo.value.questions,
- questionInfo.value.survey.is_one_page_one_question
- ),
- version: Base64.encode(`${new Date().getTime()}`)
- }
- }
- }).then(() => {
- sync({ sn: route.query.sn });
- });
};
const emitFun = {
diff --git a/src/views/Survey/Index.vue b/src/views/Survey/Index.vue
index 3817063..ba95ecb 100644
--- a/src/views/Survey/Index.vue
+++ b/src/views/Survey/Index.vue
@@ -98,7 +98,7 @@
>
复制
删除
- 存为模板
+ 保存为模板
diff --git a/src/views/Survey/views/Create/Index.vue b/src/views/Survey/views/Create/Index.vue
index ddcf015..e8bac65 100644
--- a/src/views/Survey/views/Create/Index.vue
+++ b/src/views/Survey/views/Create/Index.vue
@@ -442,6 +442,7 @@ const onConfirmDate = (e) => {
// 获取选中的题目
const getActiveQuestion = (activeQues) => {
+ activeQuestionIndex.value = questionInfo.value.questions.length - 1;
chooseQuestionId.value = activeQues.id;
activeId.value = activeQues.id;
// 在questions 里 查找index 给 activeQuestionIndex
@@ -453,20 +454,22 @@ const getActiveQuestion = (activeQues) => {
};
const saveTitle = () => {
+ let sn = sessionStorage.setItem('sn');
+
if (!questionInfo.value.survey.title || questionInfo.value.survey.title === '
') {
showToast('问卷标题不能为空');
return false;
}
titleActive.value = false;
saveQuestions({
- sn: route.query.sn,
+ sn: sn,
title: questionInfo.value.survey.title,
introduction: questionInfo.value.survey.introduction
}).then((res) => {
if (res.data) {
// questionInfo.value.survey.title 富文本转为html获取innertext
let title = questionInfo.value.survey.title.replace(/<[^>]*>/g, '');
- saveProjectName(route.query.sn, { project_name: title });
+ saveProjectName(sn, { project_name: title });
}
});
};
@@ -521,8 +524,9 @@ const questionEvent = (item) => {
// 新增保存增加的一个
const saveQuestionItem = (questionJson) => {
+ let sn = sessionStorage.setItem('sn');
const query = {
- sn: route.query.sn,
+ sn: sn,
data: {
logics: questionInfo.value.logics,
@@ -601,16 +605,18 @@ const saveSetting = (parentKey, childKeys, type) => {
// delete query['is_publish_number'];
delete query['publish_number'];
}
+ let sn = sessionStorage.setItem('sn');
saveSettings({
- sn: route.query.sn,
+ sn: sn,
...query
});
};
// 保存是否每页一题
const saveIsOnePage = () => {
+ let sn = sessionStorage.setItem('sn');
saveQuestions({
- sn: route.query.sn,
+ sn: sn,
is_one_page_one_question: questionInfo.value.survey.is_one_page_one_question
});
};
@@ -626,30 +632,35 @@ let settingList = [];
// 获取题目相亲
const getQuestionDetail = () => {
- return snQuestions({ sn: route.query.sn }).then((res) => {
- if (res.data) {
- questionInfo.value.survey = Object.assign({}, res.data.data.survey);
- questionInfo.value.questions = res.data.data.questions.map((item, index) => {
- return {
- ...item,
- title: index + 1
- };
- });
- questionInfo.value.logics = res.data.data.logics.map((item) => {
- return {
- ...item
- };
- });
+ let sn = sessionStorage.getItem('sn');
+ if (sn) {
+ console.log(sn, 213123);
- getSetting({ sn: route.query.sn }).then((setting) => {
- if (setting.data) {
- // 获取所有的key
- settingList = Object.keys(setting.data.data);
- questionInfo.value.survey = Object.assign(questionInfo.value.survey, setting.data.data);
- }
- });
- }
- });
+ snQuestions({ sn: sn }).then((res) => {
+ if (res.data) {
+ questionInfo.value.survey = Object.assign({}, res.data.data.survey);
+ questionInfo.value.questions = res.data.data.questions.map((item, index) => {
+ return {
+ ...item,
+ title: index + 1
+ };
+ });
+ questionInfo.value.logics = res.data.data.logics.map((item) => {
+ return {
+ ...item
+ };
+ });
+
+ getSetting({ sn: sn }).then((setting) => {
+ if (setting.data) {
+ // 获取所有的key
+ settingList = Object.keys(setting.data.data);
+ questionInfo.value.survey = Object.assign(questionInfo.value.survey, setting.data.data);
+ }
+ });
+ }
+ });
+ }
};
const questionInfo = computed(() => store.questionsInfo.value);
@@ -746,7 +757,9 @@ watch(
}
}
);
-
+if (route.query.sn) {
+ sessionStorage.setItem('sn', route.query.sn);
+}
// 监听ip数量
watch(
() => questionInfo.value.survey.ip_number,
@@ -774,6 +787,7 @@ watch(
// 保存 目前没有任何逻辑可以执行所有保存
const saveAs = (back) => {
+ let sn = sessionStorage.getItem('sn');
let questions = JSON.parse(JSON.stringify(questionInfo.value.questions));
questions = questions.map((item, index) => {
return {
@@ -783,7 +797,7 @@ const saveAs = (back) => {
});
let query = {
- sn: route.query.sn,
+ sn: sn,
data: {
logics: questionInfo.value.logics,
@@ -799,7 +813,7 @@ const saveAs = (back) => {
}
};
saveQuestion(query).then(() => {
- sync({ sn: route.query.sn }).then(() => {
+ sync({ sn: sn }).then(() => {
if (back) {
back();
} else {
@@ -827,18 +841,19 @@ const previewQuestion = () => {
};
const surveyDetailFun = (back) => {
- getSurveysDetail(route.query.sn).then((res) => {
+ let sn = sessionStorage.getItem('sn');
+ getSurveysDetail(sn).then((res) => {
if (res.data) {
// 投放中
if (res.data.data.status === 1) {
- changeStatus({ sn: route.query.sn, status: 0 });
+ changeStatus({ sn: sn, status: 0 });
}
}
});
};
-onMounted(async () => {
- await getQuestionDetail();
+onMounted(() => {
+ getQuestionDetail();
surveyDetailFun();
});