feat: 新增选项操作功能并优化问卷设计页面

- 新增 OptionAction 组件用于选项操作
- 更新 BaseSelect 组件,集成 OptionAction 功能
- 优化 Paging 组件样式
- 调整 Design 页面布局和样式
This commit is contained in:
陈昱达
2025-03-04 18:46:26 +08:00
parent d5d189c916
commit 520242ec51
9 changed files with 87 additions and 66 deletions

View File

@@ -1,9 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import Layouts from './layouts/index.vue'; import { RouterView } from 'vue-router';
</script> </script>
<template> <template>
<div> <div>
<Layouts /> <RouterView />
</div> </div>
</template> </template>

View File

@@ -4,11 +4,11 @@
src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834'); src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834');
src: src:
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834#iefix') url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834#iefix')
format('embedded-opentype'), format('embedded-opentype'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.woff?t=1545807318834') format('woff'), url('https://at.alicdn.com/t/font_985780_km7mi63cihi.woff?t=1545807318834') format('woff'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.ttf?t=1545807318834') format('truetype'), url('https://at.alicdn.com/t/font_985780_km7mi63cihi.ttf?t=1545807318834') format('truetype'),
url('https://at.alicdn.com/t/font_985780_km7mi63cihi.svg?t=1545807318834#iconfont') url('https://at.alicdn.com/t/font_985780_km7mi63cihi.svg?t=1545807318834#iconfont')
format('svg'); format('svg');
} }
.logo { .logo {

View File

@@ -1,16 +1,43 @@
import { createRouter, createWebHistory } from 'vue-router'; import { createRouter, createWebHistory } from 'vue-router';
import Home from '../views/Home/Index.vue'; import layout from '@/layouts/index.vue';
import Design from '@/views/Design/Index.vue'; import Design from '@/views/Design/Index.vue';
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes: [ routes: [
{ {
path: '/', path: '/',
name: 'home', name: '/',
component: Home, component: layout,
redirect: '/home',
meta: { meta: {
title: '首页' title: '首页'
} },
children: [
{
path: '/home',
name: 'home',
meta: {
title: '首页'
},
component: () => import('../views/Home/Index.vue')
},
{
path: '/survey',
name: 'survey',
meta: {
title: '问卷'
},
component: () => import('../views/Survey/Index.vue')
},
{
path: '/market',
name: 'market',
meta: {
title: '模板'
},
component: () => import('../views/Market/Index.vue')
}
]
}, },
{ {
path: '/design', path: '/design',
@@ -20,22 +47,6 @@ const router = createRouter({
// this generates a separate chunk (About.[hash].js) for this route // this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited. // which is lazy-loaded when the route is visited.
component: Design component: Design
},
{
path: '/survey',
name: 'survey',
meta: {
title: '问卷'
},
component: () => import('../views/Survey/Index.vue')
},
{
path: '/market',
name: 'market',
meta: {
title: '模板'
},
component: () => import('../views/Market/Index.vue')
} }
] ]
}); });

View File

@@ -82,23 +82,23 @@ const openOptionActionModel = (item, index) => {
// 上下移动 // 上下移动
const optionMove = (action) => { const optionMove = (action) => {
switch (action) { switch (action) {
case 'up': case 'up':
if (activeIndex.value === 0) { if (activeIndex.value === 0) {
show.value = false; show.value = false;
return; return;
} }
// 向上移动 // 向上移动
element.value.splice(activeIndex.value - 1, 0, element.value.splice(activeIndex.value, 1)[0]); element.value.splice(activeIndex.value - 1, 0, element.value.splice(activeIndex.value, 1)[0]);
activeIndex.value -= 1; activeIndex.value -= 1;
break; break;
case 'down': case 'down':
if (activeIndex.value === element.value.length) { if (activeIndex.value === element.value.length) {
show.value = false; show.value = false;
return; return;
} }
element.value.splice(activeIndex.value + 1, 0, element.value.splice(activeIndex.value, 1)[0]); element.value.splice(activeIndex.value + 1, 0, element.value.splice(activeIndex.value, 1)[0]);
activeIndex.value += 1; activeIndex.value += 1;
break; break;
} }
}; };

View File

@@ -35,19 +35,21 @@
<van-divider></van-divider> <van-divider></van-divider>
<van-cell title="题前隐藏" :border="false"> <van-cell title="题前隐藏" :border="false">
<template #right-icon> <template #right-icon>
<span> {{ getSkipTypeText() }} <van-icon name="arrow"></van-icon></span> <span> {{ getSkipTypeText(0) }} <van-icon name="arrow"></van-icon></span>
</template> </template>
</van-cell> </van-cell>
<van-cell title="题后跳转" :border="false"> <van-cell title="题后跳转" :border="false">
<template #right-icon> <template #right-icon>
<span> 设置 <van-icon name="arrow"></van-icon></span> <span> {{ getSkipTypeText(1) }} <van-icon name="arrow"></van-icon></span>
</template> </template>
</van-cell> </van-cell>
<van-divider></van-divider> <van-divider></van-divider>
<van-cell title="下移选项" :border="false" @click="questionMove('down')"></van-cell> <van-cell title="下移题目" :border="false" @click="questionMove('down')"></van-cell>
<van-cell title="上移选项" :border="false" @click="questionMove('up')"></van-cell> <van-cell title="上移题目" :border="false" @click="questionMove('up')"></van-cell>
</van-cell-group> </van-cell-group>
</van-action-sheet> </van-action-sheet>
<!-- 题目操作 题前 题后-->
</template> </template>
<script setup> <script setup>
import { showConfirmDialog } from 'vant'; import { showConfirmDialog } from 'vant';
@@ -80,6 +82,7 @@ const props = defineProps({
} }
}); });
const questions = ref(props.questions); const questions = ref(props.questions);
// 当前题目 // 当前题目
const activeQuestion = ref(props.data); const activeQuestion = ref(props.data);
@@ -122,11 +125,21 @@ const questionMove = (action) => {
}; };
// 获取题前隐藏 和题后 跳转 文字 // 获取题前隐藏 和题后 跳转 文字
const getSkipTypeText = () => { const getSkipTypeText = (skipType) => {
setTimeout(() => { const ls = [];
logics[0].id = 123; logics.map((item) => {
}, 2000); if (
return logics[0].id; item.skip_type === skipType &&
item.question_index === activeQuestion.value.question_index
) {
ls.push(item);
}
});
let text = '未设置';
if (ls.length > 0) {
text = `已配置 (${ls.length})`;
}
return text;
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -11,7 +11,8 @@
class="iconfont active-icon" class="iconfont active-icon"
:style="{ marginRight: isLastPage ? '0' : '16px' }" :style="{ marginRight: isLastPage ? '0' : '16px' }"
@click="activePage" @click="activePage"
>&#xe86c;</i> >&#xe86c;</i
>
<template v-if="!isLastPage"> <template v-if="!isLastPage">
<i class="iconfont moverQues" style="margin-right: 16px">&#xe71b;</i> <i class="iconfont moverQues" style="margin-right: 16px">&#xe71b;</i>
<i class="iconfont" @click="deleteHandle">&#xe6c5;</i> <i class="iconfont" @click="deleteHandle">&#xe6c5;</i>

View File

@@ -11,13 +11,11 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts"></script>
</script>
<style scoped> <style scoped>
.market { .market {
&> :first-child { & > :first-child {
display: flex; display: flex;
align-items: end; align-items: end;
justify-content: space-between; justify-content: space-between;

View File

@@ -6,25 +6,22 @@
<span @click="$router.push('/survey')">全部问卷></span> <span @click="$router.push('/survey')">全部问卷></span>
</div> </div>
<div class="survey_items"> <div class="survey_items">
<div v-for="survey in 3" :key="survey"> <div v-for="survey in 3" :key="survey"></div>
</div>
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts"></script>
</script>
<style scoped> <style scoped>
.survey { .survey {
&> :first-child { & > :first-child {
display: flex; display: flex;
align-items: end; align-items: end;
justify-content: space-between; justify-content: space-between;
margin: 10px 0; margin: 10px 0;
&>span { & > span {
color: grey; color: grey;
font-size: 10px; font-size: 10px;
} }
@@ -44,6 +41,5 @@
background-color: white; background-color: white;
} }
} }
} }
</style> </style>

View File

@@ -3,7 +3,9 @@
<div v-for="item in 10" :key="item" class="template"> <div v-for="item in 10" :key="item" class="template">
<img src="https://picsum.photos/131/128" width="110" height="100" alt="" /> <img src="https://picsum.photos/131/128" width="110" height="100" alt="" />
<span>报名/签到模板</span> <span>报名/签到模板</span>
<span style="color: rgb(127, 127, 127);">报名签到 | 引用 {{ item }} | 创建人: {{ '张三' }}</span> <span style="color: rgb(127, 127, 127)"
>报名签到 | 引用 {{ item }} | 创建人: {{ '张三' }}</span
>
</div> </div>
</div> </div>
</template> </template>