feat: add edit dutytable page

This commit is contained in:
Dawn1Ocean
2024-09-19 13:59:56 +08:00
parent f023e4b64a
commit d74cbcb229
4 changed files with 190 additions and 2 deletions
@@ -0,0 +1,105 @@
import { Todo } from '@/components';
import { PageContainer } from '@ant-design/pro-components';
import { Card, Modal } from 'antd';
import React, { useState } from 'react';
const EditTable: React.FC = () => {
const [isSaveOpen, setIsSaveOpen] = useState(false);
const [isSetOpen, setIsSetOpen] = useState(false);
// const showSave = () => {
// setIsSaveOpen(true);
// };
const handleSaveOk = () => {
setIsSaveOpen(false);
};
const handleSaveCancel = () => {
setIsSaveOpen(false);
};
// const showSet = () => {
// setIsSetOpen(true);
// };
const handleSetOk = () => {
setIsSetOpen(false);
};
const handleSetCancel = () => {
setIsSetOpen(false);
};
// const columns: ProColumns<DataSourceType>[] = [
// {
// title: '活动名称',
// dataIndex: 'title',
// width: '30%',
// formItemProps: {
// rules: [
// {
// required: true,
// whitespace: true,
// message: '此项是必填项',
// },
// {
// message: '必须包含数字',
// pattern: /[0-9]/,
// },
// {
// max: 16,
// whitespace: true,
// message: '最长为 16 位',
// },
// {
// min: 6,
// whitespace: true,
// message: '最小为 6 位',
// },
// ],
// },
// },
// {
// title: '状态',
// key: 'state',
// dataIndex: 'state',
// valueType: 'select',
// valueEnum: {
// all: { text: '全部', status: 'Default' },
// open: {
// text: '未解决',
// status: 'Error',
// },
// closed: {
// text: '已解决',
// status: 'Success',
// },
// },
// },
// {
// title: '描述',
// dataIndex: 'decs',
// },
// ];
return (
<PageContainer>
<Modal title="确认保存?" open={isSaveOpen} onOk={handleSaveOk} onCancel={handleSaveCancel}>
<p>保存后将回到值班表页面!</p>
</Modal>
<Modal
title="确认设为当前值班表?"
open={isSetOpen}
onOk={handleSetOk}
onCancel={handleSetCancel}
>
<p>同一时间只能启用一份值班表!</p>
</Modal>
<Card>
<Todo />
</Card>
</PageContainer>
);
};
export default EditTable;
@@ -0,0 +1,10 @@
export type TableItem = {
id: React.Key;
mon?: string;
tue?: string;
wed?: string;
thu?: string;
fri?: string;
sat?: string;
sun?: string;
};
+63 -1
View File
@@ -1,12 +1,61 @@
import { PageContainer, ProList } from '@ant-design/pro-components';
import { Card, Space, Tag } from 'antd';
import { history } from '@umijs/max';
import { Button, Card, Modal, Space, Tag } from 'antd';
import moment from 'moment';
import React, { useState } from 'react';
import request from 'umi-request';
import { DutyTableItem } from './dutyTableItem';
const DutyTable: React.FC = () => {
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
const [isSetOpen, setIsSetOpen] = useState(false);
const showDelete = () => {
setIsDeleteOpen(true);
};
const handleDeleteOk = () => {
setIsDeleteOpen(false);
};
const handleDeleteCancel = () => {
setIsDeleteOpen(false);
};
const showSet = () => {
setIsSetOpen(true);
};
const handleSetOk = () => {
setIsSetOpen(false);
};
const handleSetCancel = () => {
setIsSetOpen(false);
};
const newDutyTable = () => {
history.push('/admin/dutytable/edit');
};
return (
<PageContainer>
<Modal
title="确认删除?"
open={isDeleteOpen}
onOk={handleDeleteOk}
onCancel={handleDeleteCancel}
>
<p>删除后将无法恢复!</p>
</Modal>
<Modal
title="确认设为当前值班表?"
open={isSetOpen}
onOk={handleSetOk}
onCancel={handleSetCancel}
>
<p>同一时间只能启用一份值班表!</p>
</Modal>
<Card>
<ProList<DutyTableItem>
search={{
@@ -59,10 +108,23 @@ const DutyTable: React.FC = () => {
<a href="" target="_blank" rel="noopener noreferrer" key="view">
查看
</a>,
<a onClick={showSet} key="view">
设为当前值班表
</a>,
<a onClick={showDelete} key="view">
删除
</a>,
],
search: false,
},
}}
toolbar={{
actions: [
<Button type="primary" key="primary" onClick={newDutyTable}>
新建值班表
</Button>,
],
}}
/>
</Card>
</PageContainer>