fix: 新建问卷重置计数

This commit is contained in:
sudoooooo 2024-08-12 23:10:21 +08:00
parent 4d580bb789
commit 8950073141
2 changed files with 34 additions and 8 deletions

View File

@ -1,14 +1,22 @@
<template> <template>
<div class="setter-wrapper"> <div class="setter-wrapper">
<div class="no-select-question" v-if="editStore.currentEditOne === null"> <el-tabs v-model="confType" type="border-card" stretch>
<img src="/imgs/icons/unselected.webp" />
<h4 class="tipFont">选中题型可以编辑</h4>
<span class="tip">试试看</span>
</div>
<el-tabs v-else v-model="confType" type="border-card" stretch>
<el-tab-pane name="baseConf" label="单题设置"> <el-tab-pane name="baseConf" label="单题设置">
<div class="setter-title">{{ currentEditMeta?.title || '' }}</div> <div v-if="currentEditMeta?.title" class="setter-title">
{{ currentEditMeta?.title || '' }}
</div>
<div
class="no-select-question"
v-if="editStore.currentEditOne === 'mainTitle' || editStore.currentEditOne === null"
>
<img src="/imgs/icons/unselected.webp" />
<h4 class="tipFont">选中题型可以编辑</h4>
<span class="tip">试试看</span>
</div>
<SetterField <SetterField
v-else
:form-config-list="formConfigList" :form-config-list="formConfigList"
:module-config="moduleConfig" :module-config="moduleConfig"
@form-change="handleFormChange" @form-change="handleFormChange"
@ -26,8 +34,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { ref } from 'vue'
import { useEditStore } from '@/management/stores/edit' import { useEditStore } from '@/management/stores/edit'
import basicConfig from '@/materials/questions/common/config/basicConfig' import basicConfig from '@/materials/questions/common/config/basicConfig'
import SetterField from '@/management/pages/edit/components/SetterField.vue' import SetterField from '@/management/pages/edit/components/SetterField.vue'
@ -44,6 +53,15 @@ const handleFormChange = (data: any) => {
if (key in editStore.editGlobalBaseConf.globalBaseConfig) if (key in editStore.editGlobalBaseConf.globalBaseConfig)
editStore.editGlobalBaseConf.updateCounts('MODIFY', { key, value }) editStore.editGlobalBaseConf.updateCounts('MODIFY', { key, value })
} }
watch(
() => editStore.currentEditOne,
(newVal) => {
if (newVal === 0 || (!!newVal && newVal !== 'mainTitle')) {
confType.value = 'baseConf'
}
}
)
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -22,8 +22,16 @@ export default function useEditGlobalBaseConf(
showSpliterCount: 0 showSpliterCount: 0
} }
const resetCount = () => {
optionCheckedCounts.isRequiredCount = 0
optionCheckedCounts.showIndexCount = 0
optionCheckedCounts.showTypeCount = 0
optionCheckedCounts.showSpliterCount = 0
}
// 初始化统计 // 初始化统计
function initCounts() { function initCounts() {
resetCount()
questionDetailList.value.forEach((question: any) => { questionDetailList.value.forEach((question: any) => {
calculateCountsForQuestion('INIT', { question }) calculateCountsForQuestion('INIT', { question })
}) })