index.tsx
2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import useInitial from "@/hooks/useInitail";
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import { Button, Card, Row, Table, Popconfirm, message } from "antd";
import React, { useState } from "react";
import * as API from "./api";
import Modal from "./components/Modal";
import FeeModal from './components/FeeModal';
const Column = Table.Column;
const CateringSubsidies = () => {
const { data, loading, setLoading } = useInitial(API.fetchList, [], "");
const [visiable, setVisiable] = useState(false);
const [current, setCurrent] = useState<any>();
const [feeVisible, setFeeVisible] = useState(false);
const onEdit = (row: any) => {
setCurrent(row);
setVisiable(true);
};
const onAdd = () => {
setVisiable(true);
setCurrent(undefined);
};
const onDelete = (row: any) => {
API.deleteApi(row.id)
.then((res) => {
message.success("删除成功");
setLoading(true);
})
.catch((err) => {
message.error("删除失败", err);
});
};
return (
<PageHeaderWrapper title="外勤报销">
<Card>
<Row style={{ justifyContent: "flex-end", marginBottom: 20 }}>
<Button type="primary" onClick={() => onAdd()}>
新增
</Button>
</Row>
<Table
dataSource={data}
rowKey="id"
loading={loading}
pagination={false}
>
<Column title="外勤类型" dataIndex="outsideTypeName" align="center" />
<Column title="是否允许报销" align="center" render={r => (r.isAllowReimburse ? '允许' : '不允许')} />
<Column
title="餐费补贴"
align="center"
render={r => (r.mealFee ? <a onClick={() => { setFeeVisible(true); setCurrent(r); }}>查看</a> : '无')}
/>
<Column
title="操作"
align="center"
render={(text, row: any) => (
<div>
<Button type="link" onClick={() => onEdit(row)}>
编辑
</Button>
<Popconfirm
title="是否删除"
onConfirm={() => onDelete(row)}
okText="确定"
cancelText="取消"
>
<Button type="link" danger>
删除
</Button>
</Popconfirm>
</div>
)}
/>
</Table>
</Card>
<Modal
visiable={visiable}
setVisiable={setVisiable}
setLoading={setLoading}
current={current}
/>
<FeeModal visiable={feeVisible} setVisiable={setFeeVisible} current={current} />
</PageHeaderWrapper>
);
};
export default CateringSubsidies;