From e44184148f3245dbfce4a1ef550a71fe5fc0677d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E4=BA=9A=E9=91=AB?= <941195590@qq.com> Date: Fri, 1 Nov 2024 20:27:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=A2=98=E7=9B=AE=E4=BC=98=E5=8C=96=E9=AA=8C=E6=94=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../questionModule/components/TypeList.vue | 22 +++++++++++-------- web/src/management/stores/edit.ts | 7 ------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/web/src/management/pages/edit/modules/questionModule/components/TypeList.vue b/web/src/management/pages/edit/modules/questionModule/components/TypeList.vue index b12e5e94..7d224abe 100644 --- a/web/src/management/pages/edit/modules/questionModule/components/TypeList.vue +++ b/web/src/management/pages/edit/modules/questionModule/components/TypeList.vue @@ -53,8 +53,8 @@ import { useEditStore } from '@/management/stores/edit' import { ref } from 'vue' const editStore = useEditStore() -const { newQuestionIndex } = storeToRefs(editStore) -const { addQuestion, hasSetCurrentEditOne, createNewQuestion } = editStore +const { newQuestionIndex, schema } = storeToRefs(editStore) +const { addQuestion, setCurrentEditOne, getSorter, createNewQuestion } = editStore const activeNames = ref([0, 1]) const previewImg = ref('') @@ -66,14 +66,18 @@ questionLoader.init({ }) const onQuestionType = ({ type }) => { - const newQuestion = createNewQuestion({ type }) - addQuestion({ question: newQuestion, index: newQuestionIndex.value }) - hasSetCurrentEditOne(newQuestionIndex.value) -} + const newQuestion = createNewQuestion({ type }); + addQuestion({ question: newQuestion, index: newQuestionIndex.value }); + const { endIndex } = getSorter(); + setTimeout(() => { + setCurrentEditOne(endIndex - 1); + }); +}; -const onDragEnd = (event) => { - hasSetCurrentEditOne(event.newIndex) -} +const onDragEnd = (event) => { + const { startIndex } = getSorter(); + setCurrentEditOne(schema.pageEditOne === 1 ? event.newIndex : startIndex + event.newIndex); +}; const showPreview = ({ snapshot }, id) => { previewImg.value = snapshot diff --git a/web/src/management/stores/edit.ts b/web/src/management/stores/edit.ts index 6ef10273..133e6aab 100644 --- a/web/src/management/stores/edit.ts +++ b/web/src/management/stores/edit.ts @@ -170,12 +170,6 @@ export const useEditStore = defineStore('edit', () => { } }) - const hasSetCurrentEditOne = (value: number) => { - if(!currentEditOne.value) { - setCurrentEditOne(value) - } - } - // 题目操作:增删改 const { copyQuestion, addQuestion, deleteQuestion, moveQuestion } = useQuestionData({ questionDataList, @@ -200,7 +194,6 @@ export const useEditStore = defineStore('edit', () => { currentEditMeta, newQuestionIndex, setCurrentEditOne, - hasSetCurrentEditOne, changeCurrentEditStatus, pageEditOne,