feat: 项目进展报表

This commit is contained in:
caiyuchao
2025-09-09 17:58:34 +08:00
parent 63cb66876b
commit e4e2df0402
8 changed files with 586 additions and 7 deletions

View File

@@ -0,0 +1,47 @@
import type { Dayjs } from 'dayjs';
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace ProgressApi {
/** 客户进展信息 */
export interface Progress {
id: number; // 主键
projectId?: number; // 项目ID
userId?: number; // 用户ID
parentId?: number; // 父评论ID
author?: string; // 评论人
avatar?: string; // 头像
replyUserId?: number; // 回复用户ID
replyUser?: string; // 回复用户
updateTime?: Dayjs; // 更新时间
startTime?: Dayjs; // 项目时间
depth?: number; // 评论深度
content?: string; // 评论内容
children?: Comment[]; // 子评论
projectName?: string; // 项目名称
status?: string;
serialNo?: string;
businessOwnerName?: string;
technicalOwnerAName?: string;
technicalOwnerBName?: string;
customerName?: string;
}
}
/** 查询项目进展(项目维度)分页 */
export function getProgressByProjectPage(params: PageParam) {
return requestClient.get<PageResult<ProgressApi.Progress>>(
'/license/report/progress/project-page',
{ params },
);
}
/** 查询项目进展(人员维度)分页 */
export function getProgressByStaffPage(params: PageParam) {
return requestClient.get<PageResult<ProgressApi.Progress>>(
'/license/report/progress/staff-page',
{ params },
);
}

View File

@@ -85,5 +85,10 @@
"customer": "Customer Management",
"project": "Project Management",
"license": "License Management",
"alert": "Alarm Management"
"alert": "Alarm Management",
"report": {
"base": "Report Center",
"progress": "Project Progress",
"license": "License Expire"
}
}

View File

@@ -85,5 +85,10 @@
"customer": "客户管理",
"project": "项目管理",
"license": "License管理",
"alert": "告警管理"
"alert": "告警管理",
"report": {
"base": "报表中心",
"progress": "项目进展",
"license": "License到期"
}
}

View File

@@ -258,14 +258,12 @@ export function useGridFormSchema(): VbenFormSchema[] {
allowClear: true,
api: async () => {
const data = await getSimpleUserList();
return data.map((item) => ({
label: item.nickname,
value: item.id,
}));
return data.filter((item) => item.nickname !== '管理员');
},
fieldNames: { label: 'nickname', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.label.toLowerCase().includes(input.toLowerCase()),
option.nickname.toLowerCase().includes(input.toLowerCase()),
},
},
{

View File

@@ -0,0 +1,300 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ProgressApi } from '#/api/report/progress';
import dayjs from 'dayjs';
import { getCustomerList } from '#/api/license/customer';
import { getProjectList } from '#/api/license/project';
import { getSimpleUserList } from '#/api/system/user';
import { $t } from '#/locales';
import { DICT_TYPE, getRangePickerDefaultProps } from '#/utils';
// ==================== 项目进展(项目维度) ====================
/** 列表的搜索表单 */
export function useProjectGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'customerId',
label: $t('license.customer'),
component: 'ApiSelect',
componentProps: {
api: getCustomerList,
allowClear: true,
fieldNames: { label: 'name', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.name.toLowerCase().includes(input.toLowerCase()),
},
},
{
fieldName: 'projectId',
label: $t('license.project'),
component: 'ApiSelect',
componentProps: {
api: getProjectList,
allowClear: true,
fieldNames: { label: 'name', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.name.toLowerCase().includes(input.toLowerCase()),
},
},
{
fieldName: 'serialNo',
label: 'SN',
component: 'Input',
componentProps: {
allowClear: true,
},
},
{
fieldName: 'authorId',
label: '处理人',
component: 'ApiSelect',
componentProps: {
allowClear: true,
api: async () => {
const data = await getSimpleUserList();
return data.filter((item) => item.nickname !== '管理员');
},
fieldNames: { label: 'nickname', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.nickname.toLowerCase().includes(input.toLowerCase()),
},
},
{
fieldName: 'updateTime',
label: '更新时间',
component: 'RangePicker',
defaultValue: [dayjs().subtract(7, 'days'), dayjs()],
componentProps: {
...getRangePickerDefaultProps(),
format: 'YYYY-MM-DD',
showTime: false,
},
},
];
}
/** 列表的字段 */
export function useProjectGridColumns(): VxeTableGridOptions<ProgressApi.Progress>['columns'] {
return [
{
field: 'customerName',
title: '客户名称',
showOverflow: false,
minWidth: 60,
},
{
field: 'projectName',
title: '项目名称',
showOverflow: false,
minWidth: 80,
},
{
field: 'status',
title: $t('project.status'),
minWidth: 40,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.LIC_PROJECT_STATUS },
},
},
{
field: 'serialNo',
title: 'SN',
showOverflow: false,
minWidth: 40,
},
{
field: 'businessOwnerName',
title: '业务负责人',
minWidth: 40,
},
{
field: 'technicalOwnerAName',
title: '技术负责人1',
minWidth: 40,
},
{
field: 'technicalOwnerBName',
title: '技术负责人2',
visible: false,
minWidth: 40,
},
{
field: 'startTime',
title: '项目开始时间',
minWidth: 80,
visible: false,
formatter: 'formatDateTime',
},
{
field: 'author',
title: '处理人',
minWidth: 40,
},
{
field: 'content',
title: '进展记录',
type: 'html',
showOverflow: false,
align: 'left',
// headerAlign: 'center',
minWidth: 800,
},
{
field: 'updateTime',
title: '更新时间',
minWidth: 80,
formatter: 'formatDateTime',
},
];
}
// ==================== 项目进展(项目维度) ====================
/** 列表的搜索表单 */
export function useStaffGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'authorId',
label: '处理人',
component: 'ApiSelect',
componentProps: {
allowClear: true,
api: async () => {
const data = await getSimpleUserList();
return data.filter((item) => item.nickname !== '管理员');
},
fieldNames: { label: 'nickname', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.nickname.toLowerCase().includes(input.toLowerCase()),
},
},
{
fieldName: 'customerId',
label: $t('license.customer'),
component: 'ApiSelect',
componentProps: {
api: getCustomerList,
allowClear: true,
fieldNames: { label: 'name', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.name.toLowerCase().includes(input.toLowerCase()),
},
},
{
fieldName: 'projectId',
label: $t('license.project'),
component: 'ApiSelect',
componentProps: {
api: getProjectList,
allowClear: true,
fieldNames: { label: 'name', value: 'id' },
showSearch: true,
filterOption: (input: string, option: any) =>
option.name.toLowerCase().includes(input.toLowerCase()),
},
},
{
fieldName: 'serialNo',
label: 'SN',
component: 'Input',
componentProps: {
allowClear: true,
},
},
{
fieldName: 'updateTime',
label: '更新时间',
component: 'RangePicker',
defaultValue: [dayjs().subtract(7, 'days'), dayjs()],
componentProps: {
...getRangePickerDefaultProps(),
format: 'YYYY-MM-DD',
showTime: false,
},
},
];
}
/** 列表的字段 */
export function useStaffGridColumns(): VxeTableGridOptions<ProgressApi.Progress>['columns'] {
return [
{
field: 'author',
title: '处理人',
minWidth: 40,
},
{
field: 'customerName',
title: '客户名称',
showOverflow: false,
minWidth: 60,
},
{
field: 'projectName',
title: '项目名称',
showOverflow: false,
minWidth: 80,
},
{
field: 'status',
title: $t('project.status'),
minWidth: 40,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.LIC_PROJECT_STATUS },
},
},
{
field: 'serialNo',
title: 'SN',
showOverflow: false,
minWidth: 40,
},
{
field: 'businessOwnerName',
title: '业务负责人',
minWidth: 40,
},
{
field: 'technicalOwnerAName',
title: '技术负责人1',
minWidth: 40,
},
{
field: 'technicalOwnerBName',
title: '技术负责人2',
visible: false,
minWidth: 40,
},
{
field: 'startTime',
title: '项目开始时间',
minWidth: 80,
visible: false,
formatter: 'formatDateTime',
},
{
field: 'content',
title: '进展记录',
type: 'html',
showOverflow: false,
align: 'left',
// headerAlign: 'center',
minWidth: 800,
},
{
field: 'updateTime',
title: '更新时间',
minWidth: 80,
formatter: 'formatDateTime',
},
];
}

View File

@@ -0,0 +1,30 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { Page } from '@vben/common-ui';
import { Tabs } from 'ant-design-vue';
import ProjectList from './modules/project.vue';
import StaffList from './modules/staff.vue';
const subTabsName = ref('project');
</script>
<template>
<Page auto-content-height>
<div class="card-container">
<Tabs
v-model:active-key="subTabsName"
:tab-bar-style="{ marginTop: '-10px' }"
>
<Tabs.TabPane key="project" tab="项目分组">
<ProjectList />
</Tabs.TabPane>
<Tabs.TabPane key="author" tab="人员分组">
<StaffList />
</Tabs.TabPane>
</Tabs>
</div>
</Page>
</template>

View File

@@ -0,0 +1,97 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProgressByProjectPage } from '#/api/report/progress';
import { useProjectGridColumns, useProjectGridFormSchema } from '../data';
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: useProjectGridFormSchema(),
submitOnEnter: true,
fieldMappingTime: [['updateTime', ['updateTimeStart', 'updateTimeEnd']]],
},
gridOptions: {
columns: useProjectGridColumns(),
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getProgressByProjectPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
pagerConfig: {
enabled: true,
},
exportConfig: {},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
// export: true,
},
rowConfig: {
keyField: 'id',
isHover: false,
useKey: true,
},
columnConfig: {
useKey: true,
},
border: true,
virtualXConfig: {
enabled: false,
},
virtualYConfig: {
enabled: false,
},
headerCellStyle: { backgroundColor: '#fafafa' },
spanMethod({ row, rowIndex, column, visibleData }) {
const spanFields = ['projectName', 'customerName'];
let columnField = column.field as string;
const mergeFields = [
'serialNo',
'status',
'businessOwnerName',
'technicalOwnerAName',
'technicalOwnerBName',
'startTime',
];
if (mergeFields.includes(columnField)) {
// 字段与前面的合并方式相同
columnField = 'projectName';
}
const cellValue = (row as Record<string, any>)[columnField];
if (cellValue && spanFields.includes(columnField)) {
const prevRow = visibleData[rowIndex - 1];
let nextRow = visibleData[rowIndex + 1];
if (
prevRow &&
(prevRow as Record<string, any>)[columnField] === cellValue
) {
return { rowspan: 0, colspan: 0 };
} else {
let countRowspan = 1;
while (
nextRow &&
(nextRow as Record<string, any>)[columnField] === cellValue
) {
nextRow = visibleData[++countRowspan + rowIndex];
}
if (countRowspan > 1) {
return { rowspan: countRowspan, colspan: 1 };
}
}
}
},
} as VxeTableGridOptions<any>,
});
</script>
<template>
<Grid table-title="项目进展" />
</template>

View File

@@ -0,0 +1,97 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getProgressByStaffPage } from '#/api/report/progress';
import { useStaffGridColumns, useStaffGridFormSchema } from '../data';
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: useStaffGridFormSchema(),
submitOnEnter: true,
fieldMappingTime: [['updateTime', ['updateTimeStart', 'updateTimeEnd']]],
},
gridOptions: {
columns: useStaffGridColumns(),
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getProgressByStaffPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
pagerConfig: {
enabled: true,
},
exportConfig: {},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
// export: true,
},
rowConfig: {
keyField: 'id',
isHover: false,
useKey: true,
},
columnConfig: {
useKey: true,
},
border: true,
virtualXConfig: {
enabled: false,
},
virtualYConfig: {
enabled: false,
},
headerCellStyle: { backgroundColor: '#fafafa' },
spanMethod({ row, rowIndex, column, visibleData }) {
const spanFields = ['projectName', 'customerName', 'author'];
let columnField = column.field as string;
const mergeFields = [
'serialNo',
'status',
'businessOwnerName',
'technicalOwnerAName',
'technicalOwnerBName',
'startTime',
];
if (mergeFields.includes(columnField)) {
// 字段与前面的合并方式相同
columnField = 'projectName';
}
const cellValue = (row as Record<string, any>)[columnField];
if (cellValue && spanFields.includes(columnField)) {
const prevRow = visibleData[rowIndex - 1];
let nextRow = visibleData[rowIndex + 1];
if (
prevRow &&
(prevRow as Record<string, any>)[columnField] === cellValue
) {
return { rowspan: 0, colspan: 0 };
} else {
let countRowspan = 1;
while (
nextRow &&
(nextRow as Record<string, any>)[columnField] === cellValue
) {
nextRow = visibleData[++countRowspan + rowIndex];
}
if (countRowspan > 1) {
return { rowspan: countRowspan, colspan: 1 };
}
}
}
},
} as VxeTableGridOptions<any>,
});
</script>
<template>
<Grid table-title="项目进展" />
</template>