From a0237c8c5fa863b15ce6e1ed54c3f04b2c4ea5e1 Mon Sep 17 00:00:00 2001 From: dayou <853094838@qq.com> Date: Wed, 17 Jul 2024 15:14:12 +0800 Subject: [PATCH] =?UTF-8?q?perl:=20=E9=80=89=E9=A1=B9=E9=85=8D=E9=A2=9D?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/interfaces/survey.ts | 2 +- .../surveyTemplate/survey/normal.json | 2 +- web/src/management/config/questionConfig.js | 2 +- .../edit/modules/contentModule/SavePanel.vue | 2 +- .../questions/widgets/BaseChoice/index.jsx | 9 +- .../widgets/CheckboxModule/index.jsx | 8 +- .../questions/widgets/CheckboxModule/meta.js | 24 +++++- .../questions/widgets/RadioModule/index.jsx | 4 +- .../questions/widgets/RadioModule/meta.js | 37 +++++++- .../materials/setters/widgets/QuotaConfig.vue | 42 ++++------ web/src/render/components/QuestionWrapper.vue | 21 ++++- web/src/render/hooks/useOptionsQuota.js | 22 +++++ web/src/render/hooks/useVoteMap.js | 1 - web/src/render/pages/RenderPage.vue | 4 +- web/src/render/store/actions.js | 84 +++++++++++++++++-- web/src/render/store/mutations.js | 8 +- web/src/render/store/state.js | 2 +- 17 files changed, 211 insertions(+), 63 deletions(-) create mode 100644 web/src/render/hooks/useOptionsQuota.js diff --git a/server/src/interfaces/survey.ts b/server/src/interfaces/survey.ts index 86ddf2c1..25729dca 100644 --- a/server/src/interfaces/survey.ts +++ b/server/src/interfaces/survey.ts @@ -61,7 +61,7 @@ export interface DataItem { starStyle?: string; innerType?: string; deleteRecover?: boolean; - noDisplay?: boolean; + quotaNoDisplay?: boolean; } export interface Option { diff --git a/server/src/modules/survey/template/surveyTemplate/survey/normal.json b/server/src/modules/survey/template/surveyTemplate/survey/normal.json index 21d89101..b666c597 100644 --- a/server/src/modules/survey/template/surveyTemplate/survey/normal.json +++ b/server/src/modules/survey/template/surveyTemplate/survey/normal.json @@ -63,7 +63,7 @@ } ], "deleteRecover": false, - "noDisplay": false + "quotaNoDisplay": false } ] } diff --git a/web/src/management/config/questionConfig.js b/web/src/management/config/questionConfig.js index 7aed7f64..68d53913 100644 --- a/web/src/management/config/questionConfig.js +++ b/web/src/management/config/questionConfig.js @@ -77,5 +77,5 @@ export const defaultQuestionConfig = { } }, deleteRecover: false, - noDisplay: false + quotaNoDisplay: false } diff --git a/web/src/management/pages/edit/modules/contentModule/SavePanel.vue b/web/src/management/pages/edit/modules/contentModule/SavePanel.vue index f1ba04fb..965ef087 100644 --- a/web/src/management/pages/edit/modules/contentModule/SavePanel.vue +++ b/web/src/management/pages/edit/modules/contentModule/SavePanel.vue @@ -25,7 +25,7 @@ import 'element-plus/theme-chalk/src/message.scss' import { saveSurvey } from '@/management/api/survey' import { showLogicEngine } from '@/management/hooks/useShowLogicEngine' import buildData from './buildData' -import { getSurveyHistory, getConflictHistory } from '@/management/api/survey' +import { getConflictHistory } from '@/management/api/survey' const isSaving = ref(false) const isShowAutoSave = ref(false) diff --git a/web/src/materials/questions/widgets/BaseChoice/index.jsx b/web/src/materials/questions/widgets/BaseChoice/index.jsx index 4d871391..063a0cca 100644 --- a/web/src/materials/questions/widgets/BaseChoice/index.jsx +++ b/web/src/materials/questions/widgets/BaseChoice/index.jsx @@ -48,7 +48,7 @@ export default defineComponent({ type: Number, default: 10 }, - noDisplay:{ + quotaNoDisplay:{ type: Boolean, default: true } @@ -103,7 +103,6 @@ export default defineComponent({
{getOptions.map((item, index) => { - item.disabled = !this.readonly && item.quota !== "0" && (item.quota - item.voteCount) === 0 return ( !item.hide && (
- 剩余{item.quota - item.voteCount} + 剩余{item.release} )} {slots.vote?.({ diff --git a/web/src/materials/questions/widgets/CheckboxModule/index.jsx b/web/src/materials/questions/widgets/CheckboxModule/index.jsx index 90141539..b197a3f5 100644 --- a/web/src/materials/questions/widgets/CheckboxModule/index.jsx +++ b/web/src/materials/questions/widgets/CheckboxModule/index.jsx @@ -42,7 +42,7 @@ export default defineComponent({ type: [Number, String], default: 1 }, - noDisplay:{ + quotaNoDisplay:{ type: Boolean, default: false } @@ -64,7 +64,7 @@ export default defineComponent({ return options.map((item) => { return { ...item, - disabled: isDisabled(item) + disabled: (item.release === 0) || isDisabled(item) } }) }) @@ -101,7 +101,7 @@ export default defineComponent({ } }, render() { - const { readonly, field, myOptions, onChange, maxNum, value, noDisplay, selectMoreView } = this + const { readonly, field, myOptions, onChange, maxNum, value, quotaNoDisplay, selectMoreView } = this return ( {{ selectMore: (scoped) => { diff --git a/web/src/materials/questions/widgets/CheckboxModule/meta.js b/web/src/materials/questions/widgets/CheckboxModule/meta.js index 586077ed..ba5cce79 100644 --- a/web/src/materials/questions/widgets/CheckboxModule/meta.js +++ b/web/src/materials/questions/widgets/CheckboxModule/meta.js @@ -112,9 +112,27 @@ const meta = { ] }, { - key: "quotaConfig", - name: "quotaConfig", - type: "QuotaConfig", + name: 'optionQuota', + label: '选项配额', + labelStyle: { + 'font-weight': 'bold' + }, + type: 'QuotaConfig', + // 输出转换 + valueSetter({ options, deleteRecover, quotaNoDisplay}) { + return [{ + key: 'options', + value: options + }, + { + key: 'deleteRecover', + value: deleteRecover + }, + { + key: 'quotaNoDisplay', + value: quotaNoDisplay + }] + } } ], editConfigure: { diff --git a/web/src/materials/questions/widgets/RadioModule/index.jsx b/web/src/materials/questions/widgets/RadioModule/index.jsx index 120fb2e0..008dc0c2 100644 --- a/web/src/materials/questions/widgets/RadioModule/index.jsx +++ b/web/src/materials/questions/widgets/RadioModule/index.jsx @@ -32,7 +32,7 @@ export default defineComponent({ type: Boolean, default: false }, - noDisplay:{ + quotaNoDisplay:{ type: Boolean, default: false } @@ -85,7 +85,7 @@ export default defineComponent({ field={this.field} layout={this.layout} onChange={this.onChange} - noDisplay={this.noDisplay} + quotaNoDisplay={this.quotaNoDisplay} > {{ selectMore: (scoped) => { diff --git a/web/src/materials/questions/widgets/RadioModule/meta.js b/web/src/materials/questions/widgets/RadioModule/meta.js index 2b47aed6..7b08ed2f 100644 --- a/web/src/materials/questions/widgets/RadioModule/meta.js +++ b/web/src/materials/questions/widgets/RadioModule/meta.js @@ -72,6 +72,19 @@ const meta = { } ] }, + // deleteRecover + { + name: 'deleteRecover', + propType: Boolean, + description: '删除后恢复选项配额', + defaultValue: false + }, + { + name: 'quotaNoDisplay', + propType: Boolean, + description: '不展示配额剩余数量', + defaultValue: false + } ], formConfig: [ basicConfig, @@ -87,9 +100,27 @@ const meta = { hidden: true }, { - key: "quotaConfig", - name: "quotaConfig", - type: "QuotaConfig", + name: 'optionQuota', + label: '选项配额', + labelStyle: { + 'font-weight': 'bold' + }, + type: 'QuotaConfig', + // 输出转换 + valueSetter({ options, deleteRecover, quotaNoDisplay}) { + return [{ + key: 'options', + value: options + }, + { + key: 'deleteRecover', + value: deleteRecover + }, + { + key: 'quotaNoDisplay', + value: quotaNoDisplay + }] + } } ], editConfigure: { diff --git a/web/src/materials/setters/widgets/QuotaConfig.vue b/web/src/materials/setters/widgets/QuotaConfig.vue index 23d6c76d..2a8dd842 100644 --- a/web/src/materials/setters/widgets/QuotaConfig.vue +++ b/web/src/materials/setters/widgets/QuotaConfig.vue @@ -1,9 +1,7 @@