-
-
必填
+
+
高级设置 >
+
+
+
+
+
+
+
+
+
+
+
+
changeOptionOthers(val, element)"
+ >
+
+
+ 必填
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- 添加新选项
+
+
+
+
+ 添加新选项
+
-
-
-
- 其他____
-
+
+ 其他____
+
-
-
-
-
-
+
+
+
+
+
diff --git a/web/src/management/pages/edit/modules/questionModule/components/AdvancedConfig/index.vue b/web/src/management/pages/edit/modules/questionModule/components/AdvancedConfig/index.vue
new file mode 100644
index 00000000..ba18f6c2
--- /dev/null
+++ b/web/src/management/pages/edit/modules/questionModule/components/AdvancedConfig/index.vue
@@ -0,0 +1,47 @@
+
+
+
+
+
diff --git a/web/src/management/pages/edit/modules/questionModule/components/QuestionCatalog.vue b/web/src/management/pages/edit/modules/questionModule/components/QuestionCatalog.vue
index cff08a4e..807ba8ef 100644
--- a/web/src/management/pages/edit/modules/questionModule/components/QuestionCatalog.vue
+++ b/web/src/management/pages/edit/modules/questionModule/components/QuestionCatalog.vue
@@ -1,72 +1,108 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/web/src/management/pages/edit/modules/settingModule/components/OverTime.vue b/web/src/management/pages/edit/modules/resultModule/components/OverTime.vue
similarity index 100%
rename from web/src/management/pages/edit/modules/settingModule/components/OverTime.vue
rename to web/src/management/pages/edit/modules/resultModule/components/OverTime.vue
diff --git a/web/src/management/pages/edit/modules/settingModule/components/SuccessContent.vue b/web/src/management/pages/edit/modules/resultModule/components/SuccessContent.vue
similarity index 100%
rename from web/src/management/pages/edit/modules/settingModule/components/SuccessContent.vue
rename to web/src/management/pages/edit/modules/resultModule/components/SuccessContent.vue
diff --git a/web/src/management/pages/edit/modules/settingModule/enum.js b/web/src/management/pages/edit/modules/resultModule/components/enum.js
similarity index 100%
rename from web/src/management/pages/edit/modules/settingModule/enum.js
rename to web/src/management/pages/edit/modules/resultModule/components/enum.js
diff --git a/web/src/management/pages/edit/modules/settingModule/SettingPanel.vue b/web/src/management/pages/edit/modules/settingModule/SettingPanel.vue
index 629b713e..747b79bb 100644
--- a/web/src/management/pages/edit/modules/settingModule/SettingPanel.vue
+++ b/web/src/management/pages/edit/modules/settingModule/SettingPanel.vue
@@ -2,117 +2,57 @@
-
+
{{ form.title }}
-
-
-
-
-
-
-
+ :form-config-list="form.formList"
+ :module-config="baseConf"
+ :custom-components="{
+ WhiteList,
+ TeamMemberList
+ }"
+ @form-change="handleFormChange"
+ >
diff --git a/web/src/management/pages/edit/modules/settingModule/components/WhiteList.vue b/web/src/management/pages/edit/modules/settingModule/components/WhiteList.vue
new file mode 100644
index 00000000..6db2d252
--- /dev/null
+++ b/web/src/management/pages/edit/modules/settingModule/components/WhiteList.vue
@@ -0,0 +1,155 @@
+
+
+
添加
+
+ 全部删除
+
+
+
+
+ {{ whitelist[scope.$index] }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 手机号
+ 邮箱
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/src/management/pages/edit/modules/settingModule/config/baseConfig.js b/web/src/management/pages/edit/modules/settingModule/config/baseConfig.js
deleted file mode 100644
index 6af2a296..00000000
--- a/web/src/management/pages/edit/modules/settingModule/config/baseConfig.js
+++ /dev/null
@@ -1,12 +0,0 @@
-export default [
- {
- title: '时间配置',
- key: 'timeConfig',
- formList: ['base_effectTime', 'limit_answerTime']
- },
- {
- title: '提交限制',
- key: 'limitConfig',
- formList: ['limit_tLimit', 'limit_breakAnswer', 'limit_backAnswer']
- }
-]
diff --git a/web/src/management/pages/edit/modules/settingModule/config/baseFormConfig.js b/web/src/management/pages/edit/modules/settingModule/config/baseFormConfig.js
deleted file mode 100644
index e1556f87..00000000
--- a/web/src/management/pages/edit/modules/settingModule/config/baseFormConfig.js
+++ /dev/null
@@ -1,39 +0,0 @@
-// 问卷设置,定义了字段和对应的设置器
-export default {
- base_effectTime: {
- keys: ['baseConf.begTime', 'baseConf.endTime'],
- label: '答题有效期',
- type: 'QuestionTime',
- placeholder: 'yyyy-MM-dd hh:mm:ss'
- },
- limit_tLimit: {
- key: 'baseConf.tLimit',
- label: '问卷回收总数',
- type: 'InputNumber',
- tip: '0为无限制,此功能用于限制该问卷总提交的数据量。当数据量达到限额时,该问卷将不能继续提交',
- tipShow: true,
- placement: 'top',
- min: 0
- },
- limit_answerTime: {
- keys: ['baseConf.answerBegTime', 'baseConf.answerEndTime'],
- label: '答题时段',
- tip: '问卷仅在指定时间段内可填写',
- type: 'QuestionTimeHour',
- placement: 'top'
- },
- limit_breakAnswer: {
- key: 'baseConf.breakAnswer',
- label: '允许断点续答',
- tip: '回填前一次作答中的内容(注:更换设备/浏览器/清除缓存/更改内容重新发布则此功能失效)',
- type: 'ELSwitch',
- value: false
- },
- limit_backAnswer: {
- key: 'baseConf.backAnswer',
- label: '自动填充上次填写内容',
- tip: '回填前一次提交的内容(注:更换设备/浏览器/清除缓存/更改内容重新发布则此功能失效)',
- type: 'ELSwitch',
- value: false
- }
-}
diff --git a/web/src/management/pages/edit/modules/settingModule/result/SetterPanel.vue b/web/src/management/pages/edit/modules/settingModule/result/SetterPanel.vue
deleted file mode 100644
index 28c74093..00000000
--- a/web/src/management/pages/edit/modules/settingModule/result/SetterPanel.vue
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
diff --git a/web/src/management/pages/edit/modules/settingModule/skin/CatalogPanel.vue b/web/src/management/pages/edit/modules/skinModule/CatalogPanel.vue
similarity index 91%
rename from web/src/management/pages/edit/modules/settingModule/skin/CatalogPanel.vue
rename to web/src/management/pages/edit/modules/skinModule/CatalogPanel.vue
index 7f663cd6..6d6c7275 100644
--- a/web/src/management/pages/edit/modules/settingModule/skin/CatalogPanel.vue
+++ b/web/src/management/pages/edit/modules/skinModule/CatalogPanel.vue
@@ -27,13 +27,14 @@
diff --git a/web/src/management/pages/edit/pages/edit/index.vue b/web/src/management/pages/edit/pages/edit/index.vue
index 3565a758..d0b0cb7c 100644
--- a/web/src/management/pages/edit/pages/edit/index.vue
+++ b/web/src/management/pages/edit/pages/edit/index.vue
@@ -37,7 +37,9 @@ const activeRouter = ref(route.name)
watch(
activeRouter,
(val: any) => {
- router.push({ name: val })
+ // 避免编辑页刷新丢失query
+ const query = route.query
+ router.push({ name: val, query })
},
{
immediate: true
@@ -55,6 +57,8 @@ watch(
.navbar-tab {
position: absolute;
top: 10px;
+ left: 50%;
+ transform: translate(-50%);
cursor: pointer;
:deep(.el-radio-button__original-radio + .el-radio-button__inner) {
font-size: 12px;
diff --git a/web/src/management/pages/edit/pages/skin/ContentPage.vue b/web/src/management/pages/edit/pages/skin/ContentPage.vue
index 5960d677..50bfe5f0 100644
--- a/web/src/management/pages/edit/pages/skin/ContentPage.vue
+++ b/web/src/management/pages/edit/pages/skin/ContentPage.vue
@@ -13,17 +13,17 @@
diff --git a/web/src/management/pages/list/components/SpaceList.vue b/web/src/management/pages/list/components/SpaceList.vue
index a9237e96..b2128f01 100644
--- a/web/src/management/pages/list/components/SpaceList.vue
+++ b/web/src/management/pages/list/components/SpaceList.vue
@@ -1,14 +1,19 @@
-
+
+
+
+
@@ -30,7 +35,6 @@
-
-
+
+
+
+
diff --git a/web/src/management/pages/list/components/SpaceModify.vue b/web/src/management/pages/list/components/SpaceModify.vue
index 668fd038..5e6dac82 100644
--- a/web/src/management/pages/list/components/SpaceModify.vue
+++ b/web/src/management/pages/list/components/SpaceModify.vue
@@ -44,15 +44,17 @@
diff --git a/web/src/management/pages/list/components/TextSearch.vue b/web/src/management/pages/list/components/TextSearch.vue
index 10a39692..5c3ace96 100644
--- a/web/src/management/pages/list/components/TextSearch.vue
+++ b/web/src/management/pages/list/components/TextSearch.vue
@@ -7,7 +7,7 @@
:placeholder="placeholder"
>
-
+
diff --git a/web/src/management/pages/list/index.vue b/web/src/management/pages/list/index.vue
index 248b4bed..e9f0f23e 100644
--- a/web/src/management/pages/list/index.vue
+++ b/web/src/management/pages/list/index.vue
@@ -18,10 +18,12 @@
-
{{ spaceType === SpaceType.Group ? '团队空间' : '问卷' }}列表
+
+ {{ spaceType === SpaceType.Group ? '团队空间' : currentTeamSpace?.name || '问卷列表' }}
+
创建团队空间
+
+
+ 团队管理
+
-
+
import { ref, computed, onMounted } from 'vue'
-import { useStore } from 'vuex'
+import { storeToRefs } from 'pinia'
import { useRouter } from 'vue-router'
import BaseList from './components/BaseList.vue'
import SpaceList from './components/SpaceList.vue'
import SliderBar from './components/SliderBar.vue'
import SpaceModify from './components/SpaceModify.vue'
import { SpaceType } from '@/management/utils/types/workSpace'
+import { useUserStore } from '@/management/stores/user'
+import { useWorkSpaceStore } from '@/management/stores/workSpace'
+import { useSurveyListStore } from '@/management/stores/surveyList'
-const store = useStore()
+const userStore = useUserStore()
+const workSpaceStore = useWorkSpaceStore()
+const surveyListStore = useSurveyListStore()
+
+const { surveyList, surveyTotal } = storeToRefs(surveyListStore)
+const { spaceMenus, workSpaceId, spaceType, workSpaceList, workSpaceListTotal } =
+ storeToRefs(workSpaceStore)
const router = useRouter()
const userInfo = computed(() => {
- return store.state.user.userInfo
+ return userStore.userInfo
})
+
const loading = ref(false)
-const surveyList = computed(() => {
- return store.state.list.surveyList
-})
-const surveyTotal = computed(() => {
- return store.state.list.surveyTotal
-})
+
+const spaceListRef = ref(null)
+const spaceLoading = ref(false)
+
const activeIndex = ref('1')
-const spaceMenus = computed(() => {
- return store.state.list.spaceMenus
-})
-const workSpaceId = computed(() => {
- return store.state.list.workSpaceId
-})
-const spaceType = computed(() => {
- return store.state.list.spaceType
-})
-const handleSpaceSelect = (id: any) => {
- if (id === SpaceType.Personal) {
- // 点击个人空间菜单
- if (store.state.list.spaceType === SpaceType.Personal) {
- return
- }
- store.commit('list/changeSpaceType', SpaceType.Personal)
- store.commit('list/changeWorkSpace', '')
- } else if (id === SpaceType.Group) {
- // 点击团队空间组菜单
- if (store.state.list.spaceType === SpaceType.Group) {
- return
- }
- store.commit('list/changeSpaceType', SpaceType.Group)
- store.commit('list/changeWorkSpace', '')
- } else if (!Object.values(SpaceType).includes(id)) {
- // 点击具体团队空间
- if (store.state.list.workSpaceId === id) {
- return
- }
- store.commit('list/changeSpaceType', SpaceType.Teamwork)
- store.commit('list/changeWorkSpace', id)
+const fetchSpaceList = async (params?: any) => {
+ spaceLoading.value = true
+ workSpaceStore.changeWorkSpace('')
+ workSpaceStore.getSpaceList(params)
+ spaceLoading.value = false
+}
+
+const handleSpaceSelect = (id: SpaceType | string) => {
+ if (id === spaceType.value || id === workSpaceId.value) {
+ return void 0
}
+ switch (id) {
+ case SpaceType.Personal:
+ workSpaceStore.changeSpaceType(SpaceType.Personal)
+ workSpaceStore.changeWorkSpace('')
+ break
+ case SpaceType.Group:
+ workSpaceStore.changeSpaceType(SpaceType.Group)
+ workSpaceStore.changeWorkSpace('')
+ fetchSpaceList()
+ break
+ default:
+ workSpaceStore.changeSpaceType(SpaceType.Teamwork)
+ workSpaceStore.changeWorkSpace(id)
+ break
+ }
fetchSurveyList()
}
-onMounted(() => {
- fetchSpaceList()
- fetchSurveyList()
-})
-const fetchSpaceList = () => {
- store.dispatch('list/getSpaceList')
-}
+
const fetchSurveyList = async (params?: any) => {
if (!params) {
params = {
@@ -136,15 +145,35 @@ const fetchSurveyList = async (params?: any) => {
params.workspaceId = workSpaceId.value
}
loading.value = true
- await store.dispatch('list/getSurveyList', params)
+ await surveyListStore.getSurveyList(params)
loading.value = false
}
+
+onMounted(() => {
+ fetchSpaceList()
+ fetchSurveyList()
+})
+
const modifyType = ref('add')
const showSpaceModify = ref(false)
+// 当前团队信息
+const currentTeamSpace = computed(() => {
+ return workSpaceList.value.find((item: any) => item._id === workSpaceId.value)
+})
+
+const onSetGroup = async () => {
+ await workSpaceStore.getSpaceDetail(workSpaceId.value)
+ modifyType.value = 'edit'
+ showSpaceModify.value = true
+}
+
const onCloseModify = (type: string) => {
showSpaceModify.value = false
- if (type === 'update') fetchSpaceList()
+ if (type === 'update' && spaceListRef.value) {
+ fetchSpaceList()
+ spaceListRef.value.onCloseModify()
+ }
}
const onSpaceCreate = () => {
showSpaceModify.value = true
@@ -153,7 +182,7 @@ const onCreate = () => {
router.push('/create')
}
const handleLogout = () => {
- store.dispatch('user/logout')
+ userStore.logout()
router.replace({ name: 'login' })
}
// 下载页面
@@ -242,10 +271,9 @@ const handleDownload = () => {
.create-btn {
background: #4a4c5b;
+ color: #fff;
}
- .space-btn {
- background: $primary-color;
- }
+
.btn {
width: 132px;
height: 32px;
@@ -253,10 +281,9 @@ const handleDownload = () => {
justify-content: center;
align-items: center;
- color: #fff;
-
+ .icon-shujuliebiao,
.icon-chuangjian {
- padding-right: 8px;
+ padding-right: 5px;
font-size: 14px;
}
diff --git a/web/src/management/pages/login/LoginPage.vue b/web/src/management/pages/login/LoginPage.vue
index d502cf84..6564c9bf 100644
--- a/web/src/management/pages/login/LoginPage.vue
+++ b/web/src/management/pages/login/LoginPage.vue
@@ -57,7 +57,6 @@
-
diff --git a/web/src/materials/questions/widgets/EditOptions/Options/OptionEdit.vue b/web/src/materials/questions/widgets/EditOptions/Options/OptionEdit.vue
index 8025a528..0fa44cf9 100644
--- a/web/src/materials/questions/widgets/EditOptions/Options/OptionEdit.vue
+++ b/web/src/materials/questions/widgets/EditOptions/Options/OptionEdit.vue
@@ -12,6 +12,7 @@
-
+
diff --git a/web/src/render/store/getters.js b/web/src/render/store/getters.js
deleted file mode 100644
index 79d8a23f..00000000
--- a/web/src/render/store/getters.js
+++ /dev/null
@@ -1,30 +0,0 @@
-export default {
- // 题目列表
- renderData: (state) => {
- const { questionSeq, questionData } = state
-
- let index = 1
- return (
- questionSeq &&
- questionSeq.reduce((pre, item) => {
- const questionArr = []
-
- item.forEach((questionKey) => {
- const question = { ...questionData[questionKey] }
- // 开启显示序号
- if (question.showIndex) {
- question.indexNumber = index++
- }
-
- questionArr.push(question)
- })
-
- if (questionArr && questionArr.length) {
- pre.push(questionArr)
- }
-
- return pre
- }, [])
- )
- }
-}
diff --git a/web/src/render/store/index.js b/web/src/render/store/index.js
deleted file mode 100644
index 4013b40c..00000000
--- a/web/src/render/store/index.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import { createStore } from 'vuex'
-
-import state from './state'
-import getters from './getters'
-import mutations from './mutations'
-import actions from './actions'
-
-export default createStore({
- state,
- getters,
- mutations,
- actions
-})
diff --git a/web/src/render/stores/errorInfo.js b/web/src/render/stores/errorInfo.js
new file mode 100644
index 00000000..b0b6e7a0
--- /dev/null
+++ b/web/src/render/stores/errorInfo.js
@@ -0,0 +1,22 @@
+import { ref } from 'vue'
+import { defineStore } from 'pinia'
+
+export const useErrorInfo = defineStore('errorInfo', () => {
+ const errorInfo = ref({
+ errorType: '',
+ errorMsg: ''
+ })
+
+ const setErrorInfo = ({ errorType, errorMsg }) => {
+ errorInfo.value = {
+ errorType,
+ errorMsg
+ }
+ }
+
+ return {
+ errorInfo,
+
+ setErrorInfo
+ }
+})
diff --git a/web/src/render/stores/question.js b/web/src/render/stores/question.js
new file mode 100644
index 00000000..0f810353
--- /dev/null
+++ b/web/src/render/stores/question.js
@@ -0,0 +1,224 @@
+import { ref, computed } from 'vue'
+import { defineStore } from 'pinia'
+import { set } from 'lodash-es'
+import { useSurveyStore } from '@/render/stores/survey'
+import { queryVote } from '@/render/api/survey'
+
+const VOTE_INFO_KEY = 'voteinfo'
+
+export const useQuestionStore = defineStore('question', () => {
+ const voteMap = ref({})
+ const questionData = ref(null)
+ const questionSeq = ref([]) // 题目的顺序,因为可能会有分页的情况,所以是一个二维数组[[qid1, qid2], [qid3,qid4]]
+ const pageIndex = ref(1) // 当前分页的索引
+ const changeField = ref(null)
+ const changeIndex = computed(() => {
+ return questionData.value[changeField.value].index
+ })
+ const needHideFields = ref([])
+
+ // 题目列表
+ const questionList = computed(() => {
+ let index = 1
+ return (
+ questionSeq.value &&
+ questionSeq.value.reduce((pre, item) => {
+ const questionArr = []
+
+ item.forEach((questionKey) => {
+ const question = { ...questionData.value[questionKey] }
+ // 开启显示序号
+ if (question.showIndex) {
+ question.indexNumber = index++
+ }
+
+ questionArr.push(question)
+ })
+
+ if (questionArr && questionArr.length) {
+ pre.push(questionArr)
+ }
+
+ return pre
+ }, [])
+ )
+ })
+
+ const renderData = computed(() => {
+ const { startIndex, endIndex } = getSorter()
+ const data = questionList.value[0]
+ if (!data || !Array.isArray(data) || data.length === 0) return []
+ return [data.slice(startIndex, endIndex)]
+ })
+
+ const isFinallyPage = computed(() => {
+ const surveyStore = useSurveyStore()
+ return pageIndex.value === surveyStore.pageConf.length
+ })
+
+ const addPageIndex = () => {
+ pageIndex.value++
+ }
+
+ const getSorter = () => {
+ let startIndex = 0
+ const surveyStore = useSurveyStore()
+ const newPageEditOne = pageIndex.value
+ const endIndex = surveyStore.pageConf[newPageEditOne - 1]
+
+ for (let index = 0; index < surveyStore.pageConf.length; index++) {
+ const item = surveyStore.pageConf[index]
+ if (newPageEditOne - 1 == index) {
+ break
+ }
+ startIndex += item
+ }
+ return {
+ startIndex,
+ endIndex: startIndex + endIndex
+ }
+ }
+
+ const setQuestionData = (data) => {
+ questionData.value = data
+ }
+
+ const changeSelectMoreData = (data) => {
+ const { key, value, field } = data
+ set(questionData.value, `${field}.othersValue.${key}`, value)
+ }
+
+ const setQuestionSeq = (data) => {
+ questionSeq.value = data
+ }
+
+ const setVoteMap = (data) => {
+ voteMap.value = data
+ }
+
+ const updateVoteMapByKey = (data) => {
+ const { questionKey, voteKey, voteValue } = data
+ // 兼容为空的情况
+ if (!voteMap.value[questionKey]) {
+ voteMap.value[questionKey] = {}
+ }
+ voteMap.value[questionKey][voteKey] = voteValue
+ }
+
+ //初始化投票题的数据
+ const initVoteData = async () => {
+ const surveyStore = useSurveyStore()
+ const surveyPath = surveyStore.surveyPath
+
+ const fieldList = []
+
+ for (const field in questionData.value) {
+ const { type } = questionData.value[field]
+ if (/vote/.test(type)) {
+ fieldList.push(field)
+ }
+ }
+
+ if (fieldList.length <= 0) {
+ return
+ }
+ try {
+ localStorage.removeItem(VOTE_INFO_KEY)
+ const voteRes = await queryVote({
+ surveyPath,
+ fieldList: fieldList.join(',')
+ })
+
+ if (voteRes.code === 200) {
+ localStorage.setItem(
+ VOTE_INFO_KEY,
+ JSON.stringify({
+ ...voteRes.data
+ })
+ )
+ setVoteMap(voteRes.data)
+ }
+ } catch (error) {
+ console.log(error)
+ }
+ }
+
+ const updateVoteData = (data) => {
+ const { key: questionKey, value: questionVal } = data
+ // 更新前获取接口缓存在localStorage中的数据
+ const localData = localStorage.getItem(VOTE_INFO_KEY)
+ const voteinfo = JSON.parse(localData)
+ const currentQuestion = questionData.value[questionKey]
+ const options = currentQuestion.options
+ const voteTotal = voteinfo?.[questionKey]?.total || 0
+ let totalPayload = {
+ questionKey,
+ voteKey: 'total',
+ voteValue: voteTotal
+ }
+ options.forEach((option) => {
+ const optionhash = option.hash
+ const voteCount = voteinfo?.[questionKey]?.[optionhash] || 0
+ // 如果选中值包含该选项,对应voteCount 和 voteTotal + 1
+ if (
+ Array.isArray(questionVal) ? questionVal.includes(optionhash) : questionVal === optionhash
+ ) {
+ const countPayload = {
+ questionKey,
+ voteKey: optionhash,
+ voteValue: voteCount + 1
+ }
+ totalPayload.voteValue += 1
+ updateVoteMapByKey(countPayload)
+ } else {
+ const countPayload = {
+ questionKey,
+ voteKey: optionhash,
+ voteValue: voteCount
+ }
+ updateVoteMapByKey(countPayload)
+ }
+ updateVoteMapByKey(totalPayload)
+ })
+ }
+
+ const setChangeField = (field) => {
+ changeField.value = field
+ }
+ const getQuestionIndexByField = (field) => {
+ return questionData.value[field].index
+ }
+ const addNeedHideFields = (fields) => {
+ fields.forEach(field => {
+ if(!needHideFields.value.includes(field)) {
+ needHideFields.value.push(field)
+ }
+ })
+ }
+ const removeNeedHideFields = (fields) => {
+ needHideFields.value = needHideFields.value.filter(field => !fields.includes(field))
+ }
+ return {
+ voteMap,
+ questionData,
+ questionSeq,
+ renderData,
+ isFinallyPage,
+ pageIndex,
+ addPageIndex,
+ setQuestionData,
+ changeSelectMoreData,
+ setQuestionSeq,
+ setVoteMap,
+ updateVoteMapByKey,
+ initVoteData,
+ updateVoteData,
+ changeField,
+ changeIndex,
+ setChangeField,
+ needHideFields,
+ addNeedHideFields,
+ removeNeedHideFields,
+ getQuestionIndexByField
+ }
+})
diff --git a/web/src/render/stores/survey.js b/web/src/render/stores/survey.js
new file mode 100644
index 00000000..9a188d3a
--- /dev/null
+++ b/web/src/render/stores/survey.js
@@ -0,0 +1,202 @@
+import { ref } from 'vue'
+import { useRouter } from 'vue-router'
+import { defineStore } from 'pinia'
+import { pick } from 'lodash-es'
+
+import { isMobile as isInMobile } from '@/render/utils/index'
+import { getEncryptInfo as getEncryptInfoApi } from '@/render/api/survey'
+import { useQuestionStore } from '@/render/stores/question'
+import { useErrorInfo } from '@/render/stores/errorInfo'
+
+import moment from 'moment'
+// 引入中文
+import 'moment/locale/zh-cn'
+// 设置中文
+moment.locale('zh-cn')
+
+import adapter from '../adapter'
+import { RuleMatch } from '@/common/logicEngine/RulesMatch'
+// import { jumpLogicRule } from '@/common/logicEngine/jumpLogicRule'
+
+/**
+ * CODE_MAP不从management引入,在dev阶段,会导致B端 router被加载,进而导致C端路由被添加 baseUrl: /management
+ */
+const CODE_MAP = {
+ SUCCESS: 200,
+ ERROR: 500,
+ NO_AUTH: 403
+}
+export const useSurveyStore = defineStore('survey', () => {
+ const surveyPath = ref('')
+ const isMobile = ref(isInMobile())
+ const enterTime = ref(0)
+ const encryptInfo = ref(null)
+ const rules = ref({})
+ const bannerConf = ref({})
+ const baseConf = ref({})
+ const bottomConf = ref({})
+ const dataConf = ref({})
+ const skinConf = ref({})
+ const submitConf = ref({})
+ const formValues = ref({})
+ const whiteData = ref({})
+ const pageConf = ref([])
+
+
+ const router = useRouter()
+ const questionStore = useQuestionStore()
+ const { setErrorInfo } = useErrorInfo()
+
+ const setWhiteData = (data) => {
+ whiteData.value = data
+ }
+
+ const setSurveyPath = (data) => {
+ surveyPath.value = data
+ }
+
+ const setEnterTime = () => {
+ enterTime.value = Date.now()
+ }
+
+ const getEncryptInfo = async () => {
+ try {
+ const res = await getEncryptInfoApi()
+ if (res.code === CODE_MAP.SUCCESS) {
+ encryptInfo.value = res.data
+ }
+ } catch (error) {
+ console.log(error)
+ }
+ }
+
+ const canFillQuestionnaire = (baseConf, submitConf) => {
+ const { begTime, endTime, answerBegTime, answerEndTime } = baseConf
+ const { msgContent } = submitConf
+ const now = Date.now()
+ let isSuccess = true
+
+ if (now < new Date(begTime).getTime()) {
+ isSuccess = false
+ setErrorInfo({
+ errorType: 'overTime',
+ errorMsg: `问卷未到开始填写时间,暂时无法进行填写
+ 开始时间为: ${begTime}
`
+ })
+ } else if (now > new Date(endTime).getTime()) {
+ isSuccess = false
+ setErrorInfo({
+ errorType: 'overTime',
+ errorMsg: msgContent.msg_9001 || '您来晚了,感谢支持问卷~'
+ })
+ } else if (answerBegTime && answerEndTime) {
+ const momentNow = moment()
+ const todayStr = momentNow.format('yyyy-MM-DD')
+ const momentStartTime = moment(`${todayStr} ${answerBegTime}`)
+ const momentEndTime = moment(`${todayStr} ${answerEndTime}`)
+ if (momentNow.isBefore(momentStartTime) || momentNow.isAfter(momentEndTime)) {
+ isSuccess = false
+ setErrorInfo({
+ errorType: 'overTime',
+ errorMsg: `不在答题时间范围内,暂时无法进行填写
+ 答题时间为: ${answerBegTime} ~ ${answerEndTime}
`
+ })
+ }
+ }
+
+ if (!isSuccess) {
+ router.push({ name: 'errorPage' })
+ }
+
+ return isSuccess
+ }
+ const initSurvey = (option) => {
+ setEnterTime()
+
+ if (!canFillQuestionnaire(option.baseConf, option.submitConf)) {
+ return
+ }
+
+
+
+ // 根据初始的schema生成questionData, questionSeq, rules, formValues, 这四个字段
+ const {
+ questionData,
+ questionSeq,
+ rules: _rules,
+ formValues: _formValues
+ } = adapter.generateData(
+ pick(option, [
+ 'bannerConf',
+ 'baseConf',
+ 'bottomConf',
+ 'dataConf',
+ 'skinConf',
+ 'submitConf',
+ 'whiteData',
+ 'pageConf'
+ ])
+ )
+ questionStore.questionData = questionData
+ questionStore.questionSeq = questionSeq
+
+ // 将数据设置到state上
+ rules.value = _rules
+ bannerConf.value = option.bannerConf
+ baseConf.value = option.baseConf
+ bottomConf.value = option.bottomConf
+ dataConf.value = option.dataConf
+ skinConf.value = option.skinConf
+ submitConf.value = option.submitConf
+ formValues.value = _formValues
+ whiteData.value = option.whiteData
+ pageConf.value = option.pageConf
+ // 获取已投票数据
+ questionStore.initVoteData()
+ }
+
+ // 用户输入或者选择后,更新表单数据
+ const changeData = (data) => {
+ let { key, value } = data
+ if (key in formValues.value) {
+ formValues.value[key] = value
+ }
+ questionStore.setChangeField(key)
+ }
+
+ const showLogicEngine = ref()
+ const initShowLogicEngine = (showLogicConf) => {
+ showLogicEngine.value = new RuleMatch().fromJson(showLogicConf)
+ }
+ const jumpLogicEngine = ref()
+ const initJumpLogicEngine = (jumpLogicConf) => {
+ jumpLogicEngine.value = new RuleMatch().fromJson(jumpLogicConf)
+ }
+
+ return {
+ surveyPath,
+ isMobile,
+ enterTime,
+ encryptInfo,
+ rules,
+ bannerConf,
+ baseConf,
+ bottomConf,
+ dataConf,
+ skinConf,
+ submitConf,
+ formValues,
+ whiteData,
+ pageConf,
+ initSurvey,
+ changeData,
+ setWhiteData,
+ setSurveyPath,
+ setEnterTime,
+ getEncryptInfo,
+ showLogicEngine,
+ initShowLogicEngine,
+ jumpLogicEngine,
+ initJumpLogicEngine
+ }
+})
diff --git a/web/src/render/styles/default.scss b/web/src/render/styles/default.scss
deleted file mode 100644
index eaebf2a6..00000000
--- a/web/src/render/styles/default.scss
+++ /dev/null
@@ -1,22 +0,0 @@
-$primary-color: #faa600;
-$primary-color-light: hsl(48, 100%, 97%);
-
-$title-color-deep: #292a36;
-$title-color: #4a4c5b;
-$font-color: #6e707c;
-$remark-color: #4a4c5b;
-$placeholder-color: #c8c9cd;
-$light-focus-color: #666666;
-
-$disable-color: #f2f4f7;
-$border-color: #dee2e6;
-
-$spliter-color: #f7f7f7;
-
-$error-color: #ec4e29;
-
-@import './variable';
-
-$title-size: 0.32rem;
-$font-size: 0.28rem;
-$tip-size: 0.22rem;
diff --git a/web/src/render/styles/variable.scss b/web/src/render/styles/variable.scss
index 2b0db56a..eeb4fb54 100644
--- a/web/src/render/styles/variable.scss
+++ b/web/src/render/styles/variable.scss
@@ -10,6 +10,6 @@ $placeholder-color: #c8c9cd;
$disable-color: #f2f4f7;
$border-color: #dee2e6;
-$spliter-color: #f7f7f7;
+$spliter-color: hsl(0, 0%, 97%, 0.5);
$error-color: #ec4e29;
diff --git a/web/src/render/utils/index.js b/web/src/render/utils/index.js
index 610e506f..7f9cf2b2 100644
--- a/web/src/render/utils/index.js
+++ b/web/src/render/utils/index.js
@@ -29,4 +29,4 @@ export const formatLink = (url) => {
return url
}
return `http://${url}`
-}
+}
\ No newline at end of file
diff --git a/web/vite.config.ts b/web/vite.config.ts
index f8527f21..1b551271 100644
--- a/web/vite.config.ts
+++ b/web/vite.config.ts
@@ -61,7 +61,13 @@ export default defineConfig({
'clipboard',
'qrcode',
'moment',
- 'moment/locale/zh-cn'
+ 'moment/locale/zh-cn',
+ 'echarts',
+ 'nanoid',
+ 'yup',
+ 'crypto-js/sha256',
+ 'element-plus/es/locale/lang/zh-cn',
+ 'node-forge'
]
},
plugins: [
@@ -114,6 +120,11 @@ export default defineConfig({
'/api': {
target: 'http://127.0.0.1:3000',
changeOrigin: true
+ },
+ // 静态文件的默认存储文件夹
+ '/userUpload': {
+ target: 'http://127.0.0.1:3000',
+ changeOrigin: true
}
}
},