Commit 862b2d736531bab937f3492f910cf45d6877a7ed
1 parent
e93c2e09
往来单位关系设置
Showing
6 changed files
with
59 additions
and
52 deletions
src/pages/finance/CompanyRelationAuth/components/Filter.tsx
... | ... | @@ -3,8 +3,8 @@ import { Button, Col, Popconfirm, Row, Select, Input, message } from "antd"; |
3 | 3 | import { useStore } from "../index"; |
4 | 4 | import { CompanyCategoryTypeEnum } from "@/pages/finance/entitys"; |
5 | 5 | import { debounce } from "lodash"; |
6 | -import { deleteCompanyRelationApi } from '@/pages/finance/CompanyRelationAuth/api'; | |
7 | -import { history } from 'umi'; | |
6 | +import { deleteCompanyRelationApi } from "@/pages/finance/CompanyRelationAuth/api"; | |
7 | +import { history } from "umi"; | |
8 | 8 | |
9 | 9 | const Search = Input.Search; |
10 | 10 | const { Option } = Select; |
... | ... | @@ -53,7 +53,7 @@ export default function Filter() { |
53 | 53 | |
54 | 54 | // 新增 |
55 | 55 | function onAdd() { |
56 | - history.push("/finance2/companyRelationAuth/create"); | |
56 | + history.push({ pathname: "/finance2/companyRelationAuth/create", state: companyParams }); | |
57 | 57 | } |
58 | 58 | /** |
59 | 59 | * @param compId |
... | ... | @@ -61,7 +61,7 @@ export default function Filter() { |
61 | 61 | async function onDelete() { |
62 | 62 | const compIdList = selectedRelation.map((item) => item.compId); |
63 | 63 | try { |
64 | - const pa = { ...companyParams, compIdList}; | |
64 | + const pa = { ...companyParams, compIdList }; | |
65 | 65 | setSubmitLoading(true); |
66 | 66 | const { success, result } = await deleteCompanyRelationApi(pa); |
67 | 67 | setSubmitLoading(false); |
... | ... | @@ -147,7 +147,7 @@ export default function Filter() { |
147 | 147 | </Button> |
148 | 148 | |
149 | 149 | <Popconfirm title="确定删除?" onConfirm={onDelete}> |
150 | - <Button style={{marginRight:10}} hidden={!selectedRelation.length} danger loading={submitLoading}> | |
150 | + <Button style={{ marginRight: 10 }} hidden={!selectedRelation.length} danger loading={submitLoading}> | |
151 | 151 | 删除 |
152 | 152 | </Button> |
153 | 153 | </Popconfirm> | ... | ... |
src/pages/finance/CompanyRelationAuth/index.tsx
src/pages/finance/CompanyRelationCreate/components/RelationshipSettings.tsx
... | ... | @@ -14,14 +14,13 @@ interface Props { |
14 | 14 | function SelectModal({ onPrevious }: Props) { |
15 | 15 | const [form] = Form.useForm(); |
16 | 16 | const { |
17 | - visible, | |
18 | - selected, | |
19 | - setVisible, | |
17 | + // visible, | |
18 | + // selected, | |
19 | + // setVisible, | |
20 | 20 | companyParams, |
21 | - comBussinessList, | |
22 | - comBussinessLoading, | |
21 | + // comBussinessList, | |
22 | + // comBussinessLoading, | |
23 | 23 | setDisabled, |
24 | - setLoading, | |
25 | 24 | selectData, |
26 | 25 | setSelectData, |
27 | 26 | } = useStore(); |
... | ... | @@ -51,7 +50,6 @@ function SelectModal({ onPrevious }: Props) { |
51 | 50 | saveCompanyRelationApi(pa) |
52 | 51 | .then((res) => { |
53 | 52 | message.success("保存成功"); |
54 | - setLoading(true); | |
55 | 53 | setSubmitLoading(false); |
56 | 54 | setDisabled(true); |
57 | 55 | onCancel(); | ... | ... |
src/pages/finance/CompanyRelationCreate/components/SelectCorrespondenceUnits.tsx
src/pages/finance/CompanyRelationCreate/index.tsx
1 | -import React, { useState } from "react"; | |
1 | +import React, { useEffect, useState } from "react"; | |
2 | 2 | import { Card, Steps, Table, Tabs } from "antd"; |
3 | 3 | import { PageHeaderWrapper } from "@ant-design/pro-layout"; |
4 | 4 | import { createStore } from "@/hooks/moz"; |
... | ... | @@ -12,20 +12,26 @@ const { TabPane } = Tabs; |
12 | 12 | |
13 | 13 | export const { Provider, useStore } = createStore(store); |
14 | 14 | |
15 | -function CompanyRelationAuth() { | |
15 | +function CompanyRelationCreate(props) { | |
16 | + const pathParams = props.location.state || {}; | |
16 | 17 | const { Step } = Steps; |
17 | 18 | const [current, setCurrent] = useState<number>(0); |
18 | 19 | const { |
19 | 20 | selected, |
20 | - loading, | |
21 | + // loading, | |
21 | 22 | selectedRelation, |
22 | 23 | setSelectedRelation, |
23 | - companyParams, | |
24 | 24 | submitLoading, |
25 | 25 | setSubmitLoading, |
26 | - setLoading, | |
26 | + // setLoading, | |
27 | + companyParams, | |
28 | + setCompanyParams, | |
27 | 29 | } = useStore(); |
28 | 30 | |
31 | + useEffect(() => { | |
32 | + setCompanyParams({ ...pathParams }); | |
33 | + }, []); | |
34 | + | |
29 | 35 | const rowSelection = { |
30 | 36 | onChange: (selectedRowKeys: React.Key[], selectedRows: CompanyRelationListVO[]) => { |
31 | 37 | setSelectedRelation([...selectedRows]); |
... | ... | @@ -60,8 +66,8 @@ function CompanyRelationAuth() { |
60 | 66 | ); |
61 | 67 | } |
62 | 68 | |
63 | -export default () => ( | |
69 | +export default (props) => ( | |
64 | 70 | <Provider> |
65 | - <CompanyRelationAuth /> | |
71 | + <CompanyRelationCreate {...props} /> | |
66 | 72 | </Provider> |
67 | 73 | ); | ... | ... |
src/pages/finance/CompanyRelationCreate/useStore.ts
... | ... | @@ -14,52 +14,54 @@ export default function useStore() { |
14 | 14 | const [selectData, setSelectData] = useState<TradeCompany.ComList[]>([]); |
15 | 15 | // 存储已选关系,用于批量删除 |
16 | 16 | const [selectedRelation, setSelectedRelation] = useState<CompanyRelationListVO[]>([]); |
17 | + // 存储新增时选择条件 | |
18 | + const [companyParams, setCompanyParams] = useState({ dealerId: -1 }); | |
17 | 19 | |
18 | 20 | /** 商家下往来单位列表 */ |
19 | - const { | |
20 | - data: companyList, | |
21 | - setParams: setCompanyParams, | |
22 | - setLoading, | |
23 | - loading, | |
24 | - params: companyParams, | |
25 | - } = useInitial<CompanyRelationListVO[], CompanyRelationParams>( | |
26 | - getCompanyByDealerApi, | |
27 | - [], | |
28 | - { compCategory: CompanyCategoryTypeEnum["供应商"], dealerId: -1 }, | |
29 | - delay | |
30 | - ); | |
21 | + // const { | |
22 | + // data: companyList, | |
23 | + // setParams: setCompanyParams, | |
24 | + // setLoading, | |
25 | + // loading, | |
26 | + // params: companyParams, | |
27 | + // } = useInitial<CompanyRelationListVO[], CompanyRelationParams>( | |
28 | + // getCompanyByDealerApi, | |
29 | + // [], | |
30 | + // { compCategory: CompanyCategoryTypeEnum["供应商"], dealerId: -1 }, | |
31 | + // delay | |
32 | + // ); | |
31 | 33 | // 商家的列表 |
32 | - const { data: dealerList, loading: dealerLoading } = useInitial(getDealerApi, [], {}); | |
34 | + // const { data: dealerList, loading: dealerLoading } = useInitial(getDealerApi, [], {}); | |
33 | 35 | // 往来单位业务类型列表 |
34 | 36 | const { data: comBussinessList, loading: comBussinessLoading } = useInitial(getCompanyBusinessTypesApi, [], null); |
35 | 37 | |
36 | 38 | const [selected, setSelected] = useState<CompanyRelationListVO[]>([]); |
37 | 39 | |
38 | - useEffect(() => { | |
39 | - if (dealerList.length) { | |
40 | - setDelay(false); | |
41 | - setCompanyParams({ ...companyParams, dealerId: dealerList[0].id }, true); //因为usePagination 未支持 delay变为false后还需手动刷新接口 | |
42 | - } else { | |
43 | - !dealerLoading && message.warning("没有授权商家,无法查看数据"); | |
44 | - } | |
45 | - }, [dealerList, dealerLoading]); | |
40 | + // useEffect(() => { | |
41 | + // if (dealerList.length) { | |
42 | + // setDelay(false); | |
43 | + // setCompanyParams({ ...companyParams, dealerId: dealerList[0].id }, true); //因为usePagination 未支持 delay变为false后还需手动刷新接口 | |
44 | + // } else { | |
45 | + // !dealerLoading && message.warning("没有授权商家,无法查看数据"); | |
46 | + // } | |
47 | + // }, [dealerList, dealerLoading]); | |
46 | 48 | |
47 | - useEffect(() => { | |
48 | - setSelected([...companyList]); | |
49 | - }, [companyList]); | |
49 | + // useEffect(() => { | |
50 | + // setSelected([...companyList]); | |
51 | + // }, [companyList]); | |
50 | 52 | |
51 | 53 | return { |
52 | 54 | selectData, |
53 | 55 | setSelectData, |
54 | - companyList, | |
56 | + // companyList, | |
55 | 57 | visible, |
56 | 58 | setVisible, |
57 | - setCompanyParams, | |
58 | - companyParams, | |
59 | - dealerList, | |
60 | - setLoading, | |
61 | - loading, | |
62 | - dealerLoading, | |
59 | + // setCompanyParams, | |
60 | + // companyParams, | |
61 | + // dealerList, | |
62 | + // setLoading, | |
63 | + // loading, | |
64 | + // dealerLoading, | |
63 | 65 | disabled, |
64 | 66 | setDisabled, |
65 | 67 | selected, |
... | ... | @@ -70,5 +72,7 @@ export default function useStore() { |
70 | 72 | comBussinessLoading, |
71 | 73 | selectedRelation, |
72 | 74 | setSelectedRelation, |
75 | + companyParams, | |
76 | + setCompanyParams, | |
73 | 77 | }; |
74 | 78 | } | ... | ... |