feat(Design): 优化问卷设计样式和功能
- 实现选项功能 - 添加内容可编辑组件拖拽排序功能 - 优化题目和选项的样式 - 添加右键拖拽功能
This commit is contained in:
@@ -51,3 +51,51 @@
|
|||||||
background-color: rgba(0, 0, 0, 0.7) !important;
|
background-color: rgba(0, 0, 0, 0.7) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.contenteditable {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contenteditable-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px 8px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #fafbfc;
|
||||||
|
outline: 1px solid #f4f4f4;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contenteditable-label {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
//outline: 1px solid #ccc;
|
||||||
|
//border-bottom: 1px solid #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contenteditable-question-title {
|
||||||
|
& .van-cell__title {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: ' ';
|
||||||
|
position: absolute;
|
||||||
|
bottom: -2px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
border-bottom: 0.0267rem solid #ebedf0;
|
||||||
|
pointer-events: none;
|
||||||
|
transform: scaleY(0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:focus-within::after {
|
||||||
|
border-bottom-color: $theme-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .contenteditable-label {
|
||||||
|
& :focus {
|
||||||
|
//color: green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="flex contenteditable align-center space-between" :class="className">
|
||||||
<p
|
<p
|
||||||
ref="editor"
|
ref="editor"
|
||||||
:contenteditable="active"
|
:contenteditable="active"
|
||||||
class="van-field"
|
class="van-field contenteditable-content"
|
||||||
:class="className"
|
|
||||||
v-html="modelValue"
|
v-html="modelValue"
|
||||||
></p>
|
></p>
|
||||||
|
<div class="right-icon ml10">
|
||||||
|
<slot name="right-icon"></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="showAction && active" ref="editorAction" class="editor-action">
|
<div v-if="showAction && active" ref="editorAction" class="editor-action">
|
||||||
<button v-for="item in actions" :key="item.name" @click="funEvent(item, $event)">
|
<button v-for="item in actions" :key="item.name" @click="funEvent(item, $event)">
|
||||||
{{ item.label }}
|
{{ item.label }}
|
||||||
@@ -138,6 +143,14 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.contenteditable-content {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-icon {
|
||||||
|
color: #c4c9d4;
|
||||||
|
}
|
||||||
|
|
||||||
.editor-action {
|
.editor-action {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
v-if="questionInfo.questions.length > 0"
|
v-if="questionInfo.questions.length > 0"
|
||||||
v-model:data="questionInfo.questions"
|
v-model:data="questionInfo.questions"
|
||||||
item-key="id"
|
item-key="id"
|
||||||
handle=".moverQues"
|
handle=".moveQuestion"
|
||||||
chosenClass="chosen"
|
chosenClass="chosen"
|
||||||
animation="300"
|
animation="300"
|
||||||
:scroll="true"
|
:scroll="true"
|
||||||
@@ -105,8 +105,11 @@
|
|||||||
class="flex"
|
class="flex"
|
||||||
>
|
>
|
||||||
<template v-for="(act, actIndex) in item.actions" :key="actIndex">
|
<template v-for="(act, actIndex) in item.actions" :key="actIndex">
|
||||||
<div class="flex align-center action-item" @click="actionEvent(act, el)">
|
<div
|
||||||
<van-icon :name="act.icon"></van-icon>
|
class="flex align-center action-item theme-color"
|
||||||
|
@click="actionEvent(act, el)"
|
||||||
|
>
|
||||||
|
<van-icon :name="act.icon" class="icons"></van-icon>
|
||||||
<span class="ml10">{{ act.label }}</span>
|
<span class="ml10">{{ act.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -269,7 +272,7 @@ const actionOptions = [
|
|||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: '添加选项',
|
label: '添加选项',
|
||||||
icon: 'add',
|
icon: 'add-o',
|
||||||
fun: 'radioAddOption'
|
fun: 'radioAddOption'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -280,12 +283,12 @@ const actionOptions = [
|
|||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: '添加行标签',
|
label: '添加行标签',
|
||||||
icon: 'add',
|
icon: 'add-o',
|
||||||
fun: 'addMatrixRowOption'
|
fun: 'addMatrixRowOption'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '添加列标签',
|
label: '添加列标签',
|
||||||
icon: 'add',
|
icon: 'add-o',
|
||||||
fun: 'addMatrixColumnOption'
|
fun: 'addMatrixColumnOption'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -448,7 +451,11 @@ onMounted(() => {
|
|||||||
//background-color: #e9eef3;
|
//background-color: #e9eef3;
|
||||||
color: #333;
|
color: #333;
|
||||||
|
|
||||||
.slot-actions {
|
::v-deep .slot-actions {
|
||||||
|
& .action-item {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
& .action-item + .action-item {
|
& .action-item + .action-item {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="option-action">
|
<div class="option-action">
|
||||||
<template v-for="(item, index) in data" :key="index">
|
<draggable
|
||||||
|
v-model:data="data"
|
||||||
|
item-key="option_index"
|
||||||
|
:handle="handle"
|
||||||
|
chosenClass="chosen"
|
||||||
|
animation="300"
|
||||||
|
:scroll="true"
|
||||||
|
>
|
||||||
|
<template #item="{ element, index }">
|
||||||
<div class="flex align-center option-action-container">
|
<div class="flex align-center option-action-container">
|
||||||
<slot name="item" :element="item" :index="index"></slot>
|
<slot name="item" :element="element" :index="index"></slot>
|
||||||
<span v-if="active" class="flex">
|
<span v-if="active" class="flex">
|
||||||
<van-icon class-prefix="mobilefont" name="setting " @click="openMoveModel(item, index)" />
|
<!--<van-icon class-prefix="mobilefont"
|
||||||
<van-icon class-prefix="mobilefont" name="gengduo " @click="openOptionActionModel(item, index)" />
|
name="setting "
|
||||||
|
@click="openMoveModel(element, index)
|
||||||
|
"/>-->
|
||||||
|
<van-icon
|
||||||
|
class-prefix="mobilefont"
|
||||||
|
name="gengduo "
|
||||||
|
@click="openOptionActionModel(element, index)"
|
||||||
|
/>
|
||||||
<van-icon class-prefix="mobilefont" name="del1 " @click="deleteOption(index)" />
|
<van-icon class-prefix="mobilefont" name="del1 " @click="deleteOption(index)" />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
</draggable>
|
||||||
</div>
|
</div>
|
||||||
<!-- 操作项弹窗-->
|
<!-- 操作项弹窗-->
|
||||||
<van-action-sheet v-model:show="show">
|
<van-action-sheet v-model:show="show">
|
||||||
@@ -66,15 +82,8 @@
|
|||||||
import CheckboxAction from './components/OptionItemAction/CheckboxAction.vue';
|
import CheckboxAction from './components/OptionItemAction/CheckboxAction.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { showConfirmDialog } from 'vant';
|
import { showConfirmDialog } from 'vant';
|
||||||
|
import Draggable from '@/views/Design/components/Draggable.vue';
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {
|
|
||||||
return {
|
|
||||||
stem: ''
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
active: {
|
active: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@@ -84,9 +93,17 @@ const props = defineProps({
|
|||||||
default: () => {
|
default: () => {
|
||||||
// 空
|
// 空
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handle: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const data = defineModel('data', {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
});
|
||||||
const actions = [
|
const actions = [
|
||||||
{ name: '上移选项', action: 'up' },
|
{ name: '上移选项', action: 'up' },
|
||||||
{ name: '下移选项', action: 'down' }
|
{ name: '下移选项', action: 'down' }
|
||||||
@@ -109,11 +126,11 @@ const openOptionActionModel = (item, index) => {
|
|||||||
activeOption.value = item;
|
activeOption.value = item;
|
||||||
activeIndex.value = index;
|
activeIndex.value = index;
|
||||||
};
|
};
|
||||||
const openMoveModel = (item, index) => {
|
// const openMoveModel = (item, index) => {
|
||||||
moveShow.value = true;
|
// moveShow.value = true;
|
||||||
activeOption.value = item;
|
// activeOption.value = item;
|
||||||
activeIndex.value = index;
|
// activeIndex.value = index;
|
||||||
};
|
// };
|
||||||
// 上下移动
|
// 上下移动
|
||||||
const optionMove = (action) => {
|
const optionMove = (action) => {
|
||||||
switch (action.action) {
|
switch (action.action) {
|
||||||
|
|||||||
@@ -4,13 +4,18 @@
|
|||||||
:label="element.stem"
|
:label="element.stem"
|
||||||
:required="element.config.is_required === 1"
|
:required="element.config.is_required === 1"
|
||||||
label-align="top"
|
label-align="top"
|
||||||
class="base-select"
|
class="contenteditable-question-title base-select"
|
||||||
>
|
>
|
||||||
<template #left-icon>
|
<template #left-icon>
|
||||||
{{ index + 1 }}
|
{{ index + 1 }}
|
||||||
</template>
|
</template>
|
||||||
<template #label>
|
<template #label>
|
||||||
<contenteditable v-model="element.stem" :active="active" @blur="emitValue"></contenteditable>
|
<contenteditable
|
||||||
|
v-model="element.stem"
|
||||||
|
className="contenteditable-label"
|
||||||
|
:active="active"
|
||||||
|
@blur="emitValue"
|
||||||
|
></contenteditable>
|
||||||
</template>
|
</template>
|
||||||
<template #input>
|
<template #input>
|
||||||
<template v-for="(item, optionIndex) in element.options" :key="item.id">
|
<template v-for="(item, optionIndex) in element.options" :key="item.id">
|
||||||
@@ -19,6 +24,7 @@
|
|||||||
v-model:data="element.options[optionIndex]"
|
v-model:data="element.options[optionIndex]"
|
||||||
:active="active"
|
:active="active"
|
||||||
:question="element"
|
:question="element"
|
||||||
|
handle=".moverQues"
|
||||||
>
|
>
|
||||||
<template #item="{ element: it, index: itIndex }">
|
<template #item="{ element: it, index: itIndex }">
|
||||||
<van-radio
|
<van-radio
|
||||||
@@ -31,7 +37,17 @@
|
|||||||
<!-- 自定义文本 -->
|
<!-- 自定义文本 -->
|
||||||
<template #default>
|
<template #default>
|
||||||
<div class="flex align-center van-cell">
|
<div class="flex align-center van-cell">
|
||||||
<contenteditable v-model="it.option" :active="active"></contenteditable>
|
<contenteditable
|
||||||
|
v-model="it.option"
|
||||||
|
className="contenteditable-input"
|
||||||
|
:active="active"
|
||||||
|
>
|
||||||
|
<template #right-icon>
|
||||||
|
<div v-if="active" class="moverQues">
|
||||||
|
<van-icon class-prefix="mobilefont" name="option "></van-icon>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</contenteditable>
|
||||||
<div v-if="it.is_other">
|
<div v-if="it.is_other">
|
||||||
<input class="other-input" type="text" />
|
<input class="other-input" type="text" />
|
||||||
</div>
|
</div>
|
||||||
@@ -57,7 +73,17 @@
|
|||||||
>
|
>
|
||||||
<template #default>
|
<template #default>
|
||||||
<div class="flex align-center van-cell">
|
<div class="flex align-center van-cell">
|
||||||
<contenteditable v-model="it.option" :active="active"></contenteditable>
|
<contenteditable
|
||||||
|
v-model="it.option"
|
||||||
|
className="contenteditable-input"
|
||||||
|
:active="active"
|
||||||
|
>
|
||||||
|
<template #right-icon>
|
||||||
|
<div v-if="active" class="moverQues">
|
||||||
|
<van-icon class-prefix="mobilefont" name="option "></van-icon>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</contenteditable>
|
||||||
<div v-if="it.is_other">
|
<div v-if="it.is_other">
|
||||||
<input class="other-input" type="text" />
|
<input class="other-input" type="text" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user