From d6a42f60879c58b77ab8e563e070732a48765d3d Mon Sep 17 00:00:00 2001 From: Dawn1Ocean <1785590531@qq.com> Date: Tue, 16 Apr 2024 11:51:17 +0800 Subject: [PATCH] move conclusion to admin; add protable in conclusion --- config/routes.ts | 1 + doc/api.md | 38 +++++++ mock/conclusionlist.json | 73 ++++++++++++ mock/requestRecord.mock.js | 7 ++ src/pages/Admin/Conclusion/conclusionItem.ts | 31 ++++++ src/pages/Admin/Conclusion/index.tsx | 111 +++++++++++++++++++ 6 files changed, 261 insertions(+) create mode 100644 mock/conclusionlist.json create mode 100644 src/pages/Admin/Conclusion/conclusionItem.ts create mode 100644 src/pages/Admin/Conclusion/index.tsx diff --git a/config/routes.ts b/config/routes.ts index 7510edc..500c4b9 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -14,6 +14,7 @@ export default [ { path: '/admin', redirect: '/admin/dutyinfo' }, { path: '/admin/dutyinfo', name: '值班信息', component: './Admin/DutyInfo' }, { path: '/admin/dutytable', name: '值班表管理', component: './Admin/DutyTable' }, + { path: '/admin/conclusion', name: '值班总结管理', component: './Admin/Conclusion' }, { path: '/admin/report', name: '反馈信息', component: './Admin/Report' }, { path: '/admin/logs', name: '日志', component: './Admin/Logs' }, ], diff --git a/doc/api.md b/doc/api.md index 0c61a45..7417d77 100644 --- a/doc/api.md +++ b/doc/api.md @@ -315,3 +315,41 @@ data: ``` 前端显示的信息:"{op} 于 {time} {operation} 了 {target}:{prev.info} -> {curr.info}" + +## 值班总结管理页面 + +### 获取值班总结列表 `GET /admin/conclusionlist` + +request: + +```json +{ + "current": 1, + "pageSize": 10, + "op?": "晓洋", // 如果不筛选则不出现在 request-body 内 + "week": "all" | "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun", // all 之外的选项用于筛选 + "shift": "all" | "first" | "second" | "third" // all 之外的选项用于筛选 +} +``` + +data: + +```json +{ + "page": 1, + "total": 24, + "success": true, + "data": [ + { + "op": "宇航员", + "avatar": "https://...", + "time": "2024-03-07T19:52:48.523303", + "week": "2", + "shift": "3", + } + // ... + ] +} +``` + +前端显示的信息:"{op} 于 {time} 上传了{week}{shift}值班总结" diff --git a/mock/conclusionlist.json b/mock/conclusionlist.json new file mode 100644 index 0000000..75c950a --- /dev/null +++ b/mock/conclusionlist.json @@ -0,0 +1,73 @@ +[ + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:48.523303", + "week": "2", + "shift": "3" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:49.523303", + "week": "2", + "shift": "1" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:50.523303", + "week": "2", + "shift": "2" + }, + { + "op": "晓洋", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:51.523303", + "week": "7", + "shift": "3" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:52.523303", + "week": "7", + "shift": "1" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:53.523303", + "week": "2", + "shift": "3" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:54.523303", + "week": "2", + "shift": "3" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:55.523303", + "week": "2", + "shift": "3" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:56.523303", + "week": "2", + "shift": "3" + }, + { + "op": "宇航员", + "avatar": "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png", + "time": "2024-03-07T19:52:57.523303", + "week": "2", + "shift": "3" + } + ] + \ No newline at end of file diff --git a/mock/requestRecord.mock.js b/mock/requestRecord.mock.js index 935ec1d..b3c0f7d 100644 --- a/mock/requestRecord.mock.js +++ b/mock/requestRecord.mock.js @@ -2,6 +2,7 @@ import loglist from './loglist.json'; import sheet from './sheet.json'; import sheetlist from './sheetlist.json'; import reportlist from './reportlist.json'; +import conclusionlist from './conclusionlist.json'; module.exports = { 'GET /admin/stats': { @@ -55,6 +56,12 @@ module.exports = { total: 24, data: reportlist, }, + 'GET /admin/conclusionlist': { + success: true, + page: 1, + total: 24, + data: conclusionlist, + }, 'GET /api/currentUser': { data: { name: 'Serati Ma', diff --git a/src/pages/Admin/Conclusion/conclusionItem.ts b/src/pages/Admin/Conclusion/conclusionItem.ts new file mode 100644 index 0000000..3eef70b --- /dev/null +++ b/src/pages/Admin/Conclusion/conclusionItem.ts @@ -0,0 +1,31 @@ +export type ConclusionItem = { + op: string; + time: string; + week: string; + shift: string; +}; + +const weekMap: { [key: string]: string } = { + '1': '周一', + '2': '周二', + '3': '周三', + '4': '周四', + '5': '周五', + '6': '周六', + '7': '周日', +}; + +const shiftMap: { [key: string]: string } = { + '1': '第一班', + '2': '第二班', + '3': '第三班', +}; + +const transConclusion = (week: string, shift: string) => { + if (week === '7' && shift === '3') { + return '其他值班时间'; + } else { + return weekMap[week] + shiftMap[shift]; + } +}; +export default transConclusion; diff --git a/src/pages/Admin/Conclusion/index.tsx b/src/pages/Admin/Conclusion/index.tsx new file mode 100644 index 0000000..652d4a8 --- /dev/null +++ b/src/pages/Admin/Conclusion/index.tsx @@ -0,0 +1,111 @@ +import { PageContainer, ProList } from '@ant-design/pro-components'; +import { Card } from 'antd'; +import moment from 'moment'; +import request from 'umi-request'; +import transConclusion, { ConclusionItem } from './conclusionItem'; + +const Logs: React.FC = () => { + return ( + + + + search={{ + filterType: 'light', + }} + rowKey="op" + headerTitle="值班总结列表" + request={async (params = {} as Record) => + request<{ + data: ConclusionItem[]; + }>('/admin/conclusionlist', { + params, + }) + } + pagination={{ + pageSize: 10, + }} + metas={{ + title: { + dataIndex: 'op', + title: '用户', + }, + avatar: { + dataIndex: 'avatar', + search: false, + }, + description: { + dataIndex: ['time', 'week', 'shift'], + search: false, + render: (_, row) => { + return ( +
+ {'于 ' + + moment(row.time).format('YYYY-M-D HH:mm:ss') + + ' 上传了' + + transConclusion(row.week, row.shift) + + '值班总结'} +
+ ); + }, + }, + actions: { + render: () => [ + + 查看 + , + ], + search: false, + }, + week: { + // 自己扩展的字段,主要用于筛选,不在列表中显示 + title: '星期', + valueType: 'select', + valueEnum: { + all: { text: '全部', status: 'Default' }, + mon: { + text: '周一', + }, + tue: { + text: '周二', + }, + wed: { + text: '周三', + }, + thu: { + text: '周四', + }, + fri: { + text: '周五', + }, + sat: { + text: '周六', + }, + sun: { + text: '周日', + }, + }, + }, + shift: { + // 自己扩展的字段,主要用于筛选,不在列表中显示 + title: '值班', + valueType: 'select', + valueEnum: { + all: { text: '全部', status: 'Default' }, + first: { + text: '第一班', + }, + second: { + text: '第二班', + }, + third: { + text: '第三班', + }, + }, + }, + }} + /> +
+
+ ); +}; +export default Logs;