Skip to content

Commit

Permalink
fix: 修复断点续答以及样式问题
Browse files Browse the repository at this point in the history
  • Loading branch information
skique committed Aug 26, 2024
1 parent d08f1c7 commit 81e9c88
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
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
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 @@ -23,7 +23,6 @@ const tabSelected = ref<string>('0')
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 @@ -103,7 +103,6 @@ watch(
height: 100%;
border: none;
display: flex;
flex-direction: column;
.el-tabs__nav {
width: 100%;
Expand Down
4 changes: 2 additions & 2 deletions web/src/management/pages/edit/setterConfig/baseFormConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export default {
placement: 'top'
},
limit_breakAnswer: {
key: 'baseConf.breakAnswer',
key: 'breakAnswer',
label: '允许断点续答',
tip: '回填前一次作答中的内容(注:更换设备/浏览器/清除缓存/更改内容重新发布则此功能失效)',
type: 'ELSwitch',
value: false
},
limit_backAnswer: {
key: 'baseConf.backAnswer',
key: 'backAnswer',
label: '自动填充上次填写内容',
tip: '回填前一次提交的内容(注:更换设备/浏览器/清除缓存/更改内容重新发布则此功能失效)',
type: 'ELSwitch',
Expand Down
15 changes: 7 additions & 8 deletions web/src/render/stores/survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const useSurveyStore = defineStore('survey', () => {
// 加载上次填写过的数据到问卷页
function loadFormData(params, formData) {
// 根据初始的schema生成questionData, questionSeq, rules, formValues, 这四个字段
const { questionData, questionSeq, rules, formValues } = adapter.generateData({
const { questionData, questionSeq, rules:_rules, formValues: _formValues } = adapter.generateData({
bannerConf: params.bannerConf,
baseConf: params.baseConf,
bottomConf: params.bottomConf,
Expand All @@ -174,22 +174,22 @@ export const useSurveyStore = defineStore('survey', () => {
})

for(const key in formData){
formValues[key] = formData[key]
_formValues[key] = formData[key]
}

// todo: 建议通过questionStore提供setqueationdata方法修改属性,否则不好跟踪变化
questionStore.questionData = questionData
questionStore.questionSeq = questionSeq

// 将数据设置到state上
rules.value = rules
rules.value = _rules
bannerConf.value = params.bannerConf
baseConf.value = params.baseConf
bottomConf.value = params.bottomConf
dataConf.value = params.dataConf
skinConf.value = params.skinConf
submitConf.value = params.submitConf
formValues.value = formValues
formValues.value = _formValues

whiteData.value = params.whiteData
pageConf.value = params.pageConf
Expand All @@ -202,12 +202,11 @@ export const useSurveyStore = defineStore('survey', () => {
const initSurvey = (option) => {

setEnterTime()

if (!canFillQuestionnaire(option.baseConf, option.submitConf)) {
return
}

const { breakAnswer } = option.baseConf
const { breakAnswer, backAnswer } = option.baseConf

const localData = JSON.parse(localStorage.getItem(surveyPath.value + "_questionData"))
for(const key in localData){
Expand All @@ -217,7 +216,7 @@ export const useSurveyStore = defineStore('survey', () => {
const isSubmit = JSON.parse(localStorage.getItem('isSubmit'))
if(localData) {
if(isSubmit){
if(!option.baseConf.backAnswer) {
if(!backAnswer) {
clearFormData(option)
} else {
confirm({
Expand All @@ -233,7 +232,7 @@ export const useSurveyStore = defineStore('survey', () => {
},
onCancel: async() => {
try {
clearFormData({ bannerConf, baseConf, bottomConf, dataConf, skinConf, submitConf })
clearFormData(option)
} catch (error) {
console.log(error)
} finally {
Expand Down

0 comments on commit 81e9c88

Please sign in to comment.