feat: 结果页新增跳转设置 (#432)

Co-authored-by: jiangchunfu <jiangchunfu@kaike.la>
This commit is contained in:
Jiangchunfu 2024-09-27 18:14:32 +08:00 committed by GitHub
parent 0a27554bb6
commit 81df0eae05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 156 additions and 6 deletions

View File

@ -88,10 +88,17 @@ export interface MsgContent {
msg_9004: string; msg_9004: string;
} }
export interface JumpConfig {
type: string;
link: string;
buttonText?: string;
}
export interface SubmitConf { export interface SubmitConf {
submitTitle: string; submitTitle: string;
confirmAgain: ConfirmAgain; confirmAgain: ConfirmAgain;
msgContent: MsgContent; msgContent: MsgContent;
jumpConfig?: JumpConfig;
} }
// 白名单类型 // 白名单类型

View File

@ -275,6 +275,11 @@ describe('DataStatisticController', () => {
again_text: '确认要提交吗?', again_text: '确认要提交吗?',
}, },
link: '', link: '',
jumpConfig: {
type: 'link',
link: '',
buttonText: '',
},
}, },
logicConf: { logicConf: {
showLogicConf: [], showLogicConf: [],

View File

@ -71,6 +71,11 @@ export const mockSensitiveResponseSchema: ResponseSchema = {
is_again: true, is_again: true,
again_text: '确认要提交吗?', again_text: '确认要提交吗?',
}, },
jumpConfig: {
type: 'link',
link: '',
buttonText: '',
},
}, },
dataConf: { dataConf: {
dataList: [ dataList: [
@ -365,6 +370,11 @@ export const mockResponseSchema: ResponseSchema = {
is_again: true, is_again: true,
again_text: '确认要提交吗?', again_text: '确认要提交吗?',
}, },
jumpConfig: {
type: 'link',
link: '',
buttonText: '',
},
}, },
dataConf: { dataConf: {
dataList: [ dataList: [

View File

@ -25,6 +25,11 @@
"msg_9003": "您来晚了,已经满额!", "msg_9003": "您来晚了,已经满额!",
"msg_9004": "提交失败!" "msg_9004": "提交失败!"
}, },
"jumpConfig": {
"type": "link",
"link": "",
"buttonText": ""
},
"link": "" "link": ""
}, },
"bottomConf": { "bottomConf": {

View File

@ -71,6 +71,11 @@ export const mockResponseSchema: ResponseSchema = {
is_again: true, is_again: true,
again_text: '确认要提交吗?', again_text: '确认要提交吗?',
}, },
jumpConfig: {
type: 'link',
link: '',
buttonText: '',
},
}, },
dataConf: { dataConf: {
dataList: [ dataList: [

View File

@ -14,6 +14,7 @@
v-for="(content, contentIndex) in item.content" v-for="(content, contentIndex) in item.content"
:key="`${item.key}${contentIndex}`" :key="`${item.key}${contentIndex}`"
:form-config="content" :form-config="content"
v-show="isShowFormItem(content)"
> >
<Component <Component
:is="components[content.type]" :is="components[content.type]"
@ -82,6 +83,14 @@ const formFieldData = ref<Array<any>>([])
const init = ref<boolean>(true) const init = ref<boolean>(true)
const components = shallowRef<any>(props.customComponents || {}) const components = shallowRef<any>(props.customComponents || {})
const isShowFormItem = (content: any) => {
if (_isFunction(content.toggleShowFn)) {
return content.toggleShowFn(props.moduleConfig)
} else {
return true
}
}
const handleFormChange = (data: any, formConfig: any) => { const handleFormChange = (data: any, formConfig: any) => {
// //
if (_isFunction(formConfig?.valueSetter)) { if (_isFunction(formConfig?.valueSetter)) {

View File

@ -5,7 +5,7 @@
</div> </div>
<SetterField <SetterField
class="question-config-form" class="question-config-form"
label-position="top" label-position="left"
:form-config-list="formFields" :form-config-list="formFields"
:module-config="moduleConfig" :module-config="moduleConfig"
@form-change="handleFormChange" @form-change="handleFormChange"
@ -71,4 +71,25 @@ const handleFormChange = ({ key, value }: any) => {
.question-config-form { .question-config-form {
padding: 30px 20px 50px 20px; padding: 30px 20px 50px 20px;
} }
:deep(.group-wrap) {
margin-bottom: 0;
&:not(:last-child) {
margin-bottom: 32px;
}
.group-title {
margin-bottom: 12px;
}
.el-form-item {
margin-bottom: 16px;
.el-radio {
height: initial;
line-height: initial;
margin-bottom: initial;
}
}
}
</style> </style>

View File

@ -5,7 +5,9 @@
<img src="/imgs/icons/success.webp" class="success-img" /> <img src="/imgs/icons/success.webp" class="success-img" />
<div class="title-msg" v-safe-html="successText"></div> <div class="title-msg" v-safe-html="successText"></div>
</div> </div>
<div class="bottom-btn"></div> <div v-if="jumpConfig.buttonText && jumpConfig.type === 'button'" class="jump-btn">
{{ jumpConfig.buttonText }}
</div>
</div> </div>
</div> </div>
</template> </template>
@ -17,6 +19,7 @@ interface Props {
} }
const props = defineProps<Props>() const props = defineProps<Props>()
const successText = computed(() => props.moduleConfig?.msgContent?.msg_200 || '') const successText = computed(() => props.moduleConfig?.msgContent?.msg_200 || '')
const jumpConfig = computed(() => props.moduleConfig?.jumpConfig || {})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/*成功页面跳转全屏展示浮层*/ /*成功页面跳转全屏展示浮层*/
@ -50,7 +53,18 @@ const successText = computed(() => props.moduleConfig?.msgContent?.msg_200 || ''
font-size: 0.36rem; font-size: 0.36rem;
} }
} }
.bottom-btn { .jump-btn {
height: 300px; background: var(--primary-color);
border-radius: 2px;
width: 90%;
height: 40px;
line-height: 40px;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
font-weight: 500;
margin: 0 auto;
} }
</style> </style>

View File

@ -1,7 +1,7 @@
export default { export default {
Success: [ Success: [
{ {
label: '提示文案', title: '提示文案',
type: 'RichText', type: 'RichText',
key: 'msgContent.msg_200', key: 'msgContent.msg_200',
placeholder: '提交成功', placeholder: '提交成功',
@ -9,6 +9,46 @@ export default {
labelStyle: { labelStyle: {
'font-weight': 'bold' 'font-weight': 'bold'
} }
},
{
title: '交卷跳转',
type: 'Customed',
key: 'jumpConfig',
content: [
{
key: 'jumpConfig.type',
type: 'RadioGroup',
value: 'link',
options: [
{
label: '跳转网页',
value: 'link'
},
{
label: '跳转按钮',
value: 'button'
},
],
},
{
key: 'jumpConfig.buttonText',
label: '按钮文案',
type: 'InputSetter',
placeholder: '请输入按钮文案',
value: '',
toggleShowFn: (data) => {
return data?.jumpConfig?.type === 'button'
},
},
{
key: 'jumpConfig.link',
label: '跳转链接',
type: 'InputSetter',
placeholder: '请输入网址',
value: '',
},
]
} }
], ],
OverTime: [ OverTime: [

View File

@ -16,13 +16,17 @@
> >
重新填写 重新填写
</router-link> </router-link>
<a v-if="showJumpButton" :href="jumpConfig.link" class="jump-btn">
{{ jumpConfig.buttonText }}
</a>
</div> </div>
<LogoIcon :logo-conf="logoConf" :readonly="true" /> <LogoIcon :logo-conf="logoConf" :readonly="true" />
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed, ref, watchEffect } from 'vue'
import { useSurveyStore } from '../stores/survey' import { useSurveyStore } from '../stores/survey'
// @ts-ignore // @ts-ignore
import communalLoader from '@materials/communals/communalLoader.js' import communalLoader from '@materials/communals/communalLoader.js'
@ -37,6 +41,20 @@ const successMsg = computed(() => {
const msgContent = (surveyStore?.submitConf as any)?.msgContent || {} const msgContent = (surveyStore?.submitConf as any)?.msgContent || {}
return msgContent?.msg_200 || '提交成功' return msgContent?.msg_200 || '提交成功'
}) })
const jumpConfig = computed(() => {
return (surveyStore?.submitConf as any)?.jumpConfig || {}
})
const showJumpButton = ref(false)
watchEffect(() => {
const { jumpConfig } = (surveyStore?.submitConf || {}) as any
if (jumpConfig?.type === 'link' && jumpConfig?.link) {
window.location.href = jumpConfig.link
}
showJumpButton.value = jumpConfig?.type === 'button' && jumpConfig?.buttonText
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '@/render/styles/variable.scss'; @import '@/render/styles/variable.scss';
@ -87,5 +105,21 @@ const successMsg = computed(() => {
text-decoration: underline; text-decoration: underline;
display: block; display: block;
} }
.jump-btn {
background: var(--primary-color);
border-radius: 2px;
width: 90%;
height: 40px;
line-height: 40px;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
font-weight: 500;
margin: 32px auto 0;
cursor: pointer;
}
} }
</style> </style>