From f405aaa69ac1e1707b5a1ce3edc7a52592896d6e Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Wed, 19 Mar 2025 17:09:44 +0800 Subject: [PATCH] init --- src/api/user/user.js | 9 + .../BatchData/components/ShowBatchData.vue | 349 ++++++++++++++++-- .../UserStatictis/components/PieChart.vue | 159 ++++++++ src/views/UserStatictis/index.vue | 104 ++++++ 4 files changed, 591 insertions(+), 30 deletions(-) create mode 100644 src/views/UserStatictis/components/PieChart.vue create mode 100644 src/views/UserStatictis/index.vue diff --git a/src/api/user/user.js b/src/api/user/user.js index 9bcb9d0..65e9664 100644 --- a/src/api/user/user.js +++ b/src/api/user/user.js @@ -35,3 +35,12 @@ export function destroy(params, isLoading = true) { isLoading }) } + +export function chart(params, isLoading = true) { + return request({ + method: 'get', + url: '/api/admin/user/chart', + params, + isLoading: true + }) +} diff --git a/src/views/BatchData/components/ShowBatchData.vue b/src/views/BatchData/components/ShowBatchData.vue index 1149dab..c63e002 100644 --- a/src/views/BatchData/components/ShowBatchData.vue +++ b/src/views/BatchData/components/ShowBatchData.vue @@ -10,37 +10,107 @@ > -
-

{{ detail.aspiration ? detail.aspiration.title : '' }}

- - - - - - - - - - - - - - - - - - - - - - -
+ @@ -61,7 +131,8 @@ export default { loading: false, visible: false, detail: {}, - list: [] + list: [], + taicangMergeCells: [] }; }, watch: { @@ -81,6 +152,184 @@ export default { }) } }, + formatTaiCangData(arr) { + const transformedArray = []; + arr.forEach((batch, batchIndex) => { + transformedArray.push({ + v1: batch.name??"", + v2: null, + v3: null, + v4: null, + v5: null, + colspan: [ + { + col: 0, span: 5 + } + ] + }) + batch.batchSubs.forEach(sub => { + if (batchIndex === 0) { + transformedArray.push({ + v1: sub.name??"", + v2: "学校代号、名称", + v3: "专业代号、名称", + v4: "专业代号、名称", + v5: "专业服从", + colspan: [] + }) + } else if (batchIndex === 1) { + transformedArray.push({ + v1: sub.name??"", + v2: "学校代号、名称", + v3: null, + v4: "说明", + v5: null, + colspan: [ + { + col: 1, span: 2 + }, + { + col: 3, span: 2 + } + ] + }) + } else { + transformedArray.push({ + v1: sub.name??"", + v2: "学校代号、名称", + v3: "第一专业代号、名称", + v4: "第二专业代号、名称", + v5: "专业服从", + colspan: [] + }) + } + + sub.batchSubSchools.forEach((school, schoolIndex) => { + if (batchIndex === 1) { + transformedArray.push({ + v1: school.name??"", + v2: (school.code??"") + " " + (school.value??""), + v3: null, + v4: schoolIndex === 0 ? "具有指标生资格的考生可填1所学校,在江苏省太仓高级中学(0001)、江苏省太仓高级中学娄江新城校(筹)(0002)江苏省沙溪高级中学(0003)和太仓市明德高级中学(0004)中选择。" + : + "可填一至四个志愿和一个服从志愿,在江苏省太仓高级中学(0001)、江苏省太仓高级中学娄江新城校(筹)(0002)江苏省沙溪高级中学(0003)和太仓市明德高级中学(0004)中选择。", + v5: null, + colspan: [ + { col: 1, span: 2 }, + { col: 3, span: 2, hasRowspan: true }, + ], + }) + } else { + transformedArray.push({ + v1: school.name??"", + v2: (school.code??"") + " " + (school.value??""), + v3: (school.specialties[0]?.code??"") + " " + (school.specialties[0]?.value??""), + v4: (school.specialties[1]?.code??"") + " " + (school.specialties[1]?.value??""), + v5: sub.specialtyObey ? '是' : '否', + colspan: [] + }) + } + }) + + if (sub.schoolObey) { + transformedArray.push({ + v1: '是否服从'+sub.name, + v2: sub.schoolObey ? '是' : '否', + v3: null, + v4: null, + v5: null, + colspan: [ + {}, + { col: 1, span: 4, hasRowspan: batchIndex === 1 } + ], + }) + } + }) + }) + + return transformedArray + }, + getTaicangMerge() { + // 用于存储已经合并的单元格位置 + const mergedPositions = new Set() + + this.list.forEach((row, rowIndex) => { + if (row.colspan && row.colspan.length > 0) { + row.colspan.forEach((spanItem) => { + const { col, span } = spanItem + + // 创建唯一标识符来检查是否已经合并 + const mergeKey = `${rowIndex}-${col}` + if (mergedPositions.has(mergeKey)) { + return // 跳过已经合并的单元格 + } + + // 处理整行合并的情况 + if (col === 0 && span === 5) { + this.taicangMergeCells.push({ + row: rowIndex, + col: col, + rowspan: 1, + colspan: span + }) + // 标记该行的所有列都已合并 + for (let i = 0; i < span; i++) { + mergedPositions.add(`${rowIndex}-${i}`) + } + return + } + + // 处理普通的列合并和行合并 + let rowspan = 1 + if (spanItem.hasRowspan) { + let nextRowIndex = rowIndex + 1 + while ( + nextRowIndex < this.list.length && + this.list[nextRowIndex].colspan?.some(item => + item.col === col && item.hasRowspan + ) + ) { + rowspan++ + // 标记被行合并覆盖的单元格 + for (let i = 0; i < span; i++) { + mergedPositions.add(`${nextRowIndex}-${(col + i)}`) + } + nextRowIndex++ + } + } + + // 添加合并配置 + this.taicangMergeCells.push({ + row: rowIndex, + col: col, + rowspan: rowspan, + colspan: span + }) + + // 标记当前合并的所有单元格 + for (let i = 0; i < span; i++) { + mergedPositions.add(`${rowIndex}-${(col + i)}`) + } + }) + } + }) + }, + // getTaicangMerge() { + // this.list.forEach((row, rowIndex) => { + // if (row.colspan && row.colspan.length > 0) { + // row.colspan.forEach((spanItem) => { + // const { col, span, hasRowspan } = spanItem + // + // this.taicangMergeCells.push({ + // row: rowIndex, + // col: col, + // rowspan: 1, + // colspan: span + // }) + // }) + // } + // }) + // }, formatData(arr) { const transformedArray = []; arr.forEach(batch => { @@ -131,6 +380,25 @@ export default { }); } }); + if (sub.schoolObey) { + transformedArray.push({ + name: batch.name, + batchId: batch.batchId, + batchSubs: { + name: sub.name, + batchSubId: sub.batchSubId, + batchSubSchools: { + code: null, + name: null, + value: null, + specialties: [], + batchSubSchoolId: null + }, + isSchoolObey: !sub.hasOwnProperty('notShowSchoolObey'), + schoolObey: sub.schoolObey, + } + }); + } }); }); console.log(transformedArray); @@ -143,7 +411,14 @@ export default { show_relation: ["aspiration"] }); this.detail = detail - this.list = this.formatData(detail.data) + if (this.detail.aspiration?.group === '太仓') { + this.list = this.formatTaiCangData(detail.data) + console.log(333, this.list) + this.getTaicangMerge() + console.log(444, this.taicangMergeCells) + } else { + this.list = this.formatData(detail.data) + } } catch (err) { console.error(err); } @@ -222,6 +497,12 @@ export default { row: i - (c3rowspan - 1), col: 8, rowspan: c3rowspan, colspan: 1 }); } + + if (item.batchSubs.isSchoolObey) { + mergeCells.push({ + row: i, col: 3, rowspan: 1, colspan: 7 + }) + } } console.log(mergeCells); @@ -231,6 +512,14 @@ export default { }; +