fix(加班申请、工作报告、我的绩效): 重构页面样式、修复一系列bug、对不合理的地方进行调整。

This commit is contained in:
dk
2026-06-22 23:07:21 +08:00
parent b1d52b852f
commit 632c123112
30 changed files with 1574 additions and 451 deletions

View File

@@ -22,6 +22,10 @@ export interface SearchField {
dateType?: 'date' | 'month'; dateType?: 'date' | 'month';
/** dateRange 字段的日期范围粒度 */ /** dateRange 字段的日期范围粒度 */
dateRangeType?: 'daterange' | 'monthrange'; dateRangeType?: 'daterange' | 'monthrange';
/** 日期面板展示格式 */
format?: string;
/** 自定义范围分隔文案 */
rangeSeparator?: string;
/** 日期字段提交格式 */ /** 日期字段提交格式 */
valueFormat?: string; valueFormat?: string;
/** 占位列数,默认 1 */ /** 占位列数,默认 1 */
@@ -36,6 +40,10 @@ export interface SearchField {
placeholder?: string; placeholder?: string;
/** select 类型的自定义选项渲染函数 */ /** select 类型的自定义选项渲染函数 */
renderOption?: (option: Option) => VNode | VNode[] | string; renderOption?: (option: Option) => VNode | VNode[] | string;
/** 值写回模型前的转换函数 */
transformValue?: (value: any) => any;
/** 从模型值解析展示值 */
resolveValue?: (value: any) => any;
} }
interface Props { interface Props {
@@ -60,6 +68,7 @@ const props = withDefaults(defineProps<Props>(), {
}); });
interface Emits { interface Emits {
(e: 'update:modelValue', value: Record<string, any>): void;
(e: 'search'): void; (e: 'search'): void;
(e: 'reset'): void; (e: 'reset'): void;
} }
@@ -122,6 +131,19 @@ function handleReset() {
function handleSearch() { function handleSearch() {
emit('search'); emit('search');
} }
function updateFieldValue(field: SearchField, value: any) {
const nextValue = field.transformValue ? field.transformValue(value) : value;
emit('update:modelValue', {
...props.modelValue,
[field.key]: nextValue
});
}
function getFieldValue(field: SearchField) {
const value = props.modelValue[field.key];
return field.resolveValue ? field.resolveValue(value) : value;
}
</script> </script>
<!-- eslint-disable vue/no-mutating-props --> <!-- eslint-disable vue/no-mutating-props -->
@@ -139,19 +161,19 @@ function handleSearch() {
<ElFormItem :label="field.label"> <ElFormItem :label="field.label">
<ElInput <ElInput
v-if="field.type === 'input'" v-if="field.type === 'input'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
<ElSelect <ElSelect
v-else-if="field.type === 'select'" v-else-if="field.type === 'select'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
> >
<ElOption v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value"> <ElOption v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value">
<template v-if="field.renderOption" #default> <template v-if="field.renderOption" #default>
@@ -161,34 +183,37 @@ function handleSearch() {
</ElSelect> </ElSelect>
<ElDatePicker <ElDatePicker
v-else-if="field.type === 'date'" v-else-if="field.type === 'date'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:type="field.dateType || 'date'" :type="field.dateType || 'date'"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
:format="field.format"
:value-format="field.valueFormat || 'YYYY-MM-DD'" :value-format="field.valueFormat || 'YYYY-MM-DD'"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
<ElDatePicker <ElDatePicker
v-else-if="field.type === 'dateRange'" v-else-if="field.type === 'dateRange'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:type="field.dateRangeType || 'daterange'" :type="field.dateRangeType || 'daterange'"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
:format="field.format"
:value-format="field.valueFormat || 'YYYY-MM-DD'" :value-format="field.valueFormat || 'YYYY-MM-DD'"
:range-separator="field.rangeSeparator || '至'"
:start-placeholder="field.dateRangeType === 'monthrange' ? '开始月份' : '开始日期'" :start-placeholder="field.dateRangeType === 'monthrange' ? '开始月份' : '开始日期'"
:end-placeholder="field.dateRangeType === 'monthrange' ? '结束月份' : '结束日期'" :end-placeholder="field.dateRangeType === 'monthrange' ? '结束月份' : '结束日期'"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
<DictSelect <DictSelect
v-else-if="field.type === 'dict'" v-else-if="field.type === 'dict'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:dict-code="field.dictCode!" :dict-code="field.dictCode!"
:placeholder="field.placeholder" :placeholder="field.placeholder"
:disabled="props.disabled" :disabled="props.disabled"
:show-remark="field.showRemark" :show-remark="field.showRemark"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
</ElFormItem> </ElFormItem>
</ElCol> </ElCol>
@@ -236,19 +261,19 @@ function handleSearch() {
<ElFormItem :label="field.label"> <ElFormItem :label="field.label">
<ElInput <ElInput
v-if="field.type === 'input'" v-if="field.type === 'input'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
<ElSelect <ElSelect
v-else-if="field.type === 'select'" v-else-if="field.type === 'select'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
> >
<ElOption v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value"> <ElOption v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value">
<template v-if="field.renderOption" #default> <template v-if="field.renderOption" #default>
@@ -258,34 +283,37 @@ function handleSearch() {
</ElSelect> </ElSelect>
<ElDatePicker <ElDatePicker
v-else-if="field.type === 'date'" v-else-if="field.type === 'date'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:type="field.dateType || 'date'" :type="field.dateType || 'date'"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
:format="field.format"
:value-format="field.valueFormat || 'YYYY-MM-DD'" :value-format="field.valueFormat || 'YYYY-MM-DD'"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
<ElDatePicker <ElDatePicker
v-else-if="field.type === 'dateRange'" v-else-if="field.type === 'dateRange'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:type="field.dateRangeType || 'daterange'" :type="field.dateRangeType || 'daterange'"
:placeholder="field.placeholder" :placeholder="field.placeholder"
clearable clearable
:disabled="props.disabled" :disabled="props.disabled"
:format="field.format"
:value-format="field.valueFormat || 'YYYY-MM-DD'" :value-format="field.valueFormat || 'YYYY-MM-DD'"
:range-separator="field.rangeSeparator || '至'"
:start-placeholder="field.dateRangeType === 'monthrange' ? '开始月份' : '开始日期'" :start-placeholder="field.dateRangeType === 'monthrange' ? '开始月份' : '开始日期'"
:end-placeholder="field.dateRangeType === 'monthrange' ? '结束月份' : '结束日期'" :end-placeholder="field.dateRangeType === 'monthrange' ? '结束月份' : '结束日期'"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
<DictSelect <DictSelect
v-else-if="field.type === 'dict'" v-else-if="field.type === 'dict'"
:model-value="props.modelValue[field.key]" :model-value="getFieldValue(field)"
:dict-code="field.dictCode!" :dict-code="field.dictCode!"
:placeholder="field.placeholder" :placeholder="field.placeholder"
:disabled="props.disabled" :disabled="props.disabled"
:show-remark="field.showRemark" :show-remark="field.showRemark"
@update:model-value="val => (props.modelValue[field.key] = val)" @update:model-value="val => updateFieldValue(field, val)"
/> />
</ElFormItem> </ElFormItem>
</ElCol> </ElCol>

View File

@@ -15,6 +15,7 @@ interface BackendUserInfoDTO {
userId: string | number; userId: string | number;
userName?: string | null; userName?: string | null;
nickname?: string | null; nickname?: string | null;
deptId?: string | number | null;
roles?: string[] | null; roles?: string[] | null;
buttons?: string[] | null; buttons?: string[] | null;
} }
@@ -61,6 +62,7 @@ function mapUserInfo(data: BackendUserInfoDTO): Api.Auth.UserInfo {
userId: String(data.userId ?? ''), userId: String(data.userId ?? ''),
userName: data.userName ?? '', userName: data.userName ?? '',
nickname: data.nickname ?? '', nickname: data.nickname ?? '',
deptId: safeStringId(data.deptId),
roles: data.roles ?? [], roles: data.roles ?? [],
buttons: data.buttons ?? [] buttons: data.buttons ?? []
}; };

View File

@@ -34,7 +34,26 @@ type OvertimeApplicationApprovalRecordResponse = Omit<
auditorUserId: StringIdResponse; auditorUserId: StringIdResponse;
}; };
type TeamOvertimeSummaryResponse = Api.OvertimeApplication.TeamOvertimeSummary; type TeamOvertimeSummaryResponse = Omit<
Api.OvertimeApplication.TeamOvertimeSummary,
'overtimeDateStart' | 'overtimeDateEnd'
> & {
overtimeDateStart?: unknown;
overtimeDateEnd?: unknown;
};
function normalizeDateText(value: unknown) {
if (value === null || value === undefined) return undefined;
const text = String(value).trim();
const commaDateMatch = text.match(/^(\d{4}),(\d{1,2}),(\d{1,2})$/);
if (commaDateMatch) {
const [, year, month, day] = commaDateMatch;
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
}
return text || undefined;
}
function normalizeBooleanFlag(value: boolean | number | string | null | undefined) { function normalizeBooleanFlag(value: boolean | number | string | null | undefined) {
if (typeof value === 'boolean') { if (typeof value === 'boolean') {
@@ -309,7 +328,14 @@ export async function fetchGetTeamOvertimeSummary(params: Api.OvertimeApplicatio
params params
}); });
return mapServiceResult(result as ServiceRequestResult<TeamOvertimeSummaryResponse>, data => data); return mapServiceResult(result as ServiceRequestResult<TeamOvertimeSummaryResponse>, data => {
if (!data) return data;
return {
...data,
overtimeDateStart: normalizeDateText(data.overtimeDateStart) || '',
overtimeDateEnd: normalizeDateText(data.overtimeDateEnd) || ''
};
});
} }
export function fetchExportOvertimeApplications(params: Api.OvertimeApplication.OvertimeApplicationSearchParams = {}) { export function fetchExportOvertimeApplications(params: Api.OvertimeApplication.OvertimeApplicationSearchParams = {}) {

View File

@@ -324,6 +324,18 @@ export function fetchGetDeptSimpleList() {
}); });
} }
/** 获取部门自身及全部子部门 */
export async function fetchGetDeptSelfAndChildren(id: string) {
const result = await request<Api.SystemManage.DeptSelfAndChildrenList>({
...safeJsonRequestConfig,
url: `${DEPT_PREFIX}/list-self-and-children`,
method: 'get',
params: { id }
});
return mapServiceResult(result as ServiceRequestResult<Api.SystemManage.DeptSelfAndChildrenList>, data => data);
}
/** 创建部门 */ /** 创建部门 */
export function fetchCreateDept(data: Api.SystemManage.SaveDeptParams) { export function fetchCreateDept(data: Api.SystemManage.SaveDeptParams) {
return request<number>({ return request<number>({
@@ -736,6 +748,18 @@ export async function fetchGetMySubordinateTree() {
); );
} }
/** 获取某用户当前生效的直属下级列表 */
export async function fetchGetDirectSubordinates(userId: string) {
const result = await request<UserSimpleResponse[]>({
...safeJsonRequestConfig,
url: `${USER_MANAGEMENT_RELATION_PREFIX}/direct-subordinates`,
method: 'get',
params: { userId }
});
return mapServiceResult(result as ServiceRequestResult<UserSimpleResponse[]>, data => data.map(normalizeUserSimple));
}
/** /**
* 获取用户管理链路详情 * 获取用户管理链路详情
* *

View File

@@ -103,8 +103,13 @@ type TeamReportPendingUserResponse = Omit<Api.WorkReport.Common.TeamReportPendin
userId: StringIdResponse; userId: StringIdResponse;
}; };
type TeamReportSummaryResponse = Omit<Api.WorkReport.Common.TeamReportSummary, 'unsubmittedUsers'> & { type TeamReportSummaryResponse = Omit<
Api.WorkReport.Common.TeamReportSummary,
'unsubmittedUsers' | 'periodStartDate' | 'periodEndDate'
> & {
unsubmittedUsers?: TeamReportPendingUserResponse[] | null; unsubmittedUsers?: TeamReportPendingUserResponse[] | null;
periodStartDate?: unknown;
periodEndDate?: unknown;
}; };
function normalizeBooleanFlag(value: boolean | number | string | null | undefined) { function normalizeBooleanFlag(value: boolean | number | string | null | undefined) {
@@ -368,6 +373,8 @@ function normalizeProjectOption(
function normalizeTeamReportSummary(response: TeamReportSummaryResponse): Api.WorkReport.Common.TeamReportSummary { function normalizeTeamReportSummary(response: TeamReportSummaryResponse): Api.WorkReport.Common.TeamReportSummary {
return { return {
...response, ...response,
periodStartDate: normalizeDateText(response.periodStartDate) ?? undefined,
periodEndDate: normalizeDateText(response.periodEndDate) ?? undefined,
unsubmittedUsers: unsubmittedUsers:
response.unsubmittedUsers?.map(item => ({ response.unsubmittedUsers?.map(item => ({
...item, ...item,

View File

@@ -14,6 +14,7 @@ declare namespace Api {
userId: string; userId: string;
userName: string; userName: string;
nickname: string; nickname: string;
deptId?: string | null;
roles: string[]; roles: string[];
buttons: string[]; buttons: string[];
} }

View File

@@ -98,11 +98,13 @@ declare namespace Api {
} }
interface TeamOvertimeSummaryParams { interface TeamOvertimeSummaryParams {
month?: string | null; overtimeDateStart?: string | null;
overtimeDateEnd?: string | null;
} }
interface TeamOvertimeSummary { interface TeamOvertimeSummary {
month: string; overtimeDateStart: string;
overtimeDateEnd: string;
totalApplicationCount: number; totalApplicationCount: number;
pendingCount: number; pendingCount: number;
approvedCount: number; approvedCount: number;

View File

@@ -98,6 +98,8 @@ declare namespace Api {
type DeptSimpleList = DeptSimple[]; type DeptSimpleList = DeptSimple[];
type DeptSelfAndChildrenList = DeptSimple[];
type DeptSearchParams = CommonType.RecordNullable<Pick<Dept, 'name' | 'orgType' | 'status'>>; type DeptSearchParams = CommonType.RecordNullable<Pick<Dept, 'name' | 'orgType' | 'status'>>;
type SaveDeptParams = Pick<Dept, 'name' | 'parentId' | 'orgType' | 'code' | 'sort' | 'status'>; type SaveDeptParams = Pick<Dept, 'name' | 'parentId' | 'orgType' | 'code' | 'sort' | 'status'>;
@@ -457,5 +459,7 @@ declare namespace Api {
/** 部门名称 */ /** 部门名称 */
deptName?: string | null; deptName?: string | null;
} }
type UserSimpleList = UserSimple[];
} }
} }

View File

@@ -78,6 +78,8 @@ declare namespace Api {
} }
interface TeamReportSummary { interface TeamReportSummary {
periodStartDate?: string | null;
periodEndDate?: string | null;
totalShouldSubmit: number; totalShouldSubmit: number;
submittedCount: number; submittedCount: number;
unsubmittedCount: number; unsubmittedCount: number;
@@ -87,7 +89,9 @@ declare namespace Api {
interface TeamReportSummaryParams { interface TeamReportSummaryParams {
reportType: ReportType; reportType: ReportType;
periodKey: string; periodKey?: string | null;
periodStartDate?: string | null;
periodEndDate?: string | null;
} }
interface TeamReportRemindParams { interface TeamReportRemindParams {

View File

@@ -130,6 +130,7 @@ declare module 'vue' {
IconMdiFolderOpen: typeof import('~icons/mdi/folder-open')['default'] IconMdiFolderOpen: typeof import('~icons/mdi/folder-open')['default']
IconMdiFolderOutline: typeof import('~icons/mdi/folder-outline')['default'] IconMdiFolderOutline: typeof import('~icons/mdi/folder-outline')['default']
IconMdiFolderPlusOutline: typeof import('~icons/mdi/folder-plus-outline')['default'] IconMdiFolderPlusOutline: typeof import('~icons/mdi/folder-plus-outline')['default']
IconMdiInformationOutline: typeof import('~icons/mdi/information-outline')['default']
IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default'] IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default']
IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default'] IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default']
IconMdiLinkVariant: typeof import('~icons/mdi/link-variant')['default'] IconMdiLinkVariant: typeof import('~icons/mdi/link-variant')['default']

View File

@@ -7,14 +7,18 @@ import {
deletePerformanceSheet, deletePerformanceSheet,
downloadPerformanceSheet, downloadPerformanceSheet,
exportPerformanceSheets, exportPerformanceSheets,
fetchGetDeptSimpleList, fetchGetDeptSelfAndChildren,
fetchGetDirectSubordinates,
fetchGetMyProfileDetail,
fetchGetMySubordinateTree, fetchGetMySubordinateTree,
fetchPerformanceSheetPage, fetchPerformanceSheetPage,
fetchPerformanceSheetStatusDict,
fetchTeamPerformanceSummary, fetchTeamPerformanceSummary,
formatToYYYYMM, formatToYYYYMM,
resendPerformanceSheet, resendPerformanceSheet,
sendPerformanceSheet sendPerformanceSheet
} from '@/service/api'; } from '@/service/api';
import { useAuthStore } from '@/store/modules/auth';
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
import { useUIPaginatedTable } from '@/hooks/common/table'; import { useUIPaginatedTable } from '@/hooks/common/table';
import SubordinateSelector from '@/components/custom/subordinate-selector.vue'; import SubordinateSelector from '@/components/custom/subordinate-selector.vue';
@@ -39,6 +43,7 @@ import {
formatDateTime, formatDateTime,
formatScore, formatScore,
getPerformanceStatusLabel, getPerformanceStatusLabel,
getPerformanceStatusOptions,
getSheetExportName, getSheetExportName,
resolvePerformanceStatusTagType resolvePerformanceStatusTagType
} from './modules/performance-shared'; } from './modules/performance-shared';
@@ -90,6 +95,7 @@ function transformPageResult(response: PerformanceSheetPageResponse, pageNo: num
} }
const { hasAuth } = useAuth(); const { hasAuth } = useAuth();
const authStore = useAuthStore();
const searchParams = reactive(createSearchParams()); const searchParams = reactive(createSearchParams());
const teamViewMode = ref<TeamViewMode>('self'); const teamViewMode = ref<TeamViewMode>('self');
const subordinateTreeLoading = ref(false); const subordinateTreeLoading = ref(false);
@@ -100,6 +106,9 @@ const teamSummary = ref<Api.Performance.Team.Summary | null>(null);
const selectedRows = ref<Api.Performance.Sheet.Sheet[]>([]); const selectedRows = ref<Api.Performance.Sheet.Sheet[]>([]);
const currentRow = ref<Api.Performance.Sheet.Sheet | null>(null); const currentRow = ref<Api.Performance.Sheet.Sheet | null>(null);
const deptOptions = ref<Array<{ label: string; value: string }>>([]); const deptOptions = ref<Array<{ label: string; value: string }>>([]);
const directSubordinateOptions = ref<Array<{ label: string; value: string }>>([]);
const statusOptions = ref<Array<{ label: string; value: string }>>([]);
const currentDeptId = ref<string>('');
const templateVisible = ref(false); const templateVisible = ref(false);
const excelVisible = ref(false); const excelVisible = ref(false);
@@ -184,8 +193,19 @@ const currentEmployeeIds = computed(() => {
return teamContext.value?.selectedUserIds ?? []; return teamContext.value?.selectedUserIds ?? [];
}); });
const resolvedEmployeeIds = computed(() => {
if (!isTeamMode.value) {
return undefined;
}
const { columns, columnChecks, data, loading, getDataByPage, mobilePagination } = useUIPaginatedTable< if (searchParams.employeeId) {
return [searchParams.employeeId];
}
return currentEmployeeIds.value;
});
const { columns, columnChecks, data, loading, getDataByPage, mobilePagination, reloadColumns } = useUIPaginatedTable<
PerformanceSheetPageResponse, PerformanceSheetPageResponse,
Api.Performance.Sheet.Sheet Api.Performance.Sheet.Sheet
>({ >({
@@ -196,18 +216,26 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
api: () => api: () =>
fetchPerformanceSheetPage({ fetchPerformanceSheetPage({
...searchParams, ...searchParams,
employeeIds: currentEmployeeIds.value employeeIds: resolvedEmployeeIds.value,
employeeId: undefined
}), }),
transform: response => transformPageResult(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10), transform: response => transformPageResult(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
onPaginationParamsChange: params => { onPaginationParamsChange: params => {
searchParams.pageNo = params.currentPage ?? 1; searchParams.pageNo = params.currentPage ?? 1;
searchParams.pageSize = params.pageSize ?? 10; searchParams.pageSize = params.pageSize ?? 10;
}, },
columns: () => [ columns: () => {
const baseColumns: UI.TableColumn<Api.Performance.Sheet.Sheet>[] = [
{ prop: 'selection', type: 'selection', width: 48 }, { prop: 'selection', type: 'selection', width: 48 },
{ prop: 'index', type: 'index', label: '序号', width: 64 }, { prop: 'index', type: 'index', label: '序号', width: 64 },
{ prop: 'periodMonth', label: '绩效月份', minWidth: 110 }, { prop: 'periodMonth', label: '绩效月份', minWidth: 110 }
{ prop: 'employeeName', label: '员工', minWidth: 110, showOverflowTooltip: true }, ];
if (isTeamMode.value) {
baseColumns.push({ prop: 'employeeName', label: '下属', minWidth: 110, showOverflowTooltip: true });
}
baseColumns.push(
{ prop: 'employeeDeptName', label: '部门', minWidth: 110, showOverflowTooltip: true }, { prop: 'employeeDeptName', label: '部门', minWidth: 110, showOverflowTooltip: true },
{ prop: 'managerName', label: '直属上级', minWidth: 110, showOverflowTooltip: true }, { prop: 'managerName', label: '直属上级', minWidth: 110, showOverflowTooltip: true },
{ {
@@ -267,7 +295,10 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
fixed: 'right', fixed: 'right',
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" /> formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
} }
] );
return baseColumns;
}
}); });
const totalCount = computed(() => mobilePagination.value.total || data.value.length); const totalCount = computed(() => mobilePagination.value.total || data.value.length);
@@ -376,7 +407,8 @@ function createExportParams(): Api.Performance.Sheet.SearchParams {
return { return {
...params, ...params,
employeeIds: currentEmployeeIds.value ?? undefined employeeIds: resolvedEmployeeIds.value ?? undefined,
employeeId: undefined
}; };
} }
@@ -507,6 +539,11 @@ async function reloadAfterMutation() {
await loadTeamSummary(); await loadTeamSummary();
} }
async function refreshPageData(page = 1) {
await reloadTable(page);
await loadTeamSummary();
}
async function loadSubordinateTree() { async function loadSubordinateTree() {
if (!canUseTeamDashboard.value) return; if (!canUseTeamDashboard.value) return;
@@ -535,22 +572,61 @@ async function loadTeamSummary() {
} }
async function loadDeptOptions() { async function loadDeptOptions() {
const { error, data: deptList } = await fetchGetDeptSimpleList(); if (!currentDeptId.value) {
currentDeptId.value = authStore.userInfo.deptId || '';
}
if (!currentDeptId.value) {
const { error, data: profileDetail } = await fetchGetMyProfileDetail({ userId: authStore.userInfo.userId });
if (!error && profileDetail?.deptId) {
currentDeptId.value = profileDetail.deptId;
}
}
if (!currentDeptId.value) {
deptOptions.value = [];
return;
}
const { error, data: deptList } = await fetchGetDeptSelfAndChildren(currentDeptId.value);
if (error || !deptList) { if (error || !deptList) {
deptOptions.value = []; deptOptions.value = [];
return; return;
} }
const options: Array<{ label: string; value: string }> = []; deptOptions.value = deptList.map(node => ({ label: node.name, value: String(node.id) }));
const walk = (nodes: Api.SystemManage.DeptSimple[]) => { }
nodes.forEach(node => {
options.push({ label: node.name, value: String(node.id) }); async function loadDirectSubordinateOptions() {
if (node.children) walk(node.children); const currentUserId = authStore.userInfo.userId;
}); if (!currentUserId) {
}; directSubordinateOptions.value = [];
walk(deptList); return;
deptOptions.value = options; }
const { error, data: userList } = await fetchGetDirectSubordinates(currentUserId);
if (error || !userList) {
directSubordinateOptions.value = [];
return;
}
directSubordinateOptions.value = userList.map(item => ({
label: item.deptName ? `${item.nickname}${item.deptName}` : item.nickname,
value: item.id
}));
}
async function loadStatusOptions() {
const { error, data: statusDict } = await fetchPerformanceSheetStatusDict();
if (error || !statusDict) {
statusOptions.value = [];
return;
}
statusOptions.value = getPerformanceStatusOptions(statusDict);
} }
async function handleTeamViewModeChange(mode: TeamViewMode) { async function handleTeamViewModeChange(mode: TeamViewMode) {
@@ -564,16 +640,19 @@ async function handleTeamViewModeChange(mode: TeamViewMode) {
selectedSubordinateUserId.value = subordinateTree.value?.userId || null; selectedSubordinateUserId.value = subordinateTree.value?.userId || null;
} }
} }
await reloadTable(1);
await loadTeamSummary();
} }
watch( watch(
() => [teamViewMode.value, selectedSubordinateUserId.value], () => [teamViewMode.value, selectedSubordinateUserId.value],
async () => { async () => {
await reloadTable(1); await refreshPageData(1);
await loadTeamSummary(); }
);
watch(
() => isTeamMode.value,
() => {
reloadColumns();
} }
); );
@@ -584,7 +663,7 @@ watch(excelVisible, isVisible => {
}); });
onMounted(async () => { onMounted(async () => {
await loadDeptOptions(); await Promise.all([loadDeptOptions(), loadDirectSubordinateOptions(), loadStatusOptions()]);
if (canUseTeamDashboard.value) { if (canUseTeamDashboard.value) {
await loadSubordinateTree(); await loadSubordinateTree();
@@ -624,8 +703,10 @@ onMounted(async () => {
<div class="my-performance-page__main"> <div class="my-performance-page__main">
<PerformanceSearch <PerformanceSearch
v-model:model="searchParams" v-model:model="searchParams"
:team-mode="isTeamMode"
:subordinate-options="subordinateOptions" :subordinate-options="subordinateOptions"
:dept-options="deptOptions" :dept-options="deptOptions"
:status-options="statusOptions"
@reset="resetSearchParams" @reset="resetSearchParams"
@search="handleSearch" @search="handleSearch"
/> />
@@ -655,7 +736,7 @@ onMounted(async () => {
</ElDropdownMenu> </ElDropdownMenu>
</template> </template>
</ElDropdown> </ElDropdown>
<ElButton v-if="canManageTemplate" plain @click="templateVisible = true"> <ElButton v-if="isTeamMode && canManageTemplate" plain @click="templateVisible = true">
<template #icon> <template #icon>
<icon-mdi-file-cog-outline class="text-icon" /> <icon-mdi-file-cog-outline class="text-icon" />
</template> </template>
@@ -700,13 +781,17 @@ onMounted(async () => {
</div> </div>
</div> </div>
<PerformanceTemplateDialog v-model:visible="templateVisible" @updated="reloadAfterMutation" /> <PerformanceTemplateDialog
v-if="templateVisible"
v-model:visible="templateVisible"
@updated="reloadAfterMutation"
/>
<PerformanceExcelEditorDrawer <PerformanceExcelEditorDrawer
v-model:visible="excelVisible" v-model:visible="excelVisible"
:row-data="currentRow" :row-data="currentRow"
:mode="excelMode" :mode="excelMode"
:subordinate-options="subordinateOptions" :subordinate-options="directSubordinateOptions"
@saved="reloadAfterMutation" @saved="reloadAfterMutation"
@saved-and-sent="reloadAfterMutation" @saved-and-sent="reloadAfterMutation"
/> />

View File

@@ -80,7 +80,7 @@ watch(visible, isVisible => {
<ElForm ref="formRef" :model="form" :rules="rules" label-position="top"> <ElForm ref="formRef" :model="form" :rules="rules" label-position="top">
<ElDescriptions :column="1" border> <ElDescriptions :column="1" border>
<ElDescriptionsItem label="绩效月份">{{ props.rowData?.periodMonth || '--' }}</ElDescriptionsItem> <ElDescriptionsItem label="绩效月份">{{ props.rowData?.periodMonth || '--' }}</ElDescriptionsItem>
<ElDescriptionsItem label="员工">{{ props.rowData?.employeeName || '--' }}</ElDescriptionsItem> <ElDescriptionsItem label="下属">{{ props.rowData?.employeeName || '--' }}</ElDescriptionsItem>
<ElDescriptionsItem label="实际得分">{{ props.rowData?.actualScoreTotal ?? '--' }}</ElDescriptionsItem> <ElDescriptionsItem label="实际得分">{{ props.rowData?.actualScoreTotal ?? '--' }}</ElDescriptionsItem>
</ElDescriptions> </ElDescriptions>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'; import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
import type { FormRules } from 'element-plus'; import type { FormRules } from 'element-plus';
import JSZip from 'jszip';
import '@univerjs/preset-sheets-core/lib/index.css'; import '@univerjs/preset-sheets-core/lib/index.css';
import { import {
createPerformanceSheet, createPerformanceSheet,
@@ -58,8 +59,9 @@ const createForm = reactive({
const createFormRules = computed<FormRules>(() => ({ const createFormRules = computed<FormRules>(() => ({
periodMonth: [createRequiredRule('请选择绩效月份')], periodMonth: [createRequiredRule('请选择绩效月份')],
employeeId: [createRequiredRule('请选择员工')] employeeId: [createRequiredRule('请选择下属')]
})); }));
const ASSESSED_EMPLOYEE_TEXT_PATTERN = /(被考核人\s*[:]\s*)(.+)/u;
let univerInstance: any = null; let univerInstance: any = null;
let univerAPI: any = null; let univerAPI: any = null;
@@ -68,6 +70,7 @@ let createUniverFn: any = null;
let UniverSheetsCorePresetFn: any = null; let UniverSheetsCorePresetFn: any = null;
let univerLocales: Record<string, unknown> | null = null; let univerLocales: Record<string, unknown> | null = null;
let excelRuntimeLoading: Promise<void> | null = null; let excelRuntimeLoading: Promise<void> | null = null;
const DEFAULT_SHEET_ZOOM_RATIO = 0.4;
const isCreateMode = computed(() => props.mode === 'create'); const isCreateMode = computed(() => props.mode === 'create');
const drawerTitle = computed(() => { const drawerTitle = computed(() => {
@@ -160,6 +163,167 @@ function transformUniverToExcel(snapshot: any, fileName: string) {
}); });
} }
async function normalizeExcelBuffer(buffer: BlobPart): Promise<ArrayBuffer> {
if (buffer instanceof ArrayBuffer) {
return buffer;
}
if (ArrayBuffer.isView(buffer)) {
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength).slice().buffer;
}
if (buffer instanceof Blob) {
return buffer.arrayBuffer();
}
throw new Error('Excel 导出结果格式不受支持');
}
function applySheetZoomRatio(snapshot: any, zoomRatio = DEFAULT_SHEET_ZOOM_RATIO) {
const data = snapshot || {};
if (data.sheets && typeof data.sheets === 'object') {
Object.values(data.sheets).forEach((sheet: any) => {
if (sheet && typeof sheet === 'object') {
sheet.zoomRatio = zoomRatio;
}
});
}
return data;
}
function replaceAssessedEmployeeText(value: string, employeeName: string) {
if (!ASSESSED_EMPLOYEE_TEXT_PATTERN.test(value)) {
return value;
}
return value.replace(ASSESSED_EMPLOYEE_TEXT_PATTERN, `$1${employeeName}`);
}
function injectAssessedEmployeeName(snapshot: any, employeeName: string) {
if (!snapshot || !employeeName) return snapshot;
const visited = new WeakSet<object>();
const walk = (target: unknown) => {
if (typeof target === 'string') {
return replaceAssessedEmployeeText(target, employeeName);
}
if (!target || typeof target !== 'object') {
return target;
}
if (visited.has(target as object)) {
return target;
}
visited.add(target as object);
if (Array.isArray(target)) {
target.forEach((item, index) => {
target[index] = walk(item);
});
return target;
}
Object.entries(target).forEach(([key, value]) => {
(target as Record<string, unknown>)[key] = walk(value);
});
return target;
};
return walk(snapshot);
}
function findFirstElementByLocalName(parent: Element | Document, localName: string) {
return Array.from(parent.childNodes).find(
node => node.nodeType === Node.ELEMENT_NODE && (node as Element).localName === localName
) as Element | undefined;
}
function ensureChildElement(document: XMLDocument, parent: Element, localName: string) {
const existing = Array.from(parent.childNodes).find(
node => node.nodeType === Node.ELEMENT_NODE && (node as Element).localName === localName
) as Element | undefined;
if (existing) return existing;
const namespace = parent.namespaceURI || document.documentElement?.namespaceURI || null;
const element = namespace ? document.createElementNS(namespace, localName) : document.createElement(localName);
parent.appendChild(element);
return element;
}
function createXmlRoot(document: XMLDocument, localName: string, namespace?: string | null) {
const root = namespace ? document.createElementNS(namespace, localName) : document.createElement(localName);
document.appendChild(root);
return root;
}
function applyWorksheetZoomXml(xmlText: string, zoomScale: number) {
const document = new DOMParser().parseFromString(xmlText, 'application/xml');
const root =
document.documentElement && document.documentElement.localName !== 'parsererror'
? document.documentElement
: createXmlRoot(document, 'worksheet', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
const sheetViews = ensureChildElement(document, root, 'sheetViews');
const sheetView =
findFirstElementByLocalName(sheetViews, 'sheetView') || ensureChildElement(document, sheetViews, 'sheetView');
sheetView.setAttribute('workbookViewId', sheetView.getAttribute('workbookViewId') || '0');
sheetView.setAttribute('zoomScale', String(zoomScale));
sheetView.setAttribute('zoomScaleNormal', String(zoomScale));
sheetView.setAttribute('zoomScalePageLayoutView', String(zoomScale));
return new XMLSerializer().serializeToString(document);
}
function applyWorkbookZoomXml(xmlText: string, zoomScale: number) {
const document = new DOMParser().parseFromString(xmlText, 'application/xml');
const root =
document.documentElement && document.documentElement.localName !== 'parsererror'
? document.documentElement
: createXmlRoot(document, 'workbook', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
const bookViews = ensureChildElement(document, root, 'bookViews');
const workbookView =
findFirstElementByLocalName(bookViews, 'workbookView') || ensureChildElement(document, bookViews, 'workbookView');
workbookView.setAttribute('zoomScale', String(zoomScale));
workbookView.setAttribute('zoomScaleNormal', String(zoomScale));
return new XMLSerializer().serializeToString(document);
}
async function applyExcelZoomMetadata(buffer: BlobPart, zoomRatio = DEFAULT_SHEET_ZOOM_RATIO) {
const zoomScale = Math.max(10, Math.min(400, Math.round(zoomRatio * 100)));
const zip = await JSZip.loadAsync(await normalizeExcelBuffer(buffer));
const worksheetPaths = Object.keys(zip.files).filter(path => /^xl\/worksheets\/sheet\d+\.xml$/u.test(path));
await Promise.all(
worksheetPaths.map(async path => {
const entry = zip.file(path);
if (!entry) return;
const xmlText = await entry.async('string');
zip.file(path, applyWorksheetZoomXml(xmlText, zoomScale));
})
);
const workbookEntry = zip.file('xl/workbook.xml');
if (workbookEntry) {
const workbookXml = await workbookEntry.async('string');
zip.file('xl/workbook.xml', applyWorkbookZoomXml(workbookXml, zoomScale));
}
return zip.generateAsync({ type: 'arraybuffer' });
}
function createWorkbook(snapshot: any) { function createWorkbook(snapshot: any) {
if (!containerRef.value) return; if (!containerRef.value) return;
@@ -185,15 +349,8 @@ function createWorkbook(snapshot: any) {
throw new Error('Univer 工作簿初始化失败'); throw new Error('Univer 工作簿初始化失败');
} }
// 在 snapshot 数据中预设缩放比例 40%,避免调用不可用的 zoom API // 在 snapshot 数据中预设缩放比例,保证在线查看和导出文件使用同一套缩放值
const data = snapshot || {}; const data = applySheetZoomRatio(snapshot);
if (data.sheets) {
Object.values(data.sheets).forEach((sheet: any) => {
if (sheet && typeof sheet === 'object') {
sheet.zoomRatio = 0.4;
}
});
}
univer.createUnit(unitType, data); univer.createUnit(unitType, data);
} }
@@ -251,6 +408,15 @@ function getCreateEmployeeName() {
return props.subordinateOptions.find(opt => opt.value === createForm.employeeId)?.label || ''; return props.subordinateOptions.find(opt => opt.value === createForm.employeeId)?.label || '';
} }
function applyCreateEmployeeName(snapshot: any) {
if (!isCreateMode.value) return snapshot;
const employeeName = getCreateEmployeeName();
if (!employeeName) return snapshot;
return injectAssessedEmployeeName(snapshot, employeeName);
}
function createInitialFileName() { function createInitialFileName() {
const sheet = currentSheet.value; const sheet = currentSheet.value;
if (sheet) { if (sheet) {
@@ -317,7 +483,7 @@ async function loadWorkbook() {
}); });
const snapshot = await transformExcelToUniver(file); const snapshot = await transformExcelToUniver(file);
await nextTick(); await nextTick();
createWorkbook(snapshot); createWorkbook(applyCreateEmployeeName(snapshot));
} catch (error) { } catch (error) {
errorMessage.value = error instanceof Error ? error.message : 'Excel 解析失败'; errorMessage.value = error instanceof Error ? error.message : 'Excel 解析失败';
} finally { } finally {
@@ -331,7 +497,7 @@ async function ensureCreatedSheet() {
} }
if (!createForm.periodMonth || !createForm.employeeId) { if (!createForm.periodMonth || !createForm.employeeId) {
throw new Error('请先填写绩效月份和员工'); throw new Error('请先填写绩效月份和下属');
} }
const createResult = await createPerformanceSheet({ const createResult = await createPerformanceSheet({
@@ -373,10 +539,11 @@ async function executeSave(): Promise<Api.Performance.Sheet.Sheet | null> {
await ensureExcelRuntime(); await ensureExcelRuntime();
const sheet = await ensureCreatedSheet(); const sheet = await ensureCreatedSheet();
const snapshot = workbook.save(); const snapshot = applySheetZoomRatio(workbook.save());
const fileName = createInitialFileName(); const fileName = createInitialFileName();
const buffer = await transformUniverToExcel(snapshot, fileName); const buffer = await transformUniverToExcel(snapshot, fileName);
const file = new File([buffer], fileName, { const excelBuffer = await applyExcelZoomMetadata(buffer);
const file = new File([excelBuffer], fileName, {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
}); });
const uploadResult = await uploadFile(file, `performance/sheets/${sheet.periodMonth}`); const uploadResult = await uploadFile(file, `performance/sheets/${sheet.periodMonth}`);
@@ -451,6 +618,22 @@ watch(visible, async isVisible => {
await loadWorkbook(); await loadWorkbook();
}); });
watch(
() => createForm.employeeId,
async (employeeId, previousEmployeeId) => {
if (!visible.value || !isCreateMode.value || !employeeId || employeeId === previousEmployeeId) {
return;
}
const workbook = getActiveWorkbook();
if (!workbook) return;
const snapshot = workbook.save();
await nextTick();
createWorkbook(applyCreateEmployeeName(snapshot));
}
);
onBeforeUnmount(() => { onBeforeUnmount(() => {
window.removeEventListener('resize', syncViewportWidth); window.removeEventListener('resize', syncViewportWidth);
disposeUniver(); disposeUniver();
@@ -483,8 +666,8 @@ onMounted(() => {
placeholder="选择绩效月份" placeholder="选择绩效月份"
/> />
</ElFormItem> </ElFormItem>
<ElFormItem label="员工" prop="employeeId" class="performance-excel-editor__form-item"> <ElFormItem label="下属" prop="employeeId" class="performance-excel-editor__form-item">
<ElSelect v-model="createForm.employeeId" filterable placeholder="选择员工" style="width: 200px"> <ElSelect v-model="createForm.employeeId" filterable placeholder="选择下属" style="width: 200px">
<ElOption v-for="opt in props.subordinateOptions" :key="opt.value" :label="opt.label" :value="opt.value" /> <ElOption v-for="opt in props.subordinateOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</ElSelect> </ElSelect>
</ElFormItem> </ElFormItem>

View File

@@ -38,7 +38,7 @@ watch(visible, isVisible => {
<template> <template>
<BusinessFormDialog <BusinessFormDialog
v-model="visible" v-model="visible"
title="员工反馈历史" title="下属反馈历史"
preset="lg" preset="lg"
append-to-body append-to-body
:show-footer="false" :show-footer="false"

View File

@@ -2,7 +2,6 @@
import { computed } from 'vue'; import { computed } from 'vue';
import type { SearchField } from '@/components/custom/table-search-fields.vue'; import type { SearchField } from '@/components/custom/table-search-fields.vue';
import TableSearchFields from '@/components/custom/table-search-fields.vue'; import TableSearchFields from '@/components/custom/table-search-fields.vue';
import { performanceStatusOptions } from './performance-shared';
defineOptions({ name: 'PerformanceSearch' }); defineOptions({ name: 'PerformanceSearch' });
@@ -12,13 +11,17 @@ interface Option {
} }
interface Props { interface Props {
teamMode?: boolean;
subordinateOptions?: Option[]; subordinateOptions?: Option[];
deptOptions?: Option[]; deptOptions?: Option[];
statusOptions?: Option[];
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
teamMode: false,
subordinateOptions: () => [], subordinateOptions: () => [],
deptOptions: () => [] deptOptions: () => [],
statusOptions: () => []
}); });
const model = defineModel<Api.Performance.Sheet.SearchParams>('model', { required: true }); const model = defineModel<Api.Performance.Sheet.SearchParams>('model', { required: true });
@@ -28,7 +31,7 @@ const emit = defineEmits<{
search: []; search: [];
}>(); }>();
const fields = computed<SearchField[]>(() => [ const baseFields = computed<SearchField[]>(() => [
{ {
key: 'periodMonthRange', key: 'periodMonthRange',
label: '绩效月份', label: '绩效月份',
@@ -37,11 +40,18 @@ const fields = computed<SearchField[]>(() => [
valueFormat: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD',
placeholder: '选择月份区间' placeholder: '选择月份区间'
}, },
{ key: 'employeeId', label: '员工', type: 'select', placeholder: '请选择员工', options: props.subordinateOptions }, { key: 'statusCode', label: '状态', type: 'select', placeholder: '请选择状态', options: props.statusOptions }
]);
const teamFields = computed<SearchField[]>(() => [
baseFields.value[0],
{ key: 'employeeId', label: '下属', type: 'select', placeholder: '请选择下属', options: props.subordinateOptions },
{ key: 'employeeDeptId', label: '部门', type: 'select', placeholder: '请选择部门', options: props.deptOptions }, { key: 'employeeDeptId', label: '部门', type: 'select', placeholder: '请选择部门', options: props.deptOptions },
{ key: 'managerName', label: '直属上级', type: 'input', placeholder: '请输入直属上级' }, { key: 'managerName', label: '直属上级', type: 'input', placeholder: '请输入直属上级' },
{ key: 'statusCode', label: '状态', type: 'select', placeholder: '请选择状态', options: performanceStatusOptions } baseFields.value[1]
]); ]);
const fields = computed<SearchField[]>(() => (props.teamMode ? teamFields.value : baseFields.value));
</script> </script>
<template> <template>

View File

@@ -30,6 +30,19 @@ export const performanceStatusOptions: Array<{
{ label: '已退回', value: 'rejected' } { label: '已退回', value: 'rejected' }
]; ];
export function getPerformanceStatusOptions(
statusList: Api.Performance.Sheet.StatusDict[] = []
): Array<{ label: string; value: string }> {
if (!statusList.length) {
return performanceStatusOptions.map(item => ({ ...item, value: String(item.value) }));
}
return statusList.map(item => ({
label: item.statusName,
value: String(item.statusCode)
}));
}
export const performanceActionNameMap: Record<string, string> = { export const performanceActionNameMap: Record<string, string> = {
send: '发送', send: '发送',
resend: '重新发送', resend: '重新发送',

View File

@@ -25,8 +25,16 @@ const remindingKey = ref('');
const deptOrgAverageCount = computed(() => props.summary?.deptOrgAverages?.length ?? 0); const deptOrgAverageCount = computed(() => props.summary?.deptOrgAverages?.length ?? 0);
const periodLabel = computed(() => {
const start = props.periodMonthStart;
const end = props.periodMonthEnd;
if (!start) return '';
if (!end || start === end) return start;
return `${start}${end}`;
});
const cards = computed(() => [ const cards = computed(() => [
{ label: '本月绩效表总数', value: props.summary?.totalSheetCount ?? 0 }, { label: '绩效表总数', value: props.summary?.totalSheetCount ?? 0 },
{ label: '待发送数', value: props.summary?.pendingSendCount ?? 0, key: 'pending_send' as const }, { label: '待发送数', value: props.summary?.pendingSendCount ?? 0, key: 'pending_send' as const },
{ label: '待确认数', value: props.summary?.pendingConfirmCount ?? 0, key: 'pending_confirm' as const }, { label: '待确认数', value: props.summary?.pendingConfirmCount ?? 0, key: 'pending_confirm' as const },
{ label: '已确认率', value: `${props.summary?.confirmedRate ?? '0.00'}%` }, { label: '已确认率', value: `${props.summary?.confirmedRate ?? '0.00'}%` },
@@ -55,6 +63,7 @@ async function handleRemind(type: Api.Performance.Common.RemindType, userIds?: s
<template> <template>
<div v-loading="props.loading" class="performance-summary"> <div v-loading="props.loading" class="performance-summary">
<div v-if="periodLabel" class="performance-summary__period">{{ periodLabel }}</div>
<div class="performance-summary__grid"> <div class="performance-summary__grid">
<div v-for="card in cards" :key="card.label" class="performance-summary__item"> <div v-for="card in cards" :key="card.label" class="performance-summary__item">
<div class="performance-summary__label">{{ card.label }}</div> <div class="performance-summary__label">{{ card.label }}</div>
@@ -194,6 +203,11 @@ async function handleRemind(type: Api.Performance.Common.RemindType, userIds?: s
gap: 12px; gap: 12px;
} }
.performance-summary__period {
color: var(--el-text-color-secondary);
font-size: 12px;
}
.performance-summary__grid { .performance-summary__grid {
display: grid; display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-columns: repeat(5, minmax(0, 1fr));

View File

@@ -9,9 +9,10 @@ import {
uploadPerformanceTemplate uploadPerformanceTemplate
} from '@/service/api'; } from '@/service/api';
import { useUIPaginatedTable } from '@/hooks/common/table'; import { useUIPaginatedTable } from '@/hooks/common/table';
import { useAuth } from '@/hooks/business/auth';
import BusinessFormDialog from '@/components/custom/business-form-dialog.vue'; import BusinessFormDialog from '@/components/custom/business-form-dialog.vue';
import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell'; import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell';
import { formatDateTime } from './performance-shared'; import { PerformancePermission, formatDateTime } from './performance-shared';
defineOptions({ name: 'PerformanceTemplateDialog' }); defineOptions({ name: 'PerformanceTemplateDialog' });
@@ -22,6 +23,9 @@ const emit = defineEmits<{
}>(); }>();
type TemplatePageResponse = Awaited<ReturnType<typeof fetchPerformanceTemplatePage>>; type TemplatePageResponse = Awaited<ReturnType<typeof fetchPerformanceTemplatePage>>;
const { hasAuth } = useAuth();
const canQueryTemplate = computed(() => hasAuth(PerformancePermission.TemplateQuery));
const canUpdateTemplate = computed(() => hasAuth(PerformancePermission.TemplateUpdate));
const searchParams = reactive<Api.Performance.Template.SearchParams>({ const searchParams = reactive<Api.Performance.Template.SearchParams>({
pageNo: 1, pageNo: 1,
@@ -79,7 +83,7 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
prop: 'activeFlag', prop: 'activeFlag',
label: '状态', label: '状态',
width: 100, width: 100,
formatter: row => <ElTag type={row.activeFlag ? 'success' : 'info'}>{row.activeFlag ? '当前' : '历史'}</ElTag> formatter: row => <ElTag type={row.activeFlag ? 'success' : 'info'}>{row.activeFlag ? '已启用' : '已禁用'}</ElTag>
}, },
{ prop: 'uploadUserName', label: '上传人', width: 110 }, { prop: 'uploadUserName', label: '上传人', width: 110 },
{ {
@@ -101,7 +105,14 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
const selectedFileName = computed(() => uploadForm.file?.name || ''); const selectedFileName = computed(() => uploadForm.file?.name || '');
async function loadTemplatePage(page = 1) {
if (!canQueryTemplate.value) return;
await getDataByPage(page);
}
function getTemplateActions(row: Api.Performance.Template.Template): BusinessTableAction[] { function getTemplateActions(row: Api.Performance.Template.Template): BusinessTableAction[] {
if (!canUpdateTemplate.value) return [];
return [ return [
{ {
key: 'activate', key: 'activate',
@@ -125,6 +136,8 @@ function handleFileChange(file: UploadFile, _files: UploadFiles) {
} }
async function handleUploadTemplate() { async function handleUploadTemplate() {
if (!canUpdateTemplate.value) return;
if (!uploadForm.file) { if (!uploadForm.file) {
window.$message?.warning('请选择 Excel 模板文件'); window.$message?.warning('请选择 Excel 模板文件');
return; return;
@@ -159,11 +172,13 @@ async function handleUploadTemplate() {
activeFlag: true, activeFlag: true,
file: null file: null
}); });
await getDataByPage(1); await loadTemplatePage(1);
emit('updated'); emit('updated');
} }
async function handleActivate(row: Api.Performance.Template.Template) { async function handleActivate(row: Api.Performance.Template.Template) {
if (!canUpdateTemplate.value) return;
activatingId.value = row.id; activatingId.value = row.id;
const { error } = await activatePerformanceTemplate(row.id); const { error } = await activatePerformanceTemplate(row.id);
activatingId.value = ''; activatingId.value = '';
@@ -171,13 +186,13 @@ async function handleActivate(row: Api.Performance.Template.Template) {
if (error) return; if (error) return;
window.$message?.success('绩效模板已启用'); window.$message?.success('绩效模板已启用');
await getDataByPage(searchParams.pageNo ?? 1); await loadTemplatePage(searchParams.pageNo ?? 1);
emit('updated'); emit('updated');
} }
watch(visible, isVisible => { watch(visible, isVisible => {
if (isVisible) { if (isVisible && canQueryTemplate.value) {
getDataByPage(1); loadTemplatePage(1);
} }
}); });
</script> </script>
@@ -192,32 +207,59 @@ watch(visible, isVisible => {
max-body-height="76vh" max-body-height="76vh"
> >
<div class="performance-template-dialog"> <div class="performance-template-dialog">
<ElCard shadow="never"> <ElCard v-if="canUpdateTemplate" shadow="never">
<ElForm :model="uploadForm" label-position="top" class="performance-template-dialog__upload-form"> <ElForm :model="uploadForm" label-position="top" class="performance-template-dialog__upload-form">
<div class="performance-template-dialog__upload-grid"> <div class="performance-template-dialog__upload-grid">
<ElFormItem label="模板名称" class="performance-template-dialog__field"> <ElFormItem label="模板名称" class="performance-template-dialog__field">
<ElInput v-model="uploadForm.templateName" placeholder="请输入模板名称" /> <ElInput v-model="uploadForm.templateName" placeholder="请输入模板名称" />
</ElFormItem> </ElFormItem>
<ElFormItem label="Excel 文件" class="performance-template-dialog__field"> <ElFormItem class="performance-template-dialog__field">
<div class="performance-template-dialog__file-picker"> <template #label>
<div class="performance-template-dialog__label">
<span>Excel 文件</span>
</div>
</template>
<div class="performance-template-dialog__file-row">
<ElUpload <ElUpload
class="performance-template-dialog__upload-trigger"
:auto-upload="false" :auto-upload="false"
:show-file-list="false" :show-file-list="false"
accept=".xlsx,.xls" accept=".xlsx,.xls"
:limit="1" :limit="1"
:on-change="handleFileChange" :on-change="handleFileChange"
> >
<ElButton plain> <ElButton plain class="performance-template-dialog__upload-button">
<template #icon> <template #icon>
<icon-mdi-upload class="text-icon" /> <icon-mdi-upload class="text-icon" />
</template> </template>
选择文件 选择文件
</ElButton> </ElButton>
</ElUpload> </ElUpload>
<div class="performance-template-dialog__file-hint"> <div class="performance-template-dialog__file-name-wrapper">
{{ selectedFileName || '支持 .xlsx、.xls选择后会在这里显示文件名' }} <ElTooltip
:disabled="!selectedFileName"
:content="selectedFileName"
placement="top"
effect="light"
popper-class="performance-template-dialog__file-tooltip"
>
<div
class="performance-template-dialog__file-name"
:class="{ 'performance-template-dialog__file-name--placeholder': !selectedFileName }"
>
<span class="performance-template-dialog__file-name-text">
{{ selectedFileName || '未选择文件' }}
</span>
</div> </div>
</ElTooltip>
</div>
<ElTooltip placement="top" effect="light">
<template #content>支持 .xlsx.xls选择后会在这里显示文件名</template>
<button type="button" class="performance-template-dialog__hint-button" aria-label="Excel 文件说明">
<icon-mdi-information-outline />
</button>
</ElTooltip>
</div> </div>
</ElFormItem> </ElFormItem>
@@ -245,12 +287,12 @@ watch(visible, isVisible => {
</ElForm> </ElForm>
</ElCard> </ElCard>
<ElCard shadow="never" body-class="business-table-card-body"> <ElCard v-if="canQueryTemplate" shadow="never" body-class="business-table-card-body">
<template #header> <template #header>
<div class="flex items-center justify-between gap-12px"> <div class="flex items-center justify-between gap-12px">
<p class="text-16px font-600">模板列表</p> <p class="text-16px font-600">模板列表</p>
<ElSpace wrap alignment="center"> <ElSpace wrap alignment="center">
<ElButton @click="getDataByPage()"> <ElButton @click="loadTemplatePage(searchParams.pageNo ?? 1)">
<template #icon> <template #icon>
<icon-mdi-refresh class="text-icon" :class="{ 'animate-spin': loading }" /> <icon-mdi-refresh class="text-icon" :class="{ 'animate-spin': loading }" />
</template> </template>
@@ -279,6 +321,8 @@ watch(visible, isVisible => {
/> />
</div> </div>
</ElCard> </ElCard>
<ElEmpty v-if="!canQueryTemplate && !canUpdateTemplate" :image-size="80" description="当前账号没有绩效模板权限" />
</div> </div>
</BusinessFormDialog> </BusinessFormDialog>
</template> </template>
@@ -304,38 +348,122 @@ watch(visible, isVisible => {
margin-bottom: 0; margin-bottom: 0;
} }
.performance-template-dialog__field :deep(.el-form-item__label) {
display: inline-flex;
align-items: center;
min-height: 22px;
padding-bottom: 6px;
line-height: 22px;
}
.performance-template-dialog__field :deep(.el-form-item__content) {
min-height: 36px;
align-items: stretch;
width: 100%;
}
.performance-template-dialog__field--full { .performance-template-dialog__field--full {
grid-column: 1 / -1; grid-column: 1 / -1;
} }
.performance-template-dialog__file-picker { .performance-template-dialog__label {
display: grid; display: inline-flex;
gap: 10px; align-items: center;
gap: 6px;
} }
.performance-template-dialog__file-hint { .performance-template-dialog__file-row {
min-height: 40px; display: grid;
grid-template-columns: 112px minmax(0, 1fr) 24px;
align-items: stretch;
gap: 6px;
min-height: 36px;
width: 100% !important;
min-width: 0 !important;
}
.performance-template-dialog__upload-trigger {
display: block;
}
.performance-template-dialog__upload-trigger :deep(.el-upload) {
display: block;
}
.performance-template-dialog__upload-button {
width: 100%;
height: 36px;
padding: 0 12px;
}
.performance-template-dialog__file-name-wrapper {
display: block;
width: 100%;
min-width: 0;
flex: 1 1 auto;
}
.performance-template-dialog__file-name-wrapper :deep(.el-tooltip__trigger) {
display: block;
width: 100% !important;
min-width: 0 !important;
}
.performance-template-dialog__file-name {
display: flex; display: flex;
align-items: center; align-items: center;
min-width: 0;
width: 100% !important;
height: 36px;
padding: 0 12px; padding: 0 12px;
overflow: hidden; overflow: hidden;
border: 1px dashed var(--el-border-color); border: 1px solid var(--el-border-color);
border-radius: 8px; border-radius: 8px;
background: var(--el-fill-color-light); background: var(--el-fill-color-blank);
color: var(--el-text-color-secondary); color: var(--el-text-color-regular);
font-size: 12px; font-size: 13px;
line-height: 1.5; }
.performance-template-dialog__file-name-text {
display: block;
width: 100%;
overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.performance-template-dialog__file-name--placeholder {
color: var(--el-text-color-placeholder);
}
.performance-template-dialog__hint-button {
width: 24px;
height: 36px;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0;
border: none;
border-radius: 6px;
background: transparent;
color: var(--el-text-color-secondary);
cursor: pointer;
transition:
background-color 0.2s ease,
color 0.2s ease;
}
.performance-template-dialog__hint-button:hover {
background: var(--el-fill-color-light);
color: var(--el-color-primary);
}
.performance-template-dialog__switch-field { .performance-template-dialog__switch-field {
align-self: stretch; align-self: stretch;
} }
.performance-template-dialog__switch-box { .performance-template-dialog__switch-box {
height: 100%; height: 36px;
min-height: 72px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
@@ -346,6 +474,7 @@ watch(visible, isVisible => {
background: var(--el-fill-color-blank); background: var(--el-fill-color-blank);
color: var(--el-text-color-regular); color: var(--el-text-color-regular);
font-size: 13px; font-size: 13px;
line-height: 1;
} }
.performance-template-dialog__actions { .performance-template-dialog__actions {
@@ -378,7 +507,7 @@ watch(visible, isVisible => {
} }
.performance-template-dialog__switch-box { .performance-template-dialog__switch-box {
min-height: 56px; height: 36px;
} }
} }
</style> </style>

View File

@@ -45,6 +45,7 @@ function getInitSearchParams(): Api.OvertimeApplication.OvertimeApplicationSearc
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
keyword: undefined, keyword: undefined,
applicantIds: undefined,
applicantName: undefined, applicantName: undefined,
approverId: undefined, approverId: undefined,
approverName: undefined, approverName: undefined,
@@ -95,11 +96,30 @@ const ACTION_ICON_MAP = {
const canUseTeamDashboard = computed(() => hasAuth('project:overtime-application:team-dashboard')); const canUseTeamDashboard = computed(() => hasAuth('project:overtime-application:team-dashboard'));
const allSubordinateUserIds = computed(() => collectSubordinateUserIds(subordinateTree.value)); const allSubordinateUserIds = computed(() => collectSubordinateUserIds(subordinateTree.value));
const subordinateOptions = computed(() => {
const options: Array<{ label: string; value: string }> = [];
const walk = (nodes?: Api.SystemManage.MySubordinateTreeNode[] | null) => {
nodes?.forEach(node => {
options.push({ label: node.userNickname, value: node.userId });
walk(node.children ?? null);
});
};
walk(subordinateTree.value?.children ?? null);
return options;
});
const selectedSubordinateNode = computed(() => const selectedSubordinateNode = computed(() =>
findSubordinateNode(subordinateTree.value, selectedSubordinateUserId.value) findSubordinateNode(subordinateTree.value, selectedSubordinateUserId.value)
); );
const isTeamMode = computed(() => teamViewMode.value === 'team'); const isTeamMode = computed(() => teamViewMode.value === 'team');
const isRootSelected = computed(() => Boolean(isTeamMode.value && selectedSubordinateNode.value?.isRoot)); const isRootSelected = computed(() => Boolean(isTeamMode.value && selectedSubordinateNode.value?.isRoot));
const summaryPeriodLabel = computed(() => {
if (teamSummary.value?.overtimeDateStart && teamSummary.value?.overtimeDateEnd) {
return `${teamSummary.value.overtimeDateStart}${teamSummary.value.overtimeDateEnd}`;
}
return '';
});
const selectedTeamLabel = computed(() => { const selectedTeamLabel = computed(() => {
if (!isTeamMode.value) return '我自己'; if (!isTeamMode.value) return '我自己';
if (!selectedSubordinateNode.value) return '--'; if (!selectedSubordinateNode.value) return '--';
@@ -125,8 +145,19 @@ const currentApplicantIds = computed(() => {
if (isRootSelected.value) return []; if (isRootSelected.value) return [];
return teamContext.value?.selectedUserIds ?? []; return teamContext.value?.selectedUserIds ?? [];
}); });
const resolvedApplicantIds = computed(() => {
if (!isTeamMode.value) {
return undefined;
}
const { columns, columnChecks, data, loading, getDataByPage, mobilePagination } = useUIPaginatedTable< if (searchParams.applicantIds?.length) {
return searchParams.applicantIds;
}
return currentApplicantIds.value;
});
const { columns, columnChecks, data, loading, getDataByPage, mobilePagination, reloadColumns } = useUIPaginatedTable<
OvertimeApplicationPageResponse, OvertimeApplicationPageResponse,
Api.OvertimeApplication.OvertimeApplication Api.OvertimeApplication.OvertimeApplication
>({ >({
@@ -137,22 +168,29 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
api: () => api: () =>
fetchGetOvertimeApplicationPage({ fetchGetOvertimeApplicationPage({
...searchParams, ...searchParams,
applicantIds: currentApplicantIds.value applicantIds: resolvedApplicantIds.value
}), }),
transform: response => transformPageResult(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10), transform: response => transformPageResult(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
onPaginationParamsChange: params => { onPaginationParamsChange: params => {
searchParams.pageNo = params.currentPage ?? 1; searchParams.pageNo = params.currentPage ?? 1;
searchParams.pageSize = params.pageSize ?? 10; searchParams.pageSize = params.pageSize ?? 10;
}, },
columns: () => [ columns: () => {
const cols: UI.TableColumn<Api.OvertimeApplication.OvertimeApplication>[] = [
{ prop: 'index', type: 'index', label: '序号', width: 64 }, { prop: 'index', type: 'index', label: '序号', width: 64 },
...(isTeamMode.value ? [{ prop: 'applicantName', label: '申请人', minWidth: 120, showOverflowTooltip: true }] : []),
{ {
prop: 'overtimeDate', prop: 'overtimeDate',
label: '加班日期', label: '加班日期',
width: 120, width: 120,
formatter: row => formatOvertimeDate(row.overtimeDate) formatter: row => formatOvertimeDate(row.overtimeDate)
}, }
];
if (isTeamMode.value) {
cols.push({ prop: 'applicantName', label: '申请人', minWidth: 120, showOverflowTooltip: true });
}
cols.push(
{ prop: 'overtimeDuration', label: '加班时长', width: 110, showOverflowTooltip: true }, { prop: 'overtimeDuration', label: '加班时长', width: 110, showOverflowTooltip: true },
{ {
prop: 'overtimeReason', prop: 'overtimeReason',
@@ -200,7 +238,10 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
fixed: 'right', fixed: 'right',
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" /> formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
} }
] );
return cols;
}
}); });
const totalCount = computed(() => mobilePagination.value.total || data.value.length); const totalCount = computed(() => mobilePagination.value.total || data.value.length);
@@ -283,10 +324,12 @@ function resetSearchParams() {
const pageSize = searchParams.pageSize ?? 10; const pageSize = searchParams.pageSize ?? 10;
Object.assign(searchParams, getInitSearchParams(), { pageSize }); Object.assign(searchParams, getInitSearchParams(), { pageSize });
reloadTable(1); reloadTable(1);
loadTeamSummary();
} }
function handleSearch() { function handleSearch() {
reloadTable(1); reloadTable(1);
loadTeamSummary();
} }
function handleSubmitted() { function handleSubmitted() {
@@ -298,7 +341,7 @@ function createExportParams() {
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams; const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
return { return {
...params, ...params,
applicantIds: currentApplicantIds.value applicantIds: resolvedApplicantIds.value
}; };
} }
@@ -306,7 +349,7 @@ async function handleExport() {
exporting.value = true; exporting.value = true;
const { error, data: blob } = await fetchExportOvertimeApplications({ const { error, data: blob } = await fetchExportOvertimeApplications({
...createExportParams(), ...createExportParams(),
applicantIds: currentApplicantIds.value applicantIds: resolvedApplicantIds.value
}); });
exporting.value = false; exporting.value = false;
@@ -334,8 +377,16 @@ async function loadTeamSummary() {
return; return;
} }
const summaryParams: Api.OvertimeApplication.TeamOvertimeSummaryParams = {};
const dateRange = searchParams.overtimeDate;
if (dateRange?.length === 2) {
summaryParams.overtimeDateStart = dateRange[0];
summaryParams.overtimeDateEnd = dateRange[1];
}
teamSummaryLoading.value = true; teamSummaryLoading.value = true;
const { error, data: summaryData } = await fetchGetTeamOvertimeSummary(); const { error, data: summaryData } = await fetchGetTeamOvertimeSummary(summaryParams);
teamSummaryLoading.value = false; teamSummaryLoading.value = false;
teamSummary.value = error || !summaryData ? null : summaryData; teamSummary.value = error || !summaryData ? null : summaryData;
@@ -364,6 +415,13 @@ watch(
} }
); );
watch(
() => isTeamMode.value,
() => {
reloadColumns();
}
);
watch( watch(
() => isRootSelected.value, () => isRootSelected.value,
() => { () => {
@@ -383,23 +441,26 @@ watch(
@update:mode="handleTeamViewModeChange" @update:mode="handleTeamViewModeChange"
> >
<div v-if="isRootSelected" v-loading="teamSummaryLoading" class="team-overtime-summary"> <div v-if="isRootSelected" v-loading="teamSummaryLoading" class="team-overtime-summary">
<div v-if="summaryPeriodLabel" class="team-overtime-summary__period">{{ summaryPeriodLabel }}</div>
<div class="team-overtime-summary__grid">
<div class="team-overtime-summary__item"> <div class="team-overtime-summary__item">
<span class="team-overtime-summary__label">本月申请单数</span> <span class="team-overtime-summary__label">申请单数</span>
<strong class="team-overtime-summary__value">{{ teamSummary?.totalApplicationCount ?? 0 }}</strong> <strong class="team-overtime-summary__value">{{ teamSummary?.totalApplicationCount ?? 0 }}</strong>
</div> </div>
<div class="team-overtime-summary__item"> <div class="team-overtime-summary__item">
<span class="team-overtime-summary__label">本月待审批</span> <span class="team-overtime-summary__label">待审批</span>
<strong class="team-overtime-summary__value">{{ teamSummary?.pendingCount ?? 0 }}</strong> <strong class="team-overtime-summary__value">{{ teamSummary?.pendingCount ?? 0 }}</strong>
</div> </div>
<div class="team-overtime-summary__item"> <div class="team-overtime-summary__item">
<span class="team-overtime-summary__label">本月已通过</span> <span class="team-overtime-summary__label">已通过</span>
<strong class="team-overtime-summary__value">{{ teamSummary?.approvedCount ?? 0 }}</strong> <strong class="team-overtime-summary__value">{{ teamSummary?.approvedCount ?? 0 }}</strong>
</div> </div>
<div class="team-overtime-summary__item"> <div class="team-overtime-summary__item">
<span class="team-overtime-summary__label">本月已退回</span> <span class="team-overtime-summary__label">已退回</span>
<strong class="team-overtime-summary__value">{{ teamSummary?.rejectedCount ?? 0 }}</strong> <strong class="team-overtime-summary__value">{{ teamSummary?.rejectedCount ?? 0 }}</strong>
</div> </div>
</div> </div>
</div>
</TeamContextPanel> </TeamContextPanel>
<div class="overtime-application-page__content" :class="{ 'overtime-application-page__content--team': isTeamMode }"> <div class="overtime-application-page__content" :class="{ 'overtime-application-page__content--team': isTeamMode }">
@@ -412,7 +473,13 @@ watch(
</div> </div>
<div class="overtime-application-page__main"> <div class="overtime-application-page__main">
<OvertimeApplicationSearch v-model:model="searchParams" @reset="resetSearchParams" @search="handleSearch" /> <OvertimeApplicationSearch
v-model:model="searchParams"
:team-mode="isTeamMode"
:subordinate-options="subordinateOptions"
@reset="resetSearchParams"
@search="handleSearch"
/>
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body"> <ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">
<template #header> <template #header>
@@ -534,6 +601,16 @@ watch(
} }
.team-overtime-summary { .team-overtime-summary {
display: grid;
gap: 12px;
}
.team-overtime-summary__period {
color: var(--el-text-color-secondary);
font-size: 12px;
}
.team-overtime-summary__grid {
display: grid; display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px; gap: 12px;

View File

@@ -5,6 +5,21 @@ import TableSearchFields, { type SearchField } from '@/components/custom/table-s
defineOptions({ name: 'OvertimeApplicationSearch' }); defineOptions({ name: 'OvertimeApplicationSearch' });
interface Option {
label: string;
value: string | number;
}
interface Props {
teamMode?: boolean;
subordinateOptions?: Option[];
}
const props = withDefaults(defineProps<Props>(), {
teamMode: false,
subordinateOptions: () => []
});
const emit = defineEmits<{ const emit = defineEmits<{
reset: []; reset: [];
search: []; search: [];
@@ -15,7 +30,7 @@ const model = defineModel<Api.OvertimeApplication.OvertimeApplicationSearchParam
}); });
const searchModel = reactive<Record<string, any>>({ const searchModel = reactive<Record<string, any>>({
applicantName: '', applicantIds: undefined,
overtimeDate: undefined, overtimeDate: undefined,
statusCode: undefined, statusCode: undefined,
approverName: '' approverName: ''
@@ -26,11 +41,10 @@ const statusOptions = ref<Array<{ label: string; value: string }>>([]);
let syncingFromSource = false; let syncingFromSource = false;
watch( watch(
() => () => [model.value.applicantIds, model.value.overtimeDate, model.value.statusCode, model.value.approverName] as const,
[model.value.applicantName, model.value.overtimeDate, model.value.statusCode, model.value.approverName] as const, ([applicantIds, overtimeDate, statusCode, approverName]) => {
([applicantName, overtimeDate, statusCode, approverName]) => {
syncingFromSource = true; syncingFromSource = true;
searchModel.applicantName = applicantName ?? ''; searchModel.applicantIds = applicantIds;
searchModel.overtimeDate = overtimeDate; searchModel.overtimeDate = overtimeDate;
searchModel.statusCode = statusCode; searchModel.statusCode = statusCode;
searchModel.approverName = approverName ?? ''; searchModel.approverName = approverName ?? '';
@@ -40,14 +54,14 @@ watch(
); );
watch( watch(
() => () => [searchModel.applicantIds, searchModel.overtimeDate, searchModel.statusCode, searchModel.approverName] as const,
[searchModel.applicantName, searchModel.overtimeDate, searchModel.statusCode, searchModel.approverName] as const, ([applicantIds, overtimeDate, statusCode, approverName]) => {
([applicantName, overtimeDate, statusCode, approverName]) => {
if (syncingFromSource) { if (syncingFromSource) {
return; return;
} }
model.value.applicantName = applicantName?.trim() || undefined; model.value.applicantIds = applicantIds;
model.value.applicantName = undefined;
model.value.overtimeDate = overtimeDate; model.value.overtimeDate = overtimeDate;
model.value.statusCode = statusCode; model.value.statusCode = statusCode;
model.value.approverName = approverName?.trim() || undefined; model.value.approverName = approverName?.trim() || undefined;
@@ -73,13 +87,21 @@ onMounted(async () => {
await loadStatusOptions(); await loadStatusOptions();
}); });
const fields = computed<SearchField[]>(() => [ const fields = computed<SearchField[]>(() => {
const baseFields: SearchField[] = [
...(props.teamMode
? [
{ {
key: 'applicantName', key: 'applicantIds',
label: '申请人', label: '申请人',
type: 'input', type: 'select' as const,
placeholder: '请输入申请人' options: props.subordinateOptions,
}, placeholder: '请选择申请人',
transformValue: (value: string | number | null | undefined) => (value ? [value] : undefined),
resolveValue: (value: unknown) => (Array.isArray(value) ? value[0] : value)
}
]
: []),
{ {
key: 'overtimeDate', key: 'overtimeDate',
label: '加班日期', label: '加班日期',
@@ -92,14 +114,20 @@ const fields = computed<SearchField[]>(() => [
type: 'select', type: 'select',
options: statusOptions.value, options: statusOptions.value,
placeholder: '请选择状态' placeholder: '请选择状态'
}, }
{ ];
if (props.teamMode) {
baseFields.push({
key: 'approverName', key: 'approverName',
label: '审批人', label: '审批人',
type: 'input', type: 'input',
placeholder: '请输入审批人' placeholder: '请输入审批人'
});
} }
]);
return baseFields;
});
function handleReset() { function handleReset() {
emit('reset'); emit('reset');

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, onMounted, ref, watch } from 'vue'; import { type ComputedRef, type Ref, computed, nextTick, onMounted, ref, watch } from 'vue';
import { onBeforeRouteLeave } from 'vue-router'; import { onBeforeRouteLeave } from 'vue-router';
import { fetchGetMySubordinateTree, fetchGetProjectReportOwnerProjectOptions } from '@/service/api'; import { fetchGetMySubordinateTree, fetchGetProjectReportOwnerProjectOptions } from '@/service/api';
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
@@ -11,6 +11,7 @@ import {
collectSubordinateUserIds, collectSubordinateUserIds,
findSubordinateNode findSubordinateNode
} from '../shared/team-dashboard'; } from '../shared/team-dashboard';
import TeamReportSummary from './shared/components/team-report-summary.vue';
import WorkReportCreateDialog from './shared/components/create-dialog.vue'; import WorkReportCreateDialog from './shared/components/create-dialog.vue';
import WorkReportPrototypePageDialog from './shared/components/prototype-page-dialog.vue'; import WorkReportPrototypePageDialog from './shared/components/prototype-page-dialog.vue';
import WorkReportTabs from './shared/components/tabs.vue'; import WorkReportTabs from './shared/components/tabs.vue';
@@ -20,6 +21,8 @@ import {
type WorkReportType, type WorkReportType,
getWorkReportTypeDisplayLabel getWorkReportTypeDisplayLabel
} from './shared/types'; } from './shared/types';
import { formatIsoWeekRangeLabel } from './shared/utils';
import type { resolveWorkReportSummaryPeriod } from './shared/utils';
import WeeklyReportIndex from './weekly/index.vue'; import WeeklyReportIndex from './weekly/index.vue';
import WeeklyReportApprovalRecordDialog from './weekly/modules/approval-record-dialog.vue'; import WeeklyReportApprovalRecordDialog from './weekly/modules/approval-record-dialog.vue';
import MonthlyReportIndex from './monthly/index.vue'; import MonthlyReportIndex from './monthly/index.vue';
@@ -32,6 +35,12 @@ defineOptions({ name: 'PersonalCenterWorkReport' });
type PageDialogMode = 'add' | 'edit' | 'detail'; type PageDialogMode = 'add' | 'edit' | 'detail';
type ReportListExpose = { type ReportListExpose = {
reload: (page?: number) => Promise<void>; reload: (page?: number) => Promise<void>;
teamSummary: Ref<Api.WorkReport.Common.TeamReportSummary | null>;
teamSummaryLoading: Ref<boolean>;
summaryPeriod: Ref<ReturnType<typeof resolveWorkReportSummaryPeriod>>;
summaryPeriodKeys: ComputedRef<string[]>;
hasSearchedDateRange: ComputedRef<boolean>;
loadTeamSummary: () => Promise<void>;
}; };
const { hasAuth } = useAuth(); const { hasAuth } = useAuth();
@@ -67,6 +76,19 @@ const allSubordinateUserIds = computed(() => collectSubordinateUserIds(subordina
const selectedSubordinateNode = computed(() => const selectedSubordinateNode = computed(() =>
findSubordinateNode(subordinateTree.value, selectedSubordinateUserId.value) findSubordinateNode(subordinateTree.value, selectedSubordinateUserId.value)
); );
const subordinateOptions = computed(() => {
const options: Array<{ label: string; value: string }> = [];
const walk = (nodes?: Api.SystemManage.MySubordinateTreeNode[] | null) => {
nodes?.forEach(node => {
options.push({ label: node.userNickname, value: node.userId });
walk(node.children ?? null);
});
};
walk(subordinateTree.value?.children ?? null);
return options;
});
const isRootSelected = computed(() => Boolean(selectedSubordinateNode.value?.isRoot)); const isRootSelected = computed(() => Boolean(selectedSubordinateNode.value?.isRoot));
const selectedTeamLabel = computed(() => { const selectedTeamLabel = computed(() => {
if (teamViewMode.value === 'self') return '我自己'; if (teamViewMode.value === 'self') return '我自己';
@@ -118,6 +140,30 @@ function getListRef(reportType: WorkReportType) {
return weeklyRef.value; return weeklyRef.value;
} }
const activeReportRef = computed(() => getListRef(activeTab.value));
const activeTeamSummary = computed(() => activeReportRef.value?.teamSummary ?? null);
const activeTeamSummaryLoading = computed(() => activeReportRef.value?.teamSummaryLoading ?? false);
const activeSummaryPeriodKeys = computed(() => {
const activeRef = activeReportRef.value;
if (!activeRef) return [];
return activeRef.summaryPeriodKeys ?? [];
});
const activeSummaryReportType = computed<Api.WorkReport.Common.ReportType>(() => {
if (activeTab.value === 'monthly') return 'monthly';
if (activeTab.value === 'project') return 'project';
return 'weekly';
});
const activeSummaryPeriodLabel = computed(() => {
const summaryPeriod = activeReportRef.value?.summaryPeriod;
if (!summaryPeriod) return '';
if (activeTab.value === 'weekly') {
return formatIsoWeekRangeLabel(summaryPeriod.periodStartDate, summaryPeriod.periodEndDate);
}
return summaryPeriod.periodLabel ?? '';
});
async function loadProjectOptions() { async function loadProjectOptions() {
if (!canShowProjectTab.value) return; if (!canShowProjectTab.value) return;
@@ -198,6 +244,10 @@ function handleSubmitted() {
reloadReport(currentReportType.value); reloadReport(currentReportType.value);
} }
async function handleSummaryRemind() {
await activeReportRef.value?.loadTeamSummary();
}
function closeFloatingPanels() { function closeFloatingPanels() {
createVisible.value = false; createVisible.value = false;
pageDialogVisible.value = false; pageDialogVisible.value = false;
@@ -273,13 +323,24 @@ onBeforeRouteLeave(() => {
:selected-label="selectedTeamLabel" :selected-label="selectedTeamLabel"
:subordinate-count="subordinateTree?.subordinateCount || 0" :subordinate-count="subordinateTree?.subordinateCount || 0"
@update:mode="handleTeamViewModeChange" @update:mode="handleTeamViewModeChange"
>
<TeamReportSummary
v-if="isRootSelected && teamViewMode === 'team'"
:report-type="activeSummaryReportType"
:period-keys="activeSummaryPeriodKeys"
:period-label="activeSummaryPeriodLabel"
:loading="activeTeamSummaryLoading"
:summary="activeTeamSummary"
@reminded="handleSummaryRemind"
/> />
</TeamContextPanel>
<WeeklyReportIndex <WeeklyReportIndex
v-show="activeTab === 'weekly'" v-show="activeTab === 'weekly'"
ref="weeklyRef" ref="weeklyRef"
class="flex-1-hidden" class="flex-1-hidden"
:team-context="teamContext" :team-context="teamContext"
:subordinate-options="subordinateOptions"
@create="openCreate('weekly')" @create="openCreate('weekly')"
@edit="openEdit('weekly', $event)" @edit="openEdit('weekly', $event)"
@detail="openDetail('weekly', $event)" @detail="openDetail('weekly', $event)"
@@ -291,6 +352,7 @@ onBeforeRouteLeave(() => {
ref="monthlyRef" ref="monthlyRef"
class="flex-1-hidden" class="flex-1-hidden"
:team-context="teamContext" :team-context="teamContext"
:subordinate-options="subordinateOptions"
@create="openCreate('monthly')" @create="openCreate('monthly')"
@edit="openEdit('monthly', $event)" @edit="openEdit('monthly', $event)"
@detail="openDetail('monthly', $event)" @detail="openDetail('monthly', $event)"

View File

@@ -1,7 +1,8 @@
<script setup lang="tsx"> <script setup lang="tsx">
/* eslint-disable no-void */ /* eslint-disable no-void */
import { computed, markRaw, reactive, ref } from 'vue'; import { computed, markRaw, reactive, ref, watch } from 'vue';
import { ElMessageBox, ElTag } from 'element-plus'; import { ElMessageBox, ElTag } from 'element-plus';
import dayjs from 'dayjs';
import { import {
fetchDeleteMonthlyReport, fetchDeleteMonthlyReport,
fetchExportMonthlyReportContent, fetchExportMonthlyReportContent,
@@ -12,7 +13,7 @@ import {
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
import { useUIPaginatedTable } from '@/hooks/common/table'; import { useUIPaginatedTable } from '@/hooks/common/table';
import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell'; import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell';
import { type TeamViewContext, resolveTeamQueryUserIds } from '@/views/personal-center/shared/team-dashboard'; import { type TeamViewContext } from '@/views/personal-center/shared/team-dashboard';
import { import {
type WorkReportRow, type WorkReportRow,
createMonthlySearchParams, createMonthlySearchParams,
@@ -27,8 +28,7 @@ import {
resolveWorkReportStatusTagType, resolveWorkReportStatusTagType,
transformWorkReportPage transformWorkReportPage
} from '../shared/types'; } from '../shared/types';
import { resolveWorkReportSummaryPeriod } from '../shared/utils'; import { buildMonthlyPeriodFromMonth, resolveWorkReportSummaryPeriod } from '../shared/utils';
import TeamReportSummary from '../shared/components/team-report-summary.vue';
import MonthlyReportSearch from './modules/search-panel.vue'; import MonthlyReportSearch from './modules/search-panel.vue';
import IconMdiDeleteOutline from '~icons/mdi/delete-outline'; import IconMdiDeleteOutline from '~icons/mdi/delete-outline';
import IconMdiEyeOutline from '~icons/mdi/eye-outline'; import IconMdiEyeOutline from '~icons/mdi/eye-outline';
@@ -41,6 +41,7 @@ defineOptions({ name: 'MonthlyWorkReportIndex' });
const props = defineProps<{ const props = defineProps<{
teamContext?: TeamViewContext | null; teamContext?: TeamViewContext | null;
subordinateOptions?: Array<{ label: string; value: string }>;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@@ -68,8 +69,45 @@ const ACTION_ICON_MAP = {
const isTeamMode = computed(() => props.teamContext?.mode === 'team'); const isTeamMode = computed(() => props.teamContext?.mode === 'team');
const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected)); const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected));
const currentTeamReporterIds = computed(() => resolveTeamQueryUserIds(props.teamContext)); const currentTeamReporterIds = computed(() => {
if (!isTeamMode.value) {
return null;
}
if (isTeamRootSelected.value) {
return [];
}
return props.teamContext?.selectedUserIds ?? [];
});
const resolvedTeamReporterIds = computed(() => {
if (!isTeamMode.value) {
return undefined;
}
if (searchParams.reporterIds?.length) {
return searchParams.reporterIds;
}
return currentTeamReporterIds.value;
});
const reportTitle = computed(() => getWorkReportTypeDisplayLabel('monthly', isTeamMode.value)); const reportTitle = computed(() => getWorkReportTypeDisplayLabel('monthly', isTeamMode.value));
const normalizedPeriodRange = computed(() => {
const periodRange = searchParams.periodStartDate;
if (!periodRange?.length) {
return periodRange;
}
const [startDate, endDate] = periodRange;
const start = dayjs(startDate);
const end = dayjs(endDate || startDate);
if (!start.isValid() || !end.isValid()) {
return periodRange;
}
return [start.startOf('month').format('YYYY-MM-DD'), end.endOf('month').format('YYYY-MM-DD')];
});
const table = useUIPaginatedTable< const table = useUIPaginatedTable<
Awaited<ReturnType<typeof fetchGetMonthlyReportPage>>, Awaited<ReturnType<typeof fetchGetMonthlyReportPage>>,
@@ -79,17 +117,25 @@ const table = useUIPaginatedTable<
api: () => api: () =>
fetchGetMonthlyReportPage({ fetchGetMonthlyReportPage({
...searchParams, ...searchParams,
reporterIds: currentTeamReporterIds.value periodStartDate: normalizedPeriodRange.value,
reporterIds: resolvedTeamReporterIds.value
}), }),
transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10), transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
onPaginationParamsChange: params => { onPaginationParamsChange: params => {
searchParams.pageNo = params.currentPage ?? 1; searchParams.pageNo = params.currentPage ?? 1;
searchParams.pageSize = params.pageSize ?? 10; searchParams.pageSize = params.pageSize ?? 10;
}, },
columns: () => [ columns: () => {
const cols: UI.TableColumn<Api.WorkReport.Monthly.MonthlyReport>[] = [
{ prop: 'index', type: 'index', label: '序号', width: 64 }, { prop: 'index', type: 'index', label: '序号', width: 64 },
...(isTeamMode.value ? [{ prop: 'reporterName', label: '提交人', minWidth: 100, showOverflowTooltip: true }] : []), { prop: 'periodLabel', label: '月份', minWidth: 80, formatter: row => formatPeriod(row) }
{ prop: 'periodLabel', label: '月份', minWidth: 80, formatter: row => formatPeriod(row) }, ];
if (isTeamMode.value) {
cols.push({ prop: 'reporterName', label: '提交人', minWidth: 100, showOverflowTooltip: true });
}
cols.push(
{ {
prop: 'reporterDeptName', prop: 'reporterDeptName',
label: '部门', label: '部门',
@@ -120,11 +166,55 @@ const table = useUIPaginatedTable<
fixed: 'right', fixed: 'right',
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" /> formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
} }
] );
return cols;
}
}); });
// 团队统计始终使用当前周期(本月),不跟随列表第一条数据的周期 // 团队统计始终使用当前周期(本月),不跟随列表第一条数据的周期
const summaryPeriod = computed(() => resolveWorkReportSummaryPeriod('monthly')); const summaryPeriod = computed(() =>
resolveWorkReportSummaryPeriod('monthly', {
periodRange: normalizedPeriodRange.value
})
);
const summaryPeriodKeys = computed(() => {
const dateRange = normalizedPeriodRange.value;
const fallbackKey = summaryPeriod.value.periodKey;
if (!dateRange?.length) {
return fallbackKey ? [fallbackKey] : [];
}
const [startDate, endDate] = dateRange;
const start = dayjs(startDate);
const end = dayjs(endDate || startDate);
if (!start.isValid() || !end.isValid()) {
return fallbackKey ? [fallbackKey] : [];
}
const keys: string[] = [];
const endBoundary = end.endOf('month');
for (
let cursor = start.startOf('month');
cursor.isBefore(endBoundary, 'month') || cursor.isSame(endBoundary, 'month');
cursor = cursor.add(1, 'month')
) {
keys.push(buildMonthlyPeriodFromMonth(cursor).periodKey);
}
return keys;
});
const hasSearchedDateRange = computed(() => searchParams.periodStartDate?.length === 2);
watch(
() => isTeamMode.value,
() => {
table.reloadColumns();
}
);
function getRowActions(row: Api.WorkReport.Monthly.MonthlyReport): BusinessTableAction[] { function getRowActions(row: Api.WorkReport.Monthly.MonthlyReport): BusinessTableAction[] {
const actions: BusinessTableAction[] = [ const actions: BusinessTableAction[] = [
@@ -266,7 +356,8 @@ function createExportSearchParams() {
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams; const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
return { return {
...params, ...params,
reporterIds: currentTeamReporterIds.value periodStartDate: normalizedPeriodRange.value,
reporterIds: resolvedTeamReporterIds.value
}; };
} }
@@ -332,31 +423,42 @@ async function loadTeamSummary() {
return; return;
} }
const dateRange = normalizedPeriodRange.value;
const summaryParams: Api.WorkReport.Common.TeamReportSummaryParams = { reportType: 'monthly' };
if (dateRange?.length === 2) {
summaryParams.periodStartDate = dateRange[0];
summaryParams.periodEndDate = dateRange[1];
} else {
summaryParams.periodKey = summaryPeriod.value.periodKey;
}
teamSummaryLoading.value = true; teamSummaryLoading.value = true;
const { error, data } = await fetchGetTeamReportSummary({ const { error, data } = await fetchGetTeamReportSummary(summaryParams);
reportType: 'monthly',
periodKey: summaryPeriod.value.periodKey
});
teamSummaryLoading.value = false; teamSummaryLoading.value = false;
teamSummary.value = error || !data ? null : data; teamSummary.value = error || !data ? null : data;
} }
defineExpose({ reload }); defineExpose({
reload,
teamSummary,
teamSummaryLoading,
summaryPeriod,
summaryPeriodKeys,
hasSearchedDateRange,
loadTeamSummary
});
</script> </script>
<template> <template>
<div class="flex-col-stretch gap-16px overflow-hidden"> <div class="flex-col-stretch gap-16px overflow-hidden">
<MonthlyReportSearch v-model:model="searchParams" @reset="resetSearchParams" @search="handleSearch" /> <MonthlyReportSearch
v-model:model="searchParams"
<TeamReportSummary :team-mode="isTeamMode"
v-if="isTeamRootSelected" :subordinate-options="props.subordinateOptions"
report-type="monthly" @reset="resetSearchParams"
:period-key="summaryPeriod.periodKey" @search="handleSearch"
:period-label="formatPeriod(summaryPeriod)"
:loading="teamSummaryLoading"
:summary="teamSummary"
@reminded="loadTeamSummary"
/> />
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body"> <ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">

View File

@@ -4,6 +4,8 @@ import SharedWorkReportSearch from '../../shared/components/search-panel.vue';
defineOptions({ name: 'MonthlyReportSearch' }); defineOptions({ name: 'MonthlyReportSearch' });
defineProps<{ defineProps<{
teamMode?: boolean;
subordinateOptions?: Array<{ label: string; value: string }>;
projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[]; projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[];
}>(); }>();
@@ -19,6 +21,8 @@ const emit = defineEmits<{
<SharedWorkReportSearch <SharedWorkReportSearch
v-model:model="model" v-model:model="model"
report-type="monthly" report-type="monthly"
:team-mode="teamMode"
:subordinate-options="subordinateOptions"
:project-options="projectOptions" :project-options="projectOptions"
@reset="emit('reset')" @reset="emit('reset')"
@search="emit('search')" @search="emit('search')"

View File

@@ -2,6 +2,7 @@
/* eslint-disable no-void */ /* eslint-disable no-void */
import { computed, markRaw, reactive, ref } from 'vue'; import { computed, markRaw, reactive, ref } from 'vue';
import { ElMessageBox, ElTag } from 'element-plus'; import { ElMessageBox, ElTag } from 'element-plus';
import dayjs from 'dayjs';
import { import {
fetchDeleteProjectReport, fetchDeleteProjectReport,
fetchExportProjectReportContent, fetchExportProjectReportContent,
@@ -27,8 +28,7 @@ import {
resolveWorkReportStatusTagType, resolveWorkReportStatusTagType,
transformWorkReportPage transformWorkReportPage
} from '../shared/types'; } from '../shared/types';
import { resolveWorkReportSummaryPeriod } from '../shared/utils'; import { buildProjectPeriodFromMonth, resolveWorkReportSummaryPeriod } from '../shared/utils';
import TeamReportSummary from '../shared/components/team-report-summary.vue';
import ProjectReportSearch from './modules/search-panel.vue'; import ProjectReportSearch from './modules/search-panel.vue';
import IconMdiDeleteOutline from '~icons/mdi/delete-outline'; import IconMdiDeleteOutline from '~icons/mdi/delete-outline';
import IconMdiEyeOutline from '~icons/mdi/eye-outline'; import IconMdiEyeOutline from '~icons/mdi/eye-outline';
@@ -72,6 +72,22 @@ const isTeamMode = computed(() => props.teamContext?.mode === 'team');
const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected)); const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected));
const currentProjectOwnerIds = computed(() => resolveTeamQueryUserIds(props.teamContext)); const currentProjectOwnerIds = computed(() => resolveTeamQueryUserIds(props.teamContext));
const reportTitle = computed(() => getWorkReportTypeDisplayLabel('project', isTeamMode.value)); const reportTitle = computed(() => getWorkReportTypeDisplayLabel('project', isTeamMode.value));
const normalizedPeriodRange = computed(() => {
const periodRange = searchParams.periodStartDate;
if (!periodRange?.length) {
return periodRange;
}
const [startDate, endDate] = periodRange;
const start = dayjs(startDate);
const end = dayjs(endDate || startDate);
if (!start.isValid() || !end.isValid()) {
return periodRange;
}
return [start.startOf('month').format('YYYY-MM-DD'), end.endOf('month').format('YYYY-MM-DD')];
});
const table = useUIPaginatedTable< const table = useUIPaginatedTable<
Awaited<ReturnType<typeof fetchGetProjectReportPage>>, Awaited<ReturnType<typeof fetchGetProjectReportPage>>,
@@ -81,6 +97,7 @@ const table = useUIPaginatedTable<
api: () => api: () =>
fetchGetProjectReportPage({ fetchGetProjectReportPage({
...searchParams, ...searchParams,
periodStartDate: normalizedPeriodRange.value,
projectOwnerIds: currentProjectOwnerIds.value projectOwnerIds: currentProjectOwnerIds.value
}), }),
transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10), transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
@@ -129,7 +146,42 @@ const table = useUIPaginatedTable<
}); });
// 团队统计始终使用当前周期(当前半月),不跟随列表第一条数据的周期 // 团队统计始终使用当前周期(当前半月),不跟随列表第一条数据的周期
const summaryPeriod = computed(() => resolveWorkReportSummaryPeriod('project')); const summaryPeriod = computed(() =>
resolveWorkReportSummaryPeriod('project', {
periodRange: normalizedPeriodRange.value
})
);
const summaryPeriodKeys = computed(() => {
const dateRange = normalizedPeriodRange.value;
const fallbackKey = summaryPeriod.value.periodKey;
if (!dateRange?.length) {
return fallbackKey ? [fallbackKey] : [];
}
const [startDate, endDate] = dateRange;
const start = dayjs(startDate);
const end = dayjs(endDate || startDate);
if (!start.isValid() || !end.isValid()) {
return fallbackKey ? [fallbackKey] : [];
}
const keys: string[] = [];
const endBoundary = end.endOf('month');
for (
let cursor = start.startOf('month');
cursor.isBefore(endBoundary, 'month') || cursor.isSame(endBoundary, 'month');
cursor = cursor.add(1, 'month')
) {
keys.push(buildProjectPeriodFromMonth(cursor, 1).periodKey);
keys.push(buildProjectPeriodFromMonth(cursor, 2).periodKey);
}
return keys;
});
const hasSearchedDateRange = computed(() => searchParams.periodStartDate?.length === 2);
function getRowActions(row: Api.WorkReport.Project.ProjectReport): BusinessTableAction[] { function getRowActions(row: Api.WorkReport.Project.ProjectReport): BusinessTableAction[] {
const actions: BusinessTableAction[] = [ const actions: BusinessTableAction[] = [
@@ -271,6 +323,7 @@ function createExportSearchParams() {
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams; const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
return { return {
...params, ...params,
periodStartDate: normalizedPeriodRange.value,
projectOwnerIds: currentProjectOwnerIds.value projectOwnerIds: currentProjectOwnerIds.value
}; };
} }
@@ -337,17 +390,32 @@ async function loadTeamSummary() {
return; return;
} }
const dateRange = normalizedPeriodRange.value;
const summaryParams: Api.WorkReport.Common.TeamReportSummaryParams = { reportType: 'project' };
if (dateRange?.length === 2) {
summaryParams.periodStartDate = dateRange[0];
summaryParams.periodEndDate = dateRange[1];
} else {
summaryParams.periodKey = summaryPeriod.value.periodKey;
}
teamSummaryLoading.value = true; teamSummaryLoading.value = true;
const { error, data } = await fetchGetTeamReportSummary({ const { error, data } = await fetchGetTeamReportSummary(summaryParams);
reportType: 'project',
periodKey: summaryPeriod.value.periodKey
});
teamSummaryLoading.value = false; teamSummaryLoading.value = false;
teamSummary.value = error || !data ? null : data; teamSummary.value = error || !data ? null : data;
} }
defineExpose({ reload }); defineExpose({
reload,
teamSummary,
teamSummaryLoading,
summaryPeriod,
summaryPeriodKeys,
hasSearchedDateRange,
loadTeamSummary
});
</script> </script>
<template> <template>
@@ -364,16 +432,6 @@ defineExpose({ reload });
@search="handleSearch" @search="handleSearch"
/> />
<TeamReportSummary
v-if="isTeamRootSelected"
report-type="project"
:period-key="summaryPeriod.periodKey"
:period-label="formatPeriod(summaryPeriod)"
:loading="teamSummaryLoading"
:summary="teamSummary"
@reminded="loadTeamSummary"
/>
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body"> <ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">
<template #header> <template #header>
<div class="flex flex-wrap items-center justify-between gap-12px"> <div class="flex flex-wrap items-center justify-between gap-12px">

View File

@@ -1,19 +1,28 @@
<script setup lang="ts"> <script setup lang="ts">
/* eslint-disable no-void */ /* eslint-disable no-void */
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
import dayjs from 'dayjs';
import isoWeek from 'dayjs/plugin/isoWeek';
import { fetchGetWorkReportStatusDict } from '@/service/api'; import { fetchGetWorkReportStatusDict } from '@/service/api';
import type { SearchField } from '@/components/custom/table-search-fields.vue'; import type { SearchField } from '@/components/custom/table-search-fields.vue';
import TableSearchFields from '@/components/custom/table-search-fields.vue'; import TableSearchFields from '@/components/custom/table-search-fields.vue';
import { BOOLEAN_TRUE_FALSE_OPTIONS, type WorkReportSearchParams, type WorkReportType } from '../types'; import { BOOLEAN_TRUE_FALSE_OPTIONS, type WorkReportSearchParams, type WorkReportType } from '../types';
import { formatIsoWeekRangeLabel, normalizeWeeklySearchRange } from '../utils';
dayjs.extend(isoWeek);
defineOptions({ name: 'WorkReportSearch' }); defineOptions({ name: 'WorkReportSearch' });
interface Props { interface Props {
reportType: WorkReportType; reportType: WorkReportType;
teamMode?: boolean;
subordinateOptions?: Array<{ label: string; value: string }>;
projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[]; projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[];
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
teamMode: false,
subordinateOptions: () => [],
projectOptions: () => [] projectOptions: () => []
}); });
@@ -35,6 +44,12 @@ const statusOptions = computed(() =>
})) }))
); );
const weeklyPeriodPlaceholder = computed(() => {
const range = normalizeWeeklySearchRange(model.value.periodStartDate as string[] | undefined);
if (!range?.length) return '请选择周报周期';
return formatIsoWeekRangeLabel(range[0], range[1]) || '请选择周报周期';
});
const fields = computed<SearchField[]>(() => { const fields = computed<SearchField[]>(() => {
const baseFields: SearchField[] = [ const baseFields: SearchField[] = [
{ key: 'statusCode', label: '状态', type: 'select', options: statusOptions.value, placeholder: '请选择状态' }, { key: 'statusCode', label: '状态', type: 'select', options: statusOptions.value, placeholder: '请选择状态' },
@@ -51,8 +66,33 @@ const fields = computed<SearchField[]>(() => {
}; };
if (props.reportType === 'weekly') { if (props.reportType === 'weekly') {
const weeklyPeriodField: SearchField = {
key: 'periodStartDate',
label: '周期',
type: 'dateRange',
placeholder: weeklyPeriodPlaceholder.value,
format: 'YYYY[年第]ww[周]',
rangeSeparator: '至'
};
const teamReporterField: SearchField[] = props.teamMode
? [
{
key: 'reporterIds',
label: '提交人',
type: 'select',
options: props.subordinateOptions,
placeholder: '请选择提交人',
transformValue: value => (value ? [value] : undefined),
resolveValue: value => (Array.isArray(value) ? value[0] : value)
}
]
: [];
return [ return [
...baseFields, baseFields[0],
weeklyPeriodField,
...teamReporterField,
{ {
key: 'isBusinessTrip', key: 'isBusinessTrip',
label: '是否出差', label: '是否出差',
@@ -81,7 +121,21 @@ const fields = computed<SearchField[]>(() => {
} }
if (props.reportType === 'monthly') { if (props.reportType === 'monthly') {
return [baseFields[0], monthPeriodField]; const teamReporterField: SearchField[] = props.teamMode
? [
{
key: 'reporterIds',
label: '提交人',
type: 'select',
options: props.subordinateOptions,
placeholder: '请选择提交人',
transformValue: value => (value ? [value] : undefined),
resolveValue: value => (Array.isArray(value) ? value[0] : value)
}
]
: [];
return [baseFields[0], monthPeriodField, ...teamReporterField];
} }
return baseFields; return baseFields;
@@ -95,6 +149,34 @@ async function loadStatusDict() {
onMounted(() => { onMounted(() => {
loadStatusDict(); loadStatusDict();
}); });
watch(
() => props.reportType,
type => {
if (type !== 'weekly') return;
model.value.periodStartDate = normalizeWeeklySearchRange(model.value.periodStartDate as string[] | undefined);
},
{ immediate: true }
);
watch(
() => model.value.periodStartDate,
value => {
if (props.reportType !== 'weekly') return;
const normalizedValue = normalizeWeeklySearchRange(value as string[] | undefined);
const currentValue = Array.isArray(value) ? value : [];
if (
normalizedValue?.length === currentValue.length &&
normalizedValue?.every((item, index) => item === currentValue[index])
) {
return;
}
model.value.periodStartDate = normalizedValue;
}
);
</script> </script>
<template> <template>

View File

@@ -1,18 +1,21 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import dayjs from 'dayjs';
import { fetchRemindTeamReport } from '@/service/api'; import { fetchRemindTeamReport } from '@/service/api';
import { formatIsoWeekRangeLabel } from '../utils';
defineOptions({ name: 'TeamReportSummary' }); defineOptions({ name: 'TeamReportSummary' });
interface Props { interface Props {
reportType: Api.WorkReport.Common.ReportType; reportType: Api.WorkReport.Common.ReportType;
periodKey: string; periodKeys?: string[];
periodLabel?: string; periodLabel?: string;
loading?: boolean; loading?: boolean;
summary?: Api.WorkReport.Common.TeamReportSummary | null; summary?: Api.WorkReport.Common.TeamReportSummary | null;
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
periodKeys: () => [],
periodLabel: '', periodLabel: '',
loading: false, loading: false,
summary: null summary: null
@@ -24,6 +27,34 @@ const emit = defineEmits<{
const remindingAll = ref(false); const remindingAll = ref(false);
const remindingUserId = ref(''); const remindingUserId = ref('');
const canRemind = computed(() => props.periodKeys.length > 0);
function formatSummaryPeriodLabel() {
if (!props.summary?.periodStartDate || !props.summary?.periodEndDate) {
return props.periodLabel;
}
const start = dayjs(props.summary.periodStartDate);
const end = dayjs(props.summary.periodEndDate);
if (!start.isValid() || !end.isValid()) {
return `${props.summary.periodStartDate}${props.summary.periodEndDate}`;
}
if (props.reportType === 'monthly' || props.reportType === 'project') {
const startMonth = start.format('YYYY-MM');
const endMonth = end.format('YYYY-MM');
return startMonth === endMonth ? startMonth : `${startMonth}${endMonth}`;
}
if (props.reportType === 'weekly') {
return formatIsoWeekRangeLabel(props.summary.periodStartDate, props.summary.periodEndDate);
}
return `${start.format('YYYY-MM-DD')}${end.format('YYYY-MM-DD')}`;
}
const displayPeriodLabel = computed(() => formatSummaryPeriodLabel());
const cards = computed(() => [ const cards = computed(() => [
{ label: '应填人数', value: props.summary?.totalShouldSubmit ?? 0 }, { label: '应填人数', value: props.summary?.totalShouldSubmit ?? 0 },
@@ -33,6 +64,8 @@ const cards = computed(() => [
]); ]);
async function handleRemind(userIds?: string[]) { async function handleRemind(userIds?: string[]) {
if (!props.periodKeys.length) return;
const targetUserId = userIds?.length === 1 ? userIds[0] : ''; const targetUserId = userIds?.length === 1 ? userIds[0] : '';
if (targetUserId) { if (targetUserId) {
@@ -41,27 +74,36 @@ async function handleRemind(userIds?: string[]) {
remindingAll.value = true; remindingAll.value = true;
} }
const { error, data } = await fetchRemindTeamReport({ const results = await Promise.all(
props.periodKeys.map(periodKey =>
fetchRemindTeamReport({
reportType: props.reportType, reportType: props.reportType,
periodKey: props.periodKey, periodKey,
userIds userIds
}); })
)
);
if (!targetUserId) { if (!targetUserId) {
remindingAll.value = false; remindingAll.value = false;
} }
remindingUserId.value = ''; remindingUserId.value = '';
if (error) return; const remindedCount = results.reduce((total, result) => {
if (result.error) return total;
return total + (result.data?.remindedCount ?? 0);
}, 0);
window.$message?.success(`已催办 ${data?.remindedCount ?? 0}`); if (!remindedCount) return;
window.$message?.success(props.periodKeys.length > 1 ? '已按所选区间发送催办提醒' : `已催办 ${remindedCount}`);
emit('reminded'); emit('reminded');
} }
</script> </script>
<template> <template>
<div v-loading="props.loading" class="team-report-summary"> <div v-loading="props.loading" class="team-report-summary">
<div v-if="props.periodLabel" class="team-report-summary__period">{{ props.periodLabel }}</div> <div v-if="displayPeriodLabel" class="team-report-summary__period">{{ displayPeriodLabel }}</div>
<div class="team-report-summary__grid"> <div class="team-report-summary__grid">
<div v-for="card in cards" :key="card.label" class="team-report-summary__item"> <div v-for="card in cards" :key="card.label" class="team-report-summary__item">
@@ -83,6 +125,7 @@ async function handleRemind(userIds?: string[]) {
> >
<span class="team-report-summary__user-name">{{ user.userNickname }}</span> <span class="team-report-summary__user-name">{{ user.userNickname }}</span>
<ElButton <ElButton
v-if="canRemind"
link link
type="primary" type="primary"
:loading="remindingUserId === user.userId" :loading="remindingUserId === user.userId"
@@ -94,7 +137,7 @@ async function handleRemind(userIds?: string[]) {
</div> </div>
<ElEmpty v-else :image-size="60" description="暂无待提交人员" /> <ElEmpty v-else :image-size="60" description="暂无待提交人员" />
<div class="team-report-summary__popover-footer"> <div v-if="canRemind" class="team-report-summary__popover-footer">
<ElButton <ElButton
size="small" size="small"
type="primary" type="primary"

View File

@@ -155,12 +155,16 @@ export function createInitBaseSearchParams() {
export function createWeeklySearchParams(): Api.WorkReport.Weekly.WeeklyReportSearchParams { export function createWeeklySearchParams(): Api.WorkReport.Weekly.WeeklyReportSearchParams {
return { return {
...createInitBaseSearchParams(), ...createInitBaseSearchParams(),
reporterIds: undefined,
isBusinessTrip: undefined isBusinessTrip: undefined
}; };
} }
export function createMonthlySearchParams(): Api.WorkReport.Monthly.MonthlyReportSearchParams { export function createMonthlySearchParams(): Api.WorkReport.Monthly.MonthlyReportSearchParams {
return createInitBaseSearchParams(); return {
...createInitBaseSearchParams(),
reporterIds: undefined
};
} }
export function createProjectSearchParams(): Api.WorkReport.Project.ProjectReportSearchParams { export function createProjectSearchParams(): Api.WorkReport.Project.ProjectReportSearchParams {

View File

@@ -46,6 +46,29 @@ export function getIsoWeekDisplay(date: string | dayjs.Dayjs) {
return `${selectedDate.format('GGGG')}${String(selectedDate.isoWeek()).padStart(2, '0')}`; return `${selectedDate.format('GGGG')}${String(selectedDate.isoWeek()).padStart(2, '0')}`;
} }
export function formatIsoWeekCompactLabel(date: string | dayjs.Dayjs) {
const selectedDate = dayjs(date);
if (!selectedDate.isValid()) return '';
const weekDate = selectedDate.startOf('isoWeek');
const weekYear = weekDate.add(3, 'day').format('YYYY');
return `${weekYear}-${String(weekDate.isoWeek()).padStart(2, '0')}`;
}
export function formatIsoWeekRangeLabel(
startDate?: string | dayjs.Dayjs | null,
endDate?: string | dayjs.Dayjs | null
) {
const startLabel = startDate ? formatIsoWeekCompactLabel(startDate) : '';
const endLabel = endDate ? formatIsoWeekCompactLabel(endDate) : '';
if (!startLabel && !endLabel) return '';
if (!endLabel || startLabel === endLabel) return startLabel;
if (!startLabel) return endLabel;
return `${startLabel}${endLabel}`;
}
/* eslint-disable-next-line max-params */ /* eslint-disable-next-line max-params */
function buildPeriod(reportType: WorkReportType, start: dayjs.Dayjs, end: dayjs.Dayjs, label: string, flag?: number) { function buildPeriod(reportType: WorkReportType, start: dayjs.Dayjs, end: dayjs.Dayjs, label: string, flag?: number) {
const startText = start.format('YYYY-MM-DD'); const startText = start.format('YYYY-MM-DD');
@@ -67,6 +90,20 @@ export function buildWeeklyPeriodFromDate(date: string | dayjs.Dayjs) {
return buildPeriod('weekly', start, end, formatRangeLabel(start, end)); return buildPeriod('weekly', start, end, formatRangeLabel(start, end));
} }
export function normalizeWeeklySearchRange(periodRange?: string[] | null): string[] | undefined {
if (!periodRange?.length) return undefined;
const [startDate, endDate] = periodRange;
const start = dayjs(startDate);
const end = dayjs(endDate || startDate);
if (!start.isValid() || !end.isValid()) {
return periodRange ?? undefined;
}
return [start.startOf('isoWeek').format('YYYY-MM-DD'), end.startOf('isoWeek').format('YYYY-MM-DD')];
}
export function buildMonthlyPeriodFromMonth(month: string | dayjs.Dayjs) { export function buildMonthlyPeriodFromMonth(month: string | dayjs.Dayjs) {
const selectedMonth = dayjs(month); const selectedMonth = dayjs(month);
const start = selectedMonth.startOf('month'); const start = selectedMonth.startOf('month');

View File

@@ -1,7 +1,8 @@
<script setup lang="tsx"> <script setup lang="tsx">
/* eslint-disable no-void */ /* eslint-disable no-void */
import { computed, markRaw, reactive, ref } from 'vue'; import { computed, markRaw, reactive, ref, watch } from 'vue';
import { ElMessageBox, ElTag, ElTooltip } from 'element-plus'; import { ElMessageBox, ElTag, ElTooltip } from 'element-plus';
import dayjs from 'dayjs';
import { import {
fetchDeleteWeeklyReport, fetchDeleteWeeklyReport,
fetchExportWeeklyReportContent, fetchExportWeeklyReportContent,
@@ -12,7 +13,7 @@ import {
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
import { useUIPaginatedTable } from '@/hooks/common/table'; import { useUIPaginatedTable } from '@/hooks/common/table';
import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell'; import BusinessTableActionCell, { type BusinessTableAction } from '@/components/custom/business-table-action-cell';
import { type TeamViewContext, resolveTeamQueryUserIds } from '@/views/personal-center/shared/team-dashboard'; import { type TeamViewContext } from '@/views/personal-center/shared/team-dashboard';
import { import {
type WorkReportRow, type WorkReportRow,
createWeeklySearchParams, createWeeklySearchParams,
@@ -29,8 +30,7 @@ import {
resolveWorkReportStatusTagType, resolveWorkReportStatusTagType,
transformWorkReportPage transformWorkReportPage
} from '../shared/types'; } from '../shared/types';
import { resolveWorkReportSummaryPeriod } from '../shared/utils'; import { buildWeeklyPeriodFromDate, normalizeWeeklySearchRange, resolveWorkReportSummaryPeriod } from '../shared/utils';
import TeamReportSummary from '../shared/components/team-report-summary.vue';
import WeeklyReportSearch from './modules/search-panel.vue'; import WeeklyReportSearch from './modules/search-panel.vue';
import IconMdiDeleteOutline from '~icons/mdi/delete-outline'; import IconMdiDeleteOutline from '~icons/mdi/delete-outline';
import IconMdiEyeOutline from '~icons/mdi/eye-outline'; import IconMdiEyeOutline from '~icons/mdi/eye-outline';
@@ -43,6 +43,7 @@ defineOptions({ name: 'WeeklyWorkReportIndex' });
const props = defineProps<{ const props = defineProps<{
teamContext?: TeamViewContext | null; teamContext?: TeamViewContext | null;
subordinateOptions?: Array<{ label: string; value: string }>;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@@ -70,9 +71,30 @@ const ACTION_ICON_MAP = {
const isTeamMode = computed(() => props.teamContext?.mode === 'team'); const isTeamMode = computed(() => props.teamContext?.mode === 'team');
const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected)); const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected));
const currentTeamReporterIds = computed(() => resolveTeamQueryUserIds(props.teamContext)); const currentTeamReporterIds = computed(() => {
const reportTitle = computed(() => getWorkReportTypeDisplayLabel('weekly', isTeamMode.value)); if (!isTeamMode.value) {
return null;
}
if (isTeamRootSelected.value) {
return [];
}
return props.teamContext?.selectedUserIds ?? [];
});
const resolvedTeamReporterIds = computed(() => {
if (!isTeamMode.value) {
return undefined;
}
if (searchParams.reporterIds?.length) {
return searchParams.reporterIds;
}
return currentTeamReporterIds.value;
});
const reportTitle = computed(() => getWorkReportTypeDisplayLabel('weekly', isTeamMode.value));
const normalizedPeriodRange = computed(() => normalizeWeeklySearchRange(searchParams.periodStartDate));
const table = useUIPaginatedTable< const table = useUIPaginatedTable<
Awaited<ReturnType<typeof fetchGetWeeklyReportPage>>, Awaited<ReturnType<typeof fetchGetWeeklyReportPage>>,
Api.WorkReport.Weekly.WeeklyReport Api.WorkReport.Weekly.WeeklyReport
@@ -81,16 +103,17 @@ const table = useUIPaginatedTable<
api: () => api: () =>
fetchGetWeeklyReportPage({ fetchGetWeeklyReportPage({
...searchParams, ...searchParams,
reporterIds: currentTeamReporterIds.value periodStartDate: normalizedPeriodRange.value,
reporterIds: resolvedTeamReporterIds.value
}), }),
transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10), transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
onPaginationParamsChange: params => { onPaginationParamsChange: params => {
searchParams.pageNo = params.currentPage ?? 1; searchParams.pageNo = params.currentPage ?? 1;
searchParams.pageSize = params.pageSize ?? 10; searchParams.pageSize = params.pageSize ?? 10;
}, },
columns: () => [ columns: () => {
const cols: UI.TableColumn<Api.WorkReport.Weekly.WeeklyReport>[] = [
{ prop: 'index', type: 'index', label: '序号', width: 64 }, { prop: 'index', type: 'index', label: '序号', width: 64 },
...(isTeamMode.value ? [{ prop: 'reporterName', label: '提交人', minWidth: 100, showOverflowTooltip: true }] : []),
{ {
prop: 'periodLabel', prop: 'periodLabel',
label: '周期', label: '周期',
@@ -105,7 +128,14 @@ const table = useUIPaginatedTable<
</ElTooltip> </ElTooltip>
); );
} }
}, }
];
if (isTeamMode.value) {
cols.push({ prop: 'reporterName', label: '提交人', minWidth: 100, showOverflowTooltip: true });
}
cols.push(
{ {
prop: 'reporterDeptName', prop: 'reporterDeptName',
label: '部门', label: '部门',
@@ -149,11 +179,58 @@ const table = useUIPaginatedTable<
fixed: 'right', fixed: 'right',
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" /> formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
} }
] );
return cols;
}
}); });
// 团队统计始终使用当前周期(本周),不跟随列表第一条数据的周期 // 团队统计始终使用当前周期(本周),不跟随列表第一条数据的周期
const summaryPeriod = computed(() => resolveWorkReportSummaryPeriod('weekly')); const summaryPeriod = computed(() =>
resolveWorkReportSummaryPeriod('weekly', {
periodRange: normalizedPeriodRange.value
})
);
const summaryPeriodKeys = computed(() => {
const dateRange = normalizedPeriodRange.value;
const fallbackKey = summaryPeriod.value.periodKey;
if (!dateRange?.length) {
return fallbackKey ? [fallbackKey] : [];
}
const [startDate, endDate] = dateRange;
const start = dayjs(startDate);
const end = dayjs(endDate || startDate);
if (!start.isValid() || !end.isValid()) {
return fallbackKey ? [fallbackKey] : [];
}
const keys: string[] = [];
const startBoundary = start.startOf('day');
const endBoundary = end.endOf('day');
for (
let cursor = start.startOf('isoWeek');
cursor.isBefore(endBoundary, 'day') || cursor.isSame(endBoundary, 'day');
cursor = cursor.add(1, 'week')
) {
if (!cursor.isBefore(startBoundary, 'day')) {
keys.push(buildWeeklyPeriodFromDate(cursor).periodKey);
}
}
return keys;
});
const hasSearchedDateRange = computed(() => searchParams.periodStartDate?.length === 2);
watch(
() => isTeamMode.value,
() => {
table.reloadColumns();
}
);
function getRowActions(row: Api.WorkReport.Weekly.WeeklyReport): BusinessTableAction[] { function getRowActions(row: Api.WorkReport.Weekly.WeeklyReport): BusinessTableAction[] {
const actions: BusinessTableAction[] = [ const actions: BusinessTableAction[] = [
@@ -295,7 +372,8 @@ function createExportSearchParams() {
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams; const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
return { return {
...params, ...params,
reporterIds: currentTeamReporterIds.value periodStartDate: normalizedPeriodRange.value,
reporterIds: resolvedTeamReporterIds.value
}; };
} }
@@ -361,31 +439,42 @@ async function loadTeamSummary() {
return; return;
} }
const dateRange = normalizedPeriodRange.value;
const summaryParams: Api.WorkReport.Common.TeamReportSummaryParams = { reportType: 'weekly' };
if (dateRange?.length === 2) {
summaryParams.periodStartDate = dateRange[0];
summaryParams.periodEndDate = dateRange[1];
} else {
summaryParams.periodKey = summaryPeriod.value.periodKey;
}
teamSummaryLoading.value = true; teamSummaryLoading.value = true;
const { error, data } = await fetchGetTeamReportSummary({ const { error, data } = await fetchGetTeamReportSummary(summaryParams);
reportType: 'weekly',
periodKey: summaryPeriod.value.periodKey
});
teamSummaryLoading.value = false; teamSummaryLoading.value = false;
teamSummary.value = error || !data ? null : data; teamSummary.value = error || !data ? null : data;
} }
defineExpose({ reload }); defineExpose({
reload,
teamSummary,
teamSummaryLoading,
summaryPeriod,
summaryPeriodKeys,
hasSearchedDateRange,
loadTeamSummary
});
</script> </script>
<template> <template>
<div class="flex-col-stretch gap-16px overflow-hidden"> <div class="flex-col-stretch gap-16px overflow-hidden">
<WeeklyReportSearch v-model:model="searchParams" @reset="resetSearchParams" @search="handleSearch" /> <WeeklyReportSearch
v-model:model="searchParams"
<TeamReportSummary :team-mode="isTeamMode"
v-if="isTeamRootSelected" :subordinate-options="props.subordinateOptions"
report-type="weekly" @reset="resetSearchParams"
:period-key="summaryPeriod.periodKey" @search="handleSearch"
:period-label="formatWeeklyPeriodLabel(summaryPeriod)"
:loading="teamSummaryLoading"
:summary="teamSummary"
@reminded="loadTeamSummary"
/> />
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body"> <ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">

View File

@@ -4,6 +4,8 @@ import SharedWorkReportSearch from '../../shared/components/search-panel.vue';
defineOptions({ name: 'WeeklyReportSearch' }); defineOptions({ name: 'WeeklyReportSearch' });
defineProps<{ defineProps<{
teamMode?: boolean;
subordinateOptions?: Array<{ label: string; value: string }>;
projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[]; projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[];
}>(); }>();
@@ -19,6 +21,8 @@ const emit = defineEmits<{
<SharedWorkReportSearch <SharedWorkReportSearch
v-model:model="model" v-model:model="model"
report-type="weekly" report-type="weekly"
:team-mode="teamMode"
:subordinate-options="subordinateOptions"
:project-options="projectOptions" :project-options="projectOptions"
@reset="emit('reset')" @reset="emit('reset')"
@search="emit('search')" @search="emit('search')"