Commit 50fcf6892073d3aaea4393bd8437363681220606
1 parent
13912960
财务报销配置
Showing
2 changed files
with
38 additions
and
14 deletions
src/pages/finance/Reimburse/FieldService/components/FeeModal.tsx
... | ... | @@ -5,15 +5,17 @@ import * as API from '../api'; |
5 | 5 | interface Props { |
6 | 6 | visiable: boolean; |
7 | 7 | setVisiable: (value: boolean) => any; |
8 | - current?: API.Item; | |
8 | + current: API.Item; | |
9 | 9 | } |
10 | 10 | |
11 | 11 | export default function Index(props: Props) { |
12 | 12 | const {visiable, setVisiable, current} = props; |
13 | - | |
13 | + const data = [current]; | |
14 | + | |
14 | 15 | return ( |
15 | 16 | <Modal |
16 | 17 | title="餐费补贴" |
18 | + width={600} | |
17 | 19 | visible={visiable} |
18 | 20 | maskClosable={false} |
19 | 21 | onCancel={() => setVisiable(false)} |
... | ... | @@ -21,10 +23,14 @@ export default function Index(props: Props) { |
21 | 23 | <Button onClick={() => setVisiable(false)}>取消</Button> |
22 | 24 | ]} |
23 | 25 | > |
24 | - <Table> | |
25 | - <Table.Column title="早餐(元)" dataIndex="breakfast" /> | |
26 | - <Table.Column title="午餐(元)" dataIndex="lunch" /> | |
27 | - <Table.Column title="晚餐(元)" dataIndex="dinner" /> | |
26 | + <Table | |
27 | + dataSource={data} | |
28 | + pagination={false} | |
29 | + rowKey={r => `${r.id}`} | |
30 | + > | |
31 | + <Table.Column title="早餐(元)" dataIndex="breakfast" /> | |
32 | + <Table.Column title="午餐(元)" dataIndex="lunch" /> | |
33 | + <Table.Column title="晚餐(元)" dataIndex="dinner" /> | |
28 | 34 | </Table> |
29 | 35 | </Modal> |
30 | 36 | ); | ... | ... |
src/pages/finance/Reimburse/FieldService/components/Modal.tsx
1 | -import React, { useEffect, useState} from "react"; | |
1 | +import React, { useEffect} from "react"; | |
2 | 2 | import { Modal, Form, message, Select, Radio, InputNumber } from "antd"; |
3 | 3 | import * as API from '../api'; |
4 | 4 | import useInitial from '@/hooks/useInitail'; |
... | ... | @@ -17,21 +17,43 @@ function CreateModal(props: Props) { |
17 | 17 | const [form] = Form.useForm(); |
18 | 18 | const { data } = useInitial<API.outType[], {}>(API.fetchOutsideTypeList, [], {}); |
19 | 19 | |
20 | + useEffect(() => { | |
21 | + if (visiable && current?.id) { | |
22 | + form.setFieldsValue({ | |
23 | + isAllowReimburse: current.isAllowReimburse, | |
24 | + outsideId: current.outsideId, | |
25 | + breakfast: current.breakfast, | |
26 | + lunch: current.lunch, | |
27 | + dinner: current.dinner, | |
28 | + }); | |
29 | + } else { | |
30 | + form.resetFields(); | |
31 | + } | |
32 | + }, [visiable]); | |
33 | + | |
20 | 34 | const submit = (item:any) => { |
21 | 35 | const params = { |
22 | 36 | id: current?.id || undefined, |
23 | - outsideId: item.outsideId.value, | |
24 | - outsideType: data.find(i => i.id == item.outsideId.value)?.name, | |
37 | + outsideId: item.outsideId, | |
38 | + outsideType: data.find(i => i.id == item.outsideId)?.name, | |
25 | 39 | isAllowReimburse: item.isAllowReimburse, |
26 | 40 | breakfast: item.breakfast, |
27 | 41 | lunch: item.lunch, |
28 | 42 | dinner: item.dinner |
29 | 43 | }; |
30 | - API.saveApi(params).then(res => { | |
44 | + if (current?.id) { | |
45 | + API.updataApi(params).then(res => { | |
46 | + message.success('操作成功'); | |
47 | + setVisiable(false); | |
48 | + setLoading(true); | |
49 | + }).catch(e => message.error(e.message)); | |
50 | + } else { | |
51 | + API.saveApi(params).then(res => { | |
31 | 52 | message.success('操作成功'); |
32 | 53 | setVisiable(false); |
33 | 54 | setLoading(true); |
34 | 55 | }).catch(e => message.error(e.message)); |
56 | + } | |
35 | 57 | }; |
36 | 58 | |
37 | 59 | return ( |
... | ... | @@ -66,7 +88,6 @@ function CreateModal(props: Props) { |
66 | 88 | rules={[{ required: true, message: "请选择外勤类型" }]} |
67 | 89 | > |
68 | 90 | <Select |
69 | - labelInValue | |
70 | 91 | style={{ width: 200 }} |
71 | 92 | placeholder="请选择外勤类型" |
72 | 93 | showSearch |
... | ... | @@ -82,7 +103,6 @@ function CreateModal(props: Props) { |
82 | 103 | <FormItem |
83 | 104 | label="餐饮补贴(早餐)" |
84 | 105 | name="breakfast" |
85 | - rules={[{ required: true, message: "请输入餐饮补贴(早餐)" }]} | |
86 | 106 | > |
87 | 107 | <InputNumber |
88 | 108 | min={0} |
... | ... | @@ -93,7 +113,6 @@ function CreateModal(props: Props) { |
93 | 113 | <FormItem |
94 | 114 | label="餐饮补贴(午餐)" |
95 | 115 | name="lunch" |
96 | - rules={[{ required: true, message: "请输入餐饮补贴(午餐)" }]} | |
97 | 116 | > |
98 | 117 | <InputNumber |
99 | 118 | min={0} |
... | ... | @@ -104,7 +123,6 @@ function CreateModal(props: Props) { |
104 | 123 | <FormItem |
105 | 124 | label="餐饮补贴(晚餐)" |
106 | 125 | name="dinner" |
107 | - rules={[{ required: true, message: "请输入餐饮补贴(晚餐)" }]} | |
108 | 126 | > |
109 | 127 | <InputNumber |
110 | 128 | min={0} | ... | ... |