feat: 优化结构

This commit is contained in:
sudoooooo 2024-07-22 20:27:12 +08:00
parent 4ac07ef938
commit d36e33e4df
68 changed files with 686 additions and 1433 deletions

View File

@ -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,
};

View File

@ -174,6 +174,7 @@ export class WorkspaceController {
pre[id] = cur; pre[id] = cur;
return pre; return pre;
}, {}); }, {});
const surveyTotalList = await Promise.all( const surveyTotalList = await Promise.all(
workspaceIdList.map((item) => { workspaceIdList.map((item) => {
return this.surveyMetaService.countSurveyMetaByWorkspaceId({ return this.surveyMetaService.countSurveyMetaByWorkspaceId({

122
web/components.d.ts vendored
View File

@ -7,68 +7,68 @@ export {}
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
ElButton: (typeof import('element-plus/es'))['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElCheckbox: (typeof import('element-plus/es'))['ElCheckbox'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCollapse: (typeof import('element-plus/es'))['ElCollapse'] ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: (typeof import('element-plus/es'))['ElCollapseItem'] ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElColorPicker: (typeof import('element-plus/es'))['ElColorPicker'] ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElConfigProvider: (typeof import('element-plus/es'))['ElConfigProvider'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElDatePicker: (typeof import('element-plus/es'))['ElDatePicker'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: (typeof import('element-plus/es'))['ElDialog'] ElDialog: typeof import('element-plus/es')['ElDialog']
ElForm: (typeof import('element-plus/es'))['ElForm'] ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: (typeof import('element-plus/es'))['ElFormItem'] ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElInput: (typeof import('element-plus/es'))['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: (typeof import('element-plus/es'))['ElInputNumber'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElMenu: (typeof import('element-plus/es'))['ElMenu'] ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: (typeof import('element-plus/es'))['ElMenuItem'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElMenuItemGroup: (typeof import('element-plus/es'))['ElMenuItemGroup'] ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
ElOption: (typeof import('element-plus/es'))['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: (typeof import('element-plus/es'))['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: (typeof import('element-plus/es'))['ElPopover'] ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: (typeof import('element-plus/es'))['ElRadio'] ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioButton: (typeof import('element-plus/es'))['ElRadioButton'] ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: (typeof import('element-plus/es'))['ElRadioGroup'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: (typeof import('element-plus/es'))['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']
ElSegmented: (typeof import('element-plus/es'))['ElSegmented'] ElSegmented: typeof import('element-plus/es')['ElSegmented']
ElSelect: (typeof import('element-plus/es'))['ElSelect'] ElSelect: typeof import('element-plus/es')['ElSelect']
ElSelectV2: (typeof import('element-plus/es'))['ElSelectV2'] ElSelectV2: typeof import('element-plus/es')['ElSelectV2']
ElSlider: (typeof import('element-plus/es'))['ElSlider'] ElSlider: typeof import('element-plus/es')['ElSlider']
ElSwitch: (typeof import('element-plus/es'))['ElSwitch'] ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: (typeof import('element-plus/es'))['ElTable'] ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: (typeof import('element-plus/es'))['ElTableColumn'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTabPane: (typeof import('element-plus/es'))['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: (typeof import('element-plus/es'))['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: (typeof import('element-plus/es'))['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElTimePicker: (typeof import('element-plus/es'))['ElTimePicker'] ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
ElTooltip: (typeof import('element-plus/es'))['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: (typeof import('element-plus/es'))['ElTree'] ElTree: typeof import('element-plus/es')['ElTree']
IEpBottom: (typeof import('~icons/ep/bottom'))['default'] IEpBottom: typeof import('~icons/ep/bottom')['default']
IEpCheck: (typeof import('~icons/ep/check'))['default'] IEpCheck: typeof import('~icons/ep/check')['default']
IEpCirclePlus: (typeof import('~icons/ep/circle-plus'))['default'] IEpCirclePlus: typeof import('~icons/ep/circle-plus')['default']
IEpClose: (typeof import('~icons/ep/close'))['default'] IEpClose: typeof import('~icons/ep/close')['default']
IEpConnection: (typeof import('~icons/ep/connection'))['default'] IEpConnection: typeof import('~icons/ep/connection')['default']
IEpCopyDocument: (typeof import('~icons/ep/copy-document'))['default'] IEpCopyDocument: typeof import('~icons/ep/copy-document')['default']
IEpDelete: (typeof import('~icons/ep/delete'))['default'] IEpDelete: typeof import('~icons/ep/delete')['default']
IEpIphone: (typeof import('~icons/ep/iphone'))['default'] IEpIphone: typeof import('~icons/ep/iphone')['default']
IEpLoading: (typeof import('~icons/ep/loading'))['default'] IEpLoading: typeof import('~icons/ep/loading')['default']
IEpMinus: (typeof import('~icons/ep/minus'))['default'] IEpMinus: typeof import('~icons/ep/minus')['default']
IEpMonitor: (typeof import('~icons/ep/monitor'))['default'] IEpMonitor: typeof import('~icons/ep/monitor')['default']
IEpMore: (typeof import('~icons/ep/more'))['default'] IEpMore: typeof import('~icons/ep/more')['default']
IEpPlus: (typeof import('~icons/ep/plus'))['default'] IEpPlus: typeof import('~icons/ep/plus')['default']
IEpQuestionFilled: (typeof import('~icons/ep/question-filled'))['default'] IEpQuestionFilled: typeof import('~icons/ep/question-filled')['default']
IEpRank: (typeof import('~icons/ep/rank'))['default'] IEpRank: typeof import('~icons/ep/rank')['default']
IEpRemove: (typeof import('~icons/ep/remove'))['default'] IEpRemove: typeof import('~icons/ep/remove')['default']
IEpSearch: (typeof import('~icons/ep/search'))['default'] IEpSearch: typeof import('~icons/ep/search')['default']
IEpSort: (typeof import('~icons/ep/sort'))['default'] IEpSort: typeof import('~icons/ep/sort')['default']
IEpSortDown: (typeof import('~icons/ep/sort-down'))['default'] IEpSortDown: typeof import('~icons/ep/sort-down')['default']
IEpSortUp: (typeof import('~icons/ep/sort-up'))['default'] IEpSortUp: typeof import('~icons/ep/sort-up')['default']
IEpTop: (typeof import('~icons/ep/top'))['default'] IEpTop: typeof import('~icons/ep/top')['default']
IEpView: (typeof import('~icons/ep/view'))['default'] IEpView: typeof import('~icons/ep/view')['default']
IEpWarningFilled: (typeof import('~icons/ep/warning-filled'))['default'] IEpWarningFilled: typeof import('~icons/ep/warning-filled')['default']
RouterLink: (typeof import('vue-router'))['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: (typeof import('vue-router'))['RouterView'] RouterView: typeof import('vue-router')['RouterView']
} }
export interface ComponentCustomProperties { export interface ComponentCustomProperties {
vLoading: (typeof import('element-plus/es'))['ElLoadingDirective'] vLoading: typeof import('element-plus/es')['ElLoadingDirective']
} }
} }

7
web/env.d.ts vendored
View File

@ -1,8 +1 @@
/// <reference types="vite/client" /> /// <reference types="vite/client" />
declare module "vuex" {
export * from "vuex/types/index.d.ts";
export * from "vuex/types/helpers.d.ts";
export * from "vuex/types/logger.d.ts";
export * from "vuex/types/vue.d.ts";
}

View File

@ -31,7 +31,6 @@
"vue": "^3.4.15", "vue": "^3.4.15",
"vue-router": "^4.2.5", "vue-router": "^4.2.5",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"vuex": "^4.0.2",
"xss": "^1.0.14", "xss": "^1.0.14",
"yup": "^1.4.0" "yup": "^1.4.0"
}, },

View File

@ -24,7 +24,5 @@ export const replacePxWithRem = (html) => {
}) })
}) })
console.log('生成的结果', res)
return res return res
} }

View File

@ -16,11 +16,11 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from 'vue' import { computed } from 'vue'
import { useStore } from 'vuex'
import { type IMember, type ListItem } from '@/management/utils/types/workSpace' import { type IMember, type ListItem } from '@/management/utils/types/workSpace'
import OperationSelect from './OperationSelect.vue' import OperationSelect from './OperationSelect.vue'
import { useWorkSpaceStore } from '@/management/stores/workSpace'
const store = useStore() const workSpaceStore = useWorkSpaceStore()
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
members: IMember[] members: IMember[]
@ -43,7 +43,7 @@ const list = computed({
} }
}) })
const currentUserId = computed(() => { const currentUserId = computed(() => {
return store.state.list.spaceDetail?.currentUserId return workSpaceStore.spaceDetail?.currentUserId
}) })
const handleRemove = (index: number) => { const handleRemove = (index: number) => {
list.value.splice(index, 1) list.value.splice(index, 1)

View File

@ -23,7 +23,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import { ref } from 'vue'
import { useStore } from 'vuex'
import MemberList from './MemberList.vue' import MemberList from './MemberList.vue'
import { getUserList } from '@/management/api/space' import { getUserList } from '@/management/api/space'
import { import {
@ -33,8 +32,9 @@ import {
roleLabels roleLabels
} from '@/management/utils/types/workSpace' } from '@/management/utils/types/workSpace'
import { CODE_MAP } from '@/management/api/base' import { CODE_MAP } from '@/management/api/base'
import { useUserStore } from '@/management/stores/user'
const store = useStore() const userStore = useUserStore()
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
members?: IMember[] members?: IMember[]
@ -65,7 +65,7 @@ const remoteMethod = async (query: string) => {
if (res.code === CODE_MAP.SUCCESS) { if (res.code === CODE_MAP.SUCCESS) {
selectOptions.value = res.data.map((item: any) => { selectOptions.value = res.data.map((item: any) => {
// //
const currentUser = item.username === store.state.user.userInfo.username const currentUser = item.username === userStore.userInfo?.username
return { return {
value: item.userId, value: item.userId,
label: item.username, label: item.username,

View File

@ -133,9 +133,6 @@ const onPreviewImage = (e) => {
} }
.table-row-cell { .table-row-cell {
white-space: nowrap; /* 禁止自动换行 */
overflow: hidden; /* 超出部分隐藏 */
text-overflow: ellipsis; /* 显示省略号 */
:deep(img) { :deep(img) {
height: 23px !important; height: 23px !important;
width: auto !important; width: auto !important;

View File

@ -42,6 +42,7 @@ import PublishPanel from '../modules/contentModule/PublishPanel.vue'
import CooperationPanel from '../modules/contentModule/CooperationPanel.vue' import CooperationPanel from '../modules/contentModule/CooperationPanel.vue'
const editStore = useEditStore() const editStore = useEditStore()
const { schema, changeSchema } = editStore
const title = computed(() => (editStore.schema?.metaData as any)?.title || '') const title = computed(() => (editStore.schema?.metaData as any)?.title || '')
// - // -
const updateLogicConf = () => { const updateLogicConf = () => {
@ -67,10 +68,12 @@ const updateLogicConf = () => {
const showLogicConf = showLogicEngine.value.toJson() const showLogicConf = showLogicEngine.value.toJson()
// //
store.dispatch('edit/changeSchema', { key: 'logicConf', value: { showLogicConf } }) changeSchema({ key: 'logicConf', value: { showLogicConf } })
return res return res
} }
return res
} }
// - // -
@ -79,7 +82,7 @@ const updateWhiteConf = () => {
validated: true, validated: true,
message: '' message: ''
} }
const baseConf = store.state.edit.schema.baseConf || {} const baseConf = (schema?.baseConf as any) || {}
if (baseConf.passwordSwitch && !baseConf.password) { if (baseConf.passwordSwitch && !baseConf.password) {
res = { res = {
validated: false, validated: false,
@ -99,6 +102,11 @@ const updateWhiteConf = () => {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import url('@/management/styles/edit-btn.scss'); @import url('@/management/styles/edit-btn.scss');
.view-icon {
font-size: 20px;
height: 29px;
line-height: 29px;
}
.nav { .nav {
width: 100%; width: 100%;
height: 56px; height: 56px;

View File

@ -25,8 +25,7 @@
</el-popover> </el-popover>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, watch } from 'vue' import { ref, watch } from 'vue'
import { get as _get } from 'lodash-es'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useEditStore } from '@/management/stores/edit' import { useEditStore } from '@/management/stores/edit'
import moment from 'moment' import moment from 'moment'

View File

@ -67,12 +67,6 @@ const handlePublish = async () => {
return return
} }
if (updateWhiteConf()) {
isPublishing.value = false
ElMessage.error('请检查问卷设置是否有误')
return
}
try { try {
const saveRes: any = await saveSurvey(saveData) const saveRes: any = await saveSurvey(saveData)
if (saveRes.code !== 200) { if (saveRes.code !== 200) {

View File

@ -15,11 +15,9 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, nextTick, watch } from 'vue' import { ref, computed, nextTick, watch } from 'vue'
import { useRoute } from 'vue-router'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useEditStore } from '@/management/stores/edit' import { useEditStore } from '@/management/stores/edit'
import { useRoute } from 'vue-router'
import { get as _get } from 'lodash-es'
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'
@ -33,7 +31,6 @@ interface Props {
const route = useRoute() const route = useRoute()
const props = defineProps<Props>() const props = defineProps<Props>()
const isSaving = ref<boolean>(false) const isSaving = ref<boolean>(false)
const isShowAutoSave = ref<boolean>(false) const isShowAutoSave = ref<boolean>(false)
const autoSaveStatus = ref<'succeed' | 'saving' | 'failed'>('succeed') const autoSaveStatus = ref<'succeed' | 'saving' | 'failed'>('succeed')
@ -48,7 +45,7 @@ const saveText = computed(
const editStore = useEditStore() const editStore = useEditStore()
const { schemaUpdateTime } = storeToRefs(editStore) const { schemaUpdateTime } = storeToRefs(editStore)
const { schema, changeSchema } = editStore const { schema } = editStore
const validate = () => { const validate = () => {
let checked = true let checked = true
@ -130,7 +127,6 @@ const handleSave = async () => {
const { checked, msg } = validate() const { checked, msg } = validate()
if (!checked) { if (!checked) {
isSaving.value = false isSaving.value = false
ElMessage.error('请检查问卷设置是否有误')
ElMessage.error(msg) ElMessage.error(msg)
return return
} }

View File

@ -17,10 +17,11 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useEditStore } from '@/management/stores/edit'
import { EDIT_STATUS_MAP } from '../enum'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { EDIT_STATUS_MAP } from './components/enum'
import { useEditStore } from '@/management/stores/edit'
const editStore = useEditStore() const editStore = useEditStore()
const { currentEditStatus } = storeToRefs(editStore) const { currentEditStatus } = storeToRefs(editStore)
const statusList = [ const statusList = [

View File

@ -16,9 +16,9 @@ import { toRef } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useEditStore } from '@/management/stores/edit' import { useEditStore } from '@/management/stores/edit'
import SuccessContent from '../components/SuccessContent.vue' import SuccessContent from './components/SuccessContent.vue'
import OverTime from '../components/OverTime.vue' import OverTime from './components/OverTime.vue'
import { EDIT_STATUS_MAP } from '../enum' import { EDIT_STATUS_MAP } from './components/enum'
const components = { const components = {
[EDIT_STATUS_MAP.SUCCESS]: SuccessContent, [EDIT_STATUS_MAP.SUCCESS]: SuccessContent,

View File

@ -30,7 +30,7 @@ import { get as _get } from 'lodash-es'
import FormItem from '@/materials/setters/widgets/FormItem.vue' import FormItem from '@/materials/setters/widgets/FormItem.vue'
import setterLoader from '@/materials/setters/setterLoader' import setterLoader from '@/materials/setters/setterLoader'
import statusConfig from '../config/statusConfig' import statusConfig from '@/management/pages/edit/setterConfig/statusConfig'
const textMap = { const textMap = {
Success: '提交成功页面配置', Success: '提交成功页面配置',

View File

@ -0,0 +1,34 @@
<template>
<div class="over-time">
<img class="over-img" src="/imgs/icons/overtime.webp" />
<p class="title-msg" v-safe-html="resultText"></p>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
interface Props {
moduleConfig: any
}
const props = defineProps<Props>()
const resultText = computed(() => props.moduleConfig?.msgContent?.msg_9001 || '问卷已过期')
</script>
<style lang="scss" scoped>
.over-time {
text-align: center;
margin-bottom: 5.5rem;
height: 100%;
.title-msg {
width: 100%;
font-size: 16px;
color: #666;
}
}
.over-time .over-img {
margin-top: 1.6rem;
margin-bottom: 15px;
width: 100px;
}
</style>

View File

@ -0,0 +1,56 @@
<template>
<div class="suc-page">
<div class="suc-content">
<div class="title-box">
<img src="/imgs/icons/success.webp" class="success-img" />
<div class="title-msg" v-safe-html="successText"></div>
</div>
<div class="bottom-btn"></div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
interface Props {
moduleConfig: any
}
const props = defineProps<Props>()
const successText = computed(() => props.moduleConfig?.msgContent?.msg_200 || '')
</script>
<style lang="scss" scoped>
/*成功页面跳转全屏展示浮层*/
.suc-page {
padding: 0;
text-align: center;
width: 100%;
display: inline-block;
height: 100%;
.success-img {
margin-top: -0.2rem;
width: 100px;
}
}
.suc-content {
max-width: 920px;
margin: 0 auto;
height: 100%;
width: 100%;
position: relative;
padding-top: 1.8rem;
}
.title-msg {
margin-top: 0.4rem;
margin-bottom: 0.4rem;
font-size: 0.36rem;
color: #666;
:deep(*) {
font-size: 0.36rem;
}
}
.bottom-btn {
height: 300px;
}
</style>

View File

@ -38,14 +38,13 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, onMounted, shallowRef } from 'vue' import { computed, ref, onMounted, shallowRef } from 'vue'
import { useEditStore } from '@/management/stores/edit'
import { useStore } from 'vuex'
import { import {
cloneDeep as _cloneDeep, cloneDeep as _cloneDeep,
isArray as _isArray, isArray as _isArray,
get as _get, get as _get,
isFunction as _isFunction isFunction as _isFunction
} from 'lodash-es' } from 'lodash-es'
import { useEditStore } from '@/management/stores/edit'
import baseConfig from '@/management/pages/edit/setterConfig/baseConfig' import baseConfig from '@/management/pages/edit/setterConfig/baseConfig'
import baseFormConfig from '@/management/pages/edit/setterConfig/baseFormConfig' import baseFormConfig from '@/management/pages/edit/setterConfig/baseFormConfig'
@ -55,6 +54,9 @@ import setterLoader from '@/materials/setters/setterLoader'
import WhiteList from './components/WhiteList.vue' import WhiteList from './components/WhiteList.vue'
import TeamMemberList from './components/TeamMemberList.vue' import TeamMemberList from './components/TeamMemberList.vue'
const editStore = useEditStore()
const { schema, changeSchema } = editStore
const formConfigList = ref<Array<any>>([]) const formConfigList = ref<Array<any>>([])
const components = shallowRef<any>({ const components = shallowRef<any>({
['WhiteList']: WhiteList, ['WhiteList']: WhiteList,
@ -65,8 +67,8 @@ const registerTypes = ref<any>({
WhiteList: 'WhiteList', WhiteList: 'WhiteList',
TeamMemberList: 'TeamMemberList' TeamMemberList: 'TeamMemberList'
}) })
const store = useStore()
const schemaBaseConf = computed(() => store.state.edit?.schema?.baseConf || {}) const schemaBaseConf = computed(() => schema?.baseConf || {})
const setterList = computed(() => { const setterList = computed(() => {
const list = _cloneDeep(formConfigList.value) const list = _cloneDeep(formConfigList.value)
@ -173,7 +175,6 @@ onMounted(async () => {
padding-bottom: 19px; padding-bottom: 19px;
margin-bottom: 10px; margin-bottom: 10px;
border-bottom: 1px solid $border-color; border-bottom: 1px solid $border-color;
padding-left: 30px;
span { span {
position: relative; position: relative;

View File

@ -1,23 +1,33 @@
<template> <template>
<div class="team-member-wrap"> <div class="team-member-wrap">
<div class="team-tree-wrap"> <div class="team-tree-wrap">
<el-tree ref="treeRef" :default-expanded-keys="defaultCheckedKeys" :default-checked-keys="defaultCheckedKeys" <el-tree
:data="treeData" empty-text="暂无数据" @check="handleChange" style="height:201px" highlight-current show-checkbox ref="treeRef"
node-key="id" :props="defaultProps" /> :default-expanded-keys="defaultCheckedKeys"
:default-checked-keys="defaultCheckedKeys"
:data="treeData"
empty-text="暂无数据"
@check="handleChange"
style="height: 201px"
highlight-current
show-checkbox
node-key="id"
:props="defaultProps"
/>
</div>
<div class="member-count">
已选择 <span>{{ selectCount }}</span>
</div> </div>
<div class="member-count">已选择 <span>{{ selectCount }}</span> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, computed, defineProps, defineEmits, onMounted } from 'vue' import { ref, computed, onMounted } from 'vue'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant' import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
import { import { getMemberList } from '@/management/api/space'
getMemberList
} from '@/management/api/space'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
const props = defineProps({ const props = defineProps({
formConfig: Object, formConfig: Object
}) })
const emit = defineEmits([FORM_CHANGE_EVENT_KEY]) const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
@ -26,58 +36,53 @@ const treeData = ref([])
const defaultCheckedKeys = ref([]) const defaultCheckedKeys = ref([])
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'label', label: 'label'
} }
const handleChange = () => { const handleChange = () => {
const key = props.formConfig.key; const key = props.formConfig.key
const userKeys = treeRef.value?.getCheckedKeys(true); const userKeys = treeRef.value?.getCheckedKeys(true)
if (userKeys.length > 100) { if (userKeys.length > 100) {
ElMessage.error('最多添加100个') ElMessage.error('最多添加100个')
return; return
} }
emit(FORM_CHANGE_EVENT_KEY, { key: key, value: userKeys }); emit(FORM_CHANGE_EVENT_KEY, { key: key, value: userKeys })
} }
const selectCount = computed(() => { const selectCount = computed(() => {
return treeRef.value?.getCheckedKeys(true).length || 0 return treeRef.value?.getCheckedKeys(true).length || 0
}) })
const getSpaceMenus = async () => { const getSpaceMenus = async () => {
const res = await getMemberList(); const res = await getMemberList()
if (res.code != 200) { if (res.code != 200) {
ElMessage.error('获取空间成员列表失败'); ElMessage.error('获取空间成员列表失败')
return
} }
const data = res.data; const data = res.data
data.map((v) => { data.map((v) => {
const members = v.members || []; const members = v.members || []
treeData.value.push({ treeData.value.push({
id: v.ownerId, id: v.ownerId,
label: v.name, label: v.name,
children: members?.map(v => ({ children: members?.map((v) => ({
id: v.userId, id: v.userId,
label: v.role, label: v.role
})) }))
}) })
}) })
defaultCheckedKeys.value = props.formConfig.value; defaultCheckedKeys.value = props.formConfig.value
} }
onMounted(() => { onMounted(() => {
getSpaceMenus(); getSpaceMenus()
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.team-member-wrap { .team-member-wrap {
width: 508px; width: 508px;
.team-tree-wrap { .team-tree-wrap {
background: #FFFFFF; background: #ffffff;
border: 1px solid rgba(227, 228, 232, 1); border: 1px solid rgba(227, 228, 232, 1);
border-radius: 2px; border-radius: 2px;
min-height: 204px; min-height: 204px;

View File

@ -1,55 +1,64 @@
<template> <template>
<div class="white-list-wrap"> <div class="white-list-wrap">
<el-button class="create-btn" type="primary" @click="whiteVisible=true"> <el-button class="create-btn" type="primary" @click="whiteVisible = true"> 添加 </el-button>
添加 <el-button v-if="whitelist.length > 0" class="create-btn" color="#4A4C5B" @click="delAllList">
</el-button>
<el-button v-if="whitelist.length>0" class="create-btn" color="#4A4C5B" @click="delAllList">
全部删除 全部删除
</el-button> </el-button>
<el-table class="table-wrap" empty-text="暂无数据" :data="whitelist" height="240" style="width: 426px"> <el-table
<el-table-column label="名单" width="350" > class="table-wrap"
empty-text="暂无数据"
:data="whitelist"
height="240"
style="width: 426px"
>
<el-table-column label="名单" width="350">
<template #default="scope"> <template #default="scope">
<div>{{ whitelist[scope.$index] }}</div> <div>{{ whitelist[scope.$index] }}</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="74" > <el-table-column label="操作" width="74">
<template #default="scope"> <template #default="scope">
<div @click="delRowItem(scope.$index)" class="flex cursor"><i-ep-delete :size="16" /></div> <div @click="delRowItem(scope.$index)" class="flex cursor">
<i-ep-delete :size="16" />
</div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog v-model="whiteVisible" title="添加白名单" width="600" @closed="handleClose"> <el-dialog v-model="whiteVisible" title="添加白名单" width="600" @closed="handleClose">
<div> <div>
<el-form-item label-position="top" label="类型选择" label-width="auto"> <el-form-item label-position="top" label="类型选择" label-width="auto">
<el-radio-group v-model="memberType" > <el-radio-group v-model="memberType" @change="handleTypeChange">
<el-radio value="MOBILE">手机号</el-radio> <el-radio value="MOBILE">手机号</el-radio>
<el-radio value="EMAIL">邮箱</el-radio> <el-radio value="EMAIL">邮箱</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label-position="top" class="flex-column" label="名单录入" label-width="auto"> <el-form-item label-position="top" class="flex-column" label="名单录入" label-width="auto">
<el-input v-model="whiteTextarea" placeholder="多个用逗号(半角)“,”隔开" rows="7" resize="none" type="textarea" /> <el-input
v-model="whiteTextarea"
placeholder="多个用逗号(半角)“,”隔开"
rows="7"
resize="none"
type="textarea"
/>
</el-form-item> </el-form-item>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="whiteVisible = false">取消</el-button> <el-button @click="whiteVisible = false">取消</el-button>
<el-button type="primary" @click="handleChange"> <el-button type="primary" @click="handleChange"> 确定 </el-button>
确定
</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, nextTick } from 'vue'
import { ref,nextTick } from 'vue'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant' import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { regexpMap } from '@/common/regexpMap.ts' import { regexpMap } from '@/common/regexpMap.ts'
const props = defineProps({ const props = defineProps({
formConfig: Object, formConfig: Object
}) })
const emit = defineEmits([FORM_CHANGE_EVENT_KEY]) const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
@ -59,36 +68,40 @@ const whiteVisible = ref(false)
const whiteTextarea = ref(whitelist.value.join(',')) const whiteTextarea = ref(whitelist.value.join(','))
const regularMap = { const regularMap = {
MOBILE:regexpMap.m, MOBILE: regexpMap.m,
EMAIL:regexpMap.e EMAIL: regexpMap.e
} }
const checkValRule = (list) => { const checkValRule = (list) => {
let status = false; let status = false
if (list.length > 100) { if (list.length > 100) {
ElMessage.error('最多添加100个') ElMessage.error('最多添加100个')
return true; return true
}; }
const pattern = regularMap[memberType.value]; const pattern = regularMap[memberType.value]
if(!pattern) return false; if (!pattern) return false
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
if (!pattern.test(list[i])) { if (!pattern.test(list[i])) {
status = true; status = true
ElMessage.error('数据格式错误,请检查后重新输入~') ElMessage.error('格式错误,请检查后重新输入~')
break; break
} }
} }
return status;
return status
} }
const handleTypeChange = () => {
whiteTextarea.value = ''
}
const handleChange = () => { const handleChange = () => {
const keys = props.formConfig.keys; const keys = props.formConfig.keys
const list = whiteTextarea.value ? whiteTextarea.value.split(',') : [] const list = whiteTextarea.value ? whiteTextarea.value.split(',') : []
if(checkValRule(list)) return if (checkValRule(list)) return
emit(FORM_CHANGE_EVENT_KEY, { key:keys[0], value: list });
emit(FORM_CHANGE_EVENT_KEY, { key: keys[0], value: list })
emit(FORM_CHANGE_EVENT_KEY, { key: keys[1], value: memberType.value }) emit(FORM_CHANGE_EVENT_KEY, { key: keys[1], value: memberType.value })
whiteVisible.value = false whiteVisible.value = false
} }
@ -102,44 +115,41 @@ const handleClose = () => {
} }
const delRowItem = (index) => { const delRowItem = (index) => {
whitelist.value.splice(index, 1); whitelist.value.splice(index, 1)
whiteTextarea.value = whitelist.value.join(',') whiteTextarea.value = whitelist.value.join(',')
const keys = props.formConfig.keys; const keys = props.formConfig.keys
emit(FORM_CHANGE_EVENT_KEY, { key:keys[0], value: whitelist.value }); emit(FORM_CHANGE_EVENT_KEY, { key: keys[0], value: whitelist.value })
} }
const delAllList = () => { const delAllList = () => {
whitelist.value = [] whitelist.value = []
whiteTextarea.value = '' whiteTextarea.value = ''
handleChange(); handleChange()
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.white-list-wrap { .white-list-wrap {
.flex-column{ .flex-column {
flex-direction: column; flex-direction: column;
} }
:deep(th){ :deep(th) {
padding:4px 0; padding: 4px 0;
background: #F6F7F9; background: #f6f7f9;
} }
:deep(td){ :deep(td) {
padding:6px 0; padding: 6px 0;
} }
.table-wrap{ .table-wrap {
margin-top: 16px; margin-top: 16px;
border: 1px solid #ebeef5; border: 1px solid #ebeef5;
border-radius: 2px; border-radius: 2px;
overflow-x: hidden; overflow-x: hidden;
} }
.cursor{ .cursor {
cursor: pointer; cursor: pointer;
} }
.flex{ .flex {
display: flex; display: flex;
} }
} }
</style> </style>

View File

@ -93,10 +93,6 @@ const changePreset = (banner: any) => {
border: none; border: none;
overflow-y: auto; overflow-y: auto;
background-color: #fff; background-color: #fff;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
.title { .title {
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
@ -113,9 +109,11 @@ const changePreset = (banner: any) => {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.tag { .tag {
cursor: pointer; width: 55px;
width: 51px;
margin: 5px 2px; margin: 5px 2px;
cursor: pointer;
flex: auto;
cursor: pointer;
&.current { &.current {
color: $primary-color; color: $primary-color;
background-color: $primary-bg-color; background-color: $primary-bg-color;

View File

@ -28,7 +28,7 @@ import { ref } from 'vue'
import { useEditStore } from '@/management/stores/edit' import { useEditStore } from '@/management/stores/edit'
import { get as _get } from 'lodash-es' import { get as _get } from 'lodash-es'
import skinConfig from '@/management/config/setterConfig/skinConfig' import skinConfig from '@/management/pages/edit/setterConfig/skinConfig'
import SetterField from '@/management/pages/edit/components/SetterField.vue' import SetterField from '@/management/pages/edit/components/SetterField.vue'
const editStore = useEditStore() const editStore = useEditStore()

View File

@ -0,0 +1,35 @@
export default [
{
label: '顶部图片地址',
type: 'InputSetter',
key: 'bgImage',
labelStyle: { width: '120px' }
},
{
label: '顶部视频地址',
type: 'InputSetter',
key: 'videoLink',
labelStyle: { width: '120px' }
},
{
label: '视频海报地址',
type: 'InputSetter',
key: 'postImg',
labelStyle: { width: '120px' }
},
{
label: '图片支持点击',
type: 'CustomedSwitch',
labelStyle: { width: '120px' },
key: 'bgImageAllowJump'
},
{
label: '跳转链接',
type: 'InputSetter',
labelStyle: { width: '120px' },
key: 'bgImageJumpLink',
relyFunc: (data) => {
return !!data?.bgImageAllowJump
}
}
]

View File

@ -12,6 +12,13 @@ export default [
{ {
title: '作答限制', title: '作答限制',
key: 'respondConfig', key: 'respondConfig',
formList: ['interview_pwd','answer_type','white_placeholder','white_list','team_list'] formList: [
'interview_pwd_switch',
'interview_pwd',
'answer_type',
'white_placeholder',
'white_list',
'team_list'
]
} }
] ]

View File

@ -22,41 +22,62 @@ export default {
type: 'QuestionTimeHour', type: 'QuestionTimeHour',
placement: 'top' placement: 'top'
}, },
interview_pwd: { interview_pwd_switch: {
keys: ['baseConf.passwordSwitch', 'baseConf.password'], key: 'baseConf.passwordSwitch',
label: '访问密码', label: '访问密码',
type: 'SwitchInput', type: 'CustomedSwitch'
},
interview_pwd: {
type: 'InputSetter',
placeholder: '请输入6位字符串类型访问密码 ', placeholder: '请输入6位字符串类型访问密码 ',
maxLength: 6, maxLength: 6,
relyFunc: (data) => {
return !!data?.passwordSwitch
}
}, },
answer_type: { answer_type: {
key: 'baseConf.whitelistType', key: 'baseConf.whitelistType',
label: '答题名单', label: '答题名单',
type: 'AnswerRadio', type: 'RadioGroup',
options: [
{
label: '所有人',
value: 'ALL'
}, },
white_placeholder:{ {
label: '空间成员',
value: 'MEMBER'
},
{
label: '白名单',
value: 'CUSTOM'
}
]
},
white_placeholder: {
key: 'baseConf.whitelistTip', key: 'baseConf.whitelistTip',
label: '名单登录提示语', label: '名单登录提示语',
placeholder:'请输入名单提示语', placeholder: '请输入名单提示语',
type: 'InputWordLimit', type: 'InputSetter',
maxLength: 40, maxLength: 40,
relyFunc: (data) => { relyFunc: (data) => {
return ['CUSTOM','MEMBER'].includes(data.whitelistType) return ['CUSTOM', 'MEMBER'].includes(data.whitelistType)
} }
}, },
white_list:{ white_list: {
keys: ['baseConf.whitelist','baseConf.memberType'], keys: ['baseConf.whitelist', 'baseConf.memberType'],
label: '白名单列表', label: '白名单列表',
type: 'whiteList', type: 'WhiteList',
custom: true, // 自定义导入高级组件
relyFunc: (data) => { relyFunc: (data) => {
return data.whitelistType == 'CUSTOM' return data.whitelistType == 'CUSTOM'
} }
}, },
team_list:{ team_list: {
key: 'baseConf.whitelist', key: 'baseConf.whitelist',
label: '团队空间成员选择', label: '团队空间成员选择',
type: 'teamMemberList', type: 'TeamMemberList',
custom: true, // 自定义导入高级组件
relyFunc: (data) => { relyFunc: (data) => {
return data.whitelistType == 'MEMBER' return data.whitelistType == 'MEMBER'
} }

View File

@ -0,0 +1,16 @@
export default [
{
label: '自定义Logo',
type: 'InputSetter',
key: 'logoImage',
tip: '默认尺寸200px*50px',
labelStyle: { width: '120px' }
},
{
label: 'Logo大小',
type: 'InputPercent',
key: 'logoImageWidth',
tip: '填写宽度百分比例如30%',
labelStyle: { width: '120px' }
}
]

View File

@ -0,0 +1,48 @@
import bannerConfig from './bannerConfig'
import logoConfig from './logoConfig'
export default [
{
name: '头图',
key: 'bannerConf.bannerConfig',
formConfigList: bannerConfig
},
{
name: '背景',
key: 'skinConf.backgroundConf',
formConfigList: [
{
label: '背景颜色',
type: 'ColorPicker',
key: 'color'
}
]
},
{
name: '主题色',
key: 'skinConf.themeConf',
formConfigList: [
{
label: '全局应用',
type: 'ColorPicker',
key: 'color'
}
]
},
{
key: 'skinConf.contentConf',
name: '内容区域',
formConfigList: [
{
label: '内容透明度',
type: 'SliderSetter',
key: 'opacity'
}
]
},
{
name: '品牌logo',
key: 'bottomConf',
formConfigList: logoConfig
}
]

View File

@ -0,0 +1,26 @@
export default {
Success: [
{
label: '提示文案',
type: 'RichText',
key: 'msgContent.msg_200',
placeholder: '提交成功',
value: '提交成功',
labelStyle: {
'font-weight': 'bold'
}
}
],
OverTime: [
{
label: '提示文案',
type: 'RichText',
key: 'msgContent.msg_9001',
placeholder: '问卷已过期',
value: '问卷已过期',
labelStyle: {
'font-weight': 'bold'
}
}
]
}

View File

@ -0,0 +1,62 @@
export default [
{
title: '提交按钮文案',
type: 'InputSetter',
key: 'submitTitle',
placeholder: '提交',
value: ''
},
{
title: '提交确认弹窗',
type: 'Customed',
key: 'confirmAgain',
content: [
{
label: '是否配置该项',
labelStyle: { width: '120px' },
type: 'CustomedSwitch',
key: 'confirmAgain.is_again',
value: true
},
{
label: '二次确认文案',
labelStyle: { width: '120px' },
type: 'InputSetter',
key: 'confirmAgain.again_text',
placeholder: '确认要提交吗?',
value: '确认要提交吗?'
}
]
},
{
title: '提交文案配置',
type: 'Customed',
key: 'msgContent',
content: [
{
label: '已提交',
labelStyle: { width: '120px' },
type: 'InputSetter',
key: 'msgContent.msg_9002',
placeholder: '请勿多次提交!',
value: '请勿多次提交!'
},
{
label: '提交结束',
labelStyle: { width: '120px' },
type: 'InputSetter',
key: 'msgContent.msg_9003',
placeholder: '您来晚了,已经满额!',
value: '您来晚了,已经满额!'
},
{
label: '其他提交失败',
labelStyle: { width: '120px' },
type: 'InputSetter',
key: 'msgContent.msg_9004',
placeholder: '提交失败!',
value: '提交失败!'
}
]
}
]

View File

@ -244,7 +244,7 @@ const order = computed(() => {
return JSON.stringify(formatOrder) return JSON.stringify(formatOrder)
}) })
const onReflush = async () => { const onRefresh = async () => {
const filterString = JSON.stringify( const filterString = JSON.stringify(
filter.value.filter((item) => { filter.value.filter((item) => {
return item.condition[0].value return item.condition[0].value
@ -456,16 +456,20 @@ const onCooperClose = () => {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-bottom: 20px; margin-bottom: 20px;
.select { .select {
display: flex; display: flex;
} }
.search { .search {
display: flex; display: flex;
} }
} }
.list-wrapper { .list-wrapper {
padding: 10px 20px; padding: 10px 20px;
background: #fff; background: #fff;
.list-table { .list-table {
min-height: 620px; min-height: 620px;
} }
@ -473,11 +477,13 @@ const onCooperClose = () => {
.list-pagination { .list-pagination {
margin-top: 20px; margin-top: 20px;
:deep(.el-pagination) { :deep(.el-pagination) {
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
} }
} }
:deep(.el-table__header) { :deep(.el-table__header) {
.tableview-header .el-table__cell { .tableview-header .el-table__cell {
.cell { .cell {
@ -487,21 +493,26 @@ const onCooperClose = () => {
} }
} }
} }
:deep(.tableview-row) { :deep(.tableview-row) {
.tableview-cell { .tableview-cell {
padding: 5px 0; padding: 5px 0;
&.link { &.link {
cursor: pointer; cursor: pointer;
} }
.cell .cell-span { .cell .cell-span {
font-size: 14px; font-size: 14px;
} }
} }
} }
} }
.el-select-dropdown__wrap { .el-select-dropdown__wrap {
background: #eee; background: #eee;
} }
.el-select-dropdown__item.hover { .el-select-dropdown__item.hover {
background: #fff; background: #fff;
} }

View File

@ -170,7 +170,6 @@ const handleDelete = (id: string) => {
.then(async () => { .then(async () => {
await workSpaceStore.deleteSpace(id) await workSpaceStore.deleteSpace(id)
await workSpaceStore.getSpaceList() await workSpaceStore.getSpaceList()
curPage.value = 1
}) })
.catch(() => {}) .catch(() => {})
} }
@ -186,7 +185,6 @@ const handleClick = (key: string, data: any) => {
const onCloseModify = () => { const onCloseModify = () => {
showSpaceModify.value = false showSpaceModify.value = false
workSpaceStore.getSpaceList() workSpaceStore.getSpaceList()
curPage.value = 1
} }
defineExpose({ onCloseModify }) defineExpose({ onCloseModify })

View File

@ -47,11 +47,13 @@ import { computed, ref, shallowRef, onMounted } from 'vue'
import { pick as _pick } from 'lodash-es' import { pick as _pick } from 'lodash-es'
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 { QOP_MAP } from '@/management/utils/constant' import { QOP_MAP } from '@/management/utils/constant'
import MemberSelect from '@/management/components/CooperModify/MemberSelect.vue'
import { type IMember, type IWorkspace, UserRole } from '@/management/utils/types/workSpace' import { type IMember, type IWorkspace, UserRole } from '@/management/utils/types/workSpace'
import { useWorkSpaceStore } from '@/management/stores/workSpace' import { useWorkSpaceStore } from '@/management/stores/workSpace'
import MemberSelect from '@/management/components/CooperModify/MemberSelect.vue'
const workSpaceStore = useWorkSpaceStore() const workSpaceStore = useWorkSpaceStore()
const emit = defineEmits(['on-close-codify', 'onFocus', 'change', 'blur']) const emit = defineEmits(['on-close-codify', 'onFocus', 'change', 'blur'])
const props = defineProps({ const props = defineProps({

View File

@ -1,21 +0,0 @@
import { getBannerData } from '@/management/api/skin.js'
import { getCollaboratorPermissions } from '@/management/api/space.ts'
import { CODE_MAP } from '../api/base'
export default {
async getBannerData({ state, commit }) {
if (state.bannerList && state.bannerList.length > 0) {
return
}
const res = await getBannerData()
if (res.code === 200) {
commit('setBannerList', res.data)
}
},
async fetchCooperPermissions({ commit }, id) {
const res = await getCollaboratorPermissions(id)
if (res.code === CODE_MAP.SUCCESS) {
commit('setCooperPermissions', res.data.permissions)
}
}
}

View File

@ -1,72 +0,0 @@
import { getNewField } from '@/management/utils'
import { cloneDeep as _cloneDeep, get as _get } from 'lodash-es'
import { getSurveyById } from '@/management/api/survey'
export default {
async init({ state, dispatch }) {
const metaData = _get(state, 'schema.metaData')
if (!metaData || metaData._id !== state.surveyId) {
await dispatch('getSchemaFromRemote')
}
dispatch('resetState')
},
async getSchemaFromRemote({ commit, state }) {
const res = await getSurveyById(state.surveyId)
if (res.code === 200) {
const metaData = res.data.surveyMetaRes
document.title = metaData.title
const {
bannerConf,
bottomConf,
skinConf,
baseConf,
submitConf,
dataConf,
logicConf = {}
} = res.data.surveyConfRes.code
commit('initSchema', {
metaData,
codeData: {
bannerConf,
bottomConf,
skinConf,
baseConf,
submitConf,
questionDataList: dataConf.dataList,
logicConf
}
})
} else {
throw new Error(res.errmsg || '问卷不存在')
}
},
resetState({ commit }) {
commit('setCurrentEditOne', null)
commit('changeStatusPreview', { type: 'Success' })
},
// 复制题目到当前题目后
copyQuestion({ commit, state }, { index }) {
const newQuestion = _cloneDeep(state.schema.questionDataList[index])
newQuestion.field = getNewField(state.schema.questionDataList.map((item) => item.field))
commit('addQuestion', { question: newQuestion, index })
},
addQuestion({ commit }, { question, index }) {
commit('addQuestion', { question, index })
commit('updateSchemaUpdateTime', Date.now())
},
deleteQuestion({ commit }, { index }) {
commit('deleteQuestion', { index })
commit('updateSchemaUpdateTime', Date.now())
},
moveQuestion({ commit }, { index, range }) {
commit('moveQuestion', { index, range })
commit('updateSchemaUpdateTime', Date.now())
},
changeSchema({ commit }, { key, value }) {
commit('changeSchema', { key, value })
commit('updateSchemaUpdateTime', Date.now())
},
changeThemePreset({ commit }, presets) {
commit('changeThemePreset', presets)
}
}

View File

@ -1,71 +0,0 @@
import submitFormConfig from '@/management/config/setterConfig/submitConfig'
import questionLoader from '@/materials/questions/questionLoader'
const innerMetaConfig = {
submit: {
title: '提交配置',
formConfig: submitFormConfig
}
}
export default {
moduleConfig(state) {
const currentEditOne = state.currentEditOne
if (currentEditOne === null) {
return null
}
if (currentEditOne === 'banner' || currentEditOne === 'mainTitle') {
return state?.schema?.bannerConf
} else if (currentEditOne === 'submit') {
return state?.schema?.submitConf
} else if (currentEditOne === 'logo') {
return state?.schema?.bottomConf
} else if (!Number.isNaN(currentEditOne)) {
return state?.schema?.questionDataList?.[currentEditOne]
} else {
return null
}
},
formConfigList(state, getters) {
const currentEditOne = state.currentEditOne
if (currentEditOne === null) {
return null
}
return getters?.currentEditMeta?.formConfig || []
},
currentEditMeta(state) {
const currentEditOne = state.currentEditOne
if (currentEditOne === null) {
return null
} else if (innerMetaConfig[currentEditOne]) {
return innerMetaConfig[currentEditOne]
} else {
const questionType = state.schema?.questionDataList?.[currentEditOne]?.type
return questionLoader.getMeta(questionType)
}
},
currentEditKey(state) {
const currentEditOne = state.currentEditOne
if (currentEditOne === null) {
return null
}
let key = ''
switch (currentEditOne) {
case 'banner':
case 'mainTitle':
key = 'bannerConf'
break
case 'submit':
key = 'submitConf'
break
case 'logo':
key = 'bottomConf'
break
default:
key = `questionDataList.${currentEditOne}`
}
return key
}
}

View File

@ -1,12 +0,0 @@
import state from './state'
import mutations from './mutations'
import actions from './actions'
import getters from './getters'
export default {
namespaced: true,
state,
actions,
getters,
mutations
}

View File

@ -1,68 +0,0 @@
import { set as _set, merge as _merge } from 'lodash-es'
export default {
setCurrentEditOne(state, data) {
state.currentEditOne = data
},
changeStatusPreview(state, { type }) {
state.currentEditStatus = type
},
updateSchemaUpdateTime(state) {
state.schemaUpdateTime = Date.now()
},
initSchema(state, { metaData, codeData }) {
state.schema.metaData = metaData
state.schema.bannerConf = _merge({}, state.schema.bannerConf, codeData.bannerConf)
state.schema.bottomConf = _merge({}, state.schema.bottomConf, codeData.bottomConf)
state.schema.skinConf = _merge({}, state.schema.skinConf, codeData.skinConf)
state.schema.baseConf = _merge({}, state.schema.baseConf, codeData.baseConf)
state.schema.submitConf = _merge({}, state.schema.submitConf, codeData.submitConf)
state.schema.questionDataList = codeData.questionDataList || []
state.schema.logicConf = codeData.logicConf
},
setSurveyId(state, data) {
state.surveyId = data
},
addQuestion(state, { question, index }) {
state.schema.questionDataList.splice(index, 0, question)
},
deleteQuestion(state, { index }) {
state.schema.questionDataList.splice(index, 1)
},
moveQuestion(state, { index, range }) {
let start, end
if (range < 0) {
// 向上移动
start = index + range
end = index
} else if (range > 0) {
// 向下移动
start = index + 1
end = index + range + 1
} else {
// 无变化
return
}
const currentData = state.schema.questionDataList[index]
// 新位置和老位置之间所有的题目
const comparedList = state.schema.questionDataList.slice(start, end)
if (range < 0) {
// 向上移动
state.schema.questionDataList.splice(index + range, 1 - range, currentData, ...comparedList)
} else if (range > 0) {
// 向下移动
state.schema.questionDataList.splice(index, range + 1, ...comparedList, currentData)
}
},
changeSchema(state, { key, value }) {
_set(state.schema, key, value)
},
changeThemePreset(state, presets) {
Object.keys(presets).forEach((key) => {
_set(state.schema, key, presets[key])
})
},
setQuestionDataList(state, data) {
state.schema.questionDataList = data
}
}

View File

@ -1,60 +0,0 @@
export default {
currentEditOne: null,
currentEditStatus: 'Success',
schemaUpdateTime: Date.now(),
surveyId: '', // url上取的surveyId
schema: {
metaData: null,
bannerConf: {
titleConfig: {
mainTitle: '<h3 style="text-align: center">欢迎填写问卷</h3>',
subTitle: `<p>为了给您提供更好的服务,希望您能抽出几分钟时间,将您的感受和建议告诉我们,<span style="color: rgb(204, 0, 0)">期待您的参与!</span></p>`,
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: []
}
}
}

View File

@ -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
}
})

View File

@ -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)
}
}
}
}

View File

@ -1,8 +0,0 @@
export default {
setBannerList(state, data) {
state.bannerList = data
},
setCooperPermissions(state, data) {
state.cooperPermissions = data
}
}

View File

@ -1,5 +0,0 @@
import { SurveyPermissions } from '@/management/utils/types/workSpace'
export default {
bannerList: [],
cooperPermissions: Object.values(SurveyPermissions)
}

View File

@ -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)
}
}
}

View File

@ -4,7 +4,8 @@ import { merge as _merge, cloneDeep as _cloneDeep, set as _set } from 'lodash-es
import { getSurveyById } from '@/management/api/survey' 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/pages/edit/setterConfig/statusConfig'
import questionLoader from '@/materials/questions/questionLoader' import questionLoader from '@/materials/questions/questionLoader'
import { SurveyPermissions } from '@/management/utils/types/workSpace' import { SurveyPermissions } from '@/management/utils/types/workSpace'

View File

@ -52,4 +52,3 @@ export const useUserStore = defineStore('user', () => {
return { userInfo, hasLogined, loginTime, initialized, init, login, logout } return { userInfo, hasLogined, loginTime, initialized, init, login, logout }
}) })

View File

@ -41,12 +41,13 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
const workSpaceId = ref('') const workSpaceId = ref('')
const spaceDetail = ref<SpaceDetail | null>(null) const spaceDetail = ref<SpaceDetail | null>(null)
const workSpaceList = ref<SpaceItem[]>([]) const workSpaceList = ref<SpaceItem[]>([])
const workSpaceListTotal = ref(0)
const surveyListStore = useSurveyListStore() const surveyListStore = useSurveyListStore()
async function getSpaceList() { async function getSpaceList(params = { curPage: 1 }) {
try { try {
const res: any = await getSpaceListReq() const res: any = await getSpaceListReq(params)
if (res.code === CODE_MAP.SUCCESS) { if (res.code === CODE_MAP.SUCCESS) {
const { list } = res.data const { list } = res.data
@ -135,6 +136,7 @@ export const useWorkSpaceStore = defineStore('workSpace', () => {
workSpaceId, workSpaceId,
spaceDetail, spaceDetail,
workSpaceList, workSpaceList,
workSpaceListTotal,
getSpaceList, getSpaceList,
getSpaceDetail, getSpaceDetail,
changeSpaceType, changeSpaceType,

View File

@ -16,6 +16,7 @@ export type IWorkspace = {
description: string description: string
members: IMember[] members: IMember[]
} }
export type IMember = { export type IMember = {
userId: string userId: string
username: string username: string

View File

@ -2,6 +2,7 @@
<el-input <el-input
:placeholder="formConfig.placeholder" :placeholder="formConfig.placeholder"
v-model="modelValue" v-model="modelValue"
:maxlength="formConfig.maxLength"
@blur="handleInputBlur" @blur="handleInputBlur"
></el-input> ></el-input>
</template> </template>

View File

@ -1,33 +0,0 @@
<template>
<el-input
:maxlength="maxLength"
v-model="modelValue"
:placeholder="placeholder"
show-word-limit
type="text"
@change="handleInputChange"
/>
</template>
<script setup>
import { computed,ref } from 'vue'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
const props = defineProps({
formConfig: Object,
})
const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
const modelValue = ref(props.formConfig.value || '')
const maxLength = computed(() => props.formConfig.maxLength || 10)
const placeholder = computed(() => props.formConfig.placeholder || '')
const handleInputChange = (value) => {
const key = props.formConfig.key
modelValue.value = value
emit(FORM_CHANGE_EVENT_KEY, { key, value })
}
</script>

View File

@ -1,52 +0,0 @@
<template>
<div class="switch-input-wrap">
<el-switch v-model="passwordSwitch" @change="changeData(props.formConfig.keys[0],passwordSwitch)" />
<InputWordLimit
v-if="passwordSwitch"
class="mt16"
@form-change="handleFormChange"
:formConfig="{
...props.formConfig,
key: props.formConfig.keys[1],
value:props.formConfig?.value[1]
}"
/>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useStore } from 'vuex'
import { FORM_CHANGE_EVENT_KEY } from '@/materials/setters/constant'
import InputWordLimit from './InputWordLimit.vue'
const store = useStore();
const props = defineProps({
formConfig: Object,
})
const emit = defineEmits([FORM_CHANGE_EVENT_KEY])
const passwordSwitch = ref(props.formConfig?.value[0] || false);
const changeData = (key, value) => {
emit(FORM_CHANGE_EVENT_KEY, {
key,
value
})
}
const handleFormChange = (data) => {
store.dispatch('edit/changeSchema', {
key: data.key,
value: data.value
})
}
</script>
<style lang="scss" scoped>
.switch-input-wrap{
width: 100%;
.mt16{
margin-top: 16px;
}
}
</style>

View File

@ -2,12 +2,12 @@
<router-view></router-view> <router-view></router-view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, watch } from 'vue' import { watch } from 'vue'
import { useStore } from 'vuex' import { storeToRefs } from 'pinia'
import { get as _get } from 'lodash-es'
const store = useStore() import { useSurveyStore } from './stores/survey'
const skinConf = computed(() => _get(store, 'state.skinConf', {}))
const { skinConf } = storeToRefs(useSurveyStore())
const updateSkinConfig = (value: any) => { const updateSkinConfig = (value: any) => {
const root = document.documentElement const root = document.documentElement

View File

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

View File

@ -99,7 +99,6 @@ watch(
key: field, key: field,
value: value value: value
} }
// store.commit('changeFormData', data)
surveyStore.changeData(data) surveyStore.changeData(data)
} }
} }

View File

@ -8,7 +8,6 @@
:close-on-press-escape="false" :close-on-press-escape="false"
:close-on-click-modal="false" :close-on-click-modal="false"
align-center align-center
> >
<template #header> <template #header>
<div class="verify-white-head"> <div class="verify-white-head">
@ -17,27 +16,37 @@
</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 mb16" placeholder="请输入6位字符串类型访问密码" /> <el-input
<el-input v-if="isValue" v-model="state.value" class="wd255 mb16" :placeholder="placeholder" /> v-if="isPwd"
v-model="state.password"
class="wd255 mb16"
placeholder="请输入6位字符串类型访问密码"
/>
<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,watch} from 'vue' import { ref, reactive, computed, watch } from 'vue'
import { validate } from '../api/survey'
import { useStore } from 'vuex'
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 { validate } from '../api/survey'
import { useSurveyStore } from '../stores/survey'
const whiteVisible = ref(false) const whiteVisible = ref(false)
const surveyStore = useSurveyStore()
const store = useStore()
const state = reactive({ const state = reactive({
password: '', password: '',
value: '', value: '',
is_submit:false is_submit: false
}) })
const baseConf = computed(() => store.state.baseConf || {}) const baseConf = computed(() => store.state.baseConf || {})
@ -48,32 +57,32 @@ const whitelistTip = computed(() => baseConf.value.whitelistTip)
const surveyPath = computed(() => store.state?.surveyPath || '') const surveyPath = computed(() => store.state?.surveyPath || '')
const isValue = computed(() => { const isValue = computed(() => {
if(!whitelistType.value) return false if (!whitelistType.value) return false
return whitelistType.value!='ALL' return whitelistType.value != 'ALL'
}) })
const placeholder = computed(() => { const placeholder = computed(() => {
if (whitelistType.value == 'MEMBER') { if (whitelistType.value == 'MEMBER') {
return '请输入用户名' return '请输入用户名'
} }
if(memberType.value == 'MOBILE'){ if (memberType.value == 'MOBILE') {
return '请输入手机号' return '请输入手机号'
} }
if(memberType.value == 'EMAIL'){ if (memberType.value == 'EMAIL') {
return '请输入邮箱' return '请输入邮箱'
} }
return '' return ''
}) })
const handleSubmit = async() => { const handleSubmit = async () => {
if (state.is_submit) return; if (state.is_submit) return
const params = { const params = {
surveyPath:surveyPath.value surveyPath: surveyPath.value
} }
if (isValue.value) { if (isValue.value) {
params.whitelist = state.value params.whitelist = state.value
} }
if(isPwd.value){ if (isPwd.value) {
params.password = state.password params.password = state.password
} }
const res = await validate(params) const res = await validate(params)
@ -82,57 +91,57 @@ const handleSubmit = async() => {
return return
} }
whiteVisible.value = false whiteVisible.value = false
store.commit('setWhiteData',params) surveyStore.setWhiteData(params)
} }
watch(()=>baseConf.value, () => { watch(
() => baseConf.value,
() => {
if (whiteVisible.value) return if (whiteVisible.value) return
if(isValue.value || isPwd.value){ if (isValue.value || isPwd.value) {
whiteVisible.value = true; whiteVisible.value = true
} }
}) }
)
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.verify-white-wrap{ .verify-white-wrap {
.verify-white-body{ .verify-white-body {
padding:0 14px padding: 0 14px;
} }
.verify-white-head{ .verify-white-head {
padding:0 14px; padding: 0 14px;
margin-bottom: 8px; margin-bottom: 8px;
margin-top:2px; margin-top: 2px;
} }
.mb16{ .mb16 {
margin-bottom:16px; margin-bottom: 16px;
} }
.verify-white-tips{ .verify-white-tips {
text-align: center; text-align: center;
margin-top:8px; margin-top: 8px;
font-size: 14px; font-size: 14px;
color: #92949D; color: #92949d;
} }
.verify-white-title{ .verify-white-title {
font-size: 16px; font-size: 16px;
color: #292A36; color: #292a36;
font-weight: 500; font-weight: 500;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.submit-btn{ .submit-btn {
background: #FAA600; background: #faa600;
border-radius: 2px; border-radius: 2px;
width:255px; width: 255px;
height:32px; height: 32px;
color:#fff; color: #fff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top:4px; margin-top: 4px;
margin-bottom:14px; margin-bottom: 14px;
} }
} }
</style> </style>

View File

@ -62,7 +62,7 @@ const surveyStore = useSurveyStore()
const questionStore = useQuestionStore() const questionStore = useQuestionStore()
const renderData = computed(() => questionStore.renderData) const renderData = computed(() => questionStore.renderData)
const { bannerConf, submitConf, bottomConf: logoConf } = storeToRefs(surveyStore) const { bannerConf, submitConf, bottomConf: logoConf, whiteData } = storeToRefs(surveyStore)
const surveyPath = computed(() => surveyStore.surveyPath || '') const surveyPath = computed(() => surveyStore.surveyPath || '')
const validate = (cbk: (v: boolean) => void) => { const validate = (cbk: (v: boolean) => void) => {

View File

@ -1,177 +0,0 @@
import moment from 'moment'
// 引入中文
import 'moment/locale/zh-cn'
// 设置中文
moment.locale('zh-cn')
import adapter from '../adapter'
import { queryVote, getEncryptInfo } from '@/render/api/survey'
import { RuleMatch } from '@/common/logicEngine/RulesMatch'
/**
* CODE_MAP不从management引入在dev阶段会导致B端 router被加载进而导致C端路由被添加 baseUrl: /management
*/
const CODE_MAP = {
SUCCESS: 200,
ERROR: 500,
NO_AUTH: 403
}
const VOTE_INFO_KEY = 'voteinfo'
import router from '../router'
export default {
// 初始化
init({ commit, dispatch }, { bannerConf, baseConf, bottomConf, dataConf, skinConf, submitConf }) {
commit('setEnterTime')
const { begTime, endTime, answerBegTime, answerEndTime } = baseConf
const { msgContent } = submitConf
const now = Date.now()
if (now < new Date(begTime).getTime()) {
router.push({ name: 'errorPage' })
commit('setErrorInfo', {
errorType: 'overTime',
errorMsg: `<p>问卷未到开始填写时间,暂时无法进行填写<p/>
<p>开始时间为: ${begTime}</p>`
})
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: `<p>不在答题时间范围内,暂时无法进行填写<p/>
<p>答题时间为: ${answerBegTime} ~ ${answerEndTime}</p>`
})
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)
}
}

View File

@ -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
}, [])
)
}
}

View File

@ -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
})

View File

@ -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
}
}

View File

@ -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: {
}
}

View File

@ -37,11 +37,16 @@ export const useSurveyStore = defineStore('survey', () => {
const skinConf = ref({}) const skinConf = ref({})
const submitConf = ref({}) const submitConf = ref({})
const formValues = ref({}) const formValues = ref({})
const whiteData = ref({})
const router = useRouter() const router = useRouter()
const questionStore = useQuestionStore() const questionStore = useQuestionStore()
const { setErrorInfo } = useErrorInfo() const { setErrorInfo } = useErrorInfo()
const setWhiteData = (data) => {
whiteData.value = data
}
const setSurveyPath = (data) => { const setSurveyPath = (data) => {
surveyPath.value = data surveyPath.value = data
} }
@ -115,7 +120,15 @@ export const useSurveyStore = defineStore('survey', () => {
rules: _rules, rules: _rules,
formValues: _formValues formValues: _formValues
} = adapter.generateData( } = adapter.generateData(
pick(option, ['bannerConf', 'baseConf', 'bottomConf', 'dataConf', 'skinConf', 'submitConf']) pick(option, [
'bannerConf',
'baseConf',
'bottomConf',
'dataConf',
'skinConf',
'submitConf',
'whiteData'
])
) )
questionStore.questionData = questionData questionStore.questionData = questionData
@ -130,6 +143,7 @@ export const useSurveyStore = defineStore('survey', () => {
skinConf.value = option.skinConf skinConf.value = option.skinConf
submitConf.value = option.submitConf submitConf.value = option.submitConf
formValues.value = _formValues formValues.value = _formValues
whiteData.value = option.whiteData
// 获取已投票数据 // 获取已投票数据
questionStore.initVoteData() questionStore.initVoteData()
@ -156,9 +170,11 @@ export const useSurveyStore = defineStore('survey', () => {
skinConf, skinConf,
submitConf, submitConf,
formValues, formValues,
whiteData,
initSurvey, initSurvey,
changeData, changeData,
setWhiteData,
setSurveyPath, setSurveyPath,
setEnterTime, setEnterTime,
getEncryptInfo getEncryptInfo

View File

@ -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;