Skip to content

Commit

Permalink
fix: 修复断点续答以及样式问题
Browse files Browse the repository at this point in the history
fix: 修复选项引用验收bug

fix: 修复断点续答问题

fix: 修复断点续答

fix: ignore

fix: 修复投票题默认值

fix: 优化断点续答逻辑

fix: 选中图标适应高度

fix: 回退最大最小选择

fix: 修复断点续答

fix: 修复elswitch不更新问题

fix: 修复访问密码更新不生效问题

fix: 修复样式

fix: 修复多选题最大最小限制

fix: 优化断点续答问题

修复多选题命中最多选择后无法取消问题

fix: 修复服务端的富文本解析

fix:  lint

fix: min error

fix: 修复最少最多选择

fix: 修复投票问卷的最少最多选择

fix: 兼容断点续答情况下选项配额为0的情况

fix: 兼容断点续答情况下选项配额为0的情况

fix: 兼容单选题的断点续答下的选项配额

fix: 修复添加选项问题

fix: 前端提示服务的配额已满

fix: 更新填写的过程中配额减少情况
  • Loading branch information
skique committed Sep 12, 2024
1 parent d08f1c7 commit 8dd539e
Show file tree
Hide file tree
Showing 29 changed files with 312 additions and 268 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ pnpm-debug.log*

.history

exportfile
components.d.ts

# 默认的上传文件夹
userUpload
exportfile
yarn.lock
2 changes: 1 addition & 1 deletion server/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
XIAOJU_SURVEY_MONGO_DB_NAME= # xiaojuSurvey
XIAOJU_SURVEY_MONGO_DB_NAME= xiaojuSurvey
XIAOJU_SURVEY_MONGO_URL= # mongodb://localhost:27017 # 建议设置强密码
XIAOJU_SURVEY_MONGO_AUTH_SOURCE= # admin

Expand Down
3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
"svg-captcha": "^1.4.0",
"typeorm": "^0.3.19"
"typeorm": "^0.3.19",
"xss": "^1.0.15"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"innerType": "radio",
"field": "data606",
"title": "标题2",
"minNum": "",
"maxNum": "",
"minNum": 0,
"maxNum": 0,
"options": [
{
"text": "选项1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Controller, Post, Body, HttpCode } from '@nestjs/common';
import { HttpException } from 'src/exceptions/httpException';
import { SurveyNotFoundException } from 'src/exceptions/surveyNotFoundException';
import { checkSign } from 'src/utils/checkSign';
import { cleanRichTextWithMediaTag } from 'src/utils/xss'
import { ENCRYPT_TYPE } from 'src/enums/encrypt';
import { EXCEPTION_CODE } from 'src/enums/exceptionCode';
import { getPushingData } from 'src/utils/messagePushing';
Expand Down Expand Up @@ -245,7 +246,7 @@ export class SurveyResponseController {
if (quota !== 0 && quota <= optionCountData[val]) {
const item = dataList.find((item) => item['field'] === field);
throw new HttpException(
`【${item['title']}】中的【${option['text']}】所选人数已达到上限,请重新选择`,
`【${cleanRichTextWithMediaTag(item['title'])}】中的【${cleanRichTextWithMediaTag(option['text'])}】所选人数已达到上限,请重新选择`,
EXCEPTION_CODE.RESPONSE_OVER_LIMIT,
);
}
Expand Down
53 changes: 53 additions & 0 deletions server/src/utils/xss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import xss from 'xss'

const myxss = new (xss as any).FilterXSS({
onIgnoreTagAttr(tag, name, value) {
if (name === 'style' || name === 'class') {
return `${name}="${value}"`
}
return undefined
},
onIgnoreTag(tag, html) {
// <xxx>过滤为空,否则不过滤为空
var re1 = new RegExp('<.+?>', 'g')
if (re1.test(html)) {
return ''
} else {
return html
}
}
})

export const cleanRichTextWithMediaTag = (text) => {
if (!text) {
return text === 0 ? 0 : ''
}
const html = transformHtmlTag(text)
.replace(/<img([\w\W]+?)\/>/g, '[图片]')
.replace(/<video.*\/video>/g, '[视频]')
const content = html.replace(/<[^<>]+>/g, '').replace(/&nbsp;/g, '')

return content
}

export function escapeHtml(html) {
return html.replace(/</g, '&lt;').replace(/>/g, '&gt;')
}
export const transformHtmlTag = (html) => {
if (!html) return ''
if (typeof html !== 'string') return html + ''
return html
.replace(html ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&quot;/g, '"')
.replace(/&#39;/g, "'")
.replace(/\\\n/g, '\\n')
//.replace(/&nbsp;/g, "")
}

const filterXSSClone = myxss.process.bind(myxss)

export const filterXSS = (html) => filterXSSClone(transformHtmlTag(html))

export const escapeFilterXSS = (html) => escapeHtml(filterXSS(html))
14 changes: 8 additions & 6 deletions web/src/management/pages/edit/components/ModuleNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ const updateLogicConf = () => {
}
const showLogicConf = showLogicEngine.value.toJson()
// 更新逻辑配置
changeSchema({ key: 'logicConf', value: { showLogicConf } })
if(JSON.stringify(schema.logicConf.showLogicConf) !== JSON.stringify(showLogicConf)) {
// 更新逻辑配置
changeSchema({ key: 'logicConf', value: { showLogicConf } })
}
return res
}
const jumpLogicConf = jumpLogicEngine.value.toJson()
changeSchema({ key: 'logicConf', value: { jumpLogicConf } })
if(JSON.stringify(schema.logicConf.jumpLogicConf) !== JSON.stringify(jumpLogicConf)){
changeSchema({ key: 'logicConf', value: { jumpLogicConf } })
}
return res
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/management/pages/edit/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Navbar from './components/ModuleNavbar.vue'
const editStore = useEditStore()
const { init, setSurveyId, initSessionId } = editStore
const { init, setSurveyId } = editStore
const router = useRouter()
const route = useRoute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const onSave = async () => {
}
const seize = async () => {
const seizeRes: Record<string, any> = await seizeSession({ sessionId })
const seizeRes: Record<string, any> = await seizeSession({ sessionId:sessionId.value })
if (seizeRes.code === 200) {
location.reload();
} else {
Expand Down Expand Up @@ -152,6 +152,7 @@ const handleSave = async () => {
}
if (res.code === 200) {
ElMessage.success('保存成功')
return res
} else if (res.code === 3006) {
ElMessageBox.alert('当前问卷已在其它页面开启编辑,点击“抢占”以获取保存权限。', '提示', {
confirmButtonText: '抢占',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const routes = [
background-color: $primary-color;
bottom: -16px;
left: 20px;
z-index: 99;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const tabSelected = ref<string>('0')
height: 100%;
box-shadow: none;
border: none;
display: flex;
flex-direction: column;
:deep(.el-tabs__nav) {
width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ watch(
width: 360px;
height: 100%;
border: none;
display: flex;
flex-direction: column;
.el-tabs__nav {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import 'element-plus/theme-chalk/src/message.scss'
import { useEditStore } from '@/management/stores/edit'
import { cleanRichText } from '@/common/xss'
import { cleanRichTextWithMediaTag } from '@/common/xss'
export default {
name: 'OptionConfig',
Expand Down Expand Up @@ -110,7 +111,7 @@ export default {
return mapData
},
textOptions() {
return this.curOptions.map((item) => item.text)
return this.curOptions.map((item) => cleanRichTextWithMediaTag(item.text))
}
},
components: {
Expand Down
16 changes: 9 additions & 7 deletions web/src/management/pages/edit/setterConfig/baseFormConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ export default {
placement: 'top'
},
limit_breakAnswer: {
key: 'baseConf.breakAnswer',
key: 'breakAnswer',
label: '允许断点续答',
tip: '回填前一次作答中的内容(注:更换设备/浏览器/清除缓存/更改内容重新发布则此功能失效)',
type: 'ELSwitch',
value: false
placement: 'top',
type: 'CustomedSwitch',
value: false,
},
limit_backAnswer: {
key: 'baseConf.backAnswer',
label: '自动填充上次填写内容',
key: 'backAnswer',
label: '自动填充上次提交内容',
tip: '回填前一次提交的内容(注:更换设备/浏览器/清除缓存/更改内容重新发布则此功能失效)',
type: 'ELSwitch',
value: false
placement: 'top',
type: 'CustomedSwitch',
value: false,
},
interview_pwd_switch: {
key: 'passwordSwitch',
Expand Down
1 change: 0 additions & 1 deletion web/src/materials/questions/widgets/BaseChoice/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
.qicon.qicon-gouxuan {
display: inline-block;
font-size: 0.32rem;
line-height: 0.32rem;
border-color: $primary-color;
background-color: $primary-color;
color: #fff;
Expand Down
20 changes: 18 additions & 2 deletions web/src/materials/questions/widgets/CheckboxModule/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, defineComponent, shallowRef, defineAsyncComponent } from 'vue'
import { computed, defineComponent, shallowRef, defineAsyncComponent, watch } from 'vue'
import { includes } from 'lodash-es'

import BaseChoice from '../BaseChoice'
Expand Down Expand Up @@ -49,6 +49,7 @@ export default defineComponent({
},
emits: ['change'],
setup(props, { emit }) {

const disableState = computed(() => {
if (!props.maxNum) {
return false
Expand All @@ -57,7 +58,7 @@ export default defineComponent({
})
const isDisabled = (item) => {
const { value } = props
return disableState.value && !includes(value, item.value)
return disableState.value && !includes(value, item.hash)
}
const myOptions = computed(() => {
const { options } = props
Expand All @@ -68,6 +69,20 @@ export default defineComponent({
}
})
})
// 兼容断点续答情况下选项配额为0的情况
watch(() => props.value, (value) => {
const disabledHash = myOptions.value.filter(i => i.disabled).map(i => i.hash)
if (value && disabledHash.length) {
disabledHash.forEach(hash => {
const index = value.indexOf(hash)
if( index> -1) {
const newValue = [...value]
newValue.splice(index, 1)
onChange(newValue)
}
})
}
})
const onChange = (value) => {
const key = props.field
emit('change', {
Expand Down Expand Up @@ -96,6 +111,7 @@ export default defineComponent({
return {
onChange,
handleSelectMoreChange,
disableState,
myOptions,
selectMoreView
}
Expand Down
9 changes: 5 additions & 4 deletions web/src/materials/questions/widgets/CheckboxModule/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,18 @@ const meta = {
label: '至少选择数',
type: 'InputNumber',
key: 'minNum',
value: '',
value: 0,
min: 0,
max: 'maxNum',
max: moduleConfig => { return moduleConfig?.maxNum || 0 },
contentClass: 'input-number-config'
},
{
label: '最多选择数',
type: 'InputNumber',
key: 'maxNum',
value: '',
min: 'minNum',
value: 0,
min: moduleConfig => { return moduleConfig?.minNum || 0 },
max: moduleConfig => { return moduleConfig?.options?.length },
contentClass: 'input-number-config'
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@ import GetHash from '@materials/questions/common/utils/getOptionHash'
function useOptionBase(options) {
const optionList = ref(options)
const addOption = (text = '选项', others = false, index = -1, field) => {
// const {} = payload
let addOne
if (optionList.value[0]) {
addOne = cloneDeep(optionList.value[0])
} else {
addOne = {
text: '',
hash: '',
imageUrl: '',
others: false,
mustOthers: false,
othersKey: '',
placeholderDesc: '',
score: 0,
limit: ''
}
let addOne = {
text: '',
hash: '',
others: false,
mustOthers: false,
othersKey: '',
placeholderDesc: '',
}
if (typeof text !== 'string') {
text = '选项'
Expand Down
16 changes: 15 additions & 1 deletion web/src/materials/questions/widgets/RadioModule/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, shallowRef, defineAsyncComponent } from 'vue'
import { defineComponent, shallowRef, watch, defineAsyncComponent } from 'vue'
import BaseChoice from '../BaseChoice'

/**
Expand Down Expand Up @@ -39,6 +39,20 @@ export default defineComponent({
},
emits: ['change'],
setup(props, { emit }) {
// 兼容断点续答情况下选项配额为0的情况
watch(() => props.value, (value) => {
const disabledHash = props.options.filter(i => i.disabled).map(i => i.hash)
if (value && disabledHash.length) {
disabledHash.forEach(hash => {
const index = value.indexOf(hash)
if( index> -1) {
const newValue = [...value]
newValue.splice(index, 1)
onChange(newValue)
}
})
}
})
const onChange = (value) => {
const key = props.field
emit('change', {
Expand Down
5 changes: 3 additions & 2 deletions web/src/materials/questions/widgets/VoteModule/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ const meta = {
key: 'minNum',
value: '',
min: 0,
max: 'maxNum',
max: moduleConfig => { return moduleConfig?.maxNum || 0 },
contentClass: 'input-number-config'
},
{
label: '最多选择数',
type: 'InputNumber',
key: 'maxNum',
value: '',
min: 'minNum',
min: moduleConfig => { return moduleConfig?.minNum || 0 },
max: moduleConfig => { return moduleConfig?.options?.length || 0 },
contentClass: 'input-number-config'
}
]
Expand Down
Loading

0 comments on commit 8dd539e

Please sign in to comment.