feat: dutyinfo service

mgy
Dawn1Ocean 2024-04-19 19:45:58 +08:00
parent 9bf2ef67be
commit 311d67a1b1
5 changed files with 102 additions and 82 deletions

View File

@ -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': {

View File

@ -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 (
<PageContainer>
<Card>
<ProForm<{
name: string;
company?: string;
useMode?: string;
}>
submitter={{
render: (props, doms) => {
return (
<Row>
<Col span={14} offset={4}>
<Space>{doms}</Space>
</Col>
</Row>);
},
}}
onFinish={async (values) => {
await waitTime(2000);
console.log(values);
message.success('提交成功');
}}
params={{}}
request={async () => {
await waitTime(100);
return {
name: '蚂蚁设计有限公司',
useMode: 'chapter',
};
}}
>
<ProFormRadio.Group
style={{
margin: 16,
}}
/>
<ProFormText
width="md"
name="name"
label="签约客户名称"
tooltip="最长为 24 位"
placeholder="请输入名称"
/>
<ProFormText
width="md"
name="company"
label="我方公司名称"
placeholder="请输入名称"
/>
<ProFormText
name={['contract', 'name']}
width="md"
label="合同名称"
placeholder="请输入名称"
/>
</ProForm>
</Card>
</PageContainer>
);
};
export default Logs;

View File

@ -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 (
<PageContainer>
<Card>
<ProForm<Info>
submitter={{
render: (props, doms) => {
return (
<Row>
<Col span={14} offset={4}>
<Space>{doms}</Space>
</Col>
</Row>
);
},
}}
onFinish={async (values) => {
await waitTime(2000);
console.log(values);
message.success('提交成功');
}}
params={{}}
request={async (params = {} as Record<string, any>) =>
request<Info>('/admin/duty/current', {
params,
})
}
>
<ProFormRadio.Group
style={{
margin: 16,
}}
/>
<ProFormText
width="md"
name="inDutyCnt"
label="值班人数"
tooltip="请输入数字"
placeholder="请输入值班人数"
/>
<ProFormText
width="md"
name="offDutyReason"
label="暂停值班原因"
placeholder="请输入暂停值班的原因"
/>
<ProFormText
name="dutyRecoverTime"
width="md"
label="值班恢复时间"
placeholder="请输入值班恢复的时间"
/>
</ProForm>
</Card>
</PageContainer>
);
};
export default DutyInfo;

View File

@ -0,0 +1,10 @@
export type Info = {
isNormalDuty: boolean;
inDutyCnt: number;
currentDuty: string;
place: string;
otherDutyStart: string;
otherDutyEnd: string;
offDutyReason: string;
dutyRecoverTime: string;
};

View File

@ -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 || {}),
});
}