diff --git a/mock/requestRecord.mock.js b/mock/requestRecord.mock.js index 0c4c1e1..1d3e3fa 100644 --- a/mock/requestRecord.mock.js +++ b/mock/requestRecord.mock.js @@ -68,13 +68,13 @@ module.exports = { total: 24, data: loglist, }, - 'GET /admin/reportlist': { + 'GET /leader/reportlist': { success: true, page: 1, total: 24, data: reportlist, }, - 'GET /admin/conclusionlist': { + 'GET /leader/conclusionlist': { success: true, page: 1, total: 24, diff --git a/src/pages/Leader/AskLeave/askLeaveItem.ts b/src/pages/Leader/AskLeave/askLeaveItem.ts index 03db798..0b7dc48 100644 --- a/src/pages/Leader/AskLeave/askLeaveItem.ts +++ b/src/pages/Leader/AskLeave/askLeaveItem.ts @@ -6,29 +6,3 @@ export type AskLeaveItem = { reason: string; substitute: string; }; - -const weekMap: { [key: string]: string } = { - '1': '周一', - '2': '周二', - '3': '周三', - '4': '周四', - '5': '周五', - '6': '周六', - '7': '周日', -}; - -const shiftMap: { [key: string]: string } = { - '1': '第一班', - '2': '第二班', - '3': '第三班', -}; - - -const transAskLeave = (week: string, shift: string) => { - if (week === '7' && shift === '3') { - return '其他值班时间'; - } else { - return weekMap[week] + shiftMap[shift]; - } -}; -export default transAskLeave; diff --git a/src/pages/Leader/AskLeave/index.tsx b/src/pages/Leader/AskLeave/index.tsx index c161e91..3b188df 100644 --- a/src/pages/Leader/AskLeave/index.tsx +++ b/src/pages/Leader/AskLeave/index.tsx @@ -2,7 +2,8 @@ import { PageContainer, ProList } from '@ant-design/pro-components'; import { Card, Space, Tag } from 'antd'; import moment from 'moment'; import request from 'umi-request'; -import transAskLeave, { AskLeaveItem } from './askLeaveItem'; +import { AskLeaveItem } from './askLeaveItem'; +import transShift from '@/utils/common'; const Logs: React.FC = () => { return ( @@ -39,7 +40,7 @@ const Logs: React.FC = () => { return ( - {transAskLeave(row.week, row.shift)} + {transShift(row.week, row.shift)} {row.substitute ? '代班:' + row.substitute : '未找人代班'} diff --git a/src/pages/Leader/Conclusion/conclusionItem.ts b/src/pages/Leader/Conclusion/conclusionItem.ts index 1aac8eb..cd762ae 100644 --- a/src/pages/Leader/Conclusion/conclusionItem.ts +++ b/src/pages/Leader/Conclusion/conclusionItem.ts @@ -5,28 +5,3 @@ export type ConclusionItem = { shift: string; detail: 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/Leader/Conclusion/index.tsx b/src/pages/Leader/Conclusion/index.tsx index 8cbf435..d51611a 100644 --- a/src/pages/Leader/Conclusion/index.tsx +++ b/src/pages/Leader/Conclusion/index.tsx @@ -2,7 +2,8 @@ import { PageContainer, ProList } from '@ant-design/pro-components'; import { Card, Space, Tag } from 'antd'; import moment from 'moment'; import request from 'umi-request'; -import transConclusion, { ConclusionItem } from './conclusionItem'; +import { ConclusionItem } from './conclusionItem'; +import transShift from '@/utils/common'; const Logs: React.FC = () => { return ( @@ -17,7 +18,7 @@ const Logs: React.FC = () => { request={async (params = {} as Record) => request<{ data: ConclusionItem[]; - }>('/admin/conclusionlist', { + }>('/leader/conclusionlist', { params, }) } @@ -39,7 +40,7 @@ const Logs: React.FC = () => { return ( - {transConclusion(row.week, row.shift)} + {transShift(row.week, row.shift)} ); diff --git a/src/pages/Leader/Report/index.tsx b/src/pages/Leader/Report/index.tsx index 91ff741..30ec0a9 100644 --- a/src/pages/Leader/Report/index.tsx +++ b/src/pages/Leader/Report/index.tsx @@ -17,7 +17,7 @@ const Logs: React.FC = () => { request={async (params = {} as Record) => request<{ data: ReportItem[]; - }>('/admin/reportlist', { + }>('/leader/reportlist', { params, }) } diff --git a/src/utils/common.ts b/src/utils/common.ts new file mode 100644 index 0000000..f5ab03c --- /dev/null +++ b/src/utils/common.ts @@ -0,0 +1,25 @@ +const weekMap: { [key: string]: string } = { + '1': '周一', + '2': '周二', + '3': '周三', + '4': '周四', + '5': '周五', + '6': '周六', + '7': '周日', +}; + +const shiftMap: { [key: string]: string } = { + '1': '第一班', + '2': '第二班', + '3': '第三班', +}; + +const transShift = (week: string, shift: string) => { + if (week === '7' && shift === '3') { + return '其他值班时间'; + } else { + return weekMap[week] + shiftMap[shift]; + } +}; + +export default transShift;