feat: required check in dutyinfo; change service in dutyinfo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getDutyInfo, updateDutyInfo } from '@/services/api';
|
||||
import { getDutyInfo } from '@/services/api';
|
||||
import {
|
||||
EditableProTable,
|
||||
PageContainer,
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from '@ant-design/pro-components';
|
||||
import { Card, message } from 'antd';
|
||||
import { useEffect, useState } from 'react';
|
||||
import request from 'umi-request';
|
||||
import { Info } from './info';
|
||||
|
||||
type Shift = {
|
||||
@@ -81,20 +82,34 @@ const DutyInfo: React.FC = () => {
|
||||
{contextHolder}
|
||||
<Card>
|
||||
{!loading && (
|
||||
<ProForm<Info>
|
||||
submitter={{
|
||||
resetButtonProps: { style: { display: 'none' } },
|
||||
submitButtonProps: {
|
||||
style: { width: '31%' },
|
||||
},
|
||||
render: (_, doms) => {
|
||||
return <div style={{ textAlign: 'center' }}>{doms}</div>;
|
||||
},
|
||||
}}
|
||||
onFinish={updateDutyInfo}
|
||||
initialValues={dutyInfo}
|
||||
>
|
||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||
<ProForm<Info>
|
||||
submitter={{
|
||||
resetButtonProps: { style: { display: 'none' } },
|
||||
submitButtonProps: {
|
||||
style: { width: '31%' },
|
||||
},
|
||||
render: (_, doms) => {
|
||||
return <div style={{ textAlign: 'center' }}>{doms}</div>;
|
||||
},
|
||||
}}
|
||||
onFinish={async (values) => {
|
||||
setLoading(true);
|
||||
request('/admin/duty/update', {
|
||||
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
|
||||
name="dutyStatus"
|
||||
label="值班状态"
|
||||
@@ -113,8 +128,8 @@ const DutyInfo: React.FC = () => {
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||
</div>
|
||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||
<ProFormDependency name={['dutyStatus']}>
|
||||
{({ dutyStatus }) => {
|
||||
if (dutyStatus === 'pause') {
|
||||
@@ -125,11 +140,13 @@ const DutyInfo: React.FC = () => {
|
||||
name="offDutyReason"
|
||||
label="值班暂停原因"
|
||||
placeholder="请输入暂停值班的原因"
|
||||
rules={[{ required: true }]}
|
||||
/>
|
||||
<ProFormDateTimePicker
|
||||
name="dutyRecoverTime"
|
||||
width="md"
|
||||
label="值班恢复时间"
|
||||
rules={[{ required: true }]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -142,55 +159,57 @@ const DutyInfo: React.FC = () => {
|
||||
width="md"
|
||||
min={0}
|
||||
max={10}
|
||||
rules={[{ required: true }]}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</ProFormDependency>
|
||||
</div>
|
||||
<ProFormDependency name={['dutyStatus']}>
|
||||
{({ dutyStatus }) => {
|
||||
if (dutyStatus === 'others') {
|
||||
return (
|
||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||
<ProForm.Item
|
||||
label="其他值班班次"
|
||||
name="dataSource"
|
||||
initialValue={dutyInfo?.otherDutyTime}
|
||||
trigger="onValuesChange"
|
||||
style={{ width: '80%' }}
|
||||
>
|
||||
<EditableProTable<Shift>
|
||||
rowKey="id"
|
||||
toolBarRender={false}
|
||||
columns={columns}
|
||||
recordCreatorProps={{
|
||||
newRecordType: 'dataSource',
|
||||
position: 'bottom',
|
||||
creatorButtonText: '新建一个值班班次',
|
||||
style: { width: '100%', margin: 'auto', marginTop: '2%' },
|
||||
record: () => ({
|
||||
id: Date.now(),
|
||||
title: '',
|
||||
place: '',
|
||||
range: [],
|
||||
}),
|
||||
}}
|
||||
editable={{
|
||||
type: 'multiple',
|
||||
editableKeys,
|
||||
onChange: setEditableRowKeys,
|
||||
actionRender: (row, _, dom) => {
|
||||
return [dom.delete];
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</ProForm.Item>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}}
|
||||
</ProFormDependency>
|
||||
</ProForm>
|
||||
</div>
|
||||
<ProFormDependency name={['dutyStatus']}>
|
||||
{({ dutyStatus }) => {
|
||||
if (dutyStatus === 'others') {
|
||||
return (
|
||||
<div style={{ justifyContent: 'center', display: 'flex' }}>
|
||||
<ProForm.Item
|
||||
label="其他值班班次"
|
||||
name="dataSource"
|
||||
initialValue={dutyInfo?.otherDutyTime}
|
||||
trigger="onValuesChange"
|
||||
style={{ width: '80%' }}
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<EditableProTable<Shift>
|
||||
rowKey="id"
|
||||
toolBarRender={false}
|
||||
columns={columns}
|
||||
recordCreatorProps={{
|
||||
newRecordType: 'dataSource',
|
||||
position: 'bottom',
|
||||
creatorButtonText: '新建一个值班班次',
|
||||
style: { width: '100%', margin: 'auto', marginTop: '2%' },
|
||||
record: () => ({
|
||||
id: Date.now(),
|
||||
title: '',
|
||||
place: '',
|
||||
range: [],
|
||||
}),
|
||||
}}
|
||||
editable={{
|
||||
type: 'multiple',
|
||||
editableKeys,
|
||||
onChange: setEditableRowKeys,
|
||||
actionRender: (row, _, dom) => {
|
||||
return [dom.delete];
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</ProForm.Item>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}}
|
||||
</ProFormDependency>
|
||||
</ProForm>
|
||||
)}
|
||||
</Card>
|
||||
</PageContainer>
|
||||
|
||||
@@ -208,7 +208,6 @@ const Login: React.FC = () => {
|
||||
</ProFormCheckbox>
|
||||
</div>
|
||||
<div style={{ marginBottom: '2vh' }}>
|
||||
{' '}
|
||||
<Button
|
||||
type="default"
|
||||
block
|
||||
|
||||
Reference in New Issue
Block a user