Merge branch 'mgy' of https://git.zjueva.net/Dawn_Ocean/EVA-Tea into mgy
commit
1caeba1225
|
|
@ -1,4 +1,4 @@
|
||||||
import { getDutyInfo, updateDutyInfo } from '@/services/api';
|
import { getDutyInfo } from '@/services/api';
|
||||||
import {
|
import {
|
||||||
EditableProTable,
|
EditableProTable,
|
||||||
PageContainer,
|
PageContainer,
|
||||||
|
|
@ -12,6 +12,7 @@ import {
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import { Card, message } from 'antd';
|
import { Card, message } from 'antd';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
import request from 'umi-request';
|
||||||
import { Info } from './info';
|
import { Info } from './info';
|
||||||
|
|
||||||
type Shift = {
|
type Shift = {
|
||||||
|
|
@ -81,20 +82,34 @@ const DutyInfo: React.FC = () => {
|
||||||
{contextHolder}
|
{contextHolder}
|
||||||
<Card>
|
<Card>
|
||||||
{!loading && (
|
{!loading && (
|
||||||
<ProForm<Info>
|
<ProForm<Info>
|
||||||
submitter={{
|
submitter={{
|
||||||
resetButtonProps: { style: { display: 'none' } },
|
resetButtonProps: { style: { display: 'none' } },
|
||||||
submitButtonProps: {
|
submitButtonProps: {
|
||||||
style: { width: '31%' },
|
style: { width: '31%' },
|
||||||
},
|
},
|
||||||
render: (_, doms) => {
|
render: (_, doms) => {
|
||||||
return <div style={{ textAlign: 'center' }}>{doms}</div>;
|
return <div style={{ textAlign: 'center' }}>{doms}</div>;
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onFinish={updateDutyInfo}
|
onFinish={async (values) => {
|
||||||
initialValues={dutyInfo}
|
setLoading(true);
|
||||||
>
|
request('/admin/duty/update', {
|
||||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
method: 'POST',
|
||||||
|
data: values,
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
setLoading(false);
|
||||||
|
message.success('提交成功');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
setLoading(false);
|
||||||
|
message.error('提交失败:' + err);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
initialValues={dutyInfo}
|
||||||
|
>
|
||||||
|
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||||
<ProFormRadio.Group
|
<ProFormRadio.Group
|
||||||
name="dutyStatus"
|
name="dutyStatus"
|
||||||
label="值班状态"
|
label="值班状态"
|
||||||
|
|
@ -113,8 +128,8 @@ const DutyInfo: React.FC = () => {
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||||
<ProFormDependency name={['dutyStatus']}>
|
<ProFormDependency name={['dutyStatus']}>
|
||||||
{({ dutyStatus }) => {
|
{({ dutyStatus }) => {
|
||||||
if (dutyStatus === 'pause') {
|
if (dutyStatus === 'pause') {
|
||||||
|
|
@ -125,11 +140,13 @@ const DutyInfo: React.FC = () => {
|
||||||
name="offDutyReason"
|
name="offDutyReason"
|
||||||
label="值班暂停原因"
|
label="值班暂停原因"
|
||||||
placeholder="请输入暂停值班的原因"
|
placeholder="请输入暂停值班的原因"
|
||||||
|
rules={[{ required: true }]}
|
||||||
/>
|
/>
|
||||||
<ProFormDateTimePicker
|
<ProFormDateTimePicker
|
||||||
name="dutyRecoverTime"
|
name="dutyRecoverTime"
|
||||||
width="md"
|
width="md"
|
||||||
label="值班恢复时间"
|
label="值班恢复时间"
|
||||||
|
rules={[{ required: true }]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -142,55 +159,57 @@ const DutyInfo: React.FC = () => {
|
||||||
width="md"
|
width="md"
|
||||||
min={0}
|
min={0}
|
||||||
max={10}
|
max={10}
|
||||||
|
rules={[{ required: true }]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
</ProFormDependency>
|
</ProFormDependency>
|
||||||
</div>
|
</div>
|
||||||
<ProFormDependency name={['dutyStatus']}>
|
<ProFormDependency name={['dutyStatus']}>
|
||||||
{({ dutyStatus }) => {
|
{({ dutyStatus }) => {
|
||||||
if (dutyStatus === 'others') {
|
if (dutyStatus === 'others') {
|
||||||
return (
|
return (
|
||||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||||
<ProForm.Item
|
<ProForm.Item
|
||||||
label="其他值班班次"
|
label="其他值班班次"
|
||||||
name="dataSource"
|
name="dataSource"
|
||||||
initialValue={dutyInfo?.otherDutyTime}
|
initialValue={dutyInfo?.otherDutyTime}
|
||||||
trigger="onValuesChange"
|
trigger="onValuesChange"
|
||||||
style={{ width: '80%' }}
|
style={{ width: '80%' }}
|
||||||
>
|
rules={[{ required: true }]}
|
||||||
<EditableProTable<Shift>
|
>
|
||||||
rowKey="id"
|
<EditableProTable<Shift>
|
||||||
toolBarRender={false}
|
rowKey="id"
|
||||||
columns={columns}
|
toolBarRender={false}
|
||||||
recordCreatorProps={{
|
columns={columns}
|
||||||
newRecordType: 'dataSource',
|
recordCreatorProps={{
|
||||||
position: 'bottom',
|
newRecordType: 'dataSource',
|
||||||
creatorButtonText: '新建一个值班班次',
|
position: 'bottom',
|
||||||
style: { width: '100%', margin: 'auto', marginTop: '2%' },
|
creatorButtonText: '新建一个值班班次',
|
||||||
record: () => ({
|
style: { width: '100%', margin: 'auto', marginTop: '2%' },
|
||||||
id: Date.now(),
|
record: () => ({
|
||||||
title: '',
|
id: Date.now(),
|
||||||
place: '',
|
title: '',
|
||||||
range: [],
|
place: '',
|
||||||
}),
|
range: [],
|
||||||
}}
|
}),
|
||||||
editable={{
|
}}
|
||||||
type: 'multiple',
|
editable={{
|
||||||
editableKeys,
|
type: 'multiple',
|
||||||
onChange: setEditableRowKeys,
|
editableKeys,
|
||||||
actionRender: (row, _, dom) => {
|
onChange: setEditableRowKeys,
|
||||||
return [dom.delete];
|
actionRender: (row, _, dom) => {
|
||||||
},
|
return [dom.delete];
|
||||||
}}
|
},
|
||||||
/>
|
}}
|
||||||
</ProForm.Item>
|
/>
|
||||||
</div>
|
</ProForm.Item>
|
||||||
);
|
</div>
|
||||||
}
|
);
|
||||||
}}
|
}
|
||||||
</ProFormDependency>
|
}}
|
||||||
</ProForm>
|
</ProFormDependency>
|
||||||
|
</ProForm>
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { Info, ServerInfo } from '@/pages/Admin/DutyInfo/info';
|
import { ServerInfo } from '@/pages/Admin/DutyInfo/info';
|
||||||
import { Stat } from '@/pages/Welcome/stat';
|
import { Stat } from '@/pages/Welcome/stat';
|
||||||
import { request } from '@umijs/max';
|
import { request } from '@umijs/max';
|
||||||
import { API } from './typings';
|
import { API } from './typings';
|
||||||
|
|
@ -54,12 +54,3 @@ export async function getDutyInfo(options?: { [key: string]: any }) {
|
||||||
...(options || {}),
|
...(options || {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 上传当前值班信息 POST /admin/duty/update */
|
|
||||||
export async function updateDutyInfo(body: Info, options?: { [key: string]: any }) {
|
|
||||||
return request<boolean | void>('/admin/duty/update', {
|
|
||||||
method: 'POST',
|
|
||||||
data: body,
|
|
||||||
...(options || {}),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue