diff --git a/server/src/config/index.ts b/server/src/config/index.ts
deleted file mode 100644
index 4ca78c6c..00000000
--- a/server/src/config/index.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-const mongo = {
- url: process.env.XIAOJU_SURVEY_MONGO_URL || 'mongodb://localhost:27017',
- dbName: process.env.XIAOJU_SURVER_MONGO_DBNAME || 'xiaojuSurvey',
-};
-
-const session = {
- expireTime: parseInt(process.env.XIAOJU_SURVEY_JWT_EXPIRES_IN) || 8 * 3600 * 1000
-};
-
-const encrypt = {
- type: process.env.XIAOJU_SURVEY_ENCRYPT_TYPE || 'aes',
- aesCodelength: parseInt(process.env.XIAOJU_SURVEY_ENCRYPT_TYPE_LEN) || 10 //aes密钥长度
-};
-
-const jwt = {
- secret: process.env.XIAOJU_SURVEY_JWT_SECRET || 'xiaojuSurveyJwtSecret',
- expiresIn: process.env.XIAOJU_SURVEY_JWT_EXPIRES_IN || '8h'
-};
-
-
-export{
- mongo,
- session,
- encrypt,
- jwt,
-};
diff --git a/server/src/modules/workspace/controllers/workspace.controller.ts b/server/src/modules/workspace/controllers/workspace.controller.ts
index 93928cd8..b1985490 100644
--- a/server/src/modules/workspace/controllers/workspace.controller.ts
+++ b/server/src/modules/workspace/controllers/workspace.controller.ts
@@ -174,6 +174,7 @@ export class WorkspaceController {
pre[id] = cur;
return pre;
}, {});
+
const surveyTotalList = await Promise.all(
workspaceIdList.map((item) => {
return this.surveyMetaService.countSurveyMetaByWorkspaceId({
diff --git a/web/.gitignore b/web/.gitignore
index e0a576ec..94556503 100644
--- a/web/.gitignore
+++ b/web/.gitignore
@@ -26,4 +26,4 @@ yarn.lock
*.sln
*.sw?
-.history
+.history
\ No newline at end of file
diff --git a/web/components.d.ts b/web/components.d.ts
index fa277a42..02b54173 100644
--- a/web/components.d.ts
+++ b/web/components.d.ts
@@ -7,68 +7,68 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
- ElButton: (typeof import('element-plus/es'))['ElButton']
- ElCheckbox: (typeof import('element-plus/es'))['ElCheckbox']
- ElCollapse: (typeof import('element-plus/es'))['ElCollapse']
- ElCollapseItem: (typeof import('element-plus/es'))['ElCollapseItem']
- ElColorPicker: (typeof import('element-plus/es'))['ElColorPicker']
- ElConfigProvider: (typeof import('element-plus/es'))['ElConfigProvider']
- ElDatePicker: (typeof import('element-plus/es'))['ElDatePicker']
- ElDialog: (typeof import('element-plus/es'))['ElDialog']
- ElForm: (typeof import('element-plus/es'))['ElForm']
- ElFormItem: (typeof import('element-plus/es'))['ElFormItem']
- ElInput: (typeof import('element-plus/es'))['ElInput']
- ElInputNumber: (typeof import('element-plus/es'))['ElInputNumber']
- ElMenu: (typeof import('element-plus/es'))['ElMenu']
- ElMenuItem: (typeof import('element-plus/es'))['ElMenuItem']
- ElMenuItemGroup: (typeof import('element-plus/es'))['ElMenuItemGroup']
- ElOption: (typeof import('element-plus/es'))['ElOption']
- ElPagination: (typeof import('element-plus/es'))['ElPagination']
- ElPopover: (typeof import('element-plus/es'))['ElPopover']
- ElRadio: (typeof import('element-plus/es'))['ElRadio']
- ElRadioButton: (typeof import('element-plus/es'))['ElRadioButton']
- ElRadioGroup: (typeof import('element-plus/es'))['ElRadioGroup']
- ElRow: (typeof import('element-plus/es'))['ElRow']
- ElSegmented: (typeof import('element-plus/es'))['ElSegmented']
- ElSelect: (typeof import('element-plus/es'))['ElSelect']
- ElSelectV2: (typeof import('element-plus/es'))['ElSelectV2']
- ElSlider: (typeof import('element-plus/es'))['ElSlider']
- ElSwitch: (typeof import('element-plus/es'))['ElSwitch']
- ElTable: (typeof import('element-plus/es'))['ElTable']
- ElTableColumn: (typeof import('element-plus/es'))['ElTableColumn']
- ElTabPane: (typeof import('element-plus/es'))['ElTabPane']
- ElTabs: (typeof import('element-plus/es'))['ElTabs']
- ElTag: (typeof import('element-plus/es'))['ElTag']
- ElTimePicker: (typeof import('element-plus/es'))['ElTimePicker']
- ElTooltip: (typeof import('element-plus/es'))['ElTooltip']
- ElTree: (typeof import('element-plus/es'))['ElTree']
- IEpBottom: (typeof import('~icons/ep/bottom'))['default']
- IEpCheck: (typeof import('~icons/ep/check'))['default']
- IEpCirclePlus: (typeof import('~icons/ep/circle-plus'))['default']
- IEpClose: (typeof import('~icons/ep/close'))['default']
- IEpConnection: (typeof import('~icons/ep/connection'))['default']
- IEpCopyDocument: (typeof import('~icons/ep/copy-document'))['default']
- IEpDelete: (typeof import('~icons/ep/delete'))['default']
- IEpIphone: (typeof import('~icons/ep/iphone'))['default']
- IEpLoading: (typeof import('~icons/ep/loading'))['default']
- IEpMinus: (typeof import('~icons/ep/minus'))['default']
- IEpMonitor: (typeof import('~icons/ep/monitor'))['default']
- IEpMore: (typeof import('~icons/ep/more'))['default']
- IEpPlus: (typeof import('~icons/ep/plus'))['default']
- IEpQuestionFilled: (typeof import('~icons/ep/question-filled'))['default']
- IEpRank: (typeof import('~icons/ep/rank'))['default']
- IEpRemove: (typeof import('~icons/ep/remove'))['default']
- IEpSearch: (typeof import('~icons/ep/search'))['default']
- IEpSort: (typeof import('~icons/ep/sort'))['default']
- IEpSortDown: (typeof import('~icons/ep/sort-down'))['default']
- IEpSortUp: (typeof import('~icons/ep/sort-up'))['default']
- IEpTop: (typeof import('~icons/ep/top'))['default']
- IEpView: (typeof import('~icons/ep/view'))['default']
- IEpWarningFilled: (typeof import('~icons/ep/warning-filled'))['default']
- RouterLink: (typeof import('vue-router'))['RouterLink']
- RouterView: (typeof import('vue-router'))['RouterView']
+ ElButton: typeof import('element-plus/es')['ElButton']
+ ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
+ ElCollapse: typeof import('element-plus/es')['ElCollapse']
+ ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
+ ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
+ ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
+ ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
+ ElDialog: typeof import('element-plus/es')['ElDialog']
+ ElForm: typeof import('element-plus/es')['ElForm']
+ ElFormItem: typeof import('element-plus/es')['ElFormItem']
+ ElInput: typeof import('element-plus/es')['ElInput']
+ ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
+ ElMenu: typeof import('element-plus/es')['ElMenu']
+ ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
+ ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
+ ElOption: typeof import('element-plus/es')['ElOption']
+ ElPagination: typeof import('element-plus/es')['ElPagination']
+ ElPopover: typeof import('element-plus/es')['ElPopover']
+ ElRadio: typeof import('element-plus/es')['ElRadio']
+ ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
+ ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
+ ElRow: typeof import('element-plus/es')['ElRow']
+ ElSegmented: typeof import('element-plus/es')['ElSegmented']
+ ElSelect: typeof import('element-plus/es')['ElSelect']
+ ElSelectV2: typeof import('element-plus/es')['ElSelectV2']
+ ElSlider: typeof import('element-plus/es')['ElSlider']
+ ElSwitch: typeof import('element-plus/es')['ElSwitch']
+ ElTable: typeof import('element-plus/es')['ElTable']
+ ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
+ ElTabPane: typeof import('element-plus/es')['ElTabPane']
+ ElTabs: typeof import('element-plus/es')['ElTabs']
+ ElTag: typeof import('element-plus/es')['ElTag']
+ ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
+ ElTooltip: typeof import('element-plus/es')['ElTooltip']
+ ElTree: typeof import('element-plus/es')['ElTree']
+ IEpBottom: typeof import('~icons/ep/bottom')['default']
+ IEpCheck: typeof import('~icons/ep/check')['default']
+ IEpCirclePlus: typeof import('~icons/ep/circle-plus')['default']
+ IEpClose: typeof import('~icons/ep/close')['default']
+ IEpConnection: typeof import('~icons/ep/connection')['default']
+ IEpCopyDocument: typeof import('~icons/ep/copy-document')['default']
+ IEpDelete: typeof import('~icons/ep/delete')['default']
+ IEpIphone: typeof import('~icons/ep/iphone')['default']
+ IEpLoading: typeof import('~icons/ep/loading')['default']
+ IEpMinus: typeof import('~icons/ep/minus')['default']
+ IEpMonitor: typeof import('~icons/ep/monitor')['default']
+ IEpMore: typeof import('~icons/ep/more')['default']
+ IEpPlus: typeof import('~icons/ep/plus')['default']
+ IEpQuestionFilled: typeof import('~icons/ep/question-filled')['default']
+ IEpRank: typeof import('~icons/ep/rank')['default']
+ IEpRemove: typeof import('~icons/ep/remove')['default']
+ IEpSearch: typeof import('~icons/ep/search')['default']
+ IEpSort: typeof import('~icons/ep/sort')['default']
+ IEpSortDown: typeof import('~icons/ep/sort-down')['default']
+ IEpSortUp: typeof import('~icons/ep/sort-up')['default']
+ IEpTop: typeof import('~icons/ep/top')['default']
+ IEpView: typeof import('~icons/ep/view')['default']
+ IEpWarningFilled: typeof import('~icons/ep/warning-filled')['default']
+ RouterLink: typeof import('vue-router')['RouterLink']
+ RouterView: typeof import('vue-router')['RouterView']
}
export interface ComponentCustomProperties {
- vLoading: (typeof import('element-plus/es'))['ElLoadingDirective']
+ vLoading: typeof import('element-plus/es')['ElLoadingDirective']
}
}
diff --git a/web/env.d.ts b/web/env.d.ts
index 9706856f..11f02fe2 100644
--- a/web/env.d.ts
+++ b/web/env.d.ts
@@ -1,8 +1 @@
///
为了给您提供更好的服务,希望您能抽出几分钟时间,将您的感受和建议告诉我们,期待您的参与!
`, - applyTitle: '' - }, - bannerConfig: { - bgImage: '', - bgImageAllowJump: false, - bgImageJumpLink: '', - videoLink: '', - postImg: '' - } - }, - bottomConf: { - logoImage: '', - logoImageWidth: '28%' - }, - skinConf: { - backgroundConf: { - color: '#fff' - }, - themeConf: { - color: '#ffa600' - }, - contentConf: { - opacity: 100 - } - }, - baseConf: { - begTime: '', - endTime: '', - language: 'chinese', - showVoteProcess: 'allow', - tLimit: 0, - answerBegTime: '', - answerEndTime: '', - answerLimitTime: 0 - }, - submitConf: { - submitTitle: '', - msgContent: {}, - confirmAgain: { - is_again: true - }, - link: '' - }, - questionDataList: [], - logicConf: { - showLogicConf: [] - } - } -} diff --git a/web/src/management/store/index.js b/web/src/management/store/index.js deleted file mode 100644 index c0ca999b..00000000 --- a/web/src/management/store/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import { createStore } from 'vuex' -import edit from './edit' -import user from './user' -import list from './list' -import actions from './actions' -import mutations from './mutations' -import state from './state' - -export default createStore({ - state, - getters: {}, - mutations, - actions, - modules: { - edit, - user, - list - } -}) diff --git a/web/src/management/store/list/index.js b/web/src/management/store/list/index.js deleted file mode 100644 index d40fc5b3..00000000 --- a/web/src/management/store/list/index.js +++ /dev/null @@ -1,263 +0,0 @@ -import { - createSpace, - getSpaceList, - getSpaceDetail, - updateSpace, - deleteSpace -} from '@/management/api/space' -import { CODE_MAP } from '@/management/api/base' -import { ElMessage } from 'element-plus' -import 'element-plus/theme-chalk/src/message.scss' -import { getSurveyList as surveyList } from '@/management/api/survey' -import { set } from 'lodash-es' -import { SpaceType } from '@/management/utils/types/workSpace' - -export default { - namespaced: true, - state: { - // 空间管理 - spaceMenus: [ - { - icon: 'icon-wodekongjian', - name: '我的空间', - id: SpaceType.Personal - }, - { - icon: 'icon-tuanduikongjian', - name: '团队空间', - id: SpaceType.Group, - children: [ - // { - // name: '小桔问卷调研团队', - // id: 'xxxx', - // } - ] - } - ], - spaceType: SpaceType.Personal, - workSpaceId: '', - spaceDetail: null, - // 团队空间 - teamSpaceList: [], - teamSpaceListTotal: 0, - // 列表管理 - surveyList: [], - surveyTotal: 0, - searchVal: '', - selectValueMap: { - surveyType: '', - 'curStatus.status': '' - }, - buttonValueMap: { - 'curStatus.date': '', - createDate: -1 - } - }, - getters: { - listFliter(state) { - return [ - { - comparator: '', - condition: [ - { - field: 'title', - value: state.searchVal, - comparator: '$regex' - } - ] - }, - { - comparator: '', - condition: [ - { - field: 'curStatus.status', - value: state.selectValueMap['curStatus.status'] - } - ] - }, - { - comparator: '', - condition: [ - { - field: 'surveyType', - value: state.selectValueMap.surveyType - } - ] - } - ] - }, - listOrder(state) { - const { buttonValueMap } = state - return Object.entries(buttonValueMap) - .filter(([, effectValue]) => effectValue) - .reduce((prev, item) => { - const [effectKey, effectValue] = item - prev.push({ field: effectKey, value: effectValue }) - return prev - }, []) - } - }, - mutations: { - updateSpaceMenus(state, teamSpace) { - // 更新空间列表下的团队空间 - set(state, 'spaceMenus[1].children', teamSpace) - }, - changeSpaceType(state, spaceType) { - state.spaceType = spaceType - }, - changeWorkSpace(state, workSpaceId) { - // 切换空间清除筛选条件 - this.commit('list/resetSelectValueMap') - this.commit('list/resetButtonValueMap') - this.commit('list/setSearchVal', '') - state.workSpaceId = workSpaceId - }, - setSpaceDetail(state, data) { - state.spaceDetail = data - }, - setTeamSpaceList(state, data) { - state.teamSpaceList = data - }, - setTeamSpaceListTotal(state, teamSpaceListTotal) { - state.teamSpaceListTotal = teamSpaceListTotal - }, - setSurveyList(state, list) { - state.surveyList = list - }, - setSurveyTotal(state, total) { - state.surveyTotal = total - }, - setSearchVal(state, data) { - state.searchVal = data - }, - resetSelectValueMap(state) { - state.selectValueMap = { - surveyType: '', - 'curStatus.status': '' - } - }, - changeSelectValueMap(state, { key, value }) { - state.selectValueMap[key] = value - }, - resetButtonValueMap(state) { - state.buttonValueMap = { - 'curStatus.date': '', - createDate: -1 - } - }, - changeButtonValueMap(state, { key, value }) { - state.buttonValueMap[key] = value - } - }, - actions: { - async getSpaceList({ commit }, p = { curPage: 1 }) { - try { - const res = await getSpaceList(p) - if (res.code === CODE_MAP.SUCCESS) { - const { list, count } = res.data - const teamSpace = list.map((item) => { - return { - id: item._id, - name: item.name - } - }) - commit('setTeamSpaceListTotal', count) - commit('setTeamSpaceList', list) - commit('updateSpaceMenus', teamSpace) - } else { - ElMessage.error('getSpaceList' + res.errmsg) - } - } catch (err) { - ElMessage.error('getSpaceList' + err) - } - }, - async addSpace({}, params) { - const res = await createSpace({ - name: params.name, - description: params.description, - members: params.members - }) - - if (res.code === CODE_MAP.SUCCESS) { - ElMessage.success('添加成功') - } else { - ElMessage.error('createSpace code err' + res.errmsg) - } - }, - async getSpaceDetail({ state, commit }, id) { - try { - const workspaceId = id || state.workSpaceId - const res = await getSpaceDetail(workspaceId) - if (res.code === CODE_MAP.SUCCESS) { - commit('setSpaceDetail', res.data) - } else { - ElMessage.error('getSpaceList' + res.errmsg) - } - } catch (err) { - ElMessage.error('getSpaceList' + err) - } - }, - async updateSpace({}, params) { - const res = await updateSpace({ - workspaceId: params._id, - name: params.name, - description: params.description, - members: params.members - }) - - if (res.code === CODE_MAP.SUCCESS) { - ElMessage.success('更新成功') - } else { - ElMessage.error(res.errmsg) - } - }, - async deleteSpace({}, workspaceId) { - try { - const res = await deleteSpace(workspaceId) - - if (res.code === CODE_MAP.SUCCESS) { - ElMessage.success('删除成功') - } else { - ElMessage.error(res.errmsg) - } - } catch (err) { - ElMessage.error(err) - } - }, - async getSurveyList({ state, getters, commit }, payload) { - const filterString = JSON.stringify( - getters.listFliter.filter((item) => { - return item.condition[0].value - }) - ) - const orderString = JSON.stringify(getters.listOrder) - try { - let params = { - curPage: payload?.curPage || 1, - pageSize: payload?.pageSize || 10, // 默认一页10条 - filter: filterString, - order: orderString, - workspaceId: state.workSpaceId - } - // if(payload?.order) { - // params.order = payload.order - // } - // if(payload.filter) { - // params.filter = payload.filter - // } - // if(payload?.workspaceId) { - // params.workspaceId = payload.workspaceId - // } - const res = await surveyList(params) - if (res.code === CODE_MAP.SUCCESS) { - commit('setSurveyList', res.data.data) - commit('setSurveyTotal', res.data.count) - } else { - ElMessage.error(res.errmsg) - } - } catch (error) { - ElMessage.error('getSurveyList status' + error) - } - } - } -} diff --git a/web/src/management/store/mutations.js b/web/src/management/store/mutations.js deleted file mode 100644 index 0bf45451..00000000 --- a/web/src/management/store/mutations.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - setBannerList(state, data) { - state.bannerList = data - }, - setCooperPermissions(state, data) { - state.cooperPermissions = data - } -} diff --git a/web/src/management/store/state.js b/web/src/management/store/state.js deleted file mode 100644 index 8ef14c4d..00000000 --- a/web/src/management/store/state.js +++ /dev/null @@ -1,5 +0,0 @@ -import { SurveyPermissions } from '@/management/utils/types/workSpace' -export default { - bannerList: [], - cooperPermissions: Object.values(SurveyPermissions) -} diff --git a/web/src/management/store/user/index.js b/web/src/management/store/user/index.js deleted file mode 100644 index 14a991eb..00000000 --- a/web/src/management/store/user/index.js +++ /dev/null @@ -1,64 +0,0 @@ -const USER_INFO_KEY = 'surveyUserInfo' - -export default { - namespaced: true, - state: { - userInfo: { - token: '', - username: '' - }, - hasLogined: false, - loginTime: null, - initialized: false - }, - mutations: { - setUserInfo(state, data) { - state.userInfo = data - }, - setHsLogined(state, data) { - state.hasLogined = data - }, - setLoginTime(state, data) { - state.loginTime = data - }, - setInitialized(state, data) { - state.initialized = data - } - }, - actions: { - init({ dispatch, commit }) { - const localData = localStorage.getItem(USER_INFO_KEY) - if (localData) { - try { - const { userInfo, loginTime } = JSON.parse(localData) - if (Date.now() - loginTime > 7 * 3600000) { - localStorage.removeItem(USER_INFO_KEY) - } else { - dispatch('login', userInfo) - } - } catch (error) { - console.log(error) - } - } - commit('setInitialized', true) - }, - login({ commit }, data) { - const loginTime = Date.now() - commit('setUserInfo', data) - commit('setHsLogined', true) - commit('setLoginTime', loginTime) - localStorage.setItem( - USER_INFO_KEY, - JSON.stringify({ - userInfo: data, - loginTime: loginTime - }) - ) - }, - logout({ commit }) { - commit('setUserInfo', null) - commit('setHsLogined', false) - localStorage.removeItem(USER_INFO_KEY) - } - } -} diff --git a/web/src/management/stores/edit.ts b/web/src/management/stores/edit.ts index 4061c9f0..cad89467 100644 --- a/web/src/management/stores/edit.ts +++ b/web/src/management/stores/edit.ts @@ -4,7 +4,8 @@ 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 submitFormConfig from '@/management/config/setterConfig/submitConfig' + +import submitFormConfig from '@/management/pages/edit/setterConfig/statusConfig' import questionLoader from '@/materials/questions/questionLoader' import { SurveyPermissions } from '@/management/utils/types/workSpace' diff --git a/web/src/management/stores/user.ts b/web/src/management/stores/user.ts index 5b152519..7b2670af 100644 --- a/web/src/management/stores/user.ts +++ b/web/src/management/stores/user.ts @@ -52,4 +52,3 @@ export const useUserStore = defineStore('user', () => { return { userInfo, hasLogined, loginTime, initialized, init, login, logout } }) - diff --git a/web/src/management/stores/workSpace.ts b/web/src/management/stores/workSpace.ts index 4a39e4e4..f9c05c55 100644 --- a/web/src/management/stores/workSpace.ts +++ b/web/src/management/stores/workSpace.ts @@ -41,12 +41,13 @@ export const useWorkSpaceStore = defineStore('workSpace', () => { const workSpaceId = ref('') const spaceDetail = ref问卷未到开始填写时间,暂时无法进行填写
-开始时间为: ${begTime}
` - }) - return - } else if (now > new Date(endTime).getTime()) { - router.push({ name: 'errorPage' }) - commit('setErrorInfo', { - errorType: 'overTime', - errorMsg: msgContent.msg_9001 || '您来晚了,感谢支持问卷~' - }) - return - } 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)) { - router.push({ name: 'errorPage' }) - commit('setErrorInfo', { - errorType: 'overTime', - errorMsg: `不在答题时间范围内,暂时无法进行填写
-答题时间为: ${answerBegTime} ~ ${answerEndTime}
` - }) - return - } - } - router.push({ name: 'renderPage' }) - - // 根据初始的schema生成questionData, questionSeq, rules, formValues, 这四个字段 - const { questionData, questionSeq, rules, formValues } = adapter.generateData({ - bannerConf, - baseConf, - bottomConf, - dataConf, - skinConf, - submitConf - }) - - // 将数据设置到state上 - commit('assignState', { - questionData, - questionSeq, - rules, - bannerConf, - baseConf, - bottomConf, - dataConf, - skinConf, - submitConf, - formValues - }) - // 获取已投票数据 - dispatch('initVoteData') - }, - // 用户输入或者选择后,更新表单数据 - changeData({ commit }, data) { - commit('changeFormData', data) - }, - // 初始化投票题的数据 - async initVoteData({ state, commit }) { - const questionData = state.questionData - const surveyPath = state.surveyPath - - const fieldList = [] - - for (const field in questionData) { - const { type } = questionData[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 - }) - ) - commit('setVoteMap', voteRes.data) - } - } catch (error) { - console.log(error) - } - }, - updateVoteData({ state, commit }, data) { - const { key: questionKey, value: questionVal } = data - // 更新前获取接口缓存在localStorage中的数据 - const localData = localStorage.getItem(VOTE_INFO_KEY) - const voteinfo = JSON.parse(localData) - const currentQuestion = state.questionData[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 - commit('updateVoteMapByKey', countPayload) - } else { - const countPayload = { - questionKey, - voteKey: optionhash, - voteValue: voteCount - } - commit('updateVoteMapByKey', countPayload) - } - commit('updateVoteMapByKey', totalPayload) - }) - }, - async getEncryptInfo({ commit }) { - try { - const res = await getEncryptInfo() - if (res.code === CODE_MAP.SUCCESS) { - commit('setEncryptInfo', res.data) - } - } catch (error) { - console.log(error) - } - }, - async initRuleEngine({ commit }, ruleConf) { - const ruleEngine = new RuleMatch(ruleConf) - commit('setRuleEgine', ruleEngine) - } -} 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/store/mutations.js b/web/src/render/store/mutations.js deleted file mode 100644 index 39585610..00000000 --- a/web/src/render/store/mutations.js +++ /dev/null @@ -1,56 +0,0 @@ -import { forEach, set } from 'lodash-es' -export default { - // 将数据设置到state上 - assignState(state, data) { - forEach(data, (value, key) => { - state[key] = value - }) - }, - setQuestionData(state, data) { - state.questionData = data - }, - setErrorInfo(state, { errorType, errorMsg }) { - state.errorInfo = { - errorType, - errorMsg - } - }, - changeFormData(state, data) { - let { key, value } = data - // console.log('formValues', key, value) - set(state, `formValues.${key}`, value) - }, - changeSelectMoreData(state, data) { - const { key, value, field } = data - set(state, `questionData.${field}.othersValue.${key}`, value) - }, - setEnterTime(state) { - state.enterTime = Date.now() - }, - setSurveyPath(state, data) { - state.surveyPath = data - }, - setVoteMap(state, data) { - state.voteMap = data - }, - updateVoteMapByKey(state, data) { - const { questionKey, voteKey, voteValue } = data - // 兼容为空的情况 - if (!state.voteMap[questionKey]) { - state.voteMap[questionKey] = {} - } - state.voteMap[questionKey][voteKey] = voteValue - }, - setQuestionSeq(state, data) { - state.questionSeq = data - }, - setEncryptInfo(state, data) { - state.encryptInfo = data - }, - setRuleEgine(state, ruleEngine) { - state.ruleEngine = ruleEngine - }, - setWhiteData(state, data) { - state.whiteData = data - } -} diff --git a/web/src/render/store/state.js b/web/src/render/store/state.js deleted file mode 100644 index 11ba0ef0..00000000 --- a/web/src/render/store/state.js +++ /dev/null @@ -1,19 +0,0 @@ -import { isMobile } from '../utils/index' - -export default { - surveyPath: '', - questionData: null, - isMobile: isMobile(), - errorInfo: { - errorType: '', - errorMsg: '' - }, - enterTime: null, - questionSeq: [], // 题目的顺序,因为可能会有分页的情况,所以是一个二维数组[[qid1, qid2], [qid3,qid4]] - voteMap: {}, - encryptInfo: null, - ruleEngine: null, - whiteData: { - - } -} diff --git a/web/src/render/stores/survey.js b/web/src/render/stores/survey.js index 182b1275..23c49c31 100644 --- a/web/src/render/stores/survey.js +++ b/web/src/render/stores/survey.js @@ -37,11 +37,16 @@ export const useSurveyStore = defineStore('survey', () => { const skinConf = ref({}) const submitConf = ref({}) const formValues = ref({}) + const whiteData = ref({}) const router = useRouter() const questionStore = useQuestionStore() const { setErrorInfo } = useErrorInfo() + const setWhiteData = (data) => { + whiteData.value = data + } + const setSurveyPath = (data) => { surveyPath.value = data } @@ -115,7 +120,15 @@ export const useSurveyStore = defineStore('survey', () => { rules: _rules, formValues: _formValues } = adapter.generateData( - pick(option, ['bannerConf', 'baseConf', 'bottomConf', 'dataConf', 'skinConf', 'submitConf']) + pick(option, [ + 'bannerConf', + 'baseConf', + 'bottomConf', + 'dataConf', + 'skinConf', + 'submitConf', + 'whiteData' + ]) ) questionStore.questionData = questionData @@ -130,6 +143,7 @@ export const useSurveyStore = defineStore('survey', () => { skinConf.value = option.skinConf submitConf.value = option.submitConf formValues.value = _formValues + whiteData.value = option.whiteData // 获取已投票数据 questionStore.initVoteData() @@ -156,9 +170,11 @@ export const useSurveyStore = defineStore('survey', () => { skinConf, submitConf, formValues, + whiteData, initSurvey, changeData, + setWhiteData, setSurveyPath, setEnterTime, getEncryptInfo 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;