style(css): 优化问卷设计和预览样式

- 添加自定义复选框和单选按钮样式
- 调整矩阵问题表格样式
- 优化 NPS 问题布局
- 统一预览组件属性命名
-调整部分颜色变量
This commit is contained in:
陈昱达
2025-03-23 17:55:15 +08:00
parent 876f98dfab
commit c6194a97b3
11 changed files with 118 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
/* color palette from <https://github.com/vuejs/theme> */ /* color palette from <https://github.com/vuejs/theme> */
:root { :root {
--primary-color: #71b73c; --primary-color: #71b73c;
--van-primary-color: #71b73c;
--vt-c-white: #fff; --vt-c-white: #fff;
--vt-c-white-soft: #f8f8f8; --vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2; --vt-c-white-mute: #f2f2f2;
@@ -28,6 +29,9 @@
--van-loading-text-color: #fff; --van-loading-text-color: #fff;
--van-loading-spinner-color: #fff; --van-loading-spinner-color: #fff;
--van-action-sheet-cancel-text-color: #000; --van-action-sheet-cancel-text-color: #000;
--van-checkbox-checked-icon-color: var(--primary-color);
--van-coupon-checkbox-color: var(--primary-color);
--van-blue: var(--primary-color);
} }
/* semantic color variables for this project */ /* semantic color variables for this project */

View File

@@ -1,6 +1,7 @@
<template> <template>
<input <input
type="checkbox" type="checkbox"
class="mobilefont"
:name="`R${rowIndex + 1}`" :name="`R${rowIndex + 1}`"
:checked="isOptionChecked(rowIndex, colIndex)" :checked="isOptionChecked(rowIndex, colIndex)"
@change="handleMatrixCheckboxChange(rowIndex, colIndex)" @change="handleMatrixCheckboxChange(rowIndex, colIndex)"
@@ -58,3 +59,35 @@ const emitValue = (/* val: unknown */) => {
emit('update:element', element.value); emit('update:element', element.value);
}; };
</script> </script>
<style scoped lang="scss">
@import '@/assets/css/main';
input[type='checkbox'] {
appearance: none;
-webkit-appearance: none;
width: 16px;
height: 16px;
border: 1px solid #ccc;
border-radius: 1px;
outline: none;
overflow: hidden;
cursor: pointer;
position: relative;
transition: border-color 0.4s ease;
&:checked {
border-color: $theme-color;
background: $theme-color;
&::after {
content: '\2713';
font-family: 'Arial', sans-serif; // 确保符号正常显示
color: #fff; // 勾选符号的颜色
font-size: 12px; // 勾选符号的大小
display: block;
position: absolute;
background: $theme-color;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
</style>

View File

@@ -127,7 +127,7 @@ const errorMessage = defineModel('errorMessage', {
</template> </template>
<template #input> <template #input>
<el-table :data="rows" style="width: 90vw"> <el-table :data="rows" style="width: 90vw" border stripe>
<el-table-column :width="tableWidth"> <el-table-column :width="tableWidth">
<template #header></template> <template #header></template>
<template #default="{ row /*, column, $index*/ }"> <template #default="{ row /*, column, $index*/ }">
@@ -173,13 +173,15 @@ const errorMessage = defineModel('errorMessage', {
</div> </div>
</template> </template>
<template #default="{ /*row, column, */ $index: rowIndex }"> <template #default="{ /*row, column, */ $index: rowIndex }">
<component <div>
:is="activeComponent" <component
:element="element" :is="activeComponent"
:rowIndex="rowIndex" :element="element"
:colIndex="colIndex" :rowIndex="rowIndex"
v-model:rowRecord="rowRecord" :colIndex="colIndex"
/> v-model:rowRecord="rowRecord"
/>
</div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -219,7 +221,6 @@ input[type='text'] {
.matrix-radio:checked { .matrix-radio:checked {
border-color: transparent; /* 选中时边框颜色 */ border-color: transparent; /* 选中时边框颜色 */
} }
.matrix-radio:checked::before { .matrix-radio:checked::before {
content: '\e728'; content: '\e728';
position: absolute; position: absolute;

View File

@@ -45,3 +45,34 @@ const emitValue = () => {
emit('update:element', element.value); emit('update:element', element.value);
}; };
</script> </script>
<style scoped lang="scss">
@import '@/assets/css/main';
input[type='radio'] {
appearance: none;
-webkit-appearance: none;
width: 16px;
height: 16px;
border: 1px solid #ccc;
border-radius: 50%;
outline: none;
cursor: pointer;
position: relative;
transition: border-color 0.4s ease;
&:checked {
border-color: $theme-color;
&::after {
content: '';
display: block;
width: 8px;
height: 8px;
border-radius: 50%;
background-color: $theme-color;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
</style>

View File

@@ -1,6 +1,7 @@
<template> <template>
<input <input
type="text" type="text"
class="el-input"
style="width: 100%" style="width: 100%"
:name="`R${rowIndex + 1}`" :name="`R${rowIndex + 1}`"
:value="getInputValue(rowIndex, colIndex)" :value="getInputValue(rowIndex, colIndex)"

View File

@@ -23,23 +23,23 @@
:key="optionItemIndex" :key="optionItemIndex"
class="rate-content" class="rate-content"
> >
<div <!-- <div-->
v-for="(item, optionIndex) in isPreview ? optionItem.options : optionItem" <!-- v-for="(item, optionIndex) in isPreview ? optionItem.options : optionItem"-->
:key="optionIndex" <!-- :key="optionIndex"-->
@click="chooseOption(item)" <!-- @click="chooseOption(item)"-->
> <!-- >-->
<div class="tips mb5"> <div class="tips mb5">
<p>{{ element.config.prompt_left }}</p> <p>{{ element.config.prompt_left }}</p>
<p>{{ element.config.prompt_center }}</p> <p>{{ element.config.prompt_center }}</p>
<p>{{ element.config.prompt_right }}</p> <p>{{ element.config.prompt_right }}</p>
</div>
<RateCharacter
v-model:model="value"
:config="element.config"
:index="optionIndex"
@change="handleRateChange"
/>
</div> </div>
<RateCharacter
v-model:model="value"
:config="element.config"
:index="optionItemIndex"
@change="handleRateChange"
/>
<!-- </div>-->
</div> </div>
</template> </template>
</van-field> </van-field>
@@ -83,6 +83,8 @@ const element = defineModel('element', {
} }
}); });
console.log(element.value, 1);
/** /**
* *
* @param index {number} 索引 * @param index {number} 索引

View File

@@ -72,7 +72,7 @@
<!-- <el-space direction="horizontal">--> <!-- <el-space direction="horizontal">-->
<div> <div>
<el-button :disabled="item.source === 0" @click="deleteItem(item)"> 删除</el-button> <el-button :disabled="item.source === 0" @click="deleteItem(item)"> 删除</el-button>
<el-button :disabled="item.source === 0" @click="copyItem(item)"> 复制</el-button> <!-- <el-button :disabled="item.source === 0" @click="copyItem(item)"> 复制</el-button>-->
<el-button style="border: 2px solid #71b73c" @click="toPreview(item)"> <el-button style="border: 2px solid #71b73c" @click="toPreview(item)">
<el-text style="color: #71b73c">预览</el-text> <el-text style="color: #71b73c">预览</el-text>
</el-button> </el-button>
@@ -96,6 +96,7 @@
:close-on-click-overlay="false" :close-on-click-overlay="false"
:close-on-click-outside="false" :close-on-click-outside="false"
> >
<el-dropdown-item @click="copyItem(item)">复制</el-dropdown-item>
<el-dropdown-item @click="editItem(item)">编辑</el-dropdown-item> <el-dropdown-item @click="editItem(item)">编辑</el-dropdown-item>
<el-dropdown-item @click="saveTemplate(item)">存为模板</el-dropdown-item> <el-dropdown-item @click="saveTemplate(item)">存为模板</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>

View File

@@ -1528,7 +1528,7 @@ function clearAnswer(questions) {
.question { .question {
overflow: hidden; overflow: hidden;
//margin-top: 10px; //margin-top: 10px;
//margin-bottom: 10px; margin-bottom: 10px;
border: 1px solid #e5e5e5; border: 1px solid #e5e5e5;
border-radius: 16px; border-radius: 16px;
background: #fff; background: #fff;

View File

@@ -1,17 +1,20 @@
<template> <template>
<n-p-s <div>
v-model:element="question" <NPS
v-model:value="value" v-model:element="question"
:active="false" v-model:value="value"
:isPreview="true" :active="false"
:index="answerIndex" :is-preview="true"
:errorMessage="question.error" :index="answerIndex"
/> :errorMessage="question.error"
/>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import NPS from '@/views/Design/components/Questions/NPS.vue'; import NPS from '@/views/Design/components/Questions/NPS.vue';
import { watch, ref } from 'vue'; import { watch, ref } from 'vue';
import Rate from '@/views/Design/components/Questions/Rate.vue';
const value = ref(-1); const value = ref(-1);
// // 预览新增 emit ['changeAnswer', 'previous', 'next'] // // 预览新增 emit ['changeAnswer', 'previous', 'next']

View File

@@ -3,7 +3,7 @@
v-model:element="question" v-model:element="question"
v-model:answer-value="value" v-model:answer-value="value"
:active="false" :active="false"
:isPreview="true" :is-preview="true"
:index="answerIndex" :index="answerIndex"
:errorMessage="question.error" :errorMessage="question.error"
/> />

View File

@@ -12,7 +12,12 @@ answer.value = {};
</script> </script>
<template> <template>
<text-with-images :element="question" :index="answerIndex" :error-message="question.error" /> <text-with-images
:element="question"
:index="answerIndex"
:error-message="question.error"
:is-preview="true"
/>
</template> </template>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>