diff --git a/src/views/Design/Index.vue b/src/views/Design/Index.vue index 7574f84..780c631 100644 --- a/src/views/Design/Index.vue +++ b/src/views/Design/Index.vue @@ -262,6 +262,16 @@ if (previewQuestionInfo.value?.answer) { const debouncedSaveQueItem = debounce((logics, newVal) => { if (newVal && !isPreview.value) { saveQueItem(logics, newVal); + + let questionCopy = JSON.parse(JSON.stringify(questionInfo.value.questions)); + questionCopy = questionCopy.map((item, index) => { + return { + ...item, + title: index + 1 + }; + }); + // 保存全部 更新title + saveQueItem(questionInfo.value.logics, questionCopy); } }, 1000); diff --git a/src/views/Design/components/ChooseQuestion.vue b/src/views/Design/components/ChooseQuestion.vue index 93ef3a1..b554564 100644 --- a/src/views/Design/components/ChooseQuestion.vue +++ b/src/views/Design/components/ChooseQuestion.vue @@ -73,12 +73,12 @@ const index = defineModel('index', { type: Number }); -watch( - () => index.value, - (newVal) => { - element.value.title = newVal + 1; - } -); +// watch( +// () => index.value, +// (newVal) => { +// element.value.title = newVal + 1; +// } +// ); // 获取题目选项 const getQuestionType = (type) => { diff --git a/src/views/Survey/views/Create/Index.vue b/src/views/Survey/views/Create/Index.vue index 6df78df..3f948b3 100644 --- a/src/views/Survey/views/Create/Index.vue +++ b/src/views/Survey/views/Create/Index.vue @@ -110,7 +110,7 @@ plain type="primary" :disabled="activeActionButton" - @click="saveAs" + @click="() => saveAs()" > 保存 @@ -590,22 +590,56 @@ watch( ); // 保存 目前没有任何逻辑可以执行所有保存 -const saveAs = () => { - sync({ sn: route.query.sn }).then(() => { - // 保存所有 - showConfirmDialog({ - message: '问卷保存成功', - showCancelButton: false +const saveAs = (back) => { + let questions = JSON.parse(JSON.stringify(questionInfo.value.questions)); + questions = questions.map((item, index) => { + return { + ...item, + title: index + 1 + }; + }); + + let query = { + sn: route.query.sn, + + data: { + logics: questionInfo.value.logics, + questions: questions, + survey: { + local_pages: [], + pages: getPages( + questionInfo.value.questions, + questionInfo.value.survey.is_one_page_one_question + ), + version: Base64.encode(`${new Date().getTime()}`) + } + } + }; + saveQuestion(query).then(() => { + sync({ sn: route.query.sn }).then(() => { + if (back) { + back(); + } else { + // 保存所有 + showConfirmDialog({ + message: '问卷保存成功', + showCancelButton: false + }); + } }); }); }; // 投放 const publishQuestion = () => { - router.push({ name: 'publish', query: { ...route.query } }); + saveAs(() => { + router.push({ name: 'publish', query: { ...route.query } }); + }); }; // 预览 const previewQuestion = () => { - router.push({ name: 'preview', query: { ...route.query } }); + saveAs(() => { + router.push({ name: 'preview', query: { ...route.query } }); + }); }; const surveyDetailFun = (back) => {