Skip to content

Commit 9155c1a

Browse files
committed
add flow
1 parent a22ed69 commit 9155c1a

File tree

27 files changed

+802
-55
lines changed

27 files changed

+802
-55
lines changed

admin-ui/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@ag-grid-community/locale": "^33.0.3",
67
"@ant-design/icons": "^5.4.0",
7-
"@ant-design/pro-components": "^2.7.19",
8+
"@ant-design/pro-components": "^2.8.2",
89
"@babel/standalone": "^7.25.6",
910
"@dnd-kit/core": "^6.2.0",
1011
"@dnd-kit/sortable": "^9.0.0",
12+
"@handsontable/react-wrapper": "^15.0.0",
1113
"@logicflow/core": "^2.0.5",
1214
"@logicflow/extension": "^2.0.9",
1315
"@reduxjs/toolkit": "^2.2.7",
1416
"@types/babel__standalone": "^7.1.7",
1517
"@types/node": "^16.18.108",
1618
"@types/react": "^18.3.5",
1719
"@types/react-dom": "^18.3.0",
20+
"ag-grid-react": "^33.0.3",
1821
"antd": "^5.20.6",
1922
"axios": "^1.7.7",
2023
"base64-js": "^1.5.1",
24+
"handsontable": "^15.0.0",
2125
"jszip": "^3.10.1",
2226
"lodash": "^4.17.21",
2327
"moment": "^2.30.1",

admin-ui/src/api/salary.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const users = async () => {
2+
const data = [];
3+
for(let i=0;i<500;i++){
4+
data.push({
5+
id:i,
6+
name:`张三${i}`
7+
});
8+
}
9+
return data
10+
}

admin-ui/src/config/menus.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export const menus = [
1616
page: 'welcome',
1717
},
1818
{
19-
path: '/portal',
20-
name: '门户',
19+
path: '/salary',
20+
name: '薪酬',
2121
icon: "SmileOutlined",
22-
page: 'portal',
22+
page: 'salary',
2323
},
2424
{
2525
path: '/user',
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import {AgGridReact} from 'ag-grid-react';
2+
import {AllCommunityModule, ModuleRegistry, themeQuartz,} from "ag-grid-community";
3+
import {AG_GRID_LOCALE_CN} from '@ag-grid-community/locale';
4+
import {useCallback, useMemo, useState} from "react";
5+
6+
const localeText = AG_GRID_LOCALE_CN;
7+
// Register all Community features
8+
ModuleRegistry.registerModules([AllCommunityModule]);
9+
10+
11+
const myTheme = themeQuartz.withParams({
12+
/* Low spacing = very compact */
13+
spacing: 2,
14+
accentColor: "red",
15+
16+
});
17+
const AGTable = () => {
18+
const [rowData, setRowData] = useState();
19+
const [columnDefs, setColumnDefs] = useState([
20+
{
21+
field: "athlete",
22+
headerName: "运动员"
23+
},
24+
{
25+
field: "age",
26+
headerName: "年龄"
27+
},
28+
{
29+
field: "country",
30+
headerName: '国家信息',
31+
headerClass: 'country-header',
32+
children: [
33+
{
34+
field: "country",
35+
headerName: "国家",
36+
},
37+
{field: "name"},
38+
{field: "code"}
39+
]
40+
},
41+
{field: "year", headerName: "年份"},
42+
{field: "date", headerName: "日期"},
43+
{field: "sport", headerName: "运动"},
44+
{field: "gold", headerName: "金牌"},
45+
{field: "silver", headerName: "银牌"},
46+
{field: "bronze", headerName: "铜牌"},
47+
{field: "total", headerName: "总计", editable: false},
48+
]);
49+
const theme = useMemo(() => {
50+
return myTheme;
51+
}, []);
52+
const defaultColDef = useMemo(() => {
53+
return {
54+
editable: true,
55+
filter: true,
56+
};
57+
}, []);
58+
59+
const onGridReady = useCallback((params: any) => {
60+
fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
61+
.then((resp) => resp.json())
62+
.then((data) => setRowData(data));
63+
}, []);
64+
65+
66+
const onChange = (row:any,updateRow:(row:any)=>void,refreshColumns:()=>void)=>{
67+
const gold = row.gold;
68+
const silver = row.silver;
69+
const bronze = row.bronze;
70+
const total = gold + silver + bronze;
71+
72+
updateRow({...row,total});
73+
74+
// update redux store message
75+
76+
refreshColumns()
77+
}
78+
79+
return (
80+
<div
81+
// define a height because the Data Grid will fill the size of the parent container
82+
style={{height: 900}}
83+
>
84+
<AgGridReact
85+
rowData={rowData}
86+
localeText={localeText}
87+
onCellValueChanged={(event) => {
88+
//@ts-ignore
89+
if (['gold', 'silver', 'bronze'].includes(event.colDef.field)) {
90+
onChange( event.data,(data:any)=>{
91+
event.data.total = data.total;
92+
},()=>{
93+
event.api.refreshCells({columns: ['total']});
94+
});
95+
}
96+
}}
97+
columnDefs={columnDefs}
98+
theme={theme}
99+
// pagination={true}
100+
defaultColDef={defaultColDef}
101+
onGridReady={onGridReady}
102+
/>
103+
</div>
104+
);
105+
}
106+
107+
export default AGTable;
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import React, {useEffect} from "react";
2+
import {ActionType, EditableProTable, ProTable} from "@ant-design/pro-components";
3+
import {useDispatch, useSelector} from "react-redux";
4+
import {SalaryState, updateTable1} from "@/pages/salary/store/salary";
5+
import {Table1UpdateService} from "@/pages/salary/data/table1";
6+
import {ProColumns} from "@ant-design/pro-table/es/typing";
7+
import {Input, InputNumber, Space} from "antd";
8+
import AGTable from "@/pages/salary/compoments/AGTable";
9+
10+
const SalaryTable1 = () => {
11+
12+
const users = useSelector((state: SalaryState) => state.salary.users);
13+
14+
const table1 = useSelector((state: SalaryState) => state.salary.table1);
15+
16+
const store = useSelector((state: SalaryState) => state.salary);
17+
18+
const table2 = useSelector((state: SalaryState) => state.salary.table2);
19+
20+
const table2Version = useSelector((state: SalaryState) => state.salary.table2Version);
21+
22+
const actionRef = React.useRef<ActionType>(null);
23+
24+
const dispatch = useDispatch();
25+
26+
const table1UpdateService = new Table1UpdateService(store,
27+
(data) => {
28+
dispatch(updateTable1(data));
29+
}, () => {
30+
actionRef.current?.reload();
31+
});
32+
33+
useEffect(() => {
34+
table1UpdateService.initData(users);
35+
}, [users]);
36+
37+
// useEffect(() => {
38+
// table1UpdateService.reloadData(table2);
39+
// }, [table2Version]);
40+
41+
const columns = [
42+
{
43+
title: 'id',
44+
dataIndex: 'id',
45+
valueType: 'text',
46+
editable: false,
47+
},
48+
{
49+
title: '姓名',
50+
dataIndex: 'name',
51+
valueType: 'text',
52+
editable: false,
53+
render: (text, record) => {
54+
return <InputNumber
55+
value={record.name}
56+
defaultValue={record.name}/>
57+
}
58+
},
59+
{
60+
title: '绩效工资',
61+
dataIndex: 'jxgz',
62+
valueType: 'digit',
63+
editable: false,
64+
render: (text, record) => {
65+
return <InputNumber
66+
value={record.jxgz}
67+
defaultValue={record.jxgz}/>
68+
}
69+
},
70+
{
71+
title: '小计',
72+
dataIndex: 'sum',
73+
valueType: 'text',
74+
editable: false,
75+
render: (text, record) => {
76+
return <InputNumber
77+
value={record.sum}
78+
defaultValue={record.sum}/>
79+
}
80+
}
81+
] as ProColumns[];
82+
83+
return (
84+
<>
85+
{/*<ProTable*/}
86+
{/* actionRef={actionRef}*/}
87+
{/* columns={columns}*/}
88+
{/* search={false}*/}
89+
{/* rowKey={"id"}*/}
90+
{/* virtual={true}*/}
91+
{/* pagination={{*/}
92+
{/* pageSize: 20*/}
93+
{/* }}*/}
94+
{/* scroll={{*/}
95+
{/* x:2900,*/}
96+
{/* y:800*/}
97+
{/* }}*/}
98+
{/* request={async () => {*/}
99+
{/* return {*/}
100+
{/* // table1 top 100*/}
101+
{/* data: table1,*/}
102+
{/* success: true*/}
103+
{/* }*/}
104+
{/* }}*/}
105+
{/*/>*/}
106+
107+
<AGTable/>
108+
</>
109+
)
110+
}
111+
112+
export default SalaryTable1;

0 commit comments

Comments
 (0)