diff --git a/superManagement/src/views/unitManage/police/assessmentCriteria/index.ts b/superManagement/src/views/unitManage/police/assessmentCriteria/index.ts index e5813a9..8b1bd57 100644 --- a/superManagement/src/views/unitManage/police/assessmentCriteria/index.ts +++ b/superManagement/src/views/unitManage/police/assessmentCriteria/index.ts @@ -7,6 +7,7 @@ import {deleteDataModal, submitSimpleFormModal} from "@/components/tsx/ModalPro. import api from "@/axios"; import {message} from "ant-design-vue"; import {dictSelectNodes} from "@/config/dict.ts"; +import {calculationMergeSpan} from "@/views/unitManage/police/assessmentRecord"; export const saveOrUpdateCkProject = (params: SaveOrUpdateCkProjectParams = { name: '', @@ -62,35 +63,7 @@ export const deleteCkProjectById = (name: string, ckProjectId: string, callback: export const ckProjectDetail = async (ckProjectId: string): Promise => { const {data} = await api.get('/assessmentCriteria/ckProjectDetail', {ckProjectId}) - - const groupRowSpan: Record = {} - const itemRowSpan: Record = {} - - data.forEach((item, index) => { - //如果第一次没有值 - if (item.ckGroupId) { - if (!groupRowSpan[item.ckGroupId]) { - groupRowSpan[item.ckGroupId] = {count: 1, firstIndex: index} - } else { - groupRowSpan[item.ckGroupId].count++; - data[index].groupRowSpan = 0 - } - } - - if (item.ckItemId) { - if (!itemRowSpan[item.ckItemId]) { - itemRowSpan[item.ckItemId] = {count: 1, firstIndex: index} - } else { - itemRowSpan[item.ckItemId].count++; - data[index].itemRowSpan = 0 - } - } - }) - - Object.values(groupRowSpan).forEach(({count, firstIndex}) => data[firstIndex].groupRowSpan = count) - - Object.values(itemRowSpan).forEach(({count, firstIndex}) => data[firstIndex].itemRowSpan = count) - + calculationMergeSpan(data) return data } diff --git a/superManagement/src/views/unitManage/police/assessmentRecord/index.tsx b/superManagement/src/views/unitManage/police/assessmentRecord/index.tsx index 0a62bbe..029dcc4 100644 --- a/superManagement/src/views/unitManage/police/assessmentRecord/index.tsx +++ b/superManagement/src/views/unitManage/police/assessmentRecord/index.tsx @@ -5,37 +5,8 @@ import {Modal, Table} from "ant-design-vue"; export const deductedDetail = async (assessmentRecord: AssessmentRecordPagerVo) => { const {data} = await api.get('/assessmentRecord/deductedDetail', {assessmentRecordId: assessmentRecord.snowFlakeId}) - const groupRowSpan: Record = {} - const itemRowSpan: Record = {} - data.forEach((item, index) => { - //如果第一次没有值 - if (item.ckGroupId) { - if (!groupRowSpan[item.ckGroupId]) { - groupRowSpan[item.ckGroupId] = {count: 1, firstIndex: index} - } else { - groupRowSpan[item.ckGroupId].count++; - data[index].groupRowSpan = 0 - } - } - - if (item.ckItemId) { - if (!itemRowSpan[item.ckItemId]) { - itemRowSpan[item.ckItemId] = {count: 1, firstIndex: index} - } else { - itemRowSpan[item.ckItemId].count++; - data[index].itemRowSpan = 0 - } - } - }) - - Object.values(groupRowSpan).forEach(({count, firstIndex}) => { - data[firstIndex].groupRowSpan = count; - }) - - Object.values(itemRowSpan).forEach(({count, firstIndex}) => { - data[firstIndex].itemRowSpan = count; - }) + calculationMergeSpan(data) const ckProjectDetailTableColumns: ColumnsType = [ { @@ -99,5 +70,37 @@ export const deductedDetail = async (assessmentRecord: AssessmentRecordPagerVo) > }) - +} + +/** + * 计算合并数值 + * @param data + */ +export const calculationMergeSpan = (data: Record[]) => { + const groupRowSpan: Record = {} + const itemRowSpan: Record = {} + + data.forEach((item, index) => { + //如果第一次没有值 + if (item.ckGroupId) { + if (!groupRowSpan[item.ckGroupId]) { + groupRowSpan[item.ckGroupId] = {count: 1, firstIndex: index} + } else { + groupRowSpan[item.ckGroupId].count++; + data[index].groupRowSpan = 0 + } + } + + if (item.ckItemId) { + if (!itemRowSpan[item.ckItemId]) { + itemRowSpan[item.ckItemId] = {count: 1, firstIndex: index} + } else { + itemRowSpan[item.ckItemId].count++; + data[index].itemRowSpan = 0 + } + } + }) + + Object.values(groupRowSpan).forEach(({count, firstIndex}) => data[firstIndex].groupRowSpan = count) + Object.values(itemRowSpan).forEach(({count, firstIndex}) => data[firstIndex].itemRowSpan = count) }