fix(加班申请、工作报告、我的绩效): 重构页面样式、修复一系列bug、对不合理的地方进行调整。
This commit is contained in:
@@ -22,6 +22,10 @@ export interface SearchField {
|
||||
dateType?: 'date' | 'month';
|
||||
/** dateRange 字段的日期范围粒度 */
|
||||
dateRangeType?: 'daterange' | 'monthrange';
|
||||
/** 日期面板展示格式 */
|
||||
format?: string;
|
||||
/** 自定义范围分隔文案 */
|
||||
rangeSeparator?: string;
|
||||
/** 日期字段提交格式 */
|
||||
valueFormat?: string;
|
||||
/** 占位列数,默认 1 */
|
||||
@@ -36,6 +40,10 @@ export interface SearchField {
|
||||
placeholder?: string;
|
||||
/** select 类型的自定义选项渲染函数 */
|
||||
renderOption?: (option: Option) => VNode | VNode[] | string;
|
||||
/** 值写回模型前的转换函数 */
|
||||
transformValue?: (value: any) => any;
|
||||
/** 从模型值解析展示值 */
|
||||
resolveValue?: (value: any) => any;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -60,6 +68,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: Record<string, any>): void;
|
||||
(e: 'search'): void;
|
||||
(e: 'reset'): void;
|
||||
}
|
||||
@@ -122,6 +131,19 @@ function handleReset() {
|
||||
function handleSearch() {
|
||||
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>
|
||||
|
||||
<!-- eslint-disable vue/no-mutating-props -->
|
||||
@@ -139,19 +161,19 @@ function handleSearch() {
|
||||
<ElFormItem :label="field.label">
|
||||
<ElInput
|
||||
v-if="field.type === 'input'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
:disabled="props.disabled"
|
||||
@update:model-value="val => (props.modelValue[field.key] = val)"
|
||||
@update:model-value="val => updateFieldValue(field, val)"
|
||||
/>
|
||||
<ElSelect
|
||||
v-else-if="field.type === 'select'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
: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">
|
||||
<template v-if="field.renderOption" #default>
|
||||
@@ -161,34 +183,37 @@ function handleSearch() {
|
||||
</ElSelect>
|
||||
<ElDatePicker
|
||||
v-else-if="field.type === 'date'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:type="field.dateType || 'date'"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
:disabled="props.disabled"
|
||||
:format="field.format"
|
||||
:value-format="field.valueFormat || 'YYYY-MM-DD'"
|
||||
@update:model-value="val => (props.modelValue[field.key] = val)"
|
||||
@update:model-value="val => updateFieldValue(field, val)"
|
||||
/>
|
||||
<ElDatePicker
|
||||
v-else-if="field.type === 'dateRange'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:type="field.dateRangeType || 'daterange'"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
:disabled="props.disabled"
|
||||
:format="field.format"
|
||||
:value-format="field.valueFormat || 'YYYY-MM-DD'"
|
||||
:range-separator="field.rangeSeparator || '至'"
|
||||
:start-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
|
||||
v-else-if="field.type === 'dict'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:dict-code="field.dictCode!"
|
||||
:placeholder="field.placeholder"
|
||||
:disabled="props.disabled"
|
||||
:show-remark="field.showRemark"
|
||||
@update:model-value="val => (props.modelValue[field.key] = val)"
|
||||
@update:model-value="val => updateFieldValue(field, val)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
@@ -236,19 +261,19 @@ function handleSearch() {
|
||||
<ElFormItem :label="field.label">
|
||||
<ElInput
|
||||
v-if="field.type === 'input'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
:disabled="props.disabled"
|
||||
@update:model-value="val => (props.modelValue[field.key] = val)"
|
||||
@update:model-value="val => updateFieldValue(field, val)"
|
||||
/>
|
||||
<ElSelect
|
||||
v-else-if="field.type === 'select'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
: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">
|
||||
<template v-if="field.renderOption" #default>
|
||||
@@ -258,34 +283,37 @@ function handleSearch() {
|
||||
</ElSelect>
|
||||
<ElDatePicker
|
||||
v-else-if="field.type === 'date'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:type="field.dateType || 'date'"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
:disabled="props.disabled"
|
||||
:format="field.format"
|
||||
:value-format="field.valueFormat || 'YYYY-MM-DD'"
|
||||
@update:model-value="val => (props.modelValue[field.key] = val)"
|
||||
@update:model-value="val => updateFieldValue(field, val)"
|
||||
/>
|
||||
<ElDatePicker
|
||||
v-else-if="field.type === 'dateRange'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:type="field.dateRangeType || 'daterange'"
|
||||
:placeholder="field.placeholder"
|
||||
clearable
|
||||
:disabled="props.disabled"
|
||||
:format="field.format"
|
||||
:value-format="field.valueFormat || 'YYYY-MM-DD'"
|
||||
:range-separator="field.rangeSeparator || '至'"
|
||||
:start-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
|
||||
v-else-if="field.type === 'dict'"
|
||||
:model-value="props.modelValue[field.key]"
|
||||
:model-value="getFieldValue(field)"
|
||||
:dict-code="field.dictCode!"
|
||||
:placeholder="field.placeholder"
|
||||
:disabled="props.disabled"
|
||||
:show-remark="field.showRemark"
|
||||
@update:model-value="val => (props.modelValue[field.key] = val)"
|
||||
@update:model-value="val => updateFieldValue(field, val)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
|
||||
@@ -15,6 +15,7 @@ interface BackendUserInfoDTO {
|
||||
userId: string | number;
|
||||
userName?: string | null;
|
||||
nickname?: string | null;
|
||||
deptId?: string | number | null;
|
||||
roles?: string[] | null;
|
||||
buttons?: string[] | null;
|
||||
}
|
||||
@@ -61,6 +62,7 @@ function mapUserInfo(data: BackendUserInfoDTO): Api.Auth.UserInfo {
|
||||
userId: String(data.userId ?? ''),
|
||||
userName: data.userName ?? '',
|
||||
nickname: data.nickname ?? '',
|
||||
deptId: safeStringId(data.deptId),
|
||||
roles: data.roles ?? [],
|
||||
buttons: data.buttons ?? []
|
||||
};
|
||||
|
||||
@@ -34,7 +34,26 @@ type OvertimeApplicationApprovalRecordResponse = Omit<
|
||||
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) {
|
||||
if (typeof value === 'boolean') {
|
||||
@@ -309,7 +328,14 @@ export async function fetchGetTeamOvertimeSummary(params: Api.OvertimeApplicatio
|
||||
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 = {}) {
|
||||
|
||||
@@ -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) {
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户管理链路详情
|
||||
*
|
||||
|
||||
@@ -103,8 +103,13 @@ type TeamReportPendingUserResponse = Omit<Api.WorkReport.Common.TeamReportPendin
|
||||
userId: StringIdResponse;
|
||||
};
|
||||
|
||||
type TeamReportSummaryResponse = Omit<Api.WorkReport.Common.TeamReportSummary, 'unsubmittedUsers'> & {
|
||||
type TeamReportSummaryResponse = Omit<
|
||||
Api.WorkReport.Common.TeamReportSummary,
|
||||
'unsubmittedUsers' | 'periodStartDate' | 'periodEndDate'
|
||||
> & {
|
||||
unsubmittedUsers?: TeamReportPendingUserResponse[] | null;
|
||||
periodStartDate?: unknown;
|
||||
periodEndDate?: unknown;
|
||||
};
|
||||
|
||||
function normalizeBooleanFlag(value: boolean | number | string | null | undefined) {
|
||||
@@ -368,6 +373,8 @@ function normalizeProjectOption(
|
||||
function normalizeTeamReportSummary(response: TeamReportSummaryResponse): Api.WorkReport.Common.TeamReportSummary {
|
||||
return {
|
||||
...response,
|
||||
periodStartDate: normalizeDateText(response.periodStartDate) ?? undefined,
|
||||
periodEndDate: normalizeDateText(response.periodEndDate) ?? undefined,
|
||||
unsubmittedUsers:
|
||||
response.unsubmittedUsers?.map(item => ({
|
||||
...item,
|
||||
|
||||
1
src/typings/api/auth.d.ts
vendored
1
src/typings/api/auth.d.ts
vendored
@@ -14,6 +14,7 @@ declare namespace Api {
|
||||
userId: string;
|
||||
userName: string;
|
||||
nickname: string;
|
||||
deptId?: string | null;
|
||||
roles: string[];
|
||||
buttons: string[];
|
||||
}
|
||||
|
||||
6
src/typings/api/overtime-application.d.ts
vendored
6
src/typings/api/overtime-application.d.ts
vendored
@@ -98,11 +98,13 @@ declare namespace Api {
|
||||
}
|
||||
|
||||
interface TeamOvertimeSummaryParams {
|
||||
month?: string | null;
|
||||
overtimeDateStart?: string | null;
|
||||
overtimeDateEnd?: string | null;
|
||||
}
|
||||
|
||||
interface TeamOvertimeSummary {
|
||||
month: string;
|
||||
overtimeDateStart: string;
|
||||
overtimeDateEnd: string;
|
||||
totalApplicationCount: number;
|
||||
pendingCount: number;
|
||||
approvedCount: number;
|
||||
|
||||
4
src/typings/api/system-manage.d.ts
vendored
4
src/typings/api/system-manage.d.ts
vendored
@@ -98,6 +98,8 @@ declare namespace Api {
|
||||
|
||||
type DeptSimpleList = DeptSimple[];
|
||||
|
||||
type DeptSelfAndChildrenList = DeptSimple[];
|
||||
|
||||
type DeptSearchParams = CommonType.RecordNullable<Pick<Dept, 'name' | 'orgType' | 'status'>>;
|
||||
|
||||
type SaveDeptParams = Pick<Dept, 'name' | 'parentId' | 'orgType' | 'code' | 'sort' | 'status'>;
|
||||
@@ -457,5 +459,7 @@ declare namespace Api {
|
||||
/** 部门名称 */
|
||||
deptName?: string | null;
|
||||
}
|
||||
|
||||
type UserSimpleList = UserSimple[];
|
||||
}
|
||||
}
|
||||
|
||||
6
src/typings/api/work-report.d.ts
vendored
6
src/typings/api/work-report.d.ts
vendored
@@ -78,6 +78,8 @@ declare namespace Api {
|
||||
}
|
||||
|
||||
interface TeamReportSummary {
|
||||
periodStartDate?: string | null;
|
||||
periodEndDate?: string | null;
|
||||
totalShouldSubmit: number;
|
||||
submittedCount: number;
|
||||
unsubmittedCount: number;
|
||||
@@ -87,7 +89,9 @@ declare namespace Api {
|
||||
|
||||
interface TeamReportSummaryParams {
|
||||
reportType: ReportType;
|
||||
periodKey: string;
|
||||
periodKey?: string | null;
|
||||
periodStartDate?: string | null;
|
||||
periodEndDate?: string | null;
|
||||
}
|
||||
|
||||
interface TeamReportRemindParams {
|
||||
|
||||
1
src/typings/components.d.ts
vendored
1
src/typings/components.d.ts
vendored
@@ -130,6 +130,7 @@ declare module 'vue' {
|
||||
IconMdiFolderOpen: typeof import('~icons/mdi/folder-open')['default']
|
||||
IconMdiFolderOutline: typeof import('~icons/mdi/folder-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']
|
||||
IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default']
|
||||
IconMdiLinkVariant: typeof import('~icons/mdi/link-variant')['default']
|
||||
|
||||
@@ -7,14 +7,18 @@ import {
|
||||
deletePerformanceSheet,
|
||||
downloadPerformanceSheet,
|
||||
exportPerformanceSheets,
|
||||
fetchGetDeptSimpleList,
|
||||
fetchGetDeptSelfAndChildren,
|
||||
fetchGetDirectSubordinates,
|
||||
fetchGetMyProfileDetail,
|
||||
fetchGetMySubordinateTree,
|
||||
fetchPerformanceSheetPage,
|
||||
fetchPerformanceSheetStatusDict,
|
||||
fetchTeamPerformanceSummary,
|
||||
formatToYYYYMM,
|
||||
resendPerformanceSheet,
|
||||
sendPerformanceSheet
|
||||
} from '@/service/api';
|
||||
import { useAuthStore } from '@/store/modules/auth';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useUIPaginatedTable } from '@/hooks/common/table';
|
||||
import SubordinateSelector from '@/components/custom/subordinate-selector.vue';
|
||||
@@ -39,6 +43,7 @@ import {
|
||||
formatDateTime,
|
||||
formatScore,
|
||||
getPerformanceStatusLabel,
|
||||
getPerformanceStatusOptions,
|
||||
getSheetExportName,
|
||||
resolvePerformanceStatusTagType
|
||||
} from './modules/performance-shared';
|
||||
@@ -90,6 +95,7 @@ function transformPageResult(response: PerformanceSheetPageResponse, pageNo: num
|
||||
}
|
||||
|
||||
const { hasAuth } = useAuth();
|
||||
const authStore = useAuthStore();
|
||||
const searchParams = reactive(createSearchParams());
|
||||
const teamViewMode = ref<TeamViewMode>('self');
|
||||
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 currentRow = ref<Api.Performance.Sheet.Sheet | null>(null);
|
||||
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 excelVisible = ref(false);
|
||||
@@ -184,8 +193,19 @@ const currentEmployeeIds = computed(() => {
|
||||
|
||||
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,
|
||||
Api.Performance.Sheet.Sheet
|
||||
>({
|
||||
@@ -196,78 +216,89 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
|
||||
api: () =>
|
||||
fetchPerformanceSheetPage({
|
||||
...searchParams,
|
||||
employeeIds: currentEmployeeIds.value
|
||||
employeeIds: resolvedEmployeeIds.value,
|
||||
employeeId: undefined
|
||||
}),
|
||||
transform: response => transformPageResult(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
|
||||
onPaginationParamsChange: params => {
|
||||
searchParams.pageNo = params.currentPage ?? 1;
|
||||
searchParams.pageSize = params.pageSize ?? 10;
|
||||
},
|
||||
columns: () => [
|
||||
{ prop: 'selection', type: 'selection', width: 48 },
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
{ prop: 'periodMonth', label: '绩效月份', minWidth: 110 },
|
||||
{ prop: 'employeeName', label: '员工', minWidth: 110, showOverflowTooltip: true },
|
||||
{ prop: 'employeeDeptName', label: '部门', minWidth: 110, showOverflowTooltip: true },
|
||||
{ prop: 'managerName', label: '直属上级', minWidth: 110, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolvePerformanceStatusTagType(row.statusCode)}>
|
||||
{getPerformanceStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'actualScoreTotal',
|
||||
label: '实际得分',
|
||||
minWidth: 100,
|
||||
formatter: row => formatScore(row.actualScoreTotal)
|
||||
},
|
||||
// {
|
||||
// prop: 'baseScoreTotal',
|
||||
// label: '基础得分',
|
||||
// width: 100,
|
||||
// align: 'right',
|
||||
// formatter: row => formatScore(row.baseScoreTotal)
|
||||
// },
|
||||
// {
|
||||
// prop: 'extraScoreTotal',
|
||||
// label: '附加得分',
|
||||
// width: 100,
|
||||
// align: 'right',
|
||||
// formatter: row => formatScore(row.extraScoreTotal)
|
||||
// },
|
||||
{
|
||||
prop: 'sentTime',
|
||||
label: '发送时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatDateTime(row.sentTime)
|
||||
},
|
||||
{
|
||||
prop: 'confirmedTime',
|
||||
label: '确认时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatDateTime(row.confirmedTime)
|
||||
},
|
||||
// {
|
||||
// prop: 'updateTime',
|
||||
// label: '更新时间',
|
||||
// width: 150,
|
||||
// formatter: row => formatDateTime(row.updateTime)
|
||||
// },
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: 190,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
|
||||
columns: () => {
|
||||
const baseColumns: UI.TableColumn<Api.Performance.Sheet.Sheet>[] = [
|
||||
{ prop: 'selection', type: 'selection', width: 48 },
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
{ prop: 'periodMonth', label: '绩效月份', minWidth: 110 }
|
||||
];
|
||||
|
||||
if (isTeamMode.value) {
|
||||
baseColumns.push({ prop: 'employeeName', label: '下属', minWidth: 110, showOverflowTooltip: true });
|
||||
}
|
||||
]
|
||||
|
||||
baseColumns.push(
|
||||
{ prop: 'employeeDeptName', label: '部门', minWidth: 110, showOverflowTooltip: true },
|
||||
{ prop: 'managerName', label: '直属上级', minWidth: 110, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolvePerformanceStatusTagType(row.statusCode)}>
|
||||
{getPerformanceStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'actualScoreTotal',
|
||||
label: '实际得分',
|
||||
minWidth: 100,
|
||||
formatter: row => formatScore(row.actualScoreTotal)
|
||||
},
|
||||
// {
|
||||
// prop: 'baseScoreTotal',
|
||||
// label: '基础得分',
|
||||
// width: 100,
|
||||
// align: 'right',
|
||||
// formatter: row => formatScore(row.baseScoreTotal)
|
||||
// },
|
||||
// {
|
||||
// prop: 'extraScoreTotal',
|
||||
// label: '附加得分',
|
||||
// width: 100,
|
||||
// align: 'right',
|
||||
// formatter: row => formatScore(row.extraScoreTotal)
|
||||
// },
|
||||
{
|
||||
prop: 'sentTime',
|
||||
label: '发送时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatDateTime(row.sentTime)
|
||||
},
|
||||
{
|
||||
prop: 'confirmedTime',
|
||||
label: '确认时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatDateTime(row.confirmedTime)
|
||||
},
|
||||
// {
|
||||
// prop: 'updateTime',
|
||||
// label: '更新时间',
|
||||
// width: 150,
|
||||
// formatter: row => formatDateTime(row.updateTime)
|
||||
// },
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: 190,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
|
||||
}
|
||||
);
|
||||
|
||||
return baseColumns;
|
||||
}
|
||||
});
|
||||
|
||||
const totalCount = computed(() => mobilePagination.value.total || data.value.length);
|
||||
@@ -376,7 +407,8 @@ function createExportParams(): Api.Performance.Sheet.SearchParams {
|
||||
|
||||
return {
|
||||
...params,
|
||||
employeeIds: currentEmployeeIds.value ?? undefined
|
||||
employeeIds: resolvedEmployeeIds.value ?? undefined,
|
||||
employeeId: undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -507,6 +539,11 @@ async function reloadAfterMutation() {
|
||||
await loadTeamSummary();
|
||||
}
|
||||
|
||||
async function refreshPageData(page = 1) {
|
||||
await reloadTable(page);
|
||||
await loadTeamSummary();
|
||||
}
|
||||
|
||||
async function loadSubordinateTree() {
|
||||
if (!canUseTeamDashboard.value) return;
|
||||
|
||||
@@ -535,22 +572,61 @@ async function loadTeamSummary() {
|
||||
}
|
||||
|
||||
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) {
|
||||
deptOptions.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const options: Array<{ label: string; value: string }> = [];
|
||||
const walk = (nodes: Api.SystemManage.DeptSimple[]) => {
|
||||
nodes.forEach(node => {
|
||||
options.push({ label: node.name, value: String(node.id) });
|
||||
if (node.children) walk(node.children);
|
||||
});
|
||||
};
|
||||
walk(deptList);
|
||||
deptOptions.value = options;
|
||||
deptOptions.value = deptList.map(node => ({ label: node.name, value: String(node.id) }));
|
||||
}
|
||||
|
||||
async function loadDirectSubordinateOptions() {
|
||||
const currentUserId = authStore.userInfo.userId;
|
||||
if (!currentUserId) {
|
||||
directSubordinateOptions.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -564,16 +640,19 @@ async function handleTeamViewModeChange(mode: TeamViewMode) {
|
||||
selectedSubordinateUserId.value = subordinateTree.value?.userId || null;
|
||||
}
|
||||
}
|
||||
|
||||
await reloadTable(1);
|
||||
await loadTeamSummary();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [teamViewMode.value, selectedSubordinateUserId.value],
|
||||
async () => {
|
||||
await reloadTable(1);
|
||||
await loadTeamSummary();
|
||||
await refreshPageData(1);
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isTeamMode.value,
|
||||
() => {
|
||||
reloadColumns();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -584,7 +663,7 @@ watch(excelVisible, isVisible => {
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await loadDeptOptions();
|
||||
await Promise.all([loadDeptOptions(), loadDirectSubordinateOptions(), loadStatusOptions()]);
|
||||
|
||||
if (canUseTeamDashboard.value) {
|
||||
await loadSubordinateTree();
|
||||
@@ -624,8 +703,10 @@ onMounted(async () => {
|
||||
<div class="my-performance-page__main">
|
||||
<PerformanceSearch
|
||||
v-model:model="searchParams"
|
||||
:team-mode="isTeamMode"
|
||||
:subordinate-options="subordinateOptions"
|
||||
:dept-options="deptOptions"
|
||||
:status-options="statusOptions"
|
||||
@reset="resetSearchParams"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
@@ -655,7 +736,7 @@ onMounted(async () => {
|
||||
</ElDropdownMenu>
|
||||
</template>
|
||||
</ElDropdown>
|
||||
<ElButton v-if="canManageTemplate" plain @click="templateVisible = true">
|
||||
<ElButton v-if="isTeamMode && canManageTemplate" plain @click="templateVisible = true">
|
||||
<template #icon>
|
||||
<icon-mdi-file-cog-outline class="text-icon" />
|
||||
</template>
|
||||
@@ -700,13 +781,17 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<PerformanceTemplateDialog v-model:visible="templateVisible" @updated="reloadAfterMutation" />
|
||||
<PerformanceTemplateDialog
|
||||
v-if="templateVisible"
|
||||
v-model:visible="templateVisible"
|
||||
@updated="reloadAfterMutation"
|
||||
/>
|
||||
|
||||
<PerformanceExcelEditorDrawer
|
||||
v-model:visible="excelVisible"
|
||||
:row-data="currentRow"
|
||||
:mode="excelMode"
|
||||
:subordinate-options="subordinateOptions"
|
||||
:subordinate-options="directSubordinateOptions"
|
||||
@saved="reloadAfterMutation"
|
||||
@saved-and-sent="reloadAfterMutation"
|
||||
/>
|
||||
|
||||
@@ -80,7 +80,7 @@ watch(visible, isVisible => {
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-position="top">
|
||||
<ElDescriptions :column="1" border>
|
||||
<ElDescriptionsItem label="绩效月份">{{ props.rowData?.periodMonth || '--' }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="员工">{{ props.rowData?.employeeName || '--' }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="下属">{{ props.rowData?.employeeName || '--' }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="实际得分">{{ props.rowData?.actualScoreTotal ?? '--' }}</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
||||
import type { FormRules } from 'element-plus';
|
||||
import JSZip from 'jszip';
|
||||
import '@univerjs/preset-sheets-core/lib/index.css';
|
||||
import {
|
||||
createPerformanceSheet,
|
||||
@@ -58,8 +59,9 @@ const createForm = reactive({
|
||||
|
||||
const createFormRules = computed<FormRules>(() => ({
|
||||
periodMonth: [createRequiredRule('请选择绩效月份')],
|
||||
employeeId: [createRequiredRule('请选择员工')]
|
||||
employeeId: [createRequiredRule('请选择下属')]
|
||||
}));
|
||||
const ASSESSED_EMPLOYEE_TEXT_PATTERN = /(被考核人\s*[::]\s*)(.+)/u;
|
||||
|
||||
let univerInstance: any = null;
|
||||
let univerAPI: any = null;
|
||||
@@ -68,6 +70,7 @@ let createUniverFn: any = null;
|
||||
let UniverSheetsCorePresetFn: any = null;
|
||||
let univerLocales: Record<string, unknown> | null = null;
|
||||
let excelRuntimeLoading: Promise<void> | null = null;
|
||||
const DEFAULT_SHEET_ZOOM_RATIO = 0.4;
|
||||
|
||||
const isCreateMode = computed(() => props.mode === 'create');
|
||||
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) {
|
||||
if (!containerRef.value) return;
|
||||
|
||||
@@ -185,15 +349,8 @@ function createWorkbook(snapshot: any) {
|
||||
throw new Error('Univer 工作簿初始化失败');
|
||||
}
|
||||
|
||||
// 在 snapshot 数据中预设缩放比例 40%,避免调用不可用的 zoom API
|
||||
const data = snapshot || {};
|
||||
if (data.sheets) {
|
||||
Object.values(data.sheets).forEach((sheet: any) => {
|
||||
if (sheet && typeof sheet === 'object') {
|
||||
sheet.zoomRatio = 0.4;
|
||||
}
|
||||
});
|
||||
}
|
||||
// 在 snapshot 数据中预设缩放比例,保证在线查看和导出文件使用同一套缩放值
|
||||
const data = applySheetZoomRatio(snapshot);
|
||||
|
||||
univer.createUnit(unitType, data);
|
||||
}
|
||||
@@ -251,6 +408,15 @@ function getCreateEmployeeName() {
|
||||
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() {
|
||||
const sheet = currentSheet.value;
|
||||
if (sheet) {
|
||||
@@ -317,7 +483,7 @@ async function loadWorkbook() {
|
||||
});
|
||||
const snapshot = await transformExcelToUniver(file);
|
||||
await nextTick();
|
||||
createWorkbook(snapshot);
|
||||
createWorkbook(applyCreateEmployeeName(snapshot));
|
||||
} catch (error) {
|
||||
errorMessage.value = error instanceof Error ? error.message : 'Excel 解析失败';
|
||||
} finally {
|
||||
@@ -331,7 +497,7 @@ async function ensureCreatedSheet() {
|
||||
}
|
||||
|
||||
if (!createForm.periodMonth || !createForm.employeeId) {
|
||||
throw new Error('请先填写绩效月份和员工');
|
||||
throw new Error('请先填写绩效月份和下属');
|
||||
}
|
||||
|
||||
const createResult = await createPerformanceSheet({
|
||||
@@ -373,10 +539,11 @@ async function executeSave(): Promise<Api.Performance.Sheet.Sheet | null> {
|
||||
|
||||
await ensureExcelRuntime();
|
||||
const sheet = await ensureCreatedSheet();
|
||||
const snapshot = workbook.save();
|
||||
const snapshot = applySheetZoomRatio(workbook.save());
|
||||
const fileName = createInitialFileName();
|
||||
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'
|
||||
});
|
||||
const uploadResult = await uploadFile(file, `performance/sheets/${sheet.periodMonth}`);
|
||||
@@ -451,6 +618,22 @@ watch(visible, async isVisible => {
|
||||
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(() => {
|
||||
window.removeEventListener('resize', syncViewportWidth);
|
||||
disposeUniver();
|
||||
@@ -483,8 +666,8 @@ onMounted(() => {
|
||||
placeholder="选择绩效月份"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="员工" prop="employeeId" class="performance-excel-editor__form-item">
|
||||
<ElSelect v-model="createForm.employeeId" filterable placeholder="选择员工" style="width: 200px">
|
||||
<ElFormItem label="下属" prop="employeeId" class="performance-excel-editor__form-item">
|
||||
<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" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
@@ -38,7 +38,7 @@ watch(visible, isVisible => {
|
||||
<template>
|
||||
<BusinessFormDialog
|
||||
v-model="visible"
|
||||
title="员工反馈历史"
|
||||
title="下属反馈历史"
|
||||
preset="lg"
|
||||
append-to-body
|
||||
:show-footer="false"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { computed } from 'vue';
|
||||
import type { SearchField } from '@/components/custom/table-search-fields.vue';
|
||||
import TableSearchFields from '@/components/custom/table-search-fields.vue';
|
||||
import { performanceStatusOptions } from './performance-shared';
|
||||
|
||||
defineOptions({ name: 'PerformanceSearch' });
|
||||
|
||||
@@ -12,13 +11,17 @@ interface Option {
|
||||
}
|
||||
|
||||
interface Props {
|
||||
teamMode?: boolean;
|
||||
subordinateOptions?: Option[];
|
||||
deptOptions?: Option[];
|
||||
statusOptions?: Option[];
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
teamMode: false,
|
||||
subordinateOptions: () => [],
|
||||
deptOptions: () => []
|
||||
deptOptions: () => [],
|
||||
statusOptions: () => []
|
||||
});
|
||||
|
||||
const model = defineModel<Api.Performance.Sheet.SearchParams>('model', { required: true });
|
||||
@@ -28,7 +31,7 @@ const emit = defineEmits<{
|
||||
search: [];
|
||||
}>();
|
||||
|
||||
const fields = computed<SearchField[]>(() => [
|
||||
const baseFields = computed<SearchField[]>(() => [
|
||||
{
|
||||
key: 'periodMonthRange',
|
||||
label: '绩效月份',
|
||||
@@ -37,11 +40,18 @@ const fields = computed<SearchField[]>(() => [
|
||||
valueFormat: 'YYYY-MM-DD',
|
||||
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: '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>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -30,6 +30,19 @@ export const performanceStatusOptions: Array<{
|
||||
{ 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> = {
|
||||
send: '发送',
|
||||
resend: '重新发送',
|
||||
|
||||
@@ -25,8 +25,16 @@ const remindingKey = ref('');
|
||||
|
||||
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(() => [
|
||||
{ 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?.pendingConfirmCount ?? 0, key: 'pending_confirm' as const },
|
||||
{ label: '已确认率', value: `${props.summary?.confirmedRate ?? '0.00'}%` },
|
||||
@@ -55,6 +63,7 @@ async function handleRemind(type: Api.Performance.Common.RemindType, userIds?: s
|
||||
|
||||
<template>
|
||||
<div v-loading="props.loading" class="performance-summary">
|
||||
<div v-if="periodLabel" class="performance-summary__period">{{ periodLabel }}</div>
|
||||
<div class="performance-summary__grid">
|
||||
<div v-for="card in cards" :key="card.label" class="performance-summary__item">
|
||||
<div class="performance-summary__label">{{ card.label }}</div>
|
||||
@@ -194,6 +203,11 @@ async function handleRemind(type: Api.Performance.Common.RemindType, userIds?: s
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.performance-summary__period {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.performance-summary__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
|
||||
@@ -9,9 +9,10 @@ import {
|
||||
uploadPerformanceTemplate
|
||||
} from '@/service/api';
|
||||
import { useUIPaginatedTable } from '@/hooks/common/table';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import BusinessFormDialog from '@/components/custom/business-form-dialog.vue';
|
||||
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' });
|
||||
|
||||
@@ -22,6 +23,9 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
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>({
|
||||
pageNo: 1,
|
||||
@@ -79,7 +83,7 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
|
||||
prop: 'activeFlag',
|
||||
label: '状态',
|
||||
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 },
|
||||
{
|
||||
@@ -101,7 +105,14 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
|
||||
|
||||
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[] {
|
||||
if (!canUpdateTemplate.value) return [];
|
||||
|
||||
return [
|
||||
{
|
||||
key: 'activate',
|
||||
@@ -125,6 +136,8 @@ function handleFileChange(file: UploadFile, _files: UploadFiles) {
|
||||
}
|
||||
|
||||
async function handleUploadTemplate() {
|
||||
if (!canUpdateTemplate.value) return;
|
||||
|
||||
if (!uploadForm.file) {
|
||||
window.$message?.warning('请选择 Excel 模板文件');
|
||||
return;
|
||||
@@ -159,11 +172,13 @@ async function handleUploadTemplate() {
|
||||
activeFlag: true,
|
||||
file: null
|
||||
});
|
||||
await getDataByPage(1);
|
||||
await loadTemplatePage(1);
|
||||
emit('updated');
|
||||
}
|
||||
|
||||
async function handleActivate(row: Api.Performance.Template.Template) {
|
||||
if (!canUpdateTemplate.value) return;
|
||||
|
||||
activatingId.value = row.id;
|
||||
const { error } = await activatePerformanceTemplate(row.id);
|
||||
activatingId.value = '';
|
||||
@@ -171,13 +186,13 @@ async function handleActivate(row: Api.Performance.Template.Template) {
|
||||
if (error) return;
|
||||
|
||||
window.$message?.success('绩效模板已启用');
|
||||
await getDataByPage(searchParams.pageNo ?? 1);
|
||||
await loadTemplatePage(searchParams.pageNo ?? 1);
|
||||
emit('updated');
|
||||
}
|
||||
|
||||
watch(visible, isVisible => {
|
||||
if (isVisible) {
|
||||
getDataByPage(1);
|
||||
if (isVisible && canQueryTemplate.value) {
|
||||
loadTemplatePage(1);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -192,32 +207,59 @@ watch(visible, isVisible => {
|
||||
max-body-height="76vh"
|
||||
>
|
||||
<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">
|
||||
<div class="performance-template-dialog__upload-grid">
|
||||
<ElFormItem label="模板名称" class="performance-template-dialog__field">
|
||||
<ElInput v-model="uploadForm.templateName" placeholder="请输入模板名称" />
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="Excel 文件" class="performance-template-dialog__field">
|
||||
<div class="performance-template-dialog__file-picker">
|
||||
<ElFormItem class="performance-template-dialog__field">
|
||||
<template #label>
|
||||
<div class="performance-template-dialog__label">
|
||||
<span>Excel 文件</span>
|
||||
</div>
|
||||
</template>
|
||||
<div class="performance-template-dialog__file-row">
|
||||
<ElUpload
|
||||
class="performance-template-dialog__upload-trigger"
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
accept=".xlsx,.xls"
|
||||
:limit="1"
|
||||
:on-change="handleFileChange"
|
||||
>
|
||||
<ElButton plain>
|
||||
<ElButton plain class="performance-template-dialog__upload-button">
|
||||
<template #icon>
|
||||
<icon-mdi-upload class="text-icon" />
|
||||
</template>
|
||||
选择文件
|
||||
</ElButton>
|
||||
</ElUpload>
|
||||
<div class="performance-template-dialog__file-hint">
|
||||
{{ selectedFileName || '支持 .xlsx、.xls,选择后会在这里显示文件名' }}
|
||||
<div class="performance-template-dialog__file-name-wrapper">
|
||||
<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>
|
||||
</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>
|
||||
</ElFormItem>
|
||||
|
||||
@@ -245,12 +287,12 @@ watch(visible, isVisible => {
|
||||
</ElForm>
|
||||
</ElCard>
|
||||
|
||||
<ElCard shadow="never" body-class="business-table-card-body">
|
||||
<ElCard v-if="canQueryTemplate" shadow="never" body-class="business-table-card-body">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between gap-12px">
|
||||
<p class="text-16px font-600">模板列表</p>
|
||||
<ElSpace wrap alignment="center">
|
||||
<ElButton @click="getDataByPage()">
|
||||
<ElButton @click="loadTemplatePage(searchParams.pageNo ?? 1)">
|
||||
<template #icon>
|
||||
<icon-mdi-refresh class="text-icon" :class="{ 'animate-spin': loading }" />
|
||||
</template>
|
||||
@@ -279,6 +321,8 @@ watch(visible, isVisible => {
|
||||
/>
|
||||
</div>
|
||||
</ElCard>
|
||||
|
||||
<ElEmpty v-if="!canQueryTemplate && !canUpdateTemplate" :image-size="80" description="当前账号没有绩效模板权限" />
|
||||
</div>
|
||||
</BusinessFormDialog>
|
||||
</template>
|
||||
@@ -304,38 +348,122 @@ watch(visible, isVisible => {
|
||||
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 {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.performance-template-dialog__file-picker {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
.performance-template-dialog__label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.performance-template-dialog__file-hint {
|
||||
min-height: 40px;
|
||||
.performance-template-dialog__file-row {
|
||||
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;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
width: 100% !important;
|
||||
height: 36px;
|
||||
padding: 0 12px;
|
||||
overflow: hidden;
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
background: var(--el-fill-color-blank);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.performance-template-dialog__file-name-text {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
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 {
|
||||
align-self: stretch;
|
||||
}
|
||||
|
||||
.performance-template-dialog__switch-box {
|
||||
height: 100%;
|
||||
min-height: 72px;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -346,6 +474,7 @@ watch(visible, isVisible => {
|
||||
background: var(--el-fill-color-blank);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.performance-template-dialog__actions {
|
||||
@@ -378,7 +507,7 @@ watch(visible, isVisible => {
|
||||
}
|
||||
|
||||
.performance-template-dialog__switch-box {
|
||||
min-height: 56px;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -45,6 +45,7 @@ function getInitSearchParams(): Api.OvertimeApplication.OvertimeApplicationSearc
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
keyword: undefined,
|
||||
applicantIds: undefined,
|
||||
applicantName: undefined,
|
||||
approverId: undefined,
|
||||
approverName: undefined,
|
||||
@@ -95,11 +96,30 @@ const ACTION_ICON_MAP = {
|
||||
|
||||
const canUseTeamDashboard = computed(() => hasAuth('project:overtime-application:team-dashboard'));
|
||||
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(() =>
|
||||
findSubordinateNode(subordinateTree.value, selectedSubordinateUserId.value)
|
||||
);
|
||||
const isTeamMode = computed(() => teamViewMode.value === 'team');
|
||||
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(() => {
|
||||
if (!isTeamMode.value) return '我自己';
|
||||
if (!selectedSubordinateNode.value) return '--';
|
||||
@@ -125,8 +145,19 @@ const currentApplicantIds = computed(() => {
|
||||
if (isRootSelected.value) return [];
|
||||
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,
|
||||
Api.OvertimeApplication.OvertimeApplication
|
||||
>({
|
||||
@@ -137,70 +168,80 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
|
||||
api: () =>
|
||||
fetchGetOvertimeApplicationPage({
|
||||
...searchParams,
|
||||
applicantIds: currentApplicantIds.value
|
||||
applicantIds: resolvedApplicantIds.value
|
||||
}),
|
||||
transform: response => transformPageResult(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
|
||||
onPaginationParamsChange: params => {
|
||||
searchParams.pageNo = params.currentPage ?? 1;
|
||||
searchParams.pageSize = params.pageSize ?? 10;
|
||||
},
|
||||
columns: () => [
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
...(isTeamMode.value ? [{ prop: 'applicantName', label: '申请人', minWidth: 120, showOverflowTooltip: true }] : []),
|
||||
{
|
||||
prop: 'overtimeDate',
|
||||
label: '加班日期',
|
||||
width: 120,
|
||||
formatter: row => formatOvertimeDate(row.overtimeDate)
|
||||
},
|
||||
{ prop: 'overtimeDuration', label: '加班时长', width: 110, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'overtimeReason',
|
||||
label: '加班原因',
|
||||
minWidth: 180,
|
||||
className: 'overtime-application__cell-ellipsis',
|
||||
formatter: row => formatEmptyText(row.overtimeReason)
|
||||
},
|
||||
{
|
||||
prop: 'overtimeContent',
|
||||
label: '加班内容',
|
||||
minWidth: 200,
|
||||
className: 'overtime-application__cell-ellipsis',
|
||||
formatter: row => formatEmptyText(row.overtimeContent)
|
||||
},
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolveOvertimeApplicationStatusTagType(row.statusCode)}>
|
||||
{getOvertimeApplicationStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{ prop: 'approverName', label: '审批人', minWidth: 80, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'submitTime',
|
||||
label: '提交时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatOvertimeDateTime(row.submitTime)
|
||||
},
|
||||
{
|
||||
prop: 'approvalTime',
|
||||
label: '审批时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatOvertimeDateTime(row.approvalTime)
|
||||
},
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: isTeamMode.value ? 140 : 170,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
|
||||
columns: () => {
|
||||
const cols: UI.TableColumn<Api.OvertimeApplication.OvertimeApplication>[] = [
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
{
|
||||
prop: 'overtimeDate',
|
||||
label: '加班日期',
|
||||
width: 120,
|
||||
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: 'overtimeReason',
|
||||
label: '加班原因',
|
||||
minWidth: 180,
|
||||
className: 'overtime-application__cell-ellipsis',
|
||||
formatter: row => formatEmptyText(row.overtimeReason)
|
||||
},
|
||||
{
|
||||
prop: 'overtimeContent',
|
||||
label: '加班内容',
|
||||
minWidth: 200,
|
||||
className: 'overtime-application__cell-ellipsis',
|
||||
formatter: row => formatEmptyText(row.overtimeContent)
|
||||
},
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolveOvertimeApplicationStatusTagType(row.statusCode)}>
|
||||
{getOvertimeApplicationStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{ prop: 'approverName', label: '审批人', minWidth: 80, showOverflowTooltip: true },
|
||||
{
|
||||
prop: 'submitTime',
|
||||
label: '提交时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatOvertimeDateTime(row.submitTime)
|
||||
},
|
||||
{
|
||||
prop: 'approvalTime',
|
||||
label: '审批时间',
|
||||
minWidth: 150,
|
||||
formatter: row => formatOvertimeDateTime(row.approvalTime)
|
||||
},
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: isTeamMode.value ? 140 : 170,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
|
||||
}
|
||||
);
|
||||
|
||||
return cols;
|
||||
}
|
||||
});
|
||||
|
||||
const totalCount = computed(() => mobilePagination.value.total || data.value.length);
|
||||
@@ -283,10 +324,12 @@ function resetSearchParams() {
|
||||
const pageSize = searchParams.pageSize ?? 10;
|
||||
Object.assign(searchParams, getInitSearchParams(), { pageSize });
|
||||
reloadTable(1);
|
||||
loadTeamSummary();
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
reloadTable(1);
|
||||
loadTeamSummary();
|
||||
}
|
||||
|
||||
function handleSubmitted() {
|
||||
@@ -298,7 +341,7 @@ function createExportParams() {
|
||||
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
|
||||
return {
|
||||
...params,
|
||||
applicantIds: currentApplicantIds.value
|
||||
applicantIds: resolvedApplicantIds.value
|
||||
};
|
||||
}
|
||||
|
||||
@@ -306,7 +349,7 @@ async function handleExport() {
|
||||
exporting.value = true;
|
||||
const { error, data: blob } = await fetchExportOvertimeApplications({
|
||||
...createExportParams(),
|
||||
applicantIds: currentApplicantIds.value
|
||||
applicantIds: resolvedApplicantIds.value
|
||||
});
|
||||
exporting.value = false;
|
||||
|
||||
@@ -334,8 +377,16 @@ async function loadTeamSummary() {
|
||||
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;
|
||||
const { error, data: summaryData } = await fetchGetTeamOvertimeSummary();
|
||||
const { error, data: summaryData } = await fetchGetTeamOvertimeSummary(summaryParams);
|
||||
teamSummaryLoading.value = false;
|
||||
|
||||
teamSummary.value = error || !summaryData ? null : summaryData;
|
||||
@@ -364,6 +415,13 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isTeamMode.value,
|
||||
() => {
|
||||
reloadColumns();
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isRootSelected.value,
|
||||
() => {
|
||||
@@ -383,21 +441,24 @@ watch(
|
||||
@update:mode="handleTeamViewModeChange"
|
||||
>
|
||||
<div v-if="isRootSelected" v-loading="teamSummaryLoading" class="team-overtime-summary">
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">本月申请单数</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.totalApplicationCount ?? 0 }}</strong>
|
||||
</div>
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">本月待审批</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.pendingCount ?? 0 }}</strong>
|
||||
</div>
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">本月已通过</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.approvedCount ?? 0 }}</strong>
|
||||
</div>
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">本月已退回</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.rejectedCount ?? 0 }}</strong>
|
||||
<div v-if="summaryPeriodLabel" class="team-overtime-summary__period">{{ summaryPeriodLabel }}</div>
|
||||
<div class="team-overtime-summary__grid">
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">申请单数</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.totalApplicationCount ?? 0 }}</strong>
|
||||
</div>
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">待审批</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.pendingCount ?? 0 }}</strong>
|
||||
</div>
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">已通过</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.approvedCount ?? 0 }}</strong>
|
||||
</div>
|
||||
<div class="team-overtime-summary__item">
|
||||
<span class="team-overtime-summary__label">已退回</span>
|
||||
<strong class="team-overtime-summary__value">{{ teamSummary?.rejectedCount ?? 0 }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TeamContextPanel>
|
||||
@@ -412,7 +473,13 @@ watch(
|
||||
</div>
|
||||
|
||||
<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">
|
||||
<template #header>
|
||||
@@ -534,6 +601,16 @@ watch(
|
||||
}
|
||||
|
||||
.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;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
|
||||
@@ -5,6 +5,21 @@ import TableSearchFields, { type SearchField } from '@/components/custom/table-s
|
||||
|
||||
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<{
|
||||
reset: [];
|
||||
search: [];
|
||||
@@ -15,7 +30,7 @@ const model = defineModel<Api.OvertimeApplication.OvertimeApplicationSearchParam
|
||||
});
|
||||
|
||||
const searchModel = reactive<Record<string, any>>({
|
||||
applicantName: '',
|
||||
applicantIds: undefined,
|
||||
overtimeDate: undefined,
|
||||
statusCode: undefined,
|
||||
approverName: ''
|
||||
@@ -26,11 +41,10 @@ const statusOptions = ref<Array<{ label: string; value: string }>>([]);
|
||||
let syncingFromSource = false;
|
||||
|
||||
watch(
|
||||
() =>
|
||||
[model.value.applicantName, model.value.overtimeDate, model.value.statusCode, model.value.approverName] as const,
|
||||
([applicantName, overtimeDate, statusCode, approverName]) => {
|
||||
() => [model.value.applicantIds, model.value.overtimeDate, model.value.statusCode, model.value.approverName] as const,
|
||||
([applicantIds, overtimeDate, statusCode, approverName]) => {
|
||||
syncingFromSource = true;
|
||||
searchModel.applicantName = applicantName ?? '';
|
||||
searchModel.applicantIds = applicantIds;
|
||||
searchModel.overtimeDate = overtimeDate;
|
||||
searchModel.statusCode = statusCode;
|
||||
searchModel.approverName = approverName ?? '';
|
||||
@@ -40,14 +54,14 @@ watch(
|
||||
);
|
||||
|
||||
watch(
|
||||
() =>
|
||||
[searchModel.applicantName, searchModel.overtimeDate, searchModel.statusCode, searchModel.approverName] as const,
|
||||
([applicantName, overtimeDate, statusCode, approverName]) => {
|
||||
() => [searchModel.applicantIds, searchModel.overtimeDate, searchModel.statusCode, searchModel.approverName] as const,
|
||||
([applicantIds, overtimeDate, statusCode, approverName]) => {
|
||||
if (syncingFromSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
model.value.applicantName = applicantName?.trim() || undefined;
|
||||
model.value.applicantIds = applicantIds;
|
||||
model.value.applicantName = undefined;
|
||||
model.value.overtimeDate = overtimeDate;
|
||||
model.value.statusCode = statusCode;
|
||||
model.value.approverName = approverName?.trim() || undefined;
|
||||
@@ -73,33 +87,47 @@ onMounted(async () => {
|
||||
await loadStatusOptions();
|
||||
});
|
||||
|
||||
const fields = computed<SearchField[]>(() => [
|
||||
{
|
||||
key: 'applicantName',
|
||||
label: '申请人',
|
||||
type: 'input',
|
||||
placeholder: '请输入申请人'
|
||||
},
|
||||
{
|
||||
key: 'overtimeDate',
|
||||
label: '加班日期',
|
||||
type: 'dateRange',
|
||||
placeholder: '请选择加班日期'
|
||||
},
|
||||
{
|
||||
key: 'statusCode',
|
||||
label: '状态',
|
||||
type: 'select',
|
||||
options: statusOptions.value,
|
||||
placeholder: '请选择状态'
|
||||
},
|
||||
{
|
||||
key: 'approverName',
|
||||
label: '审批人',
|
||||
type: 'input',
|
||||
placeholder: '请输入审批人'
|
||||
const fields = computed<SearchField[]>(() => {
|
||||
const baseFields: SearchField[] = [
|
||||
...(props.teamMode
|
||||
? [
|
||||
{
|
||||
key: 'applicantIds',
|
||||
label: '申请人',
|
||||
type: 'select' as const,
|
||||
options: props.subordinateOptions,
|
||||
placeholder: '请选择申请人',
|
||||
transformValue: (value: string | number | null | undefined) => (value ? [value] : undefined),
|
||||
resolveValue: (value: unknown) => (Array.isArray(value) ? value[0] : value)
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
key: 'overtimeDate',
|
||||
label: '加班日期',
|
||||
type: 'dateRange',
|
||||
placeholder: '请选择加班日期'
|
||||
},
|
||||
{
|
||||
key: 'statusCode',
|
||||
label: '状态',
|
||||
type: 'select',
|
||||
options: statusOptions.value,
|
||||
placeholder: '请选择状态'
|
||||
}
|
||||
];
|
||||
|
||||
if (props.teamMode) {
|
||||
baseFields.push({
|
||||
key: 'approverName',
|
||||
label: '审批人',
|
||||
type: 'input',
|
||||
placeholder: '请输入审批人'
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
||||
return baseFields;
|
||||
});
|
||||
|
||||
function handleReset() {
|
||||
emit('reset');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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 { fetchGetMySubordinateTree, fetchGetProjectReportOwnerProjectOptions } from '@/service/api';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
collectSubordinateUserIds,
|
||||
findSubordinateNode
|
||||
} from '../shared/team-dashboard';
|
||||
import TeamReportSummary from './shared/components/team-report-summary.vue';
|
||||
import WorkReportCreateDialog from './shared/components/create-dialog.vue';
|
||||
import WorkReportPrototypePageDialog from './shared/components/prototype-page-dialog.vue';
|
||||
import WorkReportTabs from './shared/components/tabs.vue';
|
||||
@@ -20,6 +21,8 @@ import {
|
||||
type WorkReportType,
|
||||
getWorkReportTypeDisplayLabel
|
||||
} from './shared/types';
|
||||
import { formatIsoWeekRangeLabel } from './shared/utils';
|
||||
import type { resolveWorkReportSummaryPeriod } from './shared/utils';
|
||||
import WeeklyReportIndex from './weekly/index.vue';
|
||||
import WeeklyReportApprovalRecordDialog from './weekly/modules/approval-record-dialog.vue';
|
||||
import MonthlyReportIndex from './monthly/index.vue';
|
||||
@@ -32,6 +35,12 @@ defineOptions({ name: 'PersonalCenterWorkReport' });
|
||||
type PageDialogMode = 'add' | 'edit' | 'detail';
|
||||
type ReportListExpose = {
|
||||
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();
|
||||
@@ -67,6 +76,19 @@ const allSubordinateUserIds = computed(() => collectSubordinateUserIds(subordina
|
||||
const selectedSubordinateNode = computed(() =>
|
||||
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 selectedTeamLabel = computed(() => {
|
||||
if (teamViewMode.value === 'self') return '我自己';
|
||||
@@ -118,6 +140,30 @@ function getListRef(reportType: WorkReportType) {
|
||||
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() {
|
||||
if (!canShowProjectTab.value) return;
|
||||
|
||||
@@ -198,6 +244,10 @@ function handleSubmitted() {
|
||||
reloadReport(currentReportType.value);
|
||||
}
|
||||
|
||||
async function handleSummaryRemind() {
|
||||
await activeReportRef.value?.loadTeamSummary();
|
||||
}
|
||||
|
||||
function closeFloatingPanels() {
|
||||
createVisible.value = false;
|
||||
pageDialogVisible.value = false;
|
||||
@@ -273,13 +323,24 @@ onBeforeRouteLeave(() => {
|
||||
:selected-label="selectedTeamLabel"
|
||||
:subordinate-count="subordinateTree?.subordinateCount || 0"
|
||||
@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
|
||||
v-show="activeTab === 'weekly'"
|
||||
ref="weeklyRef"
|
||||
class="flex-1-hidden"
|
||||
:team-context="teamContext"
|
||||
:subordinate-options="subordinateOptions"
|
||||
@create="openCreate('weekly')"
|
||||
@edit="openEdit('weekly', $event)"
|
||||
@detail="openDetail('weekly', $event)"
|
||||
@@ -291,6 +352,7 @@ onBeforeRouteLeave(() => {
|
||||
ref="monthlyRef"
|
||||
class="flex-1-hidden"
|
||||
:team-context="teamContext"
|
||||
:subordinate-options="subordinateOptions"
|
||||
@create="openCreate('monthly')"
|
||||
@edit="openEdit('monthly', $event)"
|
||||
@detail="openDetail('monthly', $event)"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang="tsx">
|
||||
/* 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 dayjs from 'dayjs';
|
||||
import {
|
||||
fetchDeleteMonthlyReport,
|
||||
fetchExportMonthlyReportContent,
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useUIPaginatedTable } from '@/hooks/common/table';
|
||||
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 {
|
||||
type WorkReportRow,
|
||||
createMonthlySearchParams,
|
||||
@@ -27,8 +28,7 @@ import {
|
||||
resolveWorkReportStatusTagType,
|
||||
transformWorkReportPage
|
||||
} from '../shared/types';
|
||||
import { resolveWorkReportSummaryPeriod } from '../shared/utils';
|
||||
import TeamReportSummary from '../shared/components/team-report-summary.vue';
|
||||
import { buildMonthlyPeriodFromMonth, resolveWorkReportSummaryPeriod } from '../shared/utils';
|
||||
import MonthlyReportSearch from './modules/search-panel.vue';
|
||||
import IconMdiDeleteOutline from '~icons/mdi/delete-outline';
|
||||
import IconMdiEyeOutline from '~icons/mdi/eye-outline';
|
||||
@@ -41,6 +41,7 @@ defineOptions({ name: 'MonthlyWorkReportIndex' });
|
||||
|
||||
const props = defineProps<{
|
||||
teamContext?: TeamViewContext | null;
|
||||
subordinateOptions?: Array<{ label: string; value: string }>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -68,8 +69,45 @@ const ACTION_ICON_MAP = {
|
||||
|
||||
const isTeamMode = computed(() => props.teamContext?.mode === 'team');
|
||||
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 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<
|
||||
Awaited<ReturnType<typeof fetchGetMonthlyReportPage>>,
|
||||
@@ -79,52 +117,104 @@ const table = useUIPaginatedTable<
|
||||
api: () =>
|
||||
fetchGetMonthlyReportPage({
|
||||
...searchParams,
|
||||
reporterIds: currentTeamReporterIds.value
|
||||
periodStartDate: normalizedPeriodRange.value,
|
||||
reporterIds: resolvedTeamReporterIds.value
|
||||
}),
|
||||
transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
|
||||
onPaginationParamsChange: params => {
|
||||
searchParams.pageNo = params.currentPage ?? 1;
|
||||
searchParams.pageSize = params.pageSize ?? 10;
|
||||
},
|
||||
columns: () => [
|
||||
{ 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: 'reporterDeptName',
|
||||
label: '部门',
|
||||
minWidth: 80,
|
||||
showOverflowTooltip: true,
|
||||
formatter: row => row.reporterDeptName || '--'
|
||||
},
|
||||
{ prop: 'supervisorName', label: '直属上级', minWidth: 80 },
|
||||
{ prop: 'totalWorkHours', label: '总工时', minWidth: 80, formatter: row => formatEmptyText(row.totalWorkHours) },
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
minWidth: 80,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolveWorkReportStatusTagType(row.statusCode)}>
|
||||
{getWorkReportStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{ prop: 'submitTime', label: '提交时间', minWidth: 100, formatter: row => formatDateTime(row.submitTime) },
|
||||
{ prop: 'approvalTime', label: '审批时间', minWidth: 100, formatter: row => formatDateTime(row.approvalTime) },
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: isTeamMode.value ? 140 : 180,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
|
||||
columns: () => {
|
||||
const cols: UI.TableColumn<Api.WorkReport.Monthly.MonthlyReport>[] = [
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
{ 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',
|
||||
label: '部门',
|
||||
minWidth: 80,
|
||||
showOverflowTooltip: true,
|
||||
formatter: row => row.reporterDeptName || '--'
|
||||
},
|
||||
{ prop: 'supervisorName', label: '直属上级', minWidth: 80 },
|
||||
{ prop: 'totalWorkHours', label: '总工时', minWidth: 80, formatter: row => formatEmptyText(row.totalWorkHours) },
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
minWidth: 80,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolveWorkReportStatusTagType(row.statusCode)}>
|
||||
{getWorkReportStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{ prop: 'submitTime', label: '提交时间', minWidth: 100, formatter: row => formatDateTime(row.submitTime) },
|
||||
{ prop: 'approvalTime', label: '审批时间', minWidth: 100, formatter: row => formatDateTime(row.approvalTime) },
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: isTeamMode.value ? 140 : 180,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
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[] {
|
||||
const actions: BusinessTableAction[] = [
|
||||
@@ -266,7 +356,8 @@ function createExportSearchParams() {
|
||||
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
|
||||
return {
|
||||
...params,
|
||||
reporterIds: currentTeamReporterIds.value
|
||||
periodStartDate: normalizedPeriodRange.value,
|
||||
reporterIds: resolvedTeamReporterIds.value
|
||||
};
|
||||
}
|
||||
|
||||
@@ -332,31 +423,42 @@ async function loadTeamSummary() {
|
||||
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;
|
||||
const { error, data } = await fetchGetTeamReportSummary({
|
||||
reportType: 'monthly',
|
||||
periodKey: summaryPeriod.value.periodKey
|
||||
});
|
||||
const { error, data } = await fetchGetTeamReportSummary(summaryParams);
|
||||
teamSummaryLoading.value = false;
|
||||
|
||||
teamSummary.value = error || !data ? null : data;
|
||||
}
|
||||
|
||||
defineExpose({ reload });
|
||||
defineExpose({
|
||||
reload,
|
||||
teamSummary,
|
||||
teamSummaryLoading,
|
||||
summaryPeriod,
|
||||
summaryPeriodKeys,
|
||||
hasSearchedDateRange,
|
||||
loadTeamSummary
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex-col-stretch gap-16px overflow-hidden">
|
||||
<MonthlyReportSearch v-model:model="searchParams" @reset="resetSearchParams" @search="handleSearch" />
|
||||
|
||||
<TeamReportSummary
|
||||
v-if="isTeamRootSelected"
|
||||
report-type="monthly"
|
||||
:period-key="summaryPeriod.periodKey"
|
||||
:period-label="formatPeriod(summaryPeriod)"
|
||||
:loading="teamSummaryLoading"
|
||||
:summary="teamSummary"
|
||||
@reminded="loadTeamSummary"
|
||||
<MonthlyReportSearch
|
||||
v-model:model="searchParams"
|
||||
:team-mode="isTeamMode"
|
||||
:subordinate-options="props.subordinateOptions"
|
||||
@reset="resetSearchParams"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
|
||||
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">
|
||||
|
||||
@@ -4,6 +4,8 @@ import SharedWorkReportSearch from '../../shared/components/search-panel.vue';
|
||||
defineOptions({ name: 'MonthlyReportSearch' });
|
||||
|
||||
defineProps<{
|
||||
teamMode?: boolean;
|
||||
subordinateOptions?: Array<{ label: string; value: string }>;
|
||||
projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[];
|
||||
}>();
|
||||
|
||||
@@ -19,6 +21,8 @@ const emit = defineEmits<{
|
||||
<SharedWorkReportSearch
|
||||
v-model:model="model"
|
||||
report-type="monthly"
|
||||
:team-mode="teamMode"
|
||||
:subordinate-options="subordinateOptions"
|
||||
:project-options="projectOptions"
|
||||
@reset="emit('reset')"
|
||||
@search="emit('search')"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/* eslint-disable no-void */
|
||||
import { computed, markRaw, reactive, ref } from 'vue';
|
||||
import { ElMessageBox, ElTag } from 'element-plus';
|
||||
import dayjs from 'dayjs';
|
||||
import {
|
||||
fetchDeleteProjectReport,
|
||||
fetchExportProjectReportContent,
|
||||
@@ -27,8 +28,7 @@ import {
|
||||
resolveWorkReportStatusTagType,
|
||||
transformWorkReportPage
|
||||
} from '../shared/types';
|
||||
import { resolveWorkReportSummaryPeriod } from '../shared/utils';
|
||||
import TeamReportSummary from '../shared/components/team-report-summary.vue';
|
||||
import { buildProjectPeriodFromMonth, resolveWorkReportSummaryPeriod } from '../shared/utils';
|
||||
import ProjectReportSearch from './modules/search-panel.vue';
|
||||
import IconMdiDeleteOutline from '~icons/mdi/delete-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 currentProjectOwnerIds = computed(() => resolveTeamQueryUserIds(props.teamContext));
|
||||
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<
|
||||
Awaited<ReturnType<typeof fetchGetProjectReportPage>>,
|
||||
@@ -81,6 +97,7 @@ const table = useUIPaginatedTable<
|
||||
api: () =>
|
||||
fetchGetProjectReportPage({
|
||||
...searchParams,
|
||||
periodStartDate: normalizedPeriodRange.value,
|
||||
projectOwnerIds: currentProjectOwnerIds.value
|
||||
}),
|
||||
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[] {
|
||||
const actions: BusinessTableAction[] = [
|
||||
@@ -271,6 +323,7 @@ function createExportSearchParams() {
|
||||
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
|
||||
return {
|
||||
...params,
|
||||
periodStartDate: normalizedPeriodRange.value,
|
||||
projectOwnerIds: currentProjectOwnerIds.value
|
||||
};
|
||||
}
|
||||
@@ -337,17 +390,32 @@ async function loadTeamSummary() {
|
||||
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;
|
||||
const { error, data } = await fetchGetTeamReportSummary({
|
||||
reportType: 'project',
|
||||
periodKey: summaryPeriod.value.periodKey
|
||||
});
|
||||
const { error, data } = await fetchGetTeamReportSummary(summaryParams);
|
||||
teamSummaryLoading.value = false;
|
||||
|
||||
teamSummary.value = error || !data ? null : data;
|
||||
}
|
||||
|
||||
defineExpose({ reload });
|
||||
defineExpose({
|
||||
reload,
|
||||
teamSummary,
|
||||
teamSummaryLoading,
|
||||
summaryPeriod,
|
||||
summaryPeriodKeys,
|
||||
hasSearchedDateRange,
|
||||
loadTeamSummary
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -364,16 +432,6 @@ defineExpose({ reload });
|
||||
@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">
|
||||
<template #header>
|
||||
<div class="flex flex-wrap items-center justify-between gap-12px">
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
/* 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 type { SearchField } 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 { formatIsoWeekRangeLabel, normalizeWeeklySearchRange } from '../utils';
|
||||
|
||||
dayjs.extend(isoWeek);
|
||||
|
||||
defineOptions({ name: 'WorkReportSearch' });
|
||||
|
||||
interface Props {
|
||||
reportType: WorkReportType;
|
||||
teamMode?: boolean;
|
||||
subordinateOptions?: Array<{ label: string; value: string }>;
|
||||
projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[];
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
teamMode: false,
|
||||
subordinateOptions: () => [],
|
||||
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 baseFields: SearchField[] = [
|
||||
{ key: 'statusCode', label: '状态', type: 'select', options: statusOptions.value, placeholder: '请选择状态' },
|
||||
@@ -51,8 +66,33 @@ const fields = computed<SearchField[]>(() => {
|
||||
};
|
||||
|
||||
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 [
|
||||
...baseFields,
|
||||
baseFields[0],
|
||||
weeklyPeriodField,
|
||||
...teamReporterField,
|
||||
{
|
||||
key: 'isBusinessTrip',
|
||||
label: '是否出差',
|
||||
@@ -81,7 +121,21 @@ const fields = computed<SearchField[]>(() => {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -95,6 +149,34 @@ async function loadStatusDict() {
|
||||
onMounted(() => {
|
||||
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>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { fetchRemindTeamReport } from '@/service/api';
|
||||
import { formatIsoWeekRangeLabel } from '../utils';
|
||||
|
||||
defineOptions({ name: 'TeamReportSummary' });
|
||||
|
||||
interface Props {
|
||||
reportType: Api.WorkReport.Common.ReportType;
|
||||
periodKey: string;
|
||||
periodKeys?: string[];
|
||||
periodLabel?: string;
|
||||
loading?: boolean;
|
||||
summary?: Api.WorkReport.Common.TeamReportSummary | null;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
periodKeys: () => [],
|
||||
periodLabel: '',
|
||||
loading: false,
|
||||
summary: null
|
||||
@@ -24,6 +27,34 @@ const emit = defineEmits<{
|
||||
|
||||
const remindingAll = ref(false);
|
||||
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(() => [
|
||||
{ label: '应填人数', value: props.summary?.totalShouldSubmit ?? 0 },
|
||||
@@ -33,6 +64,8 @@ const cards = computed(() => [
|
||||
]);
|
||||
|
||||
async function handleRemind(userIds?: string[]) {
|
||||
if (!props.periodKeys.length) return;
|
||||
|
||||
const targetUserId = userIds?.length === 1 ? userIds[0] : '';
|
||||
|
||||
if (targetUserId) {
|
||||
@@ -41,27 +74,36 @@ async function handleRemind(userIds?: string[]) {
|
||||
remindingAll.value = true;
|
||||
}
|
||||
|
||||
const { error, data } = await fetchRemindTeamReport({
|
||||
reportType: props.reportType,
|
||||
periodKey: props.periodKey,
|
||||
userIds
|
||||
});
|
||||
const results = await Promise.all(
|
||||
props.periodKeys.map(periodKey =>
|
||||
fetchRemindTeamReport({
|
||||
reportType: props.reportType,
|
||||
periodKey,
|
||||
userIds
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
if (!targetUserId) {
|
||||
remindingAll.value = false;
|
||||
}
|
||||
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');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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 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>
|
||||
<ElButton
|
||||
v-if="canRemind"
|
||||
link
|
||||
type="primary"
|
||||
:loading="remindingUserId === user.userId"
|
||||
@@ -94,7 +137,7 @@ async function handleRemind(userIds?: string[]) {
|
||||
</div>
|
||||
<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
|
||||
size="small"
|
||||
type="primary"
|
||||
|
||||
@@ -155,12 +155,16 @@ export function createInitBaseSearchParams() {
|
||||
export function createWeeklySearchParams(): Api.WorkReport.Weekly.WeeklyReportSearchParams {
|
||||
return {
|
||||
...createInitBaseSearchParams(),
|
||||
reporterIds: undefined,
|
||||
isBusinessTrip: undefined
|
||||
};
|
||||
}
|
||||
|
||||
export function createMonthlySearchParams(): Api.WorkReport.Monthly.MonthlyReportSearchParams {
|
||||
return createInitBaseSearchParams();
|
||||
return {
|
||||
...createInitBaseSearchParams(),
|
||||
reporterIds: undefined
|
||||
};
|
||||
}
|
||||
|
||||
export function createProjectSearchParams(): Api.WorkReport.Project.ProjectReportSearchParams {
|
||||
|
||||
@@ -46,6 +46,29 @@ export function getIsoWeekDisplay(date: string | dayjs.Dayjs) {
|
||||
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 */
|
||||
function buildPeriod(reportType: WorkReportType, start: dayjs.Dayjs, end: dayjs.Dayjs, label: string, flag?: number) {
|
||||
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));
|
||||
}
|
||||
|
||||
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) {
|
||||
const selectedMonth = dayjs(month);
|
||||
const start = selectedMonth.startOf('month');
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang="tsx">
|
||||
/* 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 dayjs from 'dayjs';
|
||||
import {
|
||||
fetchDeleteWeeklyReport,
|
||||
fetchExportWeeklyReportContent,
|
||||
@@ -12,7 +13,7 @@ import {
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import { useUIPaginatedTable } from '@/hooks/common/table';
|
||||
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 {
|
||||
type WorkReportRow,
|
||||
createWeeklySearchParams,
|
||||
@@ -29,8 +30,7 @@ import {
|
||||
resolveWorkReportStatusTagType,
|
||||
transformWorkReportPage
|
||||
} from '../shared/types';
|
||||
import { resolveWorkReportSummaryPeriod } from '../shared/utils';
|
||||
import TeamReportSummary from '../shared/components/team-report-summary.vue';
|
||||
import { buildWeeklyPeriodFromDate, normalizeWeeklySearchRange, resolveWorkReportSummaryPeriod } from '../shared/utils';
|
||||
import WeeklyReportSearch from './modules/search-panel.vue';
|
||||
import IconMdiDeleteOutline from '~icons/mdi/delete-outline';
|
||||
import IconMdiEyeOutline from '~icons/mdi/eye-outline';
|
||||
@@ -43,6 +43,7 @@ defineOptions({ name: 'WeeklyWorkReportIndex' });
|
||||
|
||||
const props = defineProps<{
|
||||
teamContext?: TeamViewContext | null;
|
||||
subordinateOptions?: Array<{ label: string; value: string }>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -70,9 +71,30 @@ const ACTION_ICON_MAP = {
|
||||
|
||||
const isTeamMode = computed(() => props.teamContext?.mode === 'team');
|
||||
const isTeamRootSelected = computed(() => Boolean(isTeamMode.value && props.teamContext?.isRootSelected));
|
||||
const currentTeamReporterIds = computed(() => resolveTeamQueryUserIds(props.teamContext));
|
||||
const reportTitle = computed(() => getWorkReportTypeDisplayLabel('weekly', isTeamMode.value));
|
||||
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('weekly', isTeamMode.value));
|
||||
const normalizedPeriodRange = computed(() => normalizeWeeklySearchRange(searchParams.periodStartDate));
|
||||
const table = useUIPaginatedTable<
|
||||
Awaited<ReturnType<typeof fetchGetWeeklyReportPage>>,
|
||||
Api.WorkReport.Weekly.WeeklyReport
|
||||
@@ -81,79 +103,134 @@ const table = useUIPaginatedTable<
|
||||
api: () =>
|
||||
fetchGetWeeklyReportPage({
|
||||
...searchParams,
|
||||
reporterIds: currentTeamReporterIds.value
|
||||
periodStartDate: normalizedPeriodRange.value,
|
||||
reporterIds: resolvedTeamReporterIds.value
|
||||
}),
|
||||
transform: response => transformWorkReportPage(response, searchParams.pageNo ?? 1, searchParams.pageSize ?? 10),
|
||||
onPaginationParamsChange: params => {
|
||||
searchParams.pageNo = params.currentPage ?? 1;
|
||||
searchParams.pageSize = params.pageSize ?? 10;
|
||||
},
|
||||
columns: () => [
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
...(isTeamMode.value ? [{ prop: 'reporterName', label: '提交人', minWidth: 100, showOverflowTooltip: true }] : []),
|
||||
{
|
||||
prop: 'periodLabel',
|
||||
label: '周期',
|
||||
minWidth: 150,
|
||||
formatter: row => {
|
||||
const periodText = formatWeeklyPeriodLabel(row);
|
||||
const weekLabel = formatPeriodDateRange(row);
|
||||
if (!weekLabel || weekLabel === '--') return periodText;
|
||||
return (
|
||||
<ElTooltip content={weekLabel} placement="top">
|
||||
<span>{periodText}</span>
|
||||
</ElTooltip>
|
||||
);
|
||||
columns: () => {
|
||||
const cols: UI.TableColumn<Api.WorkReport.Weekly.WeeklyReport>[] = [
|
||||
{ prop: 'index', type: 'index', label: '序号', width: 64 },
|
||||
{
|
||||
prop: 'periodLabel',
|
||||
label: '周期',
|
||||
minWidth: 150,
|
||||
formatter: row => {
|
||||
const periodText = formatWeeklyPeriodLabel(row);
|
||||
const weekLabel = formatPeriodDateRange(row);
|
||||
if (!weekLabel || weekLabel === '--') return periodText;
|
||||
return (
|
||||
<ElTooltip content={weekLabel} placement="top">
|
||||
<span>{periodText}</span>
|
||||
</ElTooltip>
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'reporterDeptName',
|
||||
label: '部门',
|
||||
minWidth: 80,
|
||||
showOverflowTooltip: true,
|
||||
formatter: row => row.reporterDeptName || '--'
|
||||
},
|
||||
{ prop: 'supervisorName', label: '直属上级', minWidth: 80 },
|
||||
{ prop: 'totalWorkHours', label: '总工时', minWidth: 80, formatter: row => formatEmptyText(row.totalWorkHours) },
|
||||
{
|
||||
prop: 'isBusinessTrip',
|
||||
label: '出差',
|
||||
minWidth: 80,
|
||||
align: 'center',
|
||||
formatter: row => (row.isBusinessTrip ? '是' : '否')
|
||||
},
|
||||
{
|
||||
prop: 'totalTravelDays',
|
||||
label: '出差天数',
|
||||
minWidth: 90,
|
||||
formatter: row => formatEmptyText(row.totalTravelDays)
|
||||
},
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
minWidth: 80,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolveWorkReportStatusTagType(row.statusCode)}>
|
||||
{getWorkReportStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{ prop: 'submitTime', label: '提交时间', minWidth: 100, formatter: row => formatDateTime(row.submitTime) },
|
||||
{ prop: 'approvalTime', label: '审批时间', minWidth: 100, formatter: row => formatDateTime(row.approvalTime) },
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: isTeamMode.value ? 140 : 180,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
formatter: row => <BusinessTableActionCell actions={getRowActions(row)} variant="icon" />
|
||||
];
|
||||
|
||||
if (isTeamMode.value) {
|
||||
cols.push({ prop: 'reporterName', label: '提交人', minWidth: 100, showOverflowTooltip: true });
|
||||
}
|
||||
]
|
||||
|
||||
cols.push(
|
||||
{
|
||||
prop: 'reporterDeptName',
|
||||
label: '部门',
|
||||
minWidth: 80,
|
||||
showOverflowTooltip: true,
|
||||
formatter: row => row.reporterDeptName || '--'
|
||||
},
|
||||
{ prop: 'supervisorName', label: '直属上级', minWidth: 80 },
|
||||
{ prop: 'totalWorkHours', label: '总工时', minWidth: 80, formatter: row => formatEmptyText(row.totalWorkHours) },
|
||||
{
|
||||
prop: 'isBusinessTrip',
|
||||
label: '出差',
|
||||
minWidth: 80,
|
||||
align: 'center',
|
||||
formatter: row => (row.isBusinessTrip ? '是' : '否')
|
||||
},
|
||||
{
|
||||
prop: 'totalTravelDays',
|
||||
label: '出差天数',
|
||||
minWidth: 90,
|
||||
formatter: row => formatEmptyText(row.totalTravelDays)
|
||||
},
|
||||
{
|
||||
prop: 'statusCode',
|
||||
label: '状态',
|
||||
minWidth: 80,
|
||||
align: 'center',
|
||||
formatter: row => (
|
||||
<ElTag type={resolveWorkReportStatusTagType(row.statusCode)}>
|
||||
{getWorkReportStatusLabel(row.statusCode, row.statusName)}
|
||||
</ElTag>
|
||||
)
|
||||
},
|
||||
{ prop: 'submitTime', label: '提交时间', minWidth: 100, formatter: row => formatDateTime(row.submitTime) },
|
||||
{ prop: 'approvalTime', label: '审批时间', minWidth: 100, formatter: row => formatDateTime(row.approvalTime) },
|
||||
{
|
||||
prop: 'operate',
|
||||
label: '操作',
|
||||
width: isTeamMode.value ? 140 : 180,
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
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[] {
|
||||
const actions: BusinessTableAction[] = [
|
||||
@@ -295,7 +372,8 @@ function createExportSearchParams() {
|
||||
const { pageNo: _pageNo, pageSize: _pageSize, ...params } = searchParams;
|
||||
return {
|
||||
...params,
|
||||
reporterIds: currentTeamReporterIds.value
|
||||
periodStartDate: normalizedPeriodRange.value,
|
||||
reporterIds: resolvedTeamReporterIds.value
|
||||
};
|
||||
}
|
||||
|
||||
@@ -361,31 +439,42 @@ async function loadTeamSummary() {
|
||||
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;
|
||||
const { error, data } = await fetchGetTeamReportSummary({
|
||||
reportType: 'weekly',
|
||||
periodKey: summaryPeriod.value.periodKey
|
||||
});
|
||||
const { error, data } = await fetchGetTeamReportSummary(summaryParams);
|
||||
teamSummaryLoading.value = false;
|
||||
|
||||
teamSummary.value = error || !data ? null : data;
|
||||
}
|
||||
|
||||
defineExpose({ reload });
|
||||
defineExpose({
|
||||
reload,
|
||||
teamSummary,
|
||||
teamSummaryLoading,
|
||||
summaryPeriod,
|
||||
summaryPeriodKeys,
|
||||
hasSearchedDateRange,
|
||||
loadTeamSummary
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex-col-stretch gap-16px overflow-hidden">
|
||||
<WeeklyReportSearch v-model:model="searchParams" @reset="resetSearchParams" @search="handleSearch" />
|
||||
|
||||
<TeamReportSummary
|
||||
v-if="isTeamRootSelected"
|
||||
report-type="weekly"
|
||||
:period-key="summaryPeriod.periodKey"
|
||||
:period-label="formatWeeklyPeriodLabel(summaryPeriod)"
|
||||
:loading="teamSummaryLoading"
|
||||
:summary="teamSummary"
|
||||
@reminded="loadTeamSummary"
|
||||
<WeeklyReportSearch
|
||||
v-model:model="searchParams"
|
||||
:team-mode="isTeamMode"
|
||||
:subordinate-options="props.subordinateOptions"
|
||||
@reset="resetSearchParams"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
|
||||
<ElCard class="flex-1-hidden card-wrapper" body-class="business-table-card-body">
|
||||
|
||||
@@ -4,6 +4,8 @@ import SharedWorkReportSearch from '../../shared/components/search-panel.vue';
|
||||
defineOptions({ name: 'WeeklyReportSearch' });
|
||||
|
||||
defineProps<{
|
||||
teamMode?: boolean;
|
||||
subordinateOptions?: Array<{ label: string; value: string }>;
|
||||
projectOptions?: Api.WorkReport.Project.ProjectReportOwnerProjectOption[];
|
||||
}>();
|
||||
|
||||
@@ -19,6 +21,8 @@ const emit = defineEmits<{
|
||||
<SharedWorkReportSearch
|
||||
v-model:model="model"
|
||||
report-type="weekly"
|
||||
:team-mode="teamMode"
|
||||
:subordinate-options="subordinateOptions"
|
||||
:project-options="projectOptions"
|
||||
@reset="emit('reset')"
|
||||
@search="emit('search')"
|
||||
|
||||
Reference in New Issue
Block a user