fix: 优化类型校验

This commit is contained in:
sudoooooo 2024-09-24 12:13:44 +08:00
parent 206f91d766
commit 4bc8fbc557
7 changed files with 28 additions and 22 deletions

View File

@ -34,7 +34,7 @@ import skinPresets from '@/management/config/skinPresets.js'
const editStore = useEditStore()
const { changeThemePreset } = editStore
const groupName = ref<string>('temp')
let bannerList = ref([])
let bannerList = ref<string[]>([])
onMounted(async () => {
const res = await getBannerData()
@ -43,14 +43,14 @@ onMounted(async () => {
const groupList = computed(() =>
Object.keys(bannerList.value).map((key) => ({
label: bannerList.value[key].name,
label: (bannerList.value as any)[key].name,
value: key
}))
)
const currentBannerList = computed(() => {
const arr = Object.keys(bannerList.value)
.map((key) => {
return bannerList.value[key]
return (bannerList.value as any)[key]
})
.map((data) => {
return data.list.map((item: any) => {

View File

@ -10,14 +10,14 @@ export default function useInitializeSchema(
) {
const schema = reactive({
metaData: null,
bannerConf: {},
bottomConf: {},
skinConf: {},
baseConf: {},
submitConf: {},
pageConf: [],
logicConf: {},
questionDataList: [],
bannerConf: {} as any,
bottomConf: {} as any,
skinConf: {} as any,
baseConf: {} as any,
submitConf: {} as any,
pageConf: [] as any,
logicConf: {} as any,
questionDataList: [] as any,
pageEditOne: 1
})
const { showLogicEngine, initShowLogicEngine, jumpLogicEngine, initJumpLogicEngine } =

View File

@ -33,7 +33,7 @@ export const getEncryptInfo = () => {
return axios.get('/clientEncrypt/getEncryptInfo')
}
export const validate = ({ surveyPath, password, whitelist }) => {
export const validate = ({ surveyPath, password = '', whitelist = '' }) => {
return axios.post(`/responseSchema/${surveyPath}/validate`, {
password,
whitelist

View File

@ -51,7 +51,7 @@ interface Props {
}
interface Emit {
(ev: 'confirm', data, callback: () => void): void
(ev: 'confirm', data: any, callback: () => void): void
(ev: 'close'): void
}
@ -71,7 +71,9 @@ const isVisible = ref(props.visible)
const formValues = reactive(props.bodyContent || [])
const handleConfirm = () => {
const data = {}
const data: {
[key: string]: any
} = {}
formValues.forEach((item) => {
data[item.key] = item.value
})

View File

@ -10,6 +10,7 @@
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { ElMessage } from 'element-plus'
import { validate } from '../../api/survey'
import { useSurveyStore } from '../../stores/survey'
@ -22,7 +23,7 @@ interface Emit {
const emit = defineEmits<Emit>()
const surveyStore = useSurveyStore()
const { passwordSwitch, whitelistType, memberType, whitelistTip } = surveyStore.baseConf || {}
const { passwordSwitch, whitelistType, memberType, whitelistTip }: any = surveyStore.baseConf || {}
const bodyContent = computed(() => {
const content = []
@ -55,8 +56,11 @@ const bodyContent = computed(() => {
return content
})
const handleSubmit = async (data, close) => {
const params = {
const handleSubmit = async (data: { whitelist: string; password: string }, close: Function) => {
const params: {
surveyPath: string
[key: string]: string
} = {
surveyPath: surveyStore.surveyPath
}
if (data.whitelist) {
@ -65,7 +69,7 @@ const handleSubmit = async (data, close) => {
if (data.password) {
params.password = data.password
}
const res = await validate(params)
const res: any = await validate(params)
if (res.code != 200) {
ElMessage.error(res.errmsg || '验证失败')

View File

@ -19,7 +19,7 @@ import WhiteListDialog from './WhiteListDialog.vue'
import FillDataDialog from './FillDataDialog.vue'
const surveyStore = useSurveyStore()
const baseConf = computed(() => surveyStore?.baseConf || {})
const baseConf: any = computed(() => surveyStore?.baseConf)
const showWhiteList = ref(false)
const showFillData = ref(false)
@ -27,7 +27,7 @@ const showFillData = ref(false)
watch(
() => baseConf.value,
() => {
const { passwordSwitch, whitelistType } = baseConf.value || {}
const { passwordSwitch, whitelistType } = baseConf.value
// or
if ((whitelistType && whitelistType != 'ALL') || passwordSwitch) {

View File

@ -84,9 +84,9 @@ const validate = (callback: (v: boolean) => void) => {
const normalizationRequestBody = () => {
const enterTime = surveyStore.enterTime
const encryptInfo = surveyStore.encryptInfo as any
const encryptInfo: any = surveyStore.encryptInfo
const formValues = surveyStore.formValues
const baseConf = surveyStore.baseConf
const baseConf: any = surveyStore.baseConf
const result: any = {
surveyPath: surveyPath.value,