提交问卷时又白名单新增verifyId参数 (#316)

* --story=1059873 --user=T8罗佳明 【ALL】2024年06月日常优化 https://www.tapd.cn/23402991/s/2202857

* feat:答卷白名单功能

* fix:修复lint问题

* fix:提交问卷时添加verifyId参数
This commit is contained in:
chaorenluo 2024-06-28 18:38:54 +08:00 committed by GitHub
parent 01ce20570f
commit 99e21def1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 43 additions and 24 deletions

View File

@ -26,7 +26,8 @@ export default {
keys: ['baseConf.passwordSwitch', 'baseConf.password'], keys: ['baseConf.passwordSwitch', 'baseConf.password'],
label: '访问密码', label: '访问密码',
type: 'SwitchInput', type: 'SwitchInput',
placeholder: '请输入访问密码' placeholder: '请输入6位字符串类型访问密码 ',
maxLength: 6,
}, },
answer_type: { answer_type: {
key: 'baseConf.whitelistType', key: 'baseConf.whitelistType',
@ -38,7 +39,7 @@ export default {
label: '名单登录提示语', label: '名单登录提示语',
placeholder:'请输入名单提示语', placeholder:'请输入名单提示语',
type: 'InputWordLimit', type: 'InputWordLimit',
maxlength: 40, maxLength: 40,
relyFunc: (data) => { relyFunc: (data) => {
return ['CUSTOM','MEMBER'].includes(data.whitelistType) return ['CUSTOM','MEMBER'].includes(data.whitelistType)
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<el-input <el-input
:maxlength="maxlength" :maxlength="maxLength"
v-model="modelValue" v-model="modelValue"
:placeholder="placeholder" :placeholder="placeholder"
show-word-limit show-word-limit
@ -19,7 +19,7 @@ const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
const modelValue = ref(props.formConfig.value || '') const modelValue = ref(props.formConfig.value || '')
const maxlength = computed(() => props.formConfig.maxlength || 10) const maxLength = computed(() => props.formConfig.maxLength || 10)
const placeholder = computed(() => props.formConfig.placeholder || '') const placeholder = computed(() => props.formConfig.placeholder || '')
@ -27,7 +27,6 @@ const handleInputChange = (value) => {
const key = props.formConfig.key const key = props.formConfig.key
modelValue.value = value modelValue.value = value
emit(FORM_CHANGE_EVENT_KEY, { key, value }) emit(FORM_CHANGE_EVENT_KEY, { key, value })
} }

View File

@ -1,28 +1,31 @@
<template> <template>
<div class="switch-input-wrap"> <div class="switch-input-wrap">
<el-switch v-model="passwordSwitch" @change="changeData(props.formConfig.keys[0],passwordSwitch)" /> <el-switch v-model="passwordSwitch" @change="changeData(props.formConfig.keys[0],passwordSwitch)" />
<el-input <InputWordLimit
v-if="passwordSwitch" v-if="passwordSwitch"
class="mt16" class="mt16"
maxlength="6" @form-change="handleFormChange"
placeholder="请输入6位字符串类型访问密码" :formConfig="{
show-word-limit ...props.formConfig,
v-model="password" key: props.formConfig.keys[1],
type="text" value:props.formConfig?.value[1]
@blur="changeData(props.formConfig.keys[1],password)" }"
/> />
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import { useStore } from 'vuex'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant' import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
import InputWordLimit from './InputWordLimit.vue'
const store = useStore();
const props = defineProps({ const props = defineProps({
formConfig: Object, formConfig: Object,
}) })
const emit = defineEmits([FORM_CHANGE_EVENT_KEY]) const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
const passwordSwitch = ref(props.formConfig?.value[0] || false); const passwordSwitch = ref(props.formConfig?.value[0] || false);
const password = ref(props.formConfig?.value[1] || '');
const changeData = (key, value) => { const changeData = (key, value) => {
emit(FORM_CHANGE_EVENT_KEY, { emit(FORM_CHANGE_EVENT_KEY, {
@ -31,7 +34,12 @@ const changeData = (key,value) => {
}) })
} }
const handleFormChange = (data) => {
store.dispatch('edit/changeSchema', {
key: data.key,
value: data.value
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -17,14 +17,14 @@
</div> </div>
</template> </template>
<div class="verify-white-body"> <div class="verify-white-body">
<el-input v-if="isPwd" v-model="state.password" class="wd255" placeholder="请输入6位字符串类型访问密码" /> <el-input v-if="isPwd" v-model="state.password" class="wd255 mb16" placeholder="请输入6位字符串类型访问密码" />
<el-input v-if="isValue" v-model="state.value" class="wd255 mt16" :placeholder="placeholder" /> <el-input v-if="isValue" v-model="state.value" class="wd255 mb16" :placeholder="placeholder" />
<div class="submit-btn" @click="handleSubmit">验证并开始答题</div> <div class="submit-btn" @click="handleSubmit">验证并开始答题</div>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script setup> <script setup>
import { ref,reactive,computed,onMounted } from 'vue' import { ref,reactive,computed,watch} from 'vue'
import { validate } from '../api/survey' import { validate } from '../api/survey'
import { useStore } from 'vuex' import { useStore } from 'vuex'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@ -83,9 +83,11 @@ const handleSubmit = async() => {
return return
} }
whiteVisible.value = false whiteVisible.value = false
store.commit('setVerifyId', res.data.verifyId)
} }
onMounted(() => { watch(()=>baseConf.value, () => {
if (whiteVisible.value) return
if(isValue.value || isPwd.value){ if(isValue.value || isPwd.value){
whiteVisible.value = true; whiteVisible.value = true;
} }
@ -103,8 +105,8 @@ onMounted(() => {
margin-bottom: 8px; margin-bottom: 8px;
margin-top:2px; margin-top:2px;
} }
.mt16{ .mb16{
margin-top:16px; margin-bottom:16px;
} }
.verify-white-tips{ .verify-white-tips{
text-align: center; text-align: center;
@ -130,7 +132,7 @@ onMounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top:20px; margin-top:4px;
margin-bottom:14px; margin-bottom:14px;
} }
} }

View File

@ -14,7 +14,7 @@
@submit="handleSubmit" @submit="handleSubmit"
></SubmitButton> ></SubmitButton>
<LogoIcon :logo-conf="logoConf" :readonly="true" /> <LogoIcon :logo-conf="logoConf" :readonly="true" />
<VerifyWhiteDialog v-if="store.state?.bannerConf" /> <VerifyWhiteDialog />
</div> </div>
</div> </div>
</div> </div>
@ -65,6 +65,7 @@ const renderData = computed(() => store.getters.renderData)
const submitConf = computed(() => store.state?.submitConf || {}) const submitConf = computed(() => store.state?.submitConf || {})
const logoConf = computed(() => store.state?.bottomConf || {}) const logoConf = computed(() => store.state?.bottomConf || {})
const surveyPath = computed(() => store.state?.surveyPath || '') const surveyPath = computed(() => store.state?.surveyPath || '')
const verifyId = computed(() => store.state?.verifyId || '')
const validate = (cbk: (v: boolean) => void) => { const validate = (cbk: (v: boolean) => void) => {
const index = 0 const index = 0
@ -83,6 +84,10 @@ const normalizationRequestBody = () => {
clientTime: Date.now() clientTime: Date.now()
} }
if(verifyId.value){
result.verifyId = verifyId.value
}
if (encryptInfo?.encryptType) { if (encryptInfo?.encryptType) {
result.encryptType = encryptInfo?.encryptType result.encryptType = encryptInfo?.encryptType
result.data = encrypt[result.encryptType as 'rsa']({ result.data = encrypt[result.encryptType as 'rsa']({

View File

@ -49,5 +49,8 @@ export default {
}, },
setRuleEgine(state, ruleEngine) { setRuleEgine(state, ruleEngine) {
state.ruleEngine = ruleEngine state.ruleEngine = ruleEngine
},
setVerifyId(state, verifyId) {
state.verifyId = verifyId
} }
} }

View File

@ -12,5 +12,6 @@ export default {
questionSeq: [], // 题目的顺序,因为可能会有分页的情况,所以是一个二维数组[[qid1, qid2], [qid3,qid4]] questionSeq: [], // 题目的顺序,因为可能会有分页的情况,所以是一个二维数组[[qid1, qid2], [qid3,qid4]]
voteMap: {}, voteMap: {},
encryptInfo: null, encryptInfo: null,
ruleEngine: null ruleEngine: null,
verifyId:''
} }