feat: DingTalk attendance import + integration config + expense types + UI polish

Server:
- Add DingTalk attendance import service with SSE progress streaming
- Add IntegrationConfig entity & module for multi-tenant DingTalk setup
- Add ExpenseType entity & ExpenseTypesModule
- Add SeedModule for DB initialization
- Add UserDingMapping entity for DingTalk user linkage
- Attendance service: import flow with dedup & student auto-mapping
- Rooms service: time-range overlap queries
- Sync controller/service: DingTalk integration wiring
- Permission guard: refactor to pure re-export
- Campus scope middleware: tenant-aware filtering

Admin UI:
- Attendance page: import UI with progress & result summary
- All pages: tableStyle/tablePagination standardization
- Login page: responsive styling
- Sensitive data: useViewSensitive hook for masked viewing
- Vite config: path aliases, build optimization
- Test infra: vitest config, test utilities

Docs: PRD DingTalk batch 1 & 2 design docs
This commit is contained in:
2026-07-09 09:11:56 +08:00
parent f1959f0d2a
commit 42d3f0e27f
71 changed files with 5331 additions and 609 deletions

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useState, useMemo } from 'react';
import React, { useEffect, useState, useMemo, useCallback } from 'react';
import {
Table,
Button,
@@ -26,6 +26,7 @@ import {
import dayjs from 'dayjs';
import api from '../../api';
import PermissionButton from '../../components/PermissionButton';
import { downloadBlob } from '../../utils/download';
const { RangePicker } = DatePicker;
@@ -49,6 +50,7 @@ const ExpensesPage: React.FC = () => {
const [personalTypeFilter, setPersonalTypeFilter] = useState<string | undefined>(undefined);
const [selectedRoomKeys, setSelectedRoomKeys] = useState<number[]>([]);
const [selectedPersonalKeys, setSelectedPersonalKeys] = useState<number[]>([]);
const [saving, setSaving] = useState(false);
// Dynamic expense type options from API
const [typeOptions, setTypeOptions] = useState<{ value: string; label: string }[]>([]);
@@ -99,7 +101,7 @@ const ExpensesPage: React.FC = () => {
}
};
const fetchData = async () => {
const fetchData = useCallback(async () => {
setLoading(true);
try {
const [re, pe, rm, st]: any[] = await Promise.all([
@@ -116,11 +118,11 @@ const ExpensesPage: React.FC = () => {
console.error(e);
}
setLoading(false);
};
}, []);
useEffect(() => {
fetchData();
}, []);
}, [fetchData]);
const filteredRoomExpenses = useMemo(() => {
return roomExpenses.filter((r: any) => {
@@ -145,6 +147,7 @@ const ExpensesPage: React.FC = () => {
}, [personalExpenses, personalSearch, personalTypeFilter]);
const handleRoomExpense = async () => {
setSaving(true);
const values = await roomForm.validateFields();
const payload = {
roomId: values.roomId,
@@ -168,10 +171,13 @@ const ExpensesPage: React.FC = () => {
fetchData();
} catch (e: any) {
message.error(e?.message || '操作失败');
} finally {
setSaving(false);
}
};
const handlePersonalExpense = async () => {
setSaving(true);
const values = await personalForm.validateFields();
const payload = {
studentId: values.studentId,
@@ -195,10 +201,12 @@ const ExpensesPage: React.FC = () => {
fetchData();
} catch (e: any) {
message.error(e?.message || '操作失败');
} finally {
setSaving(false);
}
};
const roomColumns = [
const roomColumns = useMemo(() => [
{ title: '宿舍', width: 120, render: (_: any, r: any) => r.room?.roomNumber || '-' },
{
title: '费用类型', width: 100,
@@ -256,9 +264,9 @@ const ExpensesPage: React.FC = () => {
</Space>
),
},
];
], [setEditingRoom, roomForm, setRoomModal, fetchData, typeMap]);
const personalColumns = [
const personalColumns = useMemo(() => [
{ title: '学生', width: 120, render: (_: any, r: any) => r.student?.name || '-' },
{
title: '费用类型', width: 100,
@@ -312,7 +320,7 @@ const ExpensesPage: React.FC = () => {
</Space>
),
},
];
], [setEditingPersonal, personalForm, setPersonalModal, fetchData, typeMap]);
return (
<div>
@@ -357,9 +365,7 @@ const ExpensesPage: React.FC = () => {
const formData = new FormData();
formData.append('file', file);
try {
const res: any = await api.post('/expenses/utility/import', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
});
const res: any = await api.post('/expenses/utility/import', formData);
if (res.errors?.length > 0) {
Modal.warning({
title: res.message,
@@ -383,23 +389,9 @@ const ExpensesPage: React.FC = () => {
permission="expense:view"
icon={<DownloadOutlined />}
onClick={() => {
const baseURL = import.meta.env.PROD
? '/api'
: `http://localhost:${import.meta.env.VITE_API_PORT || 3002}/api`;
const token = localStorage.getItem('token');
fetch(`${baseURL}/expenses/utility/template`, {
headers: { Authorization: `Bearer ${token}` },
})
.then((res) => res.blob())
.then((blob) => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '水电费导入模板.xlsx';
a.click();
URL.revokeObjectURL(url);
})
.catch(() => message.error('下载失败'));
downloadBlob('/expenses/utility/template', '水电费导入模板.xlsx').catch(() =>
message.error('下载失败'),
);
}}
>
@@ -508,23 +500,9 @@ const ExpensesPage: React.FC = () => {
permission="expense:view"
icon={<DownloadOutlined />}
onClick={() => {
const baseURL = import.meta.env.PROD
? '/api'
: `http://localhost:${import.meta.env.VITE_API_PORT || 3002}/api`;
const token = localStorage.getItem('token');
fetch(`${baseURL}/expenses/personal/template`, {
headers: { Authorization: `Bearer ${token}` },
})
.then((res) => res.blob())
.then((blob) => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '个人附加费导入模板.xlsx';
a.click();
URL.revokeObjectURL(url);
})
.catch(() => message.error('下载失败'));
downloadBlob('/expenses/personal/template', '个人附加费导入模板.xlsx').catch(
() => message.error('下载失败'),
);
}}
>
@@ -533,23 +511,9 @@ const ExpensesPage: React.FC = () => {
permission="expense:view"
icon={<ExportOutlined />}
onClick={() => {
const baseURL = import.meta.env.PROD
? '/api'
: `http://localhost:${import.meta.env.VITE_API_PORT || 3002}/api`;
const token = localStorage.getItem('token');
fetch(`${baseURL}/expenses/personal/export`, {
headers: { Authorization: `Bearer ${token}` },
})
.then((res) => res.blob())
.then((blob) => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '个人附加费导出.xlsx';
a.click();
URL.revokeObjectURL(url);
})
.catch(() => message.error('导出失败'));
downloadBlob('/expenses/personal/export', '个人附加费导出.xlsx').catch(() =>
message.error('导出失败'),
);
}}
>
@@ -613,6 +577,7 @@ const ExpensesPage: React.FC = () => {
setEditingRoom(null);
}}
okText={editingRoom ? '保存' : '确认录入'}
confirmLoading={saving}
>
<Form form={roomForm} layout="vertical">
<Form.Item name="roomId" label="宿舍" rules={[{ required: true }]}>
@@ -653,6 +618,7 @@ const ExpensesPage: React.FC = () => {
setEditingPersonal(null);
}}
okText={editingPersonal ? '保存' : '确认录入'}
confirmLoading={saving}
>
<Form form={personalForm} layout="vertical">
<Form.Item name="studentId" label="学生" rules={[{ required: true }]}>