From c330e6000d8eeb1e4109c54fd9eb8f05149857fa Mon Sep 17 00:00:00 2001 From: chaorenluo <1243357953@qq.com> Date: Tue, 6 Aug 2024 17:30:12 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=8A=9F=E8=83=BD=20(#382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat:新增分页功能 * 修复type-check检查 * fix: server type-check * fix:修改服务端测试用例 * fix:修复分页bug --- .../__test/dataStatistic.controller.spec.ts | 10 +- .../__test/dataStatistic.service.spec.ts | 8 +- .../template/surveyTemplate/templateBase.json | 1 + .../__test/surveyResponse.controller.spec.ts | 15 +- .../__test/surveyResponse.service.spec.ts | 4 +- web/components.d.ts | 4 + web/src/management/config/dnd.ts | 1 + web/src/management/config/questionConfig.js | 1 + .../pages/edit/components/MaterialGroup.vue | 12 +- .../pages/edit/components/PagingWrapper.vue | 101 +++++++ .../pages/edit/components/QuestionWrapper.vue | 6 +- .../edit/modules/contentModule/buildData.js | 1 + .../modules/pagingModule/PaginationPanel.vue | 282 ++++++++++++++++++ .../modules/questionModule/PreviewPanel.vue | 19 +- .../components/QuestionCatalog.vue | 89 ++++-- .../questionModule/components/TypeList.vue | 28 +- .../edit/modules/skinModule/PreviewPanel.vue | 39 +-- web/src/management/stores/edit.ts | 256 +++++++++++++++- .../communals/widgets/SubmitButton/index.jsx | 5 +- web/src/render/pages/IndexPage.vue | 9 +- web/src/render/pages/RenderPage.vue | 27 +- web/src/render/stores/question.js | 41 ++- web/src/render/stores/survey.js | 8 +- 23 files changed, 832 insertions(+), 135 deletions(-) create mode 100644 web/src/management/pages/edit/components/PagingWrapper.vue create mode 100644 web/src/management/pages/edit/modules/pagingModule/PaginationPanel.vue diff --git a/server/src/modules/survey/__test/dataStatistic.controller.spec.ts b/server/src/modules/survey/__test/dataStatistic.controller.spec.ts index a2ca640f..5b9b5d82 100644 --- a/server/src/modules/survey/__test/dataStatistic.controller.spec.ts +++ b/server/src/modules/survey/__test/dataStatistic.controller.spec.ts @@ -106,12 +106,13 @@ describe('DataStatisticController', () => { field: 'xxx', title: 'xxx', type: 'xxx', + diffTime: 'xxx', othersCode: 'xxx', }, ], listBody: [ - { difTime: '0.5', createDate: '2024-02-11' }, - { difTime: '0.5', createDate: '2024-02-11' }, + { diffTime: '0.5', createDate: '2024-02-11' }, + { diffTime: '0.5', createDate: '2024-02-11' }, ], }; @@ -151,12 +152,13 @@ describe('DataStatisticController', () => { field: 'xxx', title: 'xxx', type: 'xxx', + diffTime: 'xxx', othersCode: 'xxx', }, ], listBody: [ - { difTime: '0.5', createDate: '2024-02-11', data123: '15200000000' }, - { difTime: '0.5', createDate: '2024-02-11', data123: '13800000000' }, + { diffTime: '0.5', createDate: '2024-02-11', data123: '15200000000' }, + { diffTime: '0.5', createDate: '2024-02-11', data123: '13800000000' }, ], }; diff --git a/server/src/modules/survey/__test/dataStatistic.service.spec.ts b/server/src/modules/survey/__test/dataStatistic.service.spec.ts index 1130364f..bf7b69bd 100644 --- a/server/src/modules/survey/__test/dataStatistic.service.spec.ts +++ b/server/src/modules/survey/__test/dataStatistic.service.spec.ts @@ -70,7 +70,7 @@ describe('DataStatisticService', () => { data413: 3, data863: '109239', }, - difTime: 21278, + diffTime: 21278, clientTime: 1710340862733.0, secretKeys: [], optionTextAndId: { @@ -197,7 +197,7 @@ describe('DataStatisticService', () => { data413_3: expect.any(String), data413: expect.any(Number), data863: expect.any(String), - difTime: expect.any(String), + diffTime: expect.any(String), createDate: expect.any(String), }), ]), @@ -220,7 +220,7 @@ describe('DataStatisticService', () => { 'U2FsdGVkX19bRmf3uEmXAJ/6zXd1Znr3cZsD5v4Nocr2v5XG1taXluz8cohFkDyH', data770: 'U2FsdGVkX18ldQMhJjFXO8aerjftZLpFnRQ4/FVcCLI=', }, - difTime: 806707, + diffTime: 806707, clientTime: 1710400229573.0, secretKeys: ['data458', 'data450', 'data405', 'data770'], optionTextAndId: { @@ -303,7 +303,7 @@ describe('DataStatisticService', () => { data458: expect.any(String), data515: expect.any(String), data770: expect.any(String), - difTime: expect.any(String), + diffTime: expect.any(String), }), ]), ); diff --git a/server/src/modules/survey/template/surveyTemplate/templateBase.json b/server/src/modules/survey/template/surveyTemplate/templateBase.json index 754c3110..24d588bf 100644 --- a/server/src/modules/survey/template/surveyTemplate/templateBase.json +++ b/server/src/modules/survey/template/surveyTemplate/templateBase.json @@ -49,6 +49,7 @@ "opacity": 100 } }, + "pagingConf":[], "logicConf": { "showLogicConf": [] } diff --git a/server/src/modules/surveyResponse/__test/surveyResponse.controller.spec.ts b/server/src/modules/surveyResponse/__test/surveyResponse.controller.spec.ts index 7ba95267..b7b1a6eb 100644 --- a/server/src/modules/surveyResponse/__test/surveyResponse.controller.spec.ts +++ b/server/src/modules/surveyResponse/__test/surveyResponse.controller.spec.ts @@ -32,11 +32,11 @@ const mockDecryptErrorBody = { 'SkyfsbS6MDvFrrxFJQDMxsvm53G3PTURktfZikJP2fKilC8wPW5ZdfX29Fixor5ldHBBNyILsDtxhbNahEbNCDw8n1wS8IIckFuQcaJtn6MLOD+h+Iuywka3ig4ecTN87RpdcfEQe7f38rSSx0zoFU8j37eojjSF7eETBSrz5m9WaNesQo4hhC6p7wmAo1jggkdbG8PVrFqrZPbkHN5jOBrzQEqdqYu9A5wHMM7nUteqlPpkiogEDYmBIccqmPdtO54y7LoPslXgXj6jNja8oVNaYlnp7UsisT+i5cuQ7lbDukEhrfpAIFRsT2IUwVlLjWHtFQm4/4I5HyvVBirTng==', 'IMn0E7R6cYCQPI497mz3x99CPA4cImAFEfIv8Q98Gm5bFcgKJX6KFYS7PF/VtIuI1leKwwNYexQy7+2HnF40by/huVugoPYnPd4pTpUdG6f1kh8EpzIir2+8P98Dcz2+NZ/khP2RIAM8nOr+KSC99TNGhuKaKQCItyLFDkr80s3zv+INieGc8wULIrGoWDJGN2KdU/jSq+hkV0QXypd81N5IyAoNhZLkZeM/FU6grGFPnGRtcDDc5W8YWVHO87VymlxPCTRawXRTDcvGIUqb3GuZfxvA7AULqbspmN9kzt3rktuZLNb2TFQDsJfqUuCmi+b28qP/G4OrT9/VAHhYKw==', ], - difTime: 806707, + diffTime: 806707, clientTime: 1710400229573, encryptType: 'rsa', sessionId: '65f2664c92862d6a9067ad18', - sign: '8c9ca8804c9d94de6055d68a1f3c423fe50c95b4bd69f809ee2da8fcd82fd960.1710400229589', + sign: '95d6ff5dd3d9ddc205cbab88defe40ebe889952961f1d60e760fa411e2cb39fe.1710400229589', }; const mockSubmitData = { @@ -45,11 +45,11 @@ const mockSubmitData = { 'SkyfsbS6MDvFrrxFJQDMxsvm53G3PTURktfZikJP2fKilC8wPW5ZdfX29Fixor5ldHBBNyILsDtxhbNahEbNCDw8n1wS8IIckFuQcaJtn6MLOD+h+Iuywka3ig4ecTN87RpdcfEQe7f38rSSx0zoFU8j37eojjSF7eETBSrz5m9WaNesQo4hhC6p7wmAo1jggkdbG8PVrFqrZPbkHN5jOBrzQEqdqYu9A5wHMM7nUteqlPpkiogEDYmBIccqmPdtO54y7LoPslXgXj6jNja8oVNaYlnp7UsisT+i5cuQ7lbDukEhrfpAIFRsT2IUwVlLjWHtFQm4/4I5HyvVBirTng==', 'IMn0E7R6cYCQPI497mz3x99CPA4cImAFEfIv8Q98Gm5bFcgKJX6KFYS7PF/VtIuI1leKwwNYexQy7+2HnF40by/huVugoPYnPd4pTpUdG6f1kh8EpzIir2+8P98Dcz2+NZ/khP2RIAM8nOr+KSC99TNGhuKaKQCItyLFDkr80s3zv+INieGc8wULIrGoWDJGN2KdU/jSq+hkV0QXypd81N5IyAoNhZLkZeM/FU6grGFPnGRtcDDc5W8YWVHO87VymlxPCTRawXRTDcvGIUqb3GuZfxvA7AULqbspmN9kzt3rktuZLNb2TFQDsJfqUuCmi+b28qP/G4OrT9/VAHhYKw==', ], - difTime: 806707, + diffTime: 806707, clientTime: 1710400229573, encryptType: 'rsa', sessionId: '65f29fc192862d6a9067ad28', - sign: '8c9ca8804c9d94de6055d68a1f3c423fe50c95b4bd69f809ee2da8fcd82fd960.1710400229589', + sign: '95d6ff5dd3d9ddc205cbab88defe40ebe889952961f1d60e760fa411e2cb39fe.1710400229589', }; const mockClientEncryptInfo = { @@ -185,7 +185,7 @@ describe('SurveyResponseController', () => { status: RECORD_STATUS.NEW, date: 1711025113146, }, - difTime: 30518, + diffTime: 30518, data: { data458: '15000000000', data515: '115019', @@ -220,7 +220,6 @@ describe('SurveyResponseController', () => { jest .spyOn(clientEncryptService, 'deleteEncryptInfo') .mockResolvedValueOnce(undefined); - const result = await controller.createResponse(reqBody, {}); expect(result).toEqual({ code: 200, msg: '提交成功' }); @@ -240,7 +239,7 @@ describe('SurveyResponseController', () => { data770: '123456@qq.com', }, clientTime: reqBody.clientTime, - difTime: reqBody.difTime, + diffTime: reqBody.diffTime, surveyId: mockResponseSchema.pageId, optionTextAndId: { data515: [ @@ -327,7 +326,7 @@ describe('SurveyResponseController', () => { const reqBody = { ...mockSubmitData, password: '123457', - sign: '4ff02062141d92d80629eae4797ba68056f29a9709cdf59bf206776fc0971c1a.1710400229589', + sign: '145595d85079af3b1fb30784177c348555f442837c051d90f57a01ce1ff53c32.1710400229589', }; jest diff --git a/server/src/modules/surveyResponse/__test/surveyResponse.service.spec.ts b/server/src/modules/surveyResponse/__test/surveyResponse.service.spec.ts index 91d9cb37..f91df266 100644 --- a/server/src/modules/surveyResponse/__test/surveyResponse.service.spec.ts +++ b/server/src/modules/surveyResponse/__test/surveyResponse.service.spec.ts @@ -33,7 +33,7 @@ describe('SurveyResponseService', () => { const surveyData = { data: {}, clientTime: new Date(), - difTime: 0, + diffTime: 0, surveyId: 'testId', surveyPath: 'testPath', optionTextAndId: {}, @@ -59,7 +59,7 @@ describe('SurveyResponseService', () => { surveyPath: surveyData.surveyPath, data: surveyData.data, clientTime: surveyData.clientTime, - difTime: surveyData.difTime, + diffTime: surveyData.diffTime, pageId: surveyData.surveyId, secretKeys: [], optionTextAndId: surveyData.optionTextAndId, diff --git a/web/components.d.ts b/web/components.d.ts index 02b54173..a7d55fc9 100644 --- a/web/components.d.ts +++ b/web/components.d.ts @@ -17,6 +17,7 @@ declare module 'vue' { ElDialog: typeof import('element-plus/es')['ElDialog'] ElForm: typeof import('element-plus/es')['ElForm'] ElFormItem: typeof import('element-plus/es')['ElFormItem'] + ElIcon: typeof import('element-plus/es')['ElIcon'] ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElMenu: typeof import('element-plus/es')['ElMenu'] @@ -42,6 +43,8 @@ declare module 'vue' { ElTimePicker: typeof import('element-plus/es')['ElTimePicker'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTree: typeof import('element-plus/es')['ElTree'] + IEpArrowLeft: typeof import('~icons/ep/arrow-left')['default'] + IEpArrowRight: typeof import('~icons/ep/arrow-right')['default'] IEpBottom: typeof import('~icons/ep/bottom')['default'] IEpCheck: typeof import('~icons/ep/check')['default'] IEpCirclePlus: typeof import('~icons/ep/circle-plus')['default'] @@ -54,6 +57,7 @@ declare module 'vue' { IEpMinus: typeof import('~icons/ep/minus')['default'] IEpMonitor: typeof import('~icons/ep/monitor')['default'] IEpMore: typeof import('~icons/ep/more')['default'] + IEpMoreFilled: typeof import('~icons/ep/more-filled')['default'] IEpPlus: typeof import('~icons/ep/plus')['default'] IEpQuestionFilled: typeof import('~icons/ep/question-filled')['default'] IEpRank: typeof import('~icons/ep/rank')['default'] diff --git a/web/src/management/config/dnd.ts b/web/src/management/config/dnd.ts index e704e2ed..1a74ec1f 100644 --- a/web/src/management/config/dnd.ts +++ b/web/src/management/config/dnd.ts @@ -1 +1,2 @@ export const DND_GROUP = 'question' +export const QUESTION_CATALOG = 'questionCatalog' diff --git a/web/src/management/config/questionConfig.js b/web/src/management/config/questionConfig.js index b6964730..16604a35 100644 --- a/web/src/management/config/questionConfig.js +++ b/web/src/management/config/questionConfig.js @@ -53,6 +53,7 @@ export const defaultQuestionConfig = { star: 5, optionOrigin: '', originType: 'selected', + innerType:'', matrixOptionsRely: '', numberRange: { min: { diff --git a/web/src/management/pages/edit/components/MaterialGroup.vue b/web/src/management/pages/edit/components/MaterialGroup.vue index f1decd92..ebdb9329 100644 --- a/web/src/management/pages/edit/components/MaterialGroup.vue +++ b/web/src/management/pages/edit/components/MaterialGroup.vue @@ -14,8 +14,9 @@ :ref="`questionWrapper-${element.field}`" :moduleConfig="element" :qIndex="element.qIndex" + :isFirst="index==0" :indexNumber="element.indexNumber" - :isSelected="currentEditOne === index" + :isSelected="currentEditOne === element.qIndex" :isLast="index + 1 === questionDataList.length" @select="handleSelect" @changeSeq="handleChangeSeq" @@ -24,7 +25,7 @@ :type="element.type" :moduleConfig="element" :indexNumber="element.indexNumber" - :isSelected="currentEditOne === index" + :isSelected="currentEditOne === element.qIndex" :readonly="true" @change="handleChange" > @@ -39,7 +40,6 @@ import { useEditStore } from '@/management/stores/edit' import QuestionContainerB from '@/materials/questions/QuestionContainerB' import QuestionWrapper from '@/management/pages/edit/components/QuestionWrapper.vue' import draggable from 'vuedraggable' -import { filterQuestionPreviewData } from '@/management/utils/index' import { DND_GROUP } from '@/management/config/dnd' export default defineComponent({ @@ -60,15 +60,15 @@ export default defineComponent({ } } }, - emits: ['change', 'select', 'changeSeq'], + emits: ['change', 'select', 'changeSeq','change'], setup(props, { emit }) { const editStore = useEditStore() const renderData = computed({ get() { - return filterQuestionPreviewData(props.questionDataList) + return props.questionDataList; //filterQuestionPreviewData(props.questionDataList) }, set(value) { - editStore.setQuestionDataList(value) + editStore.moveQuestionDataList(value) } }) const handleSelect = (index) => { diff --git a/web/src/management/pages/edit/components/PagingWrapper.vue b/web/src/management/pages/edit/components/PagingWrapper.vue new file mode 100644 index 00000000..b4a35a45 --- /dev/null +++ b/web/src/management/pages/edit/components/PagingWrapper.vue @@ -0,0 +1,101 @@ + + + + diff --git a/web/src/management/pages/edit/components/QuestionWrapper.vue b/web/src/management/pages/edit/components/QuestionWrapper.vue index dea0b0ff..6b03f5ad 100644 --- a/web/src/management/pages/edit/components/QuestionWrapper.vue +++ b/web/src/management/pages/edit/components/QuestionWrapper.vue @@ -51,6 +51,10 @@ const props = defineProps({ type: Boolean, default: false }, + isFirst: { + type: Boolean, + default: false + }, isLast: { type: Boolean, default: false @@ -81,7 +85,7 @@ const showHover = computed(() => { return isHover.value || props.isSelected }) const showUp = computed(() => { - return props.qIndex !== 0 + return !props.isFirst }) const showDown = computed(() => { return !props.isLast diff --git a/web/src/management/pages/edit/modules/contentModule/buildData.js b/web/src/management/pages/edit/modules/contentModule/buildData.js index e9cd602f..c9229cc2 100644 --- a/web/src/management/pages/edit/modules/contentModule/buildData.js +++ b/web/src/management/pages/edit/modules/contentModule/buildData.js @@ -10,6 +10,7 @@ export default function (schema) { 'skinConf', 'submitConf', 'questionDataList', + "pagingConf", 'logicConf' ]) configData.dataConf = { diff --git a/web/src/management/pages/edit/modules/pagingModule/PaginationPanel.vue b/web/src/management/pages/edit/modules/pagingModule/PaginationPanel.vue new file mode 100644 index 00000000..0cfbd201 --- /dev/null +++ b/web/src/management/pages/edit/modules/pagingModule/PaginationPanel.vue @@ -0,0 +1,282 @@ + + + + \ No newline at end of file diff --git a/web/src/management/pages/edit/modules/questionModule/PreviewPanel.vue b/web/src/management/pages/edit/modules/questionModule/PreviewPanel.vue index a8ca36a2..94acb146 100644 --- a/web/src/management/pages/edit/modules/questionModule/PreviewPanel.vue +++ b/web/src/management/pages/edit/modules/questionModule/PreviewPanel.vue @@ -1,8 +1,12 @@