feat: 优化引入、lint & format
This commit is contained in:
parent
2ad6a77740
commit
5a8fab4e4b
@ -1,4 +1,4 @@
|
|||||||
// 静态数据
|
// test:静态数据,实际业务里无用
|
||||||
export const ruleConf = [
|
export const ruleConf = [
|
||||||
{
|
{
|
||||||
conditions: [
|
conditions: [
|
||||||
|
@ -7,7 +7,7 @@ export enum QUESTION_TYPE {
|
|||||||
BINARY_CHOICE = 'binary-choice',
|
BINARY_CHOICE = 'binary-choice',
|
||||||
RADIO_STAR = 'radio-star',
|
RADIO_STAR = 'radio-star',
|
||||||
RADIO_NPS = 'radio-nps',
|
RADIO_NPS = 'radio-nps',
|
||||||
VOTE = 'vote',
|
VOTE = 'vote'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 题目类型标签映射对象
|
// 题目类型标签映射对象
|
||||||
@ -23,19 +23,13 @@ export const typeTagLabels: Record<QUESTION_TYPE, string> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 输入类题型
|
// 输入类题型
|
||||||
export const INPUT = [
|
export const INPUT = [QUESTION_TYPE.TEXT, QUESTION_TYPE.TEXTAREA]
|
||||||
QUESTION_TYPE.TEXT,
|
|
||||||
QUESTION_TYPE.TEXTAREA
|
|
||||||
]
|
|
||||||
|
|
||||||
// 选择类题型分类
|
// 选择类题型分类
|
||||||
export const NORMAL_CHOICES = [
|
export const NORMAL_CHOICES = [QUESTION_TYPE.RADIO, QUESTION_TYPE.CHECKBOX]
|
||||||
QUESTION_TYPE.RADIO,
|
|
||||||
QUESTION_TYPE.CHECKBOX
|
|
||||||
]
|
|
||||||
|
|
||||||
// 选择类题型分类
|
// 选择类题型分类
|
||||||
export const CHOICES = [
|
export const CHOICES = [
|
||||||
QUESTION_TYPE.RADIO,
|
QUESTION_TYPE.RADIO,
|
||||||
QUESTION_TYPE.CHECKBOX,
|
QUESTION_TYPE.CHECKBOX,
|
||||||
QUESTION_TYPE.BINARY_CHOICE,
|
QUESTION_TYPE.BINARY_CHOICE,
|
||||||
@ -43,8 +37,4 @@ export const CHOICES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
// 评分题题型分类
|
// 评分题题型分类
|
||||||
export const RATES = [
|
export const RATES = [QUESTION_TYPE.RADIO_STAR, QUESTION_TYPE.RADIO_NPS]
|
||||||
QUESTION_TYPE.RADIO_STAR,
|
|
||||||
QUESTION_TYPE.RADIO_NPS
|
|
||||||
]
|
|
||||||
|
|
||||||
|
@ -71,4 +71,4 @@ export const getCollaboratorPermissions = (surveyId: string) => {
|
|||||||
surveyId
|
surveyId
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -58,18 +58,22 @@ const tabArr = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
const tabs = ref([])
|
const tabs = ref([])
|
||||||
watch(() => store.state.cooperPermissions, (newVal) => {
|
watch(
|
||||||
tabs.value = []
|
() => store.state.cooperPermissions,
|
||||||
// 如果有问卷管理权限,则加入问卷编辑和投放菜单
|
(newVal) => {
|
||||||
if (newVal.includes(SurveyPermissions.SurveyManage)) {
|
tabs.value = []
|
||||||
tabs.value.push(tabArr[0])
|
// 如果有问卷管理权限,则加入问卷编辑和投放菜单
|
||||||
tabs.value.push(tabArr[1])
|
if (newVal.includes(SurveyPermissions.SurveyManage)) {
|
||||||
}
|
tabs.value.push(tabArr[0])
|
||||||
// 如果有数据分析权限,则加入数据分析菜单
|
tabs.value.push(tabArr[1])
|
||||||
if (newVal.includes(SurveyPermissions.DataManage)) {
|
}
|
||||||
tabs.value.push(tabArr[2])
|
// 如果有数据分析权限,则加入数据分析菜单
|
||||||
}
|
if (newVal.includes(SurveyPermissions.DataManage)) {
|
||||||
}, { immediate: true })
|
tabs.value.push(tabArr[2])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.nav {
|
.nav {
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import { createRouter, createWebHistory, type RouteLocationNormalized, type NavigationGuardNext } from 'vue-router'
|
import {
|
||||||
|
createRouter,
|
||||||
|
createWebHistory,
|
||||||
|
type RouteLocationNormalized,
|
||||||
|
type NavigationGuardNext
|
||||||
|
} from 'vue-router'
|
||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
import { useStore, type Store } from 'vuex'
|
import { useStore, type Store } from 'vuex'
|
||||||
import { SurveyPermissions } from '@/management/utils/types/workSpace'
|
import { SurveyPermissions } from '@/management/utils/types/workSpace'
|
||||||
@ -161,33 +166,43 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
// 初始化用户信息
|
// 初始化用户信息
|
||||||
if (!userStore?.initialized) {
|
if (!userStore?.initialized) {
|
||||||
await userStore.init();
|
await userStore.init()
|
||||||
}
|
}
|
||||||
// 更新页面标题
|
// 更新页面标题
|
||||||
if (to.meta.title) {
|
if (to.meta.title) {
|
||||||
document.title = to.meta.title as string;
|
document.title = to.meta.title as string
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.meta.needLogin) {
|
if (to.meta.needLogin) {
|
||||||
await handleLoginGuard(to, from, next, store);
|
await handleLoginGuard(to, from, next, store)
|
||||||
} else {
|
} else {
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
async function handleLoginGuard(to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext, store: Store<any>) {
|
async function handleLoginGuard(
|
||||||
const userStore = useUserStore();
|
to: RouteLocationNormalized,
|
||||||
|
from: RouteLocationNormalized,
|
||||||
|
next: NavigationGuardNext,
|
||||||
|
store: Store<any>
|
||||||
|
) {
|
||||||
|
const userStore = useUserStore()
|
||||||
if (userStore?.hasLogined) {
|
if (userStore?.hasLogined) {
|
||||||
await handlePermissionsGuard(to, from, next, store);
|
await handlePermissionsGuard(to, from, next, store)
|
||||||
} else {
|
} else {
|
||||||
next({
|
next({
|
||||||
name: 'login',
|
name: 'login',
|
||||||
query: { redirect: encodeURIComponent(to.path) },
|
query: { redirect: encodeURIComponent(to.path) }
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handlePermissionsGuard(to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext, store: Store<any>) {
|
async function handlePermissionsGuard(
|
||||||
|
to: RouteLocationNormalized,
|
||||||
|
from: RouteLocationNormalized,
|
||||||
|
next: NavigationGuardNext,
|
||||||
|
store: Store<any>
|
||||||
|
) {
|
||||||
const currSurveyId = to?.params?.id || ''
|
const currSurveyId = to?.params?.id || ''
|
||||||
const prevSurveyId = from?.params?.id || ''
|
const prevSurveyId = from?.params?.id || ''
|
||||||
// 如果跳转页面不存在surveyId 或者不需要页面权限,则直接跳转
|
// 如果跳转页面不存在surveyId 或者不需要页面权限,则直接跳转
|
||||||
@ -198,21 +213,19 @@ async function handlePermissionsGuard(to: RouteLocationNormalized, from: RouteLo
|
|||||||
if (currSurveyId !== prevSurveyId) {
|
if (currSurveyId !== prevSurveyId) {
|
||||||
await store.dispatch('fetchCooperPermissions', currSurveyId)
|
await store.dispatch('fetchCooperPermissions', currSurveyId)
|
||||||
if (hasRequiredPermissions(to.meta.permissions as string[], store.state.cooperPermissions)) {
|
if (hasRequiredPermissions(to.meta.permissions as string[], store.state.cooperPermissions)) {
|
||||||
next();
|
next()
|
||||||
} else {
|
} else {
|
||||||
ElMessage.warning('您没有该问卷的相关协作权限');
|
ElMessage.warning('您没有该问卷的相关协作权限')
|
||||||
next({ name: 'survey' });
|
next({ name: 'survey' })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasRequiredPermissions(requiredPermissions: string[], userPermissions: string[]) {
|
function hasRequiredPermissions(requiredPermissions: string[], userPermissions: string[]) {
|
||||||
return requiredPermissions.some(permission => userPermissions.includes(permission));
|
return requiredPermissions.some((permission) => userPermissions.includes(permission))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
@ -12,7 +12,7 @@ export default createStore({
|
|||||||
mutations,
|
mutations,
|
||||||
actions,
|
actions,
|
||||||
modules: {
|
modules: {
|
||||||
edit,
|
edit
|
||||||
// user,
|
// user,
|
||||||
// list
|
// list
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import { defineStore } from 'pinia'
|
|
||||||
import { type Ref, ref, reactive, toRef, computed } from 'vue'
|
import { type Ref, ref, reactive, toRef, computed } from 'vue'
|
||||||
import { getSurveyById } from '@/management/api/survey'
|
import { defineStore } from 'pinia'
|
||||||
import { merge as _merge, cloneDeep as _cloneDeep, set as _set } from 'lodash-es'
|
import { merge as _merge, cloneDeep as _cloneDeep, set as _set } from 'lodash-es'
|
||||||
|
|
||||||
|
import { getSurveyById } from '@/management/api/survey'
|
||||||
import { getNewField } from '@/management/utils'
|
import { getNewField } from '@/management/utils'
|
||||||
import submitFormConfig from '@/management/config/setterConfig/submitConfig'
|
import submitFormConfig from '@/management/config/setterConfig/submitConfig'
|
||||||
|
|
||||||
import questionLoader from '@/materials/questions/questionLoader'
|
import questionLoader from '@/materials/questions/questionLoader'
|
||||||
|
|
||||||
const innerMetaConfig = {
|
const innerMetaConfig = {
|
||||||
@ -78,8 +80,6 @@ function useInitializeSchema(surveyId: Ref<string>) {
|
|||||||
schema.submitConf = _merge({}, schema.submitConf, codeData.submitConf)
|
schema.submitConf = _merge({}, schema.submitConf, codeData.submitConf)
|
||||||
schema.questionDataList = codeData.questionDataList || []
|
schema.questionDataList = codeData.questionDataList || []
|
||||||
schema.logicConf = codeData.logicConf
|
schema.logicConf = codeData.logicConf
|
||||||
|
|
||||||
console.log(metaData, codeData)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSchemaFromRemote() {
|
async function getSchemaFromRemote() {
|
||||||
@ -205,6 +205,17 @@ function useCurrentEdit({
|
|||||||
return key
|
return key
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const currentEditMeta = computed(() => {
|
||||||
|
if (currentEditOne.value === null) {
|
||||||
|
return null
|
||||||
|
} else if (innerMetaConfig[currentEditOne.value as keyof typeof innerMetaConfig]) {
|
||||||
|
return innerMetaConfig[currentEditOne.value as keyof typeof innerMetaConfig]
|
||||||
|
} else {
|
||||||
|
const questionType = questionDataList.value?.[currentEditOne.value]?.type
|
||||||
|
return questionLoader.getMeta(questionType)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const moduleConfig = computed(() => {
|
const moduleConfig = computed(() => {
|
||||||
if (currentEditOne.value === null) {
|
if (currentEditOne.value === null) {
|
||||||
return null
|
return null
|
||||||
@ -231,17 +242,6 @@ function useCurrentEdit({
|
|||||||
return currentEditMeta.value?.formConfig || []
|
return currentEditMeta.value?.formConfig || []
|
||||||
})
|
})
|
||||||
|
|
||||||
const currentEditMeta = computed(() => {
|
|
||||||
if (currentEditOne.value === null) {
|
|
||||||
return null
|
|
||||||
} else if (innerMetaConfig[currentEditOne.value as keyof typeof innerMetaConfig]) {
|
|
||||||
return innerMetaConfig[currentEditOne.value as keyof typeof innerMetaConfig]
|
|
||||||
} else {
|
|
||||||
const questionType = questionDataList.value?.[currentEditOne.value]?.type
|
|
||||||
return questionLoader.getMeta(questionType)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function setCurrentEditOne(data: any) {
|
function setCurrentEditOne(data: any) {
|
||||||
currentEditOne.value = data
|
currentEditOne.value = data
|
||||||
}
|
}
|
||||||
@ -267,6 +267,7 @@ export const useEditStore = defineStore('edit', () => {
|
|||||||
const schemaUpdateTime = ref(Date.now())
|
const schemaUpdateTime = ref(Date.now())
|
||||||
const { schema, initSchema, getSchemaFromRemote } = useInitializeSchema(surveyId)
|
const { schema, initSchema, getSchemaFromRemote } = useInitializeSchema(surveyId)
|
||||||
const questionDataList = toRef(schema, 'questionDataList')
|
const questionDataList = toRef(schema, 'questionDataList')
|
||||||
|
|
||||||
function setQuestionDataList(data: any) {
|
function setQuestionDataList(data: any) {
|
||||||
schema.questionDataList = data
|
schema.questionDataList = data
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
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 { defineStore } from 'pinia'
|
|
||||||
|
|
||||||
import { CODE_MAP } from '@/management/api/base'
|
import { CODE_MAP } from '@/management/api/base'
|
||||||
import { getSurveyList as getSurveyListReq } from '@/management/api/survey'
|
import { getSurveyList as getSurveyListReq } from '@/management/api/survey'
|
||||||
|
|
||||||
import { useWorkSpaceStore } from './workSpace'
|
import { useWorkSpaceStore } from './workSpace'
|
||||||
import { ref, computed } from 'vue'
|
|
||||||
|
|
||||||
function useSearchSurvey() {
|
function useSearchSurvey() {
|
||||||
const searchVal = ref('')
|
const searchVal = ref('')
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
// Pinia Store
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
const USER_INFO_KEY = 'surveyUserInfo'
|
const USER_INFO_KEY = 'surveyUserInfo'
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
@ -41,11 +39,11 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
userInfo.value = null
|
userInfo.value = null
|
||||||
hasLogined.value = false
|
hasLogined.value = false
|
||||||
localStorage.removeItem(USER_INFO_KEY)
|
localStorage.removeItem(USER_INFO_KEY)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { userInfo, hasLogined, loginTime, initialized, init, login, logout }
|
return { userInfo, hasLogined, loginTime, initialized, init, login, logout }
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
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'
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ import {
|
|||||||
getSpaceList as getSpaceListReq,
|
getSpaceList as getSpaceListReq,
|
||||||
getSpaceDetail as getSpaceDetailReq
|
getSpaceDetail as getSpaceDetailReq
|
||||||
} from '@/management/api/space'
|
} from '@/management/api/space'
|
||||||
|
|
||||||
import { SpaceType } from '@/management/utils/types/workSpace'
|
import { SpaceType } from '@/management/utils/types/workSpace'
|
||||||
import {
|
import {
|
||||||
type SpaceDetail,
|
type SpaceDetail,
|
||||||
|
@ -39,19 +39,20 @@ export const getQuestionByType = (type, fields) => {
|
|||||||
const questionMeta = questionLoader.getMeta(type)
|
const questionMeta = questionLoader.getMeta(type)
|
||||||
const { attrs } = questionMeta
|
const { attrs } = questionMeta
|
||||||
let newQuestion = defaultQuestionConfig
|
let newQuestion = defaultQuestionConfig
|
||||||
if( attrs ) {
|
if (attrs) {
|
||||||
let questionSchema = {}
|
let questionSchema = {}
|
||||||
attrs.forEach(element => {
|
attrs.forEach((element) => {
|
||||||
questionSchema[element.name] = element.defaultValue
|
questionSchema[element.name] = element.defaultValue
|
||||||
});
|
})
|
||||||
newQuestion = questionSchema
|
newQuestion = questionSchema
|
||||||
} else {
|
} else {
|
||||||
newQuestion = defaultQuestionConfig
|
newQuestion = defaultQuestionConfig
|
||||||
newQuestion.type = type
|
newQuestion.type = type
|
||||||
}
|
}
|
||||||
|
|
||||||
newQuestion.field = getNewField(fields) // 动态生成题目id
|
newQuestion.field = getNewField(fields) // 动态生成题目id
|
||||||
if('options ' in newQuestion) { // 动态更新选项的hash-id
|
if ('options' in newQuestion) {
|
||||||
|
// 动态更新选项的hash-id
|
||||||
const hashList = []
|
const hashList = []
|
||||||
for (const option of newQuestion.options) {
|
for (const option of newQuestion.options) {
|
||||||
const hash = generateHash(hashList)
|
const hash = generateHash(hashList)
|
||||||
@ -59,7 +60,7 @@ export const getQuestionByType = (type, fields) => {
|
|||||||
option.hash = hash
|
option.hash = hash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newQuestion
|
return newQuestion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export interface SpaceDetail {
|
|||||||
|
|
||||||
export type SpaceItem = Required<Omit<SpaceDetail, 'members'>> & {
|
export type SpaceItem = Required<Omit<SpaceDetail, 'members'>> & {
|
||||||
createDate: string
|
createDate: string
|
||||||
curStatus: { date: number, status: string }
|
curStatus: { date: number; status: string }
|
||||||
memberTotal: number
|
memberTotal: number
|
||||||
currentUserRole: string
|
currentUserRole: string
|
||||||
owner: string
|
owner: string
|
||||||
|
@ -111,20 +111,10 @@ export default defineComponent({
|
|||||||
editConfigure={questionMeta?.editConfigure}
|
editConfigure={questionMeta?.editConfigure}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
>
|
>
|
||||||
<dynamicComponent
|
<dynamicComponent readonly {...props} onBlur={this.onBlur} onFocus={this.onFocus} />
|
||||||
readonly
|
|
||||||
{...props}
|
|
||||||
onBlur={this.onBlur}
|
|
||||||
onFocus={this.onFocus}
|
|
||||||
/>
|
|
||||||
</EditOptions>
|
</EditOptions>
|
||||||
) : (
|
) : (
|
||||||
<dynamicComponent
|
<dynamicComponent readonly {...props} onBlur={this.onBlur} onFocus={this.onFocus} />
|
||||||
readonly
|
|
||||||
{...props}
|
|
||||||
onBlur={this.onBlur}
|
|
||||||
onFocus={this.onFocus}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,25 +53,25 @@ const meta = {
|
|||||||
description: '这是用于描述选项',
|
description: '这是用于描述选项',
|
||||||
defaultValue: [
|
defaultValue: [
|
||||||
{
|
{
|
||||||
"text": "对",
|
text: '对',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115019"
|
hash: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "错",
|
text: '错',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115020"
|
hash: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
formConfig: [basicConfig],
|
formConfig: [basicConfig],
|
||||||
editConfigure: {
|
editConfigure: {
|
||||||
|
@ -53,22 +53,22 @@ const meta = {
|
|||||||
description: '这是用于描述选项',
|
description: '这是用于描述选项',
|
||||||
defaultValue: [
|
defaultValue: [
|
||||||
{
|
{
|
||||||
"text": "选项1",
|
text: '选项1',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115019"
|
hash: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "选项2",
|
text: '选项2',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115020"
|
hash: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.question-block {
|
.question-block {
|
||||||
padding: 0!important;
|
padding: 0 !important;
|
||||||
}
|
}
|
||||||
.radio-nps-hover {
|
.radio-nps-hover {
|
||||||
.rate-item {
|
.rate-item {
|
||||||
|
@ -53,29 +53,27 @@ const meta = {
|
|||||||
description: '这是用于描述选项',
|
description: '这是用于描述选项',
|
||||||
defaultValue: [
|
defaultValue: [
|
||||||
{
|
{
|
||||||
"text": "选项1",
|
text: '选项1',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115019"
|
hash: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "选项2",
|
text: '选项2',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115020"
|
hash: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
],
|
|
||||||
formConfig: [
|
|
||||||
basicConfig,
|
|
||||||
],
|
],
|
||||||
|
formConfig: [basicConfig],
|
||||||
editConfigure: {
|
editConfigure: {
|
||||||
optionEdit: {
|
optionEdit: {
|
||||||
show: true
|
show: true
|
||||||
|
@ -63,14 +63,14 @@ const meta = {
|
|||||||
name: 'starStyle',
|
name: 'starStyle',
|
||||||
propType: String,
|
propType: String,
|
||||||
description: '',
|
description: '',
|
||||||
defaultValue: 'star',
|
defaultValue: 'star'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'rangeConfig',
|
name: 'rangeConfig',
|
||||||
propType: Object,
|
propType: Object,
|
||||||
description: '这是用于描述评分高级设置',
|
description: '这是用于描述评分高级设置',
|
||||||
defaultValue: {}
|
defaultValue: {}
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
formConfig: [
|
formConfig: [
|
||||||
basicConfig,
|
basicConfig,
|
||||||
|
@ -53,22 +53,22 @@ const meta = {
|
|||||||
description: '这是用于描述选项',
|
description: '这是用于描述选项',
|
||||||
defaultValue: [
|
defaultValue: [
|
||||||
{
|
{
|
||||||
"text": "选项1",
|
text: '选项1',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115019"
|
hash: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "选项2",
|
text: '选项2',
|
||||||
"imageUrl": "",
|
imageUrl: '',
|
||||||
"others": false,
|
others: false,
|
||||||
"mustOthers": false,
|
mustOthers: false,
|
||||||
"othersKey": "",
|
othersKey: '',
|
||||||
"placeholderDesc": "",
|
placeholderDesc: '',
|
||||||
"hash": "115020"
|
hash: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -199,7 +199,7 @@ const generateOthersKeyMap = (question) => {
|
|||||||
let othersKeyMap = undefined
|
let othersKeyMap = undefined
|
||||||
|
|
||||||
if (RATES.includes(type)) {
|
if (RATES.includes(type)) {
|
||||||
const { rangeConfig } = question
|
const { rangeConfig } = question
|
||||||
othersKeyMap = {}
|
othersKeyMap = {}
|
||||||
for (const key in rangeConfig) {
|
for (const key in rangeConfig) {
|
||||||
if (rangeConfig[key].isShowInput) {
|
if (rangeConfig[key].isShowInput) {
|
||||||
@ -207,7 +207,7 @@ const generateOthersKeyMap = (question) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type?.includes(QUESTION_TYPE.RADIO) || type?.includes(QUESTION_TYPE.CHECKBOX)) {
|
} else if (type?.includes(QUESTION_TYPE.RADIO) || type?.includes(QUESTION_TYPE.CHECKBOX)) {
|
||||||
const { options } = question
|
const { options } = question
|
||||||
othersKeyMap = {}
|
othersKeyMap = {}
|
||||||
options
|
options
|
||||||
.filter((op) => op.others)
|
.filter((op) => op.others)
|
||||||
|
@ -57,8 +57,10 @@ const questionConfig = computed(() => {
|
|||||||
moduleConfig.othersValue = unref(othersValue)
|
moduleConfig.othersValue = unref(othersValue)
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
RATES.includes(type) && rest?.rangeConfig &&
|
RATES.includes(type) &&
|
||||||
Object.keys(rest?.rangeConfig).filter((index) => rest?.rangeConfig[index].isShowInput).length > 0
|
rest?.rangeConfig &&
|
||||||
|
Object.keys(rest?.rangeConfig).filter((index) => rest?.rangeConfig[index].isShowInput).length >
|
||||||
|
0
|
||||||
) {
|
) {
|
||||||
let { rangeConfig, othersValue } = useShowInput(field)
|
let { rangeConfig, othersValue } = useShowInput(field)
|
||||||
moduleConfig.rangeConfig = unref(rangeConfig)
|
moduleConfig.rangeConfig = unref(rangeConfig)
|
||||||
|
@ -5,7 +5,6 @@ import router from './router'
|
|||||||
import store from './store'
|
import store from './store'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
|
||||||
@ -17,5 +16,4 @@ app.use(store)
|
|||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
@ -7,9 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup></script>
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.container {
|
.container {
|
||||||
|
@ -18,15 +18,8 @@ const surveyStore = useSurveyStore()
|
|||||||
const loadData = (res: any, surveyPath: string) => {
|
const loadData = (res: any, surveyPath: string) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
const {
|
const { bannerConf, baseConf, bottomConf, dataConf, skinConf, submitConf, logicConf } =
|
||||||
bannerConf,
|
data.code
|
||||||
baseConf,
|
|
||||||
bottomConf,
|
|
||||||
dataConf,
|
|
||||||
skinConf,
|
|
||||||
submitConf,
|
|
||||||
logicConf
|
|
||||||
} = data.code
|
|
||||||
const questionData = {
|
const questionData = {
|
||||||
bannerConf,
|
bannerConf,
|
||||||
baseConf,
|
baseConf,
|
||||||
@ -62,7 +55,7 @@ const getDetail = async (surveyPath: string) => {
|
|||||||
} else {
|
} else {
|
||||||
const res: any = await getPublishedSurveyInfo({ surveyPath })
|
const res: any = await getPublishedSurveyInfo({ surveyPath })
|
||||||
loadData(res, surveyPath)
|
loadData(res, surveyPath)
|
||||||
surveyStore.getEncryptInfo();
|
surveyStore.getEncryptInfo()
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
@ -73,7 +73,7 @@ const validate = (cbk: (v: boolean) => void) => {
|
|||||||
|
|
||||||
const normalizationRequestBody = () => {
|
const normalizationRequestBody = () => {
|
||||||
const enterTime = surveyStore.enterTime
|
const enterTime = surveyStore.enterTime
|
||||||
const encryptInfo = surveyStore.encryptInfo as any;
|
const encryptInfo = surveyStore.encryptInfo as any
|
||||||
const formValues = store.state.formValues
|
const formValues = store.state.formValues
|
||||||
|
|
||||||
const result: any = {
|
const result: any = {
|
||||||
@ -82,7 +82,7 @@ const normalizationRequestBody = () => {
|
|||||||
difTime: Date.now() - enterTime,
|
difTime: Date.now() - enterTime,
|
||||||
clientTime: Date.now()
|
clientTime: Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
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']({
|
||||||
|
@ -19,12 +19,9 @@ const VOTE_INFO_KEY = 'voteinfo'
|
|||||||
import router from '../router'
|
import router from '../router'
|
||||||
export default {
|
export default {
|
||||||
// 初始化
|
// 初始化
|
||||||
init(
|
init({ commit, dispatch }, { bannerConf, baseConf, bottomConf, dataConf, skinConf, submitConf }) {
|
||||||
{ commit, dispatch },
|
|
||||||
{ bannerConf, baseConf, bottomConf, dataConf, skinConf, submitConf }
|
|
||||||
) {
|
|
||||||
const surveyStore = useSurveyStore()
|
const surveyStore = useSurveyStore()
|
||||||
surveyStore.setEnterTime();
|
surveyStore.setEnterTime()
|
||||||
const { begTime, endTime, answerBegTime, answerEndTime } = baseConf
|
const { begTime, endTime, answerBegTime, answerEndTime } = baseConf
|
||||||
const { msgContent } = submitConf
|
const { msgContent } = submitConf
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// 问卷相关的Pinia Store
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
import { isMobile as isInMobile } from '@/render/utils/index'
|
import { isMobile as isInMobile } from '@/render/utils/index'
|
||||||
import { getEncryptInfo as getEncryptInfoApi } from '@/render/api/survey'
|
import { getEncryptInfo as getEncryptInfoApi } from '@/render/api/survey'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CODE_MAP不从management引入,在dev阶段,会导致B端 router被加载,进而导致C端路由被添加 baseUrl: /management
|
* CODE_MAP不从management引入,在dev阶段,会导致B端 router被加载,进而导致C端路由被添加 baseUrl: /management
|
||||||
@ -13,12 +13,12 @@ const CODE_MAP = {
|
|||||||
NO_AUTH: 403
|
NO_AUTH: 403
|
||||||
}
|
}
|
||||||
export const useSurveyStore = defineStore('survey', () => {
|
export const useSurveyStore = defineStore('survey', () => {
|
||||||
const surveyPath = ref('');
|
const surveyPath = ref('')
|
||||||
const isMobile = ref(isInMobile())
|
const isMobile = ref(isInMobile())
|
||||||
const enterTime = ref(0)
|
const enterTime = ref(0)
|
||||||
const encryptInfo = ref(null)
|
const encryptInfo = ref(null)
|
||||||
|
|
||||||
const setSurveyPath = ( data) => {
|
const setSurveyPath = (data) => {
|
||||||
surveyPath.value = data
|
surveyPath.value = data
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ export const useSurveyStore = defineStore('survey', () => {
|
|||||||
enterTime.value = Date.now()
|
enterTime.value = Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getEncryptInfo = async() => {
|
const getEncryptInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getEncryptInfoApi()
|
const res = await getEncryptInfoApi()
|
||||||
if (res.code === CODE_MAP.SUCCESS) {
|
if (res.code === CODE_MAP.SUCCESS) {
|
||||||
@ -47,4 +47,4 @@ export const useSurveyStore = defineStore('survey', () => {
|
|||||||
setEnterTime,
|
setEnterTime,
|
||||||
getEncryptInfo
|
getEncryptInfo
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user