feat: 优化展示

This commit is contained in:
sudoooooo 2024-09-02 17:36:18 +08:00
parent 3d31245ae5
commit 70c236c879
8 changed files with 59 additions and 62 deletions

View File

@ -3,7 +3,6 @@ import { useQuestionInfo } from './useQuestionInfo'
import { useEditStore } from '../stores/edit' import { useEditStore } from '../stores/edit'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
// 目标题的显示逻辑提示文案 // 目标题的显示逻辑提示文案
export const useJumpLogicInfo = (field) => { export const useJumpLogicInfo = (field) => {
const editStore = useEditStore() const editStore = useEditStore()

View File

@ -38,7 +38,7 @@
<el-form-item label="验证码" prop="captcha"> <el-form-item label="验证码" prop="captcha">
<div class="captcha-wrapper"> <div class="captcha-wrapper">
<el-input style="width: 150px" v-model="formData.captcha" size="large"></el-input> <el-input style="width: 200px" v-model="formData.captcha" size="large"></el-input>
<div class="captcha-img" @click="refreshCaptcha" v-html="captchaImgData"></div> <div class="captcha-img" @click="refreshCaptcha" v-html="captchaImgData"></div>
</div> </div>
</el-form-item> </el-form-item>
@ -71,6 +71,8 @@ import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss' import 'element-plus/theme-chalk/src/message.scss'
import { debounce as _debounce } from 'lodash-es'
import { getPasswordStrength, login, register } from '@/management/api/auth' import { getPasswordStrength, login, register } from '@/management/api/auth'
import { refreshCaptcha as refreshCaptchaApi } from '@/management/api/captcha' import { refreshCaptcha as refreshCaptchaApi } from '@/management/api/captcha'
import { CODE_MAP } from '@/management/api/base' import { CODE_MAP } from '@/management/api/base'
@ -159,8 +161,8 @@ const rules = {
], ],
password: [ password: [
{ {
validator: passwordValidator, validator: _debounce(passwordValidator, 500),
trigger: 'blur' trigger: 'change'
} }
], ],
captcha: [ captcha: [
@ -311,18 +313,20 @@ const refreshCaptcha = async () => {
cursor: pointer; cursor: pointer;
:deep(> svg) { :deep(> svg) {
max-height: 40px; max-height: 40px;
width: 120px;
margin-left: 20px;
} }
} }
} }
.strength { .strength {
display: inline-block; display: inline-block;
width: 20%; width: 30%;
height: 6px; height: 6px;
border-radius: 8px; border-radius: 8px;
background: red; background: red;
&:not(:first-child) { &:not(:first-child) {
margin-left: 10px; margin-left: 8px;
} }
} }
} }

View File

@ -1,6 +1,7 @@
@font-face { @font-face {
font-family: 'iconfont'; /* Project id 4263849 */ font-family: 'iconfont'; /* Project id 4263849 */
src: url('//at.alicdn.com/t/c/font_4263849_2re4gm4ryc3.woff2?t=1723600417360') format('woff2'), src:
url('//at.alicdn.com/t/c/font_4263849_2re4gm4ryc3.woff2?t=1723600417360') format('woff2'),
url('//at.alicdn.com/t/c/font_4263849_2re4gm4ryc3.woff?t=1723600417360') format('woff'), url('//at.alicdn.com/t/c/font_4263849_2re4gm4ryc3.woff?t=1723600417360') format('woff'),
url('//at.alicdn.com/t/c/font_4263849_2re4gm4ryc3.ttf?t=1723600417360') format('truetype'); url('//at.alicdn.com/t/c/font_4263849_2re4gm4ryc3.ttf?t=1723600417360') format('truetype');
} }

View File

@ -15,7 +15,7 @@
</template> </template>
<script setup> <script setup>
import { ref, inject } from 'vue' import { inject } from 'vue'
import ExtraIcon from '../ExtraIcon/index.vue' import ExtraIcon from '../ExtraIcon/index.vue'
defineProps({ defineProps({
@ -34,14 +34,8 @@ defineProps({
}) })
const emit = defineEmits(['addOther', 'optionChange', 'change']) const emit = defineEmits(['addOther', 'optionChange', 'change'])
const moduleConfig = inject('moduleConfig')
const slots = inject('slots') const slots = inject('slots')
const optionConfigVisible = ref(false)
const openOptionConfig = () => {
optionConfigVisible.value = true
}
const addOther = () => { const addOther = () => {
emit('addOther') emit('addOther')
} }

View File

@ -30,7 +30,7 @@ const props = defineProps({
default: () => { default: () => {
return {} return {}
} }
}, }
}) })
const emit = defineEmits(['change']) const emit = defineEmits(['change'])
const questionStore = useQuestionStore() const questionStore = useQuestionStore()
@ -40,11 +40,7 @@ const formValues = computed(() => {
return surveyStore.formValues return surveyStore.formValues
}) })
const { showLogicEngine } = storeToRefs(surveyStore) const { showLogicEngine } = storeToRefs(surveyStore)
const { const { changeField, changeIndex, needHideFields } = storeToRefs(questionStore)
changeField,
changeIndex,
needHideFields,
} = storeToRefs(questionStore)
// //
const questionConfig = computed(() => { const questionConfig = computed(() => {
let moduleConfig = props.moduleConfig let moduleConfig = props.moduleConfig
@ -93,7 +89,6 @@ const logicshow = computed(() => {
return result === undefined ? true : result return result === undefined ? true : result
}) })
const logicskip = computed(() => { const logicskip = computed(() => {
return needHideFields.value.includes(props.moduleConfig.field) return needHideFields.value.includes(props.moduleConfig.field)
}) })
@ -101,7 +96,6 @@ const visibily = computed(() => {
return logicshow.value && !logicskip.value return logicshow.value && !logicskip.value
}) })
// abbcbc // abbcbc
watch( watch(
() => visibily.value, () => visibily.value,
@ -109,7 +103,7 @@ watch(
const { field, type, innerType } = props.moduleConfig const { field, type, innerType } = props.moduleConfig
if (!newVal && oldVal) { if (!newVal && oldVal) {
// //
if(formValues.value[field].toString()) { if (formValues.value[field].toString()) {
let value = '' let value = ''
// innerType // innerType
if (type === QUESTION_TYPE.CHECKBOX || innerType === QUESTION_TYPE.CHECKBOX) { if (type === QUESTION_TYPE.CHECKBOX || innerType === QUESTION_TYPE.CHECKBOX) {
@ -138,35 +132,41 @@ const handleChange = (data) => {
const processJumpSkip = () => { const processJumpSkip = () => {
const targetResult = surveyStore.jumpLogicEngine const targetResult = surveyStore.jumpLogicEngine
.getResultsByField(changeField.value, surveyStore.formValues) .getResultsByField(changeField.value, surveyStore.formValues)
.map(item => { .map((item) => {
// //
const index = item.target === 'end' ? surveyStore.dataConf.dataList.length : questionStore.getQuestionIndexByField(item.target) const index =
item.target === 'end'
? surveyStore.dataConf.dataList.length
: questionStore.getQuestionIndexByField(item.target)
return { return {
index, index,
...item ...item
} }
}) })
const notMatchedFields = targetResult.filter(item => !item.result) const notMatchedFields = targetResult.filter((item) => !item.result)
const matchedFields = targetResult.filter(item => item.result) const matchedFields = targetResult.filter((item) => item.result)
// //
if (notMatchedFields.length) { if (notMatchedFields.length) {
notMatchedFields.forEach(element => { notMatchedFields.forEach((element) => {
const endIndex = element.index const endIndex = element.index
const fields = surveyStore.dataConf.dataList.slice(changeIndex.value + 1, endIndex).map(item => item.field) const fields = surveyStore.dataConf.dataList
.slice(changeIndex.value + 1, endIndex)
.map((item) => item.field)
// hideMapremove // hideMapremove
questionStore.removeNeedHideFields(fields) questionStore.removeNeedHideFields(fields)
}); })
} }
if (!matchedFields.length) return if (!matchedFields.length) return
// //
const maxIndexQuestion = const maxIndexQuestion = matchedFields
matchedFields.filter(item => item.result).sort((a, b) => b.index - a.index)[0].index .filter((item) => item.result)
.sort((a, b) => b.index - a.index)[0].index
// //
const skipKey = surveyStore.dataConf.dataList const skipKey = surveyStore.dataConf.dataList
.slice(changeIndex.value + 1, maxIndexQuestion).map(item => item.field) .slice(changeIndex.value + 1, maxIndexQuestion)
.map((item) => item.field)
questionStore.addNeedHideFields(skipKey) questionStore.addNeedHideFields(skipKey)
} }
</script> </script>

View File

@ -189,14 +189,14 @@ export const useQuestionStore = defineStore('question', () => {
return questionData.value[field].index return questionData.value[field].index
} }
const addNeedHideFields = (fields) => { const addNeedHideFields = (fields) => {
fields.forEach(field => { fields.forEach((field) => {
if(!needHideFields.value.includes(field)) { if (!needHideFields.value.includes(field)) {
needHideFields.value.push(field) needHideFields.value.push(field)
} }
}) })
} }
const removeNeedHideFields = (fields) => { const removeNeedHideFields = (fields) => {
needHideFields.value = needHideFields.value.filter(field => !fields.includes(field)) needHideFields.value = needHideFields.value.filter((field) => !fields.includes(field))
} }
return { return {
voteMap, voteMap,

View File

@ -42,7 +42,6 @@ export const useSurveyStore = defineStore('survey', () => {
const whiteData = ref({}) const whiteData = ref({})
const pageConf = ref([]) const pageConf = ref([])
const router = useRouter() const router = useRouter()
const questionStore = useQuestionStore() const questionStore = useQuestionStore()
const { setErrorInfo } = useErrorInfo() const { setErrorInfo } = useErrorInfo()