From 311d67a1b1c632ab61cb3920f9fe0c9d60657f05 Mon Sep 17 00:00:00 2001
From: Dawn1Ocean <1785590531@qq.com>
Date: Fri, 19 Apr 2024 19:45:58 +0800
Subject: [PATCH] feat: dutyinfo service
---
mock/requestRecord.mock.js | 13 +++---
src/pages/Admin/DutyInfo.tsx | 75 ------------------------------
src/pages/Admin/DutyInfo/index.tsx | 73 +++++++++++++++++++++++++++++
src/pages/Admin/DutyInfo/info.ts | 10 ++++
src/services/api.ts | 13 +++++-
5 files changed, 102 insertions(+), 82 deletions(-)
delete mode 100644 src/pages/Admin/DutyInfo.tsx
create mode 100644 src/pages/Admin/DutyInfo/index.tsx
create mode 100644 src/pages/Admin/DutyInfo/info.ts
diff --git a/mock/requestRecord.mock.js b/mock/requestRecord.mock.js
index 2ae1f2f..4647598 100644
--- a/mock/requestRecord.mock.js
+++ b/mock/requestRecord.mock.js
@@ -35,13 +35,14 @@ module.exports = {
'GET /admin/duty/current': {
success: true,
data: {
- isNormalDuty: true,
- currentDuty: '2',
+ isNormalDuty: false,
+ currentDuty: 'off',
inDutyCnt: 3,
- otherDutyTime: '',
- offDutyReason: '',
- place: '204',
- dutyRecoverTime: '',
+ otherDutyStart: '2024-03-07T17:53:48.523303',
+ otherDutyEnd: '2024-03-17T17:53:48.523303',
+ offDutyReason: '期中考试周',
+ place: '',
+ dutyRecoverTime: '下周一',
},
},
'POST /admin/duty/update': {
diff --git a/src/pages/Admin/DutyInfo.tsx b/src/pages/Admin/DutyInfo.tsx
deleted file mode 100644
index 98f7935..0000000
--- a/src/pages/Admin/DutyInfo.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { PageContainer, ProForm, ProFormRadio, ProFormText } from '@ant-design/pro-components';
-import { Card, Col, Row, Space, message } from 'antd';
-
-const waitTime = (time: number = 100) => {
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve(true);
- }, time);
- });
-};
-
-const Logs: React.FC = () => {
-
- return (
-
-
-
- submitter={{
- render: (props, doms) => {
- return (
-
-
- {doms}
-
-
);
- },
- }}
- onFinish={async (values) => {
- await waitTime(2000);
- console.log(values);
- message.success('提交成功');
- }}
- params={{}}
- request={async () => {
- await waitTime(100);
- return {
- name: '蚂蚁设计有限公司',
- useMode: 'chapter',
- };
- }}
- >
-
-
-
-
-
-
-
- );
-};
-export default Logs;
\ No newline at end of file
diff --git a/src/pages/Admin/DutyInfo/index.tsx b/src/pages/Admin/DutyInfo/index.tsx
new file mode 100644
index 0000000..1297157
--- /dev/null
+++ b/src/pages/Admin/DutyInfo/index.tsx
@@ -0,0 +1,73 @@
+import { PageContainer, ProForm, ProFormRadio, ProFormText } from '@ant-design/pro-components';
+import { Card, Col, Row, Space, message } from 'antd';
+// import { useState } from 'react';
+import request from 'umi-request';
+import { Info } from './info';
+
+const waitTime = (time: number = 100) => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(true);
+ }, time);
+ });
+};
+
+const DutyInfo: React.FC = () => {
+ // const [isNormalDuty, setIsNormalDuty] = useState(true);
+ return (
+
+
+
+ submitter={{
+ render: (props, doms) => {
+ return (
+
+
+ {doms}
+
+
+ );
+ },
+ }}
+ onFinish={async (values) => {
+ await waitTime(2000);
+ console.log(values);
+ message.success('提交成功');
+ }}
+ params={{}}
+ request={async (params = {} as Record) =>
+ request('/admin/duty/current', {
+ params,
+ })
+ }
+ >
+
+
+
+
+
+
+
+ );
+};
+export default DutyInfo;
diff --git a/src/pages/Admin/DutyInfo/info.ts b/src/pages/Admin/DutyInfo/info.ts
new file mode 100644
index 0000000..aa1489d
--- /dev/null
+++ b/src/pages/Admin/DutyInfo/info.ts
@@ -0,0 +1,10 @@
+export type Info = {
+ isNormalDuty: boolean;
+ inDutyCnt: number;
+ currentDuty: string;
+ place: string;
+ otherDutyStart: string;
+ otherDutyEnd: string;
+ offDutyReason: string;
+ dutyRecoverTime: string;
+};
diff --git a/src/services/api.ts b/src/services/api.ts
index 2a54275..136ce6e 100644
--- a/src/services/api.ts
+++ b/src/services/api.ts
@@ -1,5 +1,6 @@
// @ts-ignore
/* eslint-disable */
+import { Info } from '@/pages/Admin/DutyInfo/info';
import { request } from '@umijs/max';
import { API } from './typings';
@@ -33,7 +34,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
});
}
-/** 获取首页信息 GET /admin/stats */
+/** 获取首页信息 GET /stats */
export async function getStat(options?: { [key: string]: any }) {
return request<{
data: API.Stat;
@@ -42,3 +43,13 @@ export async function getStat(options?: { [key: string]: any }) {
...(options || {}),
});
}
+
+/** 获取当前值班信息 GET /admin/duty/current */
+export async function getDutyInfo(options?: { [key: string]: any }) {
+ return request<{
+ data: Info;
+ }>('/admin/duty/current', {
+ method: 'GET',
+ ...(options || {}),
+ });
+}