From a28db13daca4bddcc62a86eb05c740df81eed431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E5=86=A0=E5=AD=A6?= <1109935898@qq.com> Date: Thu, 10 Oct 2024 11:54:27 +0800 Subject: [PATCH] style: lint and format code --- .eslintrc.js | 12 ++++++------ src/views/planetDesign/Design/components/Logical.vue | 3 ++- .../Design/components/OptionGroup.validate.js | 5 +++-- src/views/planetDesign/Design/fragement/EndLang.vue | 4 +++- .../Design/fragement/QuestionCatalog.vue | 3 ++- .../planetDesign/Logical/fragment/RandomListV2.vue | 3 ++- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1d05aa80..6878d7f9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,12 +21,12 @@ module.exports = { 'no-param-reassign': 0, 'vue/no-use-v-if-with-v-for': 0, 'max-len': ['error', { - 'code': 120, - 'tabWidth': 2, - 'ignoreStrings': true, - 'ignoreUrls': true, - 'ignoreRegExpLiterals': true, - 'ignoreTemplateLiterals': true + code: 120, + tabWidth: 2, + ignoreStrings: true, + ignoreUrls: true, + ignoreRegExpLiterals: true, + ignoreTemplateLiterals: true }], 'import/extensions': 0, eqeqeq: 0, diff --git a/src/views/planetDesign/Design/components/Logical.vue b/src/views/planetDesign/Design/components/Logical.vue index 026ee3b0..435f9662 100644 --- a/src/views/planetDesign/Design/components/Logical.vue +++ b/src/views/planetDesign/Design/components/Logical.vue @@ -1097,7 +1097,8 @@ export default { } else if (autoLogic.value) { list = autoList; } - const logicQuesList = skipLogic.value || quotaLogic.value || autoLogic.value ? skipLogicQuesList : showSkipLogicQuesList; + const tempList = skipLogic.value || quotaLogic.value || autoLogic.value; + const logicQuesList = tempList ? skipLogicQuesList : showSkipLogicQuesList; const copyList = JSON.parse(JSON.stringify(list.value)); const quesType = logicQuesList.find((x) => x.question_index === e).question_type; const { config, optionsList, rowOptionsList, colOptionsList, classifyOptionsList } = getOptionListAndConfig( diff --git a/src/views/planetDesign/Design/components/OptionGroup.validate.js b/src/views/planetDesign/Design/components/OptionGroup.validate.js index 44ac9f6a..afbcacb2 100644 --- a/src/views/planetDesign/Design/components/OptionGroup.validate.js +++ b/src/views/planetDesign/Design/components/OptionGroup.validate.js @@ -54,8 +54,9 @@ export const validateOptionGroupMatrix = (info, option_groups) => { return; } - info.config[option_groups].max = info.config[option_groups].option_group.reduce((ctx, cur) => ctx + cur.max, 0) || null; - info.config[option_groups].min = info.config[option_groups].option_group.reduce((ctx, cur) => ctx + cur.min, 0) || null; + const temp = info.config[option_groups].option_group; + info.config[option_groups].max = temp.reduce((ctx, cur) => ctx + cur.max, 0) || null; + info.config[option_groups].min = temp.reduce((ctx, cur) => ctx + cur.min, 0) || null; if (info.config[option_groups].option_group.some((x) => !x.max)) info.config[option_groups].max = null; diff --git a/src/views/planetDesign/Design/fragement/EndLang.vue b/src/views/planetDesign/Design/fragement/EndLang.vue index cde70440..db0def3d 100644 --- a/src/views/planetDesign/Design/fragement/EndLang.vue +++ b/src/views/planetDesign/Design/fragement/EndLang.vue @@ -83,7 +83,9 @@ export default { loading.value = true; try { await updateOneQuestionPerPage(store, param.is_one_page_one_question); - survey.value.is_one_page_one_question = param?.is_one_page_one_question ?? survey.value.is_one_page_one_question; + if (![undefined, null].includes(param?.is_one_page_one_question)) { + survey.value.is_one_page_one_question = param?.is_one_page_one_question + } const { questionInfo, quesSaveParam } = JSON.parse(JSON.stringify(store.state.common)); quesSaveParam.newQuestion = []; diff --git a/src/views/planetDesign/Design/fragement/QuestionCatalog.vue b/src/views/planetDesign/Design/fragement/QuestionCatalog.vue index 979e77b7..311e2212 100644 --- a/src/views/planetDesign/Design/fragement/QuestionCatalog.vue +++ b/src/views/planetDesign/Design/fragement/QuestionCatalog.vue @@ -1241,7 +1241,8 @@ function interceptorsHandle(store) { const movedList = JSON.parse(JSON.stringify(questionInfo.questions)).filter( (i) => !checkedList.some((j) => j.question_index === i.question_index) ); // 重排序后的列表 - const endIndex = movedList.findIndex((i) => i.question_index === moveQuesIndex.value) + (moveLocation.value ? 1 : 0); + const tempIndex = movedList.findIndex((i) => i.question_index === moveQuesIndex.value); + const endIndex = tempIndex + (moveLocation.value ? 1 : 0); movedList.splice(endIndex, 0, ...checkedList); const loopingStatus = loopingAvailable({ cycles: questionInfo.cycle_pages || [], diff --git a/src/views/planetDesign/Logical/fragment/RandomListV2.vue b/src/views/planetDesign/Logical/fragment/RandomListV2.vue index 61dccab6..805ff648 100644 --- a/src/views/planetDesign/Logical/fragment/RandomListV2.vue +++ b/src/views/planetDesign/Logical/fragment/RandomListV2.vue @@ -584,7 +584,8 @@ export default { start: 0, end: deal_questions?.length ?? 0 }; - const prev = options.value?.[index]?.list?.filter((s, idx) => idx < index2).map((s) => s.end || s.start || 0) ?? 0; + const temp = options.value?.[index]?.list; + const prev = temp?.filter((s, idx) => idx < index2).map((s) => s.end || s.start || 0) ?? 0; const next = options.value?.[index]?.list?.filter((s, idx) => idx > index2).map((s) => s.start || s.end) ?? 0; result.start = Math.max( ...prev.filter(function (s) {