Commit 8b11baa5a158cf639ff99bc1fdd742349e6fd9cc
Merge branch 'contract' into 'master'
Contract add:快递收费标准配置 fix:合同授权 See merge request !189
Showing
13 changed files
with
1151 additions
and
0 deletions
config/routers/contract.ts
... | ... | @@ -59,4 +59,12 @@ export default [ |
59 | 59 | path: "/contract/kt/itemamount/config", //事项款设置 |
60 | 60 | component: "./contract/ItemAmountSetting", |
61 | 61 | }, |
62 | + { | |
63 | + path: "/contract/kt/authorization/setting", //合同授权 | |
64 | + component: "./contract/AuthorizationSetting", | |
65 | + }, | |
66 | + { | |
67 | + path: "/contract/kt/expressChargingStandard/setting", //快递收费标准 | |
68 | + component: "./contract/ExpressChargingStandardSetting", | |
69 | + }, | |
62 | 70 | ]; | ... | ... |
src/pages/contract/AuthorizationSetting/api.ts
0 → 100644
1 | +import { http } from "@/typing/http"; | |
2 | +import request from "@/utils/request"; | |
3 | +import qs from 'qs'; | |
4 | +import { CONTRACT_HOST, HOST } from "@/utils/host"; | |
5 | +import { Any } from "currency.js"; | |
6 | + | |
7 | +type PrResArr<T> = http.PromiseResp<T[]>; | |
8 | + | |
9 | +export interface Item { | |
10 | + id?:number, //授权ID | |
11 | + typeName?:string, //合同类型名称 | |
12 | + createTime?:number, //创建时间 | |
13 | + updateTime?:number, //更新时间 | |
14 | + enabled?:boolean, //是否启用 | |
15 | + roles?:Roles[],//授权角色 | |
16 | +} | |
17 | +export interface Roles { | |
18 | + roleCode?:string, //角色编码 | |
19 | + roleName?:string, //角色名称 | |
20 | +} | |
21 | +export interface TypesItem { | |
22 | + id?: number; // id | |
23 | + name?: string; | |
24 | + fixedAmount?: boolean; | |
25 | + contractableTradeCompCategories?: number[]; | |
26 | + feeType?: string; | |
27 | + feeTypeValue?: string; | |
28 | + bizType?: string; | |
29 | + bizTypeValue?: number; | |
30 | + subjectType?: string; | |
31 | + subjectTypeValue?: string; | |
32 | + servicePlaceTypes?: number[]; | |
33 | +} | |
34 | + | |
35 | +export interface PageParams { | |
36 | + current?: number; | |
37 | + pageSize?: number; | |
38 | + contractTypeName?:string //合同类型名称 | |
39 | +} | |
40 | +export interface SaveParams { | |
41 | + contractAuthId?: number; | |
42 | + typeId: number;//合同类型id | |
43 | + typeName:string //合同类型名称 | |
44 | + roles?:Roles[],//授权角色 | |
45 | +} | |
46 | +interface DelParams { | |
47 | + contractAuthId?: number; //合同授权id | |
48 | +} | |
49 | + | |
50 | +export interface DisableParams { | |
51 | + contractAuthId?: number;//合同授权id | |
52 | + enabled?: boolean;//是否启用 | |
53 | +} | |
54 | + | |
55 | +/** | |
56 | + * 查询所有角色列表 | |
57 | + */ | |
58 | +export function getAllRoleCodeApi(params: CommonApi.RoleParams): PrResArr<CommonApi.RoleCodeVO> { | |
59 | + return request.get(`${HOST}/role/listAll`, { params }); | |
60 | +} | |
61 | +/** | |
62 | + * 查询合同类型列表 | |
63 | + */ | |
64 | +export function getContractTypes(params: PageParams): http.PromisePageResp<TypesItem> { | |
65 | + return request.get(`${CONTRACT_HOST}/erp/contract/type/page`, { params }); | |
66 | +} | |
67 | + | |
68 | +/** | |
69 | + * 分页查询合同授权 | |
70 | + */ | |
71 | +export function getContractAuthPage(params?: PageParams): http.PromisePageResp<Item> { | |
72 | + return request.get(`${CONTRACT_HOST}/erp/contractAuth/page`, {params}); | |
73 | +} | |
74 | + | |
75 | +/** | |
76 | + * 新增合同授权/编辑合同授权 | |
77 | + */ | |
78 | +export function addContractAuth(params?: SaveParams): http.PromisePageResp<Any> { | |
79 | + return request.post(`${CONTRACT_HOST}/erp/contractAuth/save`, {...params}); | |
80 | +} | |
81 | + | |
82 | +/** | |
83 | + * 删除合同授权 | |
84 | + */ | |
85 | + export function delContractAuth(params?: DelParams): http.PromisePageResp<Any> { | |
86 | + return request.post(`${CONTRACT_HOST}/erp/contractAuth/delete`, {...params}); | |
87 | +} | |
88 | + | |
89 | +/** | |
90 | + * 启用或禁用 | |
91 | + */ | |
92 | + export function disableContractAuth(params?: DisableParams): http.PromisePageResp<Any> { | |
93 | + return request.post(`${CONTRACT_HOST}/erp/contractAuth/enableOrDisable`, {...params}); | |
94 | +} | |
0 | 95 | \ No newline at end of file | ... | ... |
src/pages/contract/AuthorizationSetting/components/AddModel/index.tsx
0 → 100644
1 | +import React, { useCallback, useEffect, useState } from "react"; | |
2 | +import { Modal, Skeleton, Select, Form, message } from "antd"; | |
3 | +import * as API from '../../api'; | |
4 | + | |
5 | +interface Props{ | |
6 | + visible:boolean; | |
7 | + row?:API.Item; | |
8 | + contractTypesList:any[], | |
9 | + roleList:any[], | |
10 | + onRefresh: () => void; | |
11 | + onCancel?: () => void; | |
12 | +} | |
13 | + | |
14 | +function AddModel({visible, row, contractTypesList, roleList, onCancel, onRefresh}:Props) { | |
15 | + const [form] = Form.useForm(); | |
16 | + const [loading, setLoading] = useState<boolean>(false); | |
17 | + const {id, roles, typeName } = row || {}; | |
18 | + useEffect(() => { | |
19 | + if (id) { | |
20 | + form.setFieldsValue({ | |
21 | + contractType: contractTypesList.filter((item:API.TypesItem) => item.name === typeName).map((i:any) => ({label: i.name, value: i.id}))[0], | |
22 | + roleCode: roles?.length && roles.map((i:any) => ({label: i.roleName, value: i.roleCode})), | |
23 | + }); | |
24 | + } | |
25 | + }, [row]); | |
26 | + | |
27 | + /** | |
28 | + * @description: 表单提交 | |
29 | + * @param {any} feildValue | |
30 | + * @return {*} | |
31 | + */ | |
32 | + const handleSave = (feildValue: any) => { | |
33 | + setLoading(true); | |
34 | + const { roleCode, contractType } = feildValue; | |
35 | + const _roleCode = roleCode.length && roleCode.map((item:any) => ({roleCode: item.value, roleName: item.label })); | |
36 | + const params = {roles: _roleCode, typeId: contractType.value, typeName: contractType.label }; | |
37 | + API.addContractAuth({ ...params, contractAuthId: id }) | |
38 | + .then(res => { | |
39 | + message.success("操作成功"); | |
40 | + _onCancel(); | |
41 | + setLoading(false); | |
42 | + onRefresh(); | |
43 | + }) | |
44 | + .catch(err => { | |
45 | + message.error(err?.message); | |
46 | + setLoading(false); | |
47 | + }); | |
48 | + }; | |
49 | + /** | |
50 | + * @description: 关闭弹框 | |
51 | + * @param {*} | |
52 | + * @return {*} | |
53 | + */ | |
54 | + const _onCancel = () => { | |
55 | + onCancel && onCancel(); | |
56 | + form.resetFields(); | |
57 | + }; | |
58 | + | |
59 | + return ( | |
60 | + <Modal | |
61 | + title={`${id ? '编辑':'新增'}合同授权`} | |
62 | + visible={visible} | |
63 | + confirmLoading={loading} | |
64 | + onCancel={_onCancel} | |
65 | + onOk={form.submit} | |
66 | + cancelButtonProps={{ hidden: true }} | |
67 | + width="50%" | |
68 | + bodyStyle={{minHeight: 300}} | |
69 | + > | |
70 | + <Skeleton | |
71 | + loading={false} | |
72 | + > | |
73 | + <Form form={form} onFinish={handleSave} wrapperCol={{ span: 18 }} labelCol={{ span: 4 }}> | |
74 | + <Form.Item | |
75 | + label="合同类型" | |
76 | + name="contractType" | |
77 | + rules={[{ required: true, message: '请选择合同类型' }]} | |
78 | + > | |
79 | + <Select | |
80 | + placeholder="请选择合同类型" | |
81 | + showSearch | |
82 | + allowClear | |
83 | + optionFilterProp="children" | |
84 | + labelInValue | |
85 | + onSelect={(it:any) => { | |
86 | + const item = contractTypesList.filter((i:any) => it.value === i.id); | |
87 | + }} | |
88 | + filterOption={(input, option: any) => option?.children.indexOf(input) >= 0} | |
89 | + > | |
90 | + { | |
91 | + contractTypesList && contractTypesList.map((item:any) => ( | |
92 | + <Select.Option value={item.id} key={item.id}> | |
93 | + {item.name} | |
94 | + </Select.Option> | |
95 | + )) | |
96 | + } | |
97 | + </Select> | |
98 | + </Form.Item> | |
99 | + <Form.Item | |
100 | + label="授权角色" | |
101 | + name="roleCode" | |
102 | + rules={[{ required: true, message: '请选择授权角色' }]} | |
103 | + > | |
104 | + <Select | |
105 | + placeholder="请选择授权角色(支持多选)" | |
106 | + mode="multiple" | |
107 | + showSearch | |
108 | + allowClear | |
109 | + showArrow | |
110 | + optionFilterProp="children" | |
111 | + labelInValue | |
112 | + onSelect={(it:any) => { | |
113 | + const item = roleList.filter((i:any) => it.value === i.roleCode); | |
114 | + }} | |
115 | + filterOption={(input, option: any) => option?.children.indexOf(input) >= 0} | |
116 | + > | |
117 | + { | |
118 | + roleList && roleList.map((item:any) => ( | |
119 | + <Select.Option value={item.roleCode} key={item.id}> | |
120 | + {item.roleName} | |
121 | + </Select.Option> | |
122 | + )) | |
123 | + } | |
124 | + </Select> | |
125 | + </Form.Item> | |
126 | + </Form> | |
127 | + </Skeleton> | |
128 | + </Modal> | |
129 | + ); | |
130 | +} | |
131 | + | |
132 | +export default AddModel; | |
0 | 133 | \ No newline at end of file | ... | ... |
src/pages/contract/AuthorizationSetting/components/Filter/index.tsx
0 → 100644
1 | +import React, { useCallback, useState } from "react"; | |
2 | +import { Row, Col, Select } from "antd"; | |
3 | +import * as common from "@/typing/common"; | |
4 | +import _ from "lodash"; | |
5 | +import * as API from '../../api'; | |
6 | + | |
7 | +interface Props{ | |
8 | + contractTypesList?:any[], | |
9 | + setParams:any, | |
10 | + innerParams?:any, | |
11 | +} | |
12 | + | |
13 | +function Filter({ contractTypesList, innerParams, setParams }:Props) { | |
14 | + const onChange = _.debounce((contractTypeName: string) => { | |
15 | + setParams({...innerParams, contractTypeName}, true); | |
16 | + }, 350); | |
17 | + return ( | |
18 | + <Row | |
19 | + style={{ display: 'flex', flex: 1 }} | |
20 | + > | |
21 | + <Col span={12}> | |
22 | + <Select | |
23 | + placeholder="请选择合同类型" | |
24 | + showSearch | |
25 | + optionFilterProp="children" | |
26 | + allowClear | |
27 | + style={{ width: 200 }} | |
28 | + onChange={(contractTypeName) => onChange(contractTypeName)} | |
29 | + > | |
30 | + { | |
31 | + contractTypesList && contractTypesList.map((item:any) => ( | |
32 | + <Select.Option value={item.name} key={item.id}> | |
33 | + {item.name} | |
34 | + </Select.Option> | |
35 | + )) | |
36 | + } | |
37 | + </Select> | |
38 | + </Col> | |
39 | + </Row> | |
40 | + ); | |
41 | +} | |
42 | + | |
43 | +export default Filter; | |
0 | 44 | \ No newline at end of file | ... | ... |
src/pages/contract/AuthorizationSetting/components/RolesModel/index.tsx
0 → 100644
1 | +import React, { useCallback, useEffect, useState } from "react"; | |
2 | +import { Modal, Form, message, Table } from "antd"; | |
3 | +import * as API from '../../api'; | |
4 | + | |
5 | +interface Props{ | |
6 | + visible:boolean; | |
7 | + roles?:API.Roles[]; | |
8 | + onRefresh: () => void; | |
9 | + onCancel?: () => void; | |
10 | +} | |
11 | +const { Column } = Table; | |
12 | + | |
13 | +function RolesModel({visible, roles, onRefresh, onCancel}:Props) { | |
14 | + return ( | |
15 | + <Modal | |
16 | + title="授权角色" | |
17 | + visible={visible} | |
18 | + onCancel={onCancel} | |
19 | + > | |
20 | + <Table | |
21 | + dataSource={roles} | |
22 | + rowKey={(item: API.Roles) => `${item.roleCode}`} | |
23 | + | |
24 | + > | |
25 | + <Column title="角色名称" width={200} dataIndex="roleName" render={(t) => t || "-"} /> | |
26 | + <Column title="角色编码" width={200} dataIndex="roleCode" render={(t) => t || "-"} /> | |
27 | + </Table> | |
28 | + </Modal> | |
29 | + ); | |
30 | +} | |
31 | + | |
32 | +export default RolesModel; | |
0 | 33 | \ No newline at end of file | ... | ... |
src/pages/contract/AuthorizationSetting/index.tsx
0 → 100644
1 | +import React, { useCallback, useState } from "react"; | |
2 | +import { Button, Card, ConfigProvider, Divider, Input, message, Popconfirm, Select, Table } from "antd"; | |
3 | +import { PageHeaderWrapper } from "@ant-design/pro-layout"; | |
4 | +import zhCN from "antd/lib/locale-provider/zh_CN"; | |
5 | +import usePagination from "@/hooks/usePagination"; | |
6 | +import useInitial from "@/hooks/useInitail"; | |
7 | +import { PlusOutlined } from "@ant-design/icons"; | |
8 | +import AddModel from './components/AddModel'; | |
9 | +import RolesModel from './components/RolesModel'; | |
10 | +import Filter from './components/Filter'; | |
11 | +import * as API from './api'; | |
12 | +import _ from "lodash"; | |
13 | +import moment from 'moment'; | |
14 | +import st from "./style.less"; | |
15 | + | |
16 | +const { Column } = Table; | |
17 | +function AuthorizationSetting() { | |
18 | + const [visible, setVisible] = useState<boolean>(false); | |
19 | + const [searchValue, setSearchValue] = useState<API.Item>({}); | |
20 | + const [rolesVisible, setRolesVisible] = useState<boolean>(false); | |
21 | + const [row, setRow] = useState<API.Item>(); | |
22 | + const [roles, setRoles] = useState<API.Roles[]>(); | |
23 | + const {data: roleList} = useInitial<CommonApi.RoleCodeVO[], any>(API.getAllRoleCodeApi, [], {}); | |
24 | + const { | |
25 | + list: authList, | |
26 | + paginationConfig, | |
27 | + loading, | |
28 | + innerParams, | |
29 | + setParams, | |
30 | + } = usePagination<API.Item>(API.getContractAuthPage, {current: 1, pageSize: 10}); | |
31 | + const { | |
32 | + list: contractTypesList, | |
33 | + } = usePagination<API.TypesItem>(API.getContractTypes, {current: 1, pageSize: 999}); | |
34 | + /** | |
35 | + * @description: 删除 | |
36 | + * @param {*} | |
37 | + * @return {*} | |
38 | + * | |
39 | + */ | |
40 | + const _delete = (row:API.Item) => { | |
41 | + const {id} =row; | |
42 | + API.delContractAuth({contractAuthId: id}) | |
43 | + .then((res) => { | |
44 | + message.success("操作成功"); | |
45 | + setParams({ ...innerParams }, true); | |
46 | + }) | |
47 | + .catch((e) => { | |
48 | + message.error(e.message); | |
49 | + }); | |
50 | + }; | |
51 | + | |
52 | + /** | |
53 | + * @description: 编辑 | |
54 | + * @param {API} row | |
55 | + * @return {*} | |
56 | + */ | |
57 | + const edit = async (row:API.Item) => { | |
58 | + await setRow(row); | |
59 | + setVisible(true); | |
60 | + }; | |
61 | + | |
62 | + /** | |
63 | + * @description: 禁用启用 | |
64 | + * @param {API} row | |
65 | + * @return {*} | |
66 | + */ | |
67 | + const handleDisable = (row:API.Item) => { | |
68 | + const { id, enabled } = row; | |
69 | + API.disableContractAuth({contractAuthId: id, enabled: !enabled}) | |
70 | + .then((res) => { | |
71 | + message.success("操作成功"); | |
72 | + setParams({ ...innerParams }, true); | |
73 | + }) | |
74 | + .catch((err) => { | |
75 | + message.error(err.message); | |
76 | + }); | |
77 | + }; | |
78 | + | |
79 | + const showRoles = async (row:API.Item) => { | |
80 | + const {roles} = row; | |
81 | + try { | |
82 | + await setRoles(roles); | |
83 | + } finally { | |
84 | + setRolesVisible(true); | |
85 | + } | |
86 | + }; | |
87 | + | |
88 | + return ( | |
89 | + <PageHeaderWrapper title="合同授权"> | |
90 | + <ConfigProvider locale={zhCN}> | |
91 | + <Card className={st.page}> | |
92 | + <div className={st.header}> | |
93 | + <Filter | |
94 | + contractTypesList={contractTypesList} | |
95 | + setParams={setParams} | |
96 | + innerParams={innerParams} | |
97 | + /> | |
98 | + <Button | |
99 | + type="primary" | |
100 | + icon={<PlusOutlined />} | |
101 | + onClick={() => { | |
102 | + setVisible(true); | |
103 | + }} | |
104 | + > | |
105 | + 新增 | |
106 | + </Button> | |
107 | + </div> | |
108 | + <Table | |
109 | + size="middle" | |
110 | + loading={loading} | |
111 | + dataSource={authList} | |
112 | + pagination={{ ...paginationConfig }} | |
113 | + scroll={{ y: 800 }} | |
114 | + rowKey={(item: API.Item) => `${item.id}`} | |
115 | + onChange={(_pagination) => setParams({ ..._pagination }, true)} | |
116 | + > | |
117 | + <Column title="合同类型" width={200} dataIndex="typeName" render={(t) => t || "-"} /> | |
118 | + <Column | |
119 | + title="授权角色" | |
120 | + width={200} | |
121 | + dataIndex="id" | |
122 | + render={(text, row:API.Item) => ( | |
123 | + <Button | |
124 | + type="link" | |
125 | + onClick={() => showRoles(row)} | |
126 | + > | |
127 | + 查看 | |
128 | + </Button> | |
129 | + )} | |
130 | + /> | |
131 | + <Column title="状态" width={200} dataIndex="enabled" render={(t) => (t?'启用':'禁用')} /> | |
132 | + {/* <Column title="创建时间" width={200} dataIndex="createTime" render={(t) => (t ? moment(t).format('YYYY-MM-DD HH:mm') : "-")} /> | |
133 | + <Column title="更新时间" width={200} dataIndex="updateTime" render={(t) => (t ? moment(t).format('YYYY-MM-DD HH:mm') : "-")} /> */} | |
134 | + <Column | |
135 | + title="操作" | |
136 | + width={100} | |
137 | + dataIndex="unit" | |
138 | + render={(text, row:API.Item) => ( | |
139 | + <span> | |
140 | + <Popconfirm title={`是否${row.enabled ? "禁用?":"启用?"}`} onConfirm={() => handleDisable(row)} okText="确定" cancelText="取消"> | |
141 | + <a | |
142 | + onClick={(e) => { | |
143 | + e.preventDefault(); | |
144 | + }} | |
145 | + style={{ color: "#FAAD14" }} | |
146 | + > | |
147 | + {`${row.enabled ? '禁用' :'启用'}`} | |
148 | + </a> | |
149 | + </Popconfirm> | |
150 | + <Divider type="vertical" /> | |
151 | + <Popconfirm title="是否编辑?" onConfirm={() => edit(row)} okText="确定" cancelText="取消"> | |
152 | + <a | |
153 | + onClick={(e) => { | |
154 | + e.preventDefault(); | |
155 | + }} | |
156 | + style={{ color: "#FAAD14" }} | |
157 | + > | |
158 | + 编辑 | |
159 | + </a> | |
160 | + </Popconfirm> | |
161 | + <Divider type="vertical" /> | |
162 | + <Popconfirm title="是否删除?" onConfirm={() => _delete(row)} okText="确定" cancelText="取消"> | |
163 | + <a | |
164 | + onClick={(e) => { | |
165 | + e.preventDefault(); | |
166 | + }} | |
167 | + style={{ color: "red" }} | |
168 | + > | |
169 | + 删除 | |
170 | + </a> | |
171 | + </Popconfirm> | |
172 | + </span> | |
173 | + | |
174 | + )} | |
175 | + /> | |
176 | + </Table> | |
177 | + <AddModel | |
178 | + visible={visible} | |
179 | + contractTypesList={contractTypesList} | |
180 | + roleList={roleList} | |
181 | + row={row} | |
182 | + onCancel={() => { | |
183 | + setVisible(false); | |
184 | + setRow(undefined); | |
185 | + }} | |
186 | + onRefresh={() => setParams({ ...innerParams }, true)} | |
187 | + /> | |
188 | + <RolesModel | |
189 | + visible={rolesVisible} | |
190 | + roles={roles} | |
191 | + onCancel={() => { | |
192 | + setRolesVisible(false); | |
193 | + setRoles(undefined); | |
194 | + }} | |
195 | + onRefresh={() => setParams({ ...innerParams }, true)} | |
196 | + /> | |
197 | + </Card> | |
198 | + </ConfigProvider> | |
199 | + </PageHeaderWrapper> | |
200 | + ); | |
201 | +} | |
202 | +export default AuthorizationSetting; | ... | ... |
src/pages/contract/AuthorizationSetting/style.css
0 → 100644
1 | +.page { | |
2 | + position: relative; | |
3 | +} | |
4 | +.page .header { | |
5 | + margin-bottom: 10px; | |
6 | + height: 32px; | |
7 | + display: flex; | |
8 | + flex-direction: row; | |
9 | + justify-content: space-between; | |
10 | +} | |
11 | +.page .header .add { | |
12 | + position: absolute; | |
13 | + right: 28px; | |
14 | + top: 24px; | |
15 | + z-index: 10; | |
16 | +} | |
17 | +.table :global .ant-table table { | |
18 | + width: 100%; | |
19 | + border-collapse: collapse; | |
20 | + text-align: center; | |
21 | + border-radius: 4px 4px 0 0; | |
22 | +} | |
23 | +.table :global .ant-table-thead > tr > th, | |
24 | +.table :global .ant-table-tbody > tr > td { | |
25 | + padding: 16px 16px; | |
26 | + word-break: break-word; | |
27 | + text-align: center; | |
28 | + -ms-word-break: break-all; | |
29 | +} | |
30 | +.table .cover { | |
31 | + align-items: center; | |
32 | + height: 68px; | |
33 | +} | |
34 | +.table .cover img { | |
35 | + border-radius: 4%; | |
36 | + height: 100%; | |
37 | + width: auto; | |
38 | + min-width: 100px; | |
39 | + max-width: 100px; | |
40 | +} | ... | ... |
src/pages/contract/AuthorizationSetting/style.less
0 → 100644
1 | +//@import '~antd/lib/style/themes/default.less'; | |
2 | + | |
3 | +.page { | |
4 | + position: relative; | |
5 | + | |
6 | + .header { | |
7 | + margin-bottom: 10px; | |
8 | + height: 32px; | |
9 | + display: flex; | |
10 | + flex-direction: row; | |
11 | + justify-content: space-between; | |
12 | + .add { | |
13 | + position: absolute; | |
14 | + right: 28px; | |
15 | + top: 24px; | |
16 | + z-index: 10; | |
17 | + } | |
18 | + } | |
19 | + | |
20 | + } | |
21 | + .table { | |
22 | + :global { | |
23 | + .ant-table table { | |
24 | + width: 100%; | |
25 | + border-collapse: collapse; | |
26 | + text-align: center; | |
27 | + border-radius: 4px 4px 0 0; | |
28 | + } | |
29 | + .ant-table-thead > tr > th, .ant-table-tbody > tr > td { | |
30 | + padding: 16px 16px; | |
31 | + word-break: break-word; | |
32 | + text-align: center; | |
33 | + -ms-word-break: break-all; | |
34 | + } | |
35 | + } | |
36 | + .cover { | |
37 | + align-items: center; | |
38 | + height: 68px; | |
39 | + img { | |
40 | + border-radius: 4%; | |
41 | + height: 100%; | |
42 | + width: auto; | |
43 | + min-width: 100px; | |
44 | + max-width: 100px; | |
45 | + } | |
46 | + } | |
47 | + } | |
48 | + | |
0 | 49 | \ No newline at end of file | ... | ... |
src/pages/contract/ExpressChargingStandardSetting/api.ts
0 → 100644
1 | +import { http } from "@/typing/http"; | |
2 | +import request from "@/utils/request"; | |
3 | +import qs from 'qs'; | |
4 | +import { CONTRACT_HOST, HOST, FINANCE2_HOST } from "@/utils/host"; | |
5 | +import { Any } from "currency.js"; | |
6 | + | |
7 | +type PrResArr<T> = http.PromiseResp<T[]>; | |
8 | + | |
9 | +export interface PageParams { | |
10 | + current?: number; | |
11 | + pageSize?: number; | |
12 | + tradeCompId?:number; //合同类型名称 | |
13 | + sendAreaNo?:string; //寄件地区编号 | |
14 | + arriveAreaNo?:string; //到达地区编号 | |
15 | +} | |
16 | + | |
17 | +export interface SaveParams { | |
18 | + expressChargeStandardId?:number; //id,提供该参数将执行编辑操作 | |
19 | + tradeCompId:number; //往来单位id | |
20 | + tradeCompName:string; //往来单位名称 | |
21 | + sendAreaNo:string; //寄件地区编号 | |
22 | + sendAreaName:string; //寄件地区名称 | |
23 | + firstWeight:number; //首重 | |
24 | + continuedWeight:number; //续重 | |
25 | + arriveAreas:ArriveAreas[]; //到达地区 | |
26 | +} | |
27 | + | |
28 | +export interface DelParams { | |
29 | + expressChargeStandardId:number; //快递收费标准id | |
30 | +} | |
31 | + | |
32 | +export interface ArriveAreas { | |
33 | + arriveAreaNo:string; //到达地区编号 | |
34 | + arriveAreaName:string; //到达地区名称 | |
35 | +} | |
36 | + | |
37 | +export interface Item { | |
38 | + id?:number; | |
39 | + tradeCompName?:string; //往来单位名称 | |
40 | + tradeCompShortName?:string; //往来单位简称 | |
41 | + sendAreaName?:string; //寄件地区名称 | |
42 | + arriveAreaName?:string; //到达地区名称 | |
43 | + firstWeight?:number; //首重 | |
44 | + continuedWeight?:number; //续重 | |
45 | +} | |
46 | + | |
47 | +/** | |
48 | + * 分页查询快递收费标准 | |
49 | + */ | |
50 | + export function getStandardPage(params?: PageParams): http.PromisePageResp<Item> { | |
51 | + return request.get(`${CONTRACT_HOST}/erp/express/charge/standard/page`, { params }); | |
52 | +} | |
53 | + | |
54 | +/** | |
55 | + * 新增/编辑快递收费标准 | |
56 | + */ | |
57 | + export function addStandardSave(params: SaveParams): http.PromiseResp<any> { | |
58 | + return request.post(`${CONTRACT_HOST}/erp/express/charge/standard/save`, { ...params }); | |
59 | +} | |
60 | + | |
61 | +/** | |
62 | + * 删除快递收费标准 | |
63 | + */ | |
64 | + export function delStandard(params: DelParams): http.PromiseResp<void> { | |
65 | + return request.post(`${CONTRACT_HOST}/erp/express/charge/standard/delete`, { ...params }); | |
66 | +} | |
67 | + | |
68 | +/**获取往来单位列表*/ | |
69 | +export function fetchComps(params?: any): http.PromiseResp<BearCostSetting.Comp[]> { | |
70 | + return request.get(`${FINANCE2_HOST}/common/trade/company/list`, {params }); | |
71 | +} | |
72 | + | |
73 | +/** | |
74 | + * 城市列表 | |
75 | + */ | |
76 | + export function getCityLsit(): http.PromiseResp<any> { | |
77 | + const params = { pbh: 0 }; | |
78 | + return request.get(`/oop/select/region`, { params }); | |
79 | +} | |
0 | 80 | \ No newline at end of file | ... | ... |
src/pages/contract/ExpressChargingStandardSetting/components/AddModel/index.tsx
0 → 100644
1 | +import React, { useCallback, useEffect, useState } from "react"; | |
2 | +import { Modal, Skeleton, Select, Form, message, InputNumber } from "antd"; | |
3 | +import * as API from '../../api'; | |
4 | +import _ from "lodash"; | |
5 | + | |
6 | +interface Props { | |
7 | + visible:boolean; | |
8 | + row?:API.Item; | |
9 | + compList:any[]; | |
10 | + cityList:any[]; | |
11 | + onCancel:()=>void; | |
12 | + onRefresh:() => void; | |
13 | + | |
14 | +} | |
15 | + | |
16 | +function AddModel({visible, row, compList, cityList, onCancel, onRefresh}:Props) { | |
17 | + const [form] = Form.useForm(); | |
18 | + const [loading, setLoading] = useState<boolean>(false); | |
19 | + const { id } = row || {}; | |
20 | + useEffect(() => { | |
21 | + if (id) { | |
22 | + const { tradeCompName, sendAreaName, firstWeight, continuedWeight, arriveAreaName } = row || {}; | |
23 | + form.setFieldsValue({ | |
24 | + tradeComp: compList.filter(it => tradeCompName === it.name).map(item => ({value: item.id, label: item.name}))[0], | |
25 | + sendArea: cityList.filter(it => sendAreaName === it.fullName).map(item => ({value: item.bh, label: item.fullName}))[0], | |
26 | + firstWeight, | |
27 | + continuedWeight, | |
28 | + arriveAreas: cityList.filter(it => arriveAreaName === it.fullName).map(item => ({value: item.bh, label: item.fullName}))[0] | |
29 | + | |
30 | + }); | |
31 | + } | |
32 | + }, [row]); | |
33 | + | |
34 | + /** | |
35 | + * @description: 确定 | |
36 | + * @param {*} | |
37 | + * @return {*} | |
38 | + */ | |
39 | + const handleSave = (feildValue:any) => { | |
40 | + setLoading(true); | |
41 | + const {tradeComp, sendArea, arriveAreas, firstWeight, continuedWeight} = feildValue; | |
42 | + const _arriveAreas = id ? [{ ...arriveAreas }].map(item => ({arriveAreaNo: item.value, arriveAreaName: item.label})) | |
43 | + : arriveAreas.length && arriveAreas.map((item:any) => ({arriveAreaNo: item.value, arriveAreaName: item.label})); | |
44 | + | |
45 | + const params = { | |
46 | + expressChargeStandardId: id, | |
47 | + tradeCompId: tradeComp.value, | |
48 | + tradeCompName: tradeComp.label, | |
49 | + tradeCompShortName: compList && compList.filter(item => item.id == tradeComp.value)[0].shortName, | |
50 | + sendAreaNo: sendArea.value, | |
51 | + sendAreaName: sendArea.label, | |
52 | + firstWeight, | |
53 | + continuedWeight, | |
54 | + arriveAreas: _arriveAreas | |
55 | + }; | |
56 | + API.addStandardSave({ ...params }) | |
57 | + .then(res => { | |
58 | + message.success("操作成功"); | |
59 | + _onCancel(); | |
60 | + setLoading(false); | |
61 | + onRefresh(); | |
62 | + }).catch(err => { | |
63 | + message.error(err?.message); | |
64 | + setLoading(false); | |
65 | + }); | |
66 | + }; | |
67 | + /** | |
68 | + * @description: 关闭弹框 | |
69 | + * @param {*} | |
70 | + * @return {*} | |
71 | + */ | |
72 | + const _onCancel = () => { | |
73 | + onCancel && onCancel(); | |
74 | + form.resetFields(); | |
75 | + }; | |
76 | + | |
77 | + return ( | |
78 | + <Modal | |
79 | + title={`${id ? '编辑':'新增'}快递收费标准`} | |
80 | + visible={visible} | |
81 | + confirmLoading={loading} | |
82 | + onCancel={_onCancel} | |
83 | + onOk={form.submit} | |
84 | + cancelButtonProps={{ hidden: true }} | |
85 | + width="50%" | |
86 | + bodyStyle={{minHeight: 300}} | |
87 | + > | |
88 | + <Skeleton loading={false}> | |
89 | + <Form form={form} onFinish={handleSave} wrapperCol={{ span: 18 }} labelCol={{ span: 4 }}> | |
90 | + <Form.Item | |
91 | + label="快递公司" | |
92 | + name="tradeComp" | |
93 | + rules={[{required: true, message: '请选择快递公司'}]} | |
94 | + > | |
95 | + <Select | |
96 | + placeholder="请选择快递公司" | |
97 | + showSearch | |
98 | + allowClear | |
99 | + optionFilterProp="children" | |
100 | + labelInValue | |
101 | + onSelect={(it:any) => { | |
102 | + const item = compList.filter((i:any) => it.value === i.id); | |
103 | + }} | |
104 | + filterOption={(input, option: any) => option?.children.indexOf(input) >= 0} | |
105 | + > | |
106 | + { | |
107 | + compList.map(item => ( | |
108 | + <Select.Option value={item.id} key={item.id}> | |
109 | + {item.name} | |
110 | + </Select.Option> | |
111 | + )) | |
112 | + } | |
113 | + </Select> | |
114 | + </Form.Item> | |
115 | + <Form.Item | |
116 | + label="寄件地区" | |
117 | + name="sendArea" | |
118 | + rules={[{required: true, message: '请选择寄件地区'}]} | |
119 | + > | |
120 | + <Select | |
121 | + placeholder="请选择寄件地区" | |
122 | + showSearch | |
123 | + allowClear | |
124 | + optionFilterProp="children" | |
125 | + labelInValue | |
126 | + onSelect={(it:any) => { | |
127 | + const item = cityList.filter((i:any) => it.value === i.id); | |
128 | + }} | |
129 | + filterOption={(input, option: any) => option?.children.indexOf(input) >= 0} | |
130 | + > | |
131 | + { | |
132 | + cityList.map(item => ( | |
133 | + <Select.Option value={item.bh} key={item.bh}> | |
134 | + {item.fullName} | |
135 | + </Select.Option> | |
136 | + )) | |
137 | + } | |
138 | + </Select> | |
139 | + </Form.Item> | |
140 | + <Form.Item | |
141 | + label="到达地区" | |
142 | + name="arriveAreas" | |
143 | + rules={[{required: true, message: '请选择到达地区'}]} | |
144 | + > | |
145 | + <Select | |
146 | + placeholder={`请选择到达地区${id ? '' : '(支持多选)'}`} | |
147 | + mode={id ? undefined : 'multiple'} | |
148 | + showSearch | |
149 | + allowClear | |
150 | + showArrow | |
151 | + optionFilterProp="children" | |
152 | + labelInValue | |
153 | + onSelect={(it:any) => { | |
154 | + const item = cityList.filter((i:any) => it.value === i.id); | |
155 | + }} | |
156 | + filterOption={(input, option: any) => option?.children.indexOf(input) >= 0} | |
157 | + > | |
158 | + { | |
159 | + cityList.map(item => ( | |
160 | + <Select.Option value={item.bh} key={item.bh}> | |
161 | + {item.fullName} | |
162 | + </Select.Option> | |
163 | + )) | |
164 | + } | |
165 | + </Select> | |
166 | + </Form.Item> | |
167 | + <Form.Item | |
168 | + label="首重" | |
169 | + name="firstWeight" | |
170 | + rules={[{required: true, message: '请填写首重'}]} | |
171 | + > | |
172 | + <InputNumber placeholder="请填写" addonAfter="元" max={100000000} min={0} precision={2} /> | |
173 | + </Form.Item> | |
174 | + <Form.Item | |
175 | + label="续重" | |
176 | + name="continuedWeight" | |
177 | + rules={[{required: true, message: '请填写续重'}]} | |
178 | + > | |
179 | + <InputNumber placeholder="请填写" addonAfter="元/kg" max={100000000} min={0} precision={2} /> | |
180 | + </Form.Item> | |
181 | + </Form> | |
182 | + </Skeleton> | |
183 | + </Modal> | |
184 | + ); | |
185 | +} | |
186 | + | |
187 | +export default AddModel; | |
0 | 188 | \ No newline at end of file | ... | ... |
src/pages/contract/ExpressChargingStandardSetting/components/Filter/index.tsx
0 → 100644
1 | +import React, { useCallback, useState } from "react"; | |
2 | +import { Row, Col, Select } from "antd"; | |
3 | +import _ from "lodash"; | |
4 | + | |
5 | +interface Props { | |
6 | + setParams:any; | |
7 | + innerParams:any; | |
8 | + cityList:any[]; | |
9 | + compList:BearCostSetting.Comp[]; | |
10 | +} | |
11 | + | |
12 | +interface SearchData { | |
13 | + tradeCompId?:number;//往来单位id | |
14 | + sendAreaNo?:string;//寄件地区编号 | |
15 | + arriveAreaNo?:string;//到达地区编号 | |
16 | +} | |
17 | + | |
18 | +function Filter({ compList, cityList, setParams, innerParams }:Props) { | |
19 | + const [searchData, setSearchData] = useState<SearchData>({}); | |
20 | + return ( | |
21 | + <Row style={{flex: 1}}> | |
22 | + <Col span={8} style={{marginRight: 10}}> | |
23 | + <Select | |
24 | + placeholder="请选择快递公司" | |
25 | + showSearch | |
26 | + optionFilterProp="children" | |
27 | + allowClear | |
28 | + style={{ minWidth: 260, maxWidth: 280 }} | |
29 | + onChange={(tradeCompId) => { | |
30 | + setSearchData({...searchData, tradeCompId}); | |
31 | + setParams({...innerParams, ...searchData, tradeCompId}, true); | |
32 | + }} | |
33 | + > | |
34 | + { | |
35 | + compList.map(item => ( | |
36 | + <Select.Option value={item.id} key={item.id}> | |
37 | + {item.name} | |
38 | + </Select.Option> | |
39 | + )) | |
40 | + } | |
41 | + </Select> | |
42 | + </Col> | |
43 | + <Col span={6} style={{marginRight: 10}}> | |
44 | + <Select | |
45 | + placeholder="请选择寄件地区" | |
46 | + showSearch | |
47 | + optionFilterProp="children" | |
48 | + allowClear | |
49 | + style={{ width: 200 }} | |
50 | + onChange={(sendAreaNo) => { | |
51 | + setSearchData({...searchData, sendAreaNo}); | |
52 | + setParams({...innerParams, ...searchData, sendAreaNo}, true); | |
53 | + }} | |
54 | + > | |
55 | + { | |
56 | + cityList.map(item => ( | |
57 | + <Select.Option value={item.bh} key={item.bh}> | |
58 | + {item.fullName} | |
59 | + </Select.Option> | |
60 | + )) | |
61 | + } | |
62 | + </Select> | |
63 | + </Col> | |
64 | + <Col span={6} style={{marginRight: 10}}> | |
65 | + <Select | |
66 | + placeholder="请选择到达地区" | |
67 | + showSearch | |
68 | + optionFilterProp="children" | |
69 | + allowClear | |
70 | + style={{ width: 200 }} | |
71 | + onChange={(arriveAreaNo) => { | |
72 | + setSearchData({...searchData, arriveAreaNo}); | |
73 | + setParams({...innerParams, ...searchData, arriveAreaNo}, true); | |
74 | + }} | |
75 | + > | |
76 | + { | |
77 | + cityList.map(item => ( | |
78 | + <Select.Option value={item.bh} key={item.bh}> | |
79 | + {item.fullName} | |
80 | + </Select.Option> | |
81 | + )) | |
82 | + } | |
83 | + </Select> | |
84 | + </Col> | |
85 | + </Row> | |
86 | + ); | |
87 | +} | |
88 | + | |
89 | +export default Filter; | |
0 | 90 | \ No newline at end of file | ... | ... |
src/pages/contract/ExpressChargingStandardSetting/index.tsx
0 → 100644
1 | +import React, { useState } from "react"; | |
2 | +import { Button, Card, ConfigProvider, Divider, message, Popconfirm, Table } from "antd"; | |
3 | +import { PageHeaderWrapper } from "@ant-design/pro-layout"; | |
4 | +import zhCN from "antd/lib/locale-provider/zh_CN"; | |
5 | +import usePagination from "@/hooks/usePagination"; | |
6 | +import useInitial from "@/hooks/useInitail"; | |
7 | +import { PlusOutlined } from "@ant-design/icons"; | |
8 | +import AddModel from './components/AddModel'; | |
9 | +import Filter from './components/Filter'; | |
10 | +import * as API from './api'; | |
11 | +import _ from "lodash"; | |
12 | +import st from "./style.less"; | |
13 | + | |
14 | +interface Props { | |
15 | +} | |
16 | + | |
17 | +const { Column } = Table; | |
18 | + | |
19 | +function expressChargingStandard(props:Props) { | |
20 | + const [visible, setVisible] = useState<boolean>(false); | |
21 | + const { | |
22 | + list: standardList, | |
23 | + loading, | |
24 | + paginationConfig, | |
25 | + innerParams, | |
26 | + setParams, | |
27 | + setLoading | |
28 | + } = usePagination<API.Item>(API.getStandardPage, {current: 1, pageSize: 10}); | |
29 | + const { data: cityList, loading: cityLoading } = useInitial(API.getCityLsit, [], {}); | |
30 | + const { data: compList, loading: compLoading } = useInitial(API.fetchComps, [], {types: '88'}); | |
31 | + const [row, setRow] = useState<API.Item>(); | |
32 | + /** | |
33 | + * @description: 编辑 | |
34 | + * @param {*} _ | |
35 | + * @return {*} | |
36 | + */ | |
37 | + const edit = _.debounce(async (row:API.Item) => { | |
38 | + await setRow({...row}); | |
39 | + setVisible(true); | |
40 | + }, 800); | |
41 | + | |
42 | + /** | |
43 | + * @description: 删除 | |
44 | + * @param {*} _ | |
45 | + * @return {*} | |
46 | + */ | |
47 | + const _delete = _.debounce((row:API.Item) => { | |
48 | + const {id} = row; | |
49 | + if (!id) return; | |
50 | + setLoading(true); | |
51 | + API.delStandard({expressChargeStandardId: id}) | |
52 | + .then(res => { | |
53 | + message.success("操作成功"); | |
54 | + setParams({...innerParams}, true); | |
55 | + setLoading(false); | |
56 | + }).catch(err => { | |
57 | + message.error(err?.message); | |
58 | + setLoading(false); | |
59 | + }); | |
60 | + }, 800); | |
61 | + | |
62 | + return ( | |
63 | + <PageHeaderWrapper | |
64 | + loading={cityLoading || compLoading} | |
65 | + title="快递收费标准配置" | |
66 | + > | |
67 | + <ConfigProvider locale={zhCN}> | |
68 | + <Card className={st.page}> | |
69 | + <div className={st.header}> | |
70 | + <Filter | |
71 | + cityList={cityList || []} | |
72 | + compList={compList || []} | |
73 | + setParams={setParams} | |
74 | + innerParams={innerParams} | |
75 | + /> | |
76 | + <Button | |
77 | + type="primary" | |
78 | + icon={<PlusOutlined />} | |
79 | + onClick={() => { | |
80 | + setVisible(true); | |
81 | + }} | |
82 | + > | |
83 | + 新增 | |
84 | + </Button> | |
85 | + </div> | |
86 | + <Table | |
87 | + size="middle" | |
88 | + loading={loading} | |
89 | + dataSource={standardList} | |
90 | + pagination={{ ...paginationConfig }} | |
91 | + scroll={{ y: 800 }} | |
92 | + rowKey={(item: API.Item) => `${item.id}`} | |
93 | + onChange={(_pagination) => setParams({ ..._pagination }, true)} | |
94 | + > | |
95 | + <Column title="快递公司" width={200} dataIndex="tradeCompName" render={(t:any) => t || "-"} /> | |
96 | + <Column title="寄件地区" width={200} dataIndex="sendAreaName" render={(t:any) => t || '-'} /> | |
97 | + <Column title="到达地区" width={200} dataIndex="arriveAreaName" render={(t:any) => t || '-'} /> | |
98 | + <Column title="首重(元)" width={200} dataIndex="firstWeight" render={(t:any) => t || '-'} /> | |
99 | + <Column title="续重(元/kg)" width={200} dataIndex="continuedWeight" render={(t:any) => t || '-'} /> | |
100 | + <Column | |
101 | + title="操作" | |
102 | + width={100} | |
103 | + dataIndex="unit" | |
104 | + render={(text, row:API.Item) => ( | |
105 | + <span> | |
106 | + <Popconfirm title="是否编辑?" onConfirm={() => edit(row)} okText="确定" cancelText="取消"> | |
107 | + <a | |
108 | + onClick={(e) => { | |
109 | + e.preventDefault(); | |
110 | + }} | |
111 | + style={{ color: "#FAAD14" }} | |
112 | + > | |
113 | + 编辑 | |
114 | + </a> | |
115 | + </Popconfirm> | |
116 | + <Divider type="vertical" /> | |
117 | + <Popconfirm title="是否删除?" onConfirm={() => _delete(row)} okText="确定" cancelText="取消"> | |
118 | + <a | |
119 | + onClick={(e) => { | |
120 | + e.preventDefault(); | |
121 | + }} | |
122 | + style={{ color: "red" }} | |
123 | + > | |
124 | + 删除 | |
125 | + </a> | |
126 | + </Popconfirm> | |
127 | + </span> | |
128 | + | |
129 | + )} | |
130 | + /> | |
131 | + </Table> | |
132 | + <AddModel | |
133 | + visible={visible} | |
134 | + row={row} | |
135 | + compList={compList || []} | |
136 | + cityList={cityList || []} | |
137 | + onCancel={() => { | |
138 | + setVisible(false); | |
139 | + setRow(undefined); | |
140 | + }} | |
141 | + onRefresh={() => setParams({ ...innerParams }, true)} | |
142 | + /> | |
143 | + </Card> | |
144 | + </ConfigProvider> | |
145 | + </PageHeaderWrapper> | |
146 | + ); | |
147 | +} | |
148 | + | |
149 | +export default expressChargingStandard; | |
0 | 150 | \ No newline at end of file | ... | ... |
src/pages/contract/ExpressChargingStandardSetting/style.less
0 → 100644
1 | +//@import '~antd/lib/style/themes/default.less'; | |
2 | + | |
3 | +.page { | |
4 | + position: relative; | |
5 | + | |
6 | + .header { | |
7 | + margin-bottom: 10px; | |
8 | + height: 32px; | |
9 | + display: flex; | |
10 | + flex-direction: row; | |
11 | + justify-content: space-between; | |
12 | + .add { | |
13 | + position: absolute; | |
14 | + right: 28px; | |
15 | + top: 24px; | |
16 | + z-index: 10; | |
17 | + } | |
18 | + } | |
19 | + | |
20 | + } | |
21 | + .table { | |
22 | + :global { | |
23 | + .ant-table table { | |
24 | + width: 100%; | |
25 | + border-collapse: collapse; | |
26 | + text-align: center; | |
27 | + border-radius: 4px 4px 0 0; | |
28 | + } | |
29 | + .ant-table-thead > tr > th, .ant-table-tbody > tr > td { | |
30 | + padding: 16px 16px; | |
31 | + word-break: break-word; | |
32 | + text-align: center; | |
33 | + -ms-word-break: break-all; | |
34 | + } | |
35 | + } | |
36 | + .cover { | |
37 | + align-items: center; | |
38 | + height: 68px; | |
39 | + img { | |
40 | + border-radius: 4%; | |
41 | + height: 100%; | |
42 | + width: auto; | |
43 | + min-width: 100px; | |
44 | + max-width: 100px; | |
45 | + } | |
46 | + } | |
47 | + } | |
48 | + | |
0 | 49 | \ No newline at end of file | ... | ... |