feat(design): 添加题目预览功能并优化题目组件

- 新增 Preview 组件用于题目预览
- 重构 Index 组件,移除冗余代码
-优化 QuestionBefore 组件,添加题目标题
- 重构 ChooseQuestion组件,支持自定义操作
- 新增题目类型判断和对应操作功能
This commit is contained in:
陈昱达
2025-03-06 10:24:00 +08:00
parent a06d48db30
commit 6e83ccdbb3
7 changed files with 132 additions and 42 deletions

View File

@@ -8,11 +8,8 @@
<slot></slot>
<!-- 题目操作-->
<van-cell v-if="chooseQuestionId === element.id" class="choose-question-active-container">
<template v-if="element.question_type === 1 || element.question_type === 5" #icon>
<div class="flex align-center" @click="radioAddOption">
<van-icon name="add" class="fs20"></van-icon>
<span class="ml10">添加选项</span>
</div>
<template #icon>
<slot name="action" :element="element" :index="index"></slot>
</template>
<template #title>{{}}</template>
<template #right-icon>
@@ -41,9 +38,6 @@
<script setup>
import QuestionAction from '@/views/Design/components/ActionCompoents/QuestionAction.vue';
import { ref } from 'vue';
import { v4 as uuidv4 } from 'uuid';
// import { useRouter } from 'vue-router';
// const router = useRouter();
const props = defineProps({
element: {
type: Object,
@@ -66,31 +60,6 @@ const props = defineProps({
});
const element = ref(props.element);
// 单选事件 添加选项
const radioAddOption = () => {
element.value.options.map((item) => {
item.push({
id: uuidv4(),
option: `选项${item.length + 1}`,
option_config: {
image_url: [],
title: '',
instructions: [],
option_type: 0,
limit_right_content: ''
},
option_index: element.value.last_option_index + 1,
parent_id: 0,
type: 0,
cascade: [],
config: []
});
});
element.value.last_option_index += 1;
};
// emit 事件
// 选中题目后出现的操作
// const questionAction = ref([
// {