Commit b460f17012b5a89b27e29d383adeb3b21bf5b146

Authored by jiangwei
1 parent 46079f3f

货拉拉账户配置

src/pages/pms/transfer/HuolalaSetting/api.ts
... ... @@ -93,13 +93,24 @@ export interface saveParams{
93 93 // @NotBlank(message = "发单账号不能为空")
94 94 account?:string;
95 95 }
96   -
  96 +interface queryList {
  97 + current?:number
  98 + pageSize?:number
  99 + sysId?:number
  100 +}
  101 +// 查询财务账户信息列表
97 102 export function getList(params: Params):http.PromisePageResp<ListVO> {
98 103 return request.get(`${PMS_HOST}/erp/finance/account/get/page`, {params});
99 104 }
  105 +// 新增/编辑API
100 106 export function saveApi(params: saveParams) {
101 107 return request.post(`${PMS_HOST}/erp/finance/account/exit`, {...params});
102 108 }
103   -export function roleListApi(params: Role.queryList): http.PromisePageResp<Role.Info> {
  109 +// 推待办角色列表
  110 +export function roleListApi(params: queryList): http.PromisePageResp<Role.Info> {
104 111 return request.get(`${HOST}/role/list`, { params });
  112 +}
  113 +// 删除API
  114 +export function deleteApi(params: {id: number}) {
  115 + return request.post(`${PMS_HOST}/erp/finance/account/delete`, {...params});
105 116 }
106 117 \ No newline at end of file
... ...
src/pages/pms/transfer/HuolalaSetting/components/AddModal.tsx
1   -import React, { useState } from 'react';
  1 +import React, { useEffect, useState } from 'react';
2 2 import {Form, Button, InputNumber, Modal, message, Input } from 'antd';
3 3 import PmsSelect from '@/pages/pms/comonents/PmsSelect';
4 4 import { ListVO, saveApi, roleListApi } from '../api';
... ... @@ -14,15 +14,30 @@ interface Props{
14 14 onCancel: Function,
15 15 item?:ListVO
16 16 }
  17 +
17 18 export default function Index(props:Props) {
18 19 const { list: suppliers } = usePagination<item>(getPageListApi, { supplierType: 40, pageSize: 500 });
19 20 const { data: shops } = useInitail<PmsStoragePartShop.Option[], {}>(getShopApi, [], {});
20   - const { list } = usePagination<Role.Info>(roleListApi, [], {});
  21 + const { list } = usePagination<Role.Info>(roleListApi, { pageSize: 500, sysId: 229 });
21 22 const [loading, setLoading] = useState(false);
22   -
23 23 const { visible, onCancel, item } = props;
24 24 const [form] = Form.useForm();
25 25  
  26 + useEffect(() => {
  27 + if (visible && item?.id) {
  28 + form.setFieldsValue({
  29 + supplierId: item.supplierId,
  30 + shopId: item.shopId,
  31 + minAmount: item.minAmount,
  32 + roleCode: item.roleCode,
  33 + account: item.account
  34 + });
  35 + }
  36 + if (!visible) {
  37 + form.resetFields();
  38 + }
  39 + }, [visible]);
  40 +
26 41 const onSave = () => {
27 42 form.validateFields().then(files => {
28 43 const params = {
... ... @@ -32,6 +47,7 @@ export default function Index(props:Props) {
32 47 shopId: files.shopId,
33 48 minAmount: files.minAmount,
34 49 roleCode: files.roleCode,
  50 + roleName: list.find(i => i.roleCode == files.roleCode)?.roleName,
35 51 account: files.account
36 52 };
37 53 setLoading(true);
... ... @@ -80,7 +96,10 @@ export default function Index(props:Props) {
80 96 <InputNumber style={{width: '100%'}} addonAfter="元" />
81 97 </Item>
82 98 <Item label="推待办角色" name="roleCode" rules={[{ required: true, message: "请选择推办角色" }]}>
83   - <PmsSelect />
  99 + <PmsSelect
  100 + placeholder="选择待办角色"
  101 + options={list.map(item => ({value: item.roleCode, label: item.roleName}))}
  102 + />
84 103 </Item>
85 104 <Item label="发单账号" name="account" rules={[{ required: true, message: "请填写发单账号" }]}>
86 105 <Input />
... ...
src/pages/pms/transfer/HuolalaSetting/index.tsx
1 1 import React, { useState } from 'react';
2   -import { Card, Button, Table, Divider, Popconfirm } from 'antd';
  2 +import { Card, Button, Table, Divider, Popconfirm, message } from 'antd';
3 3 import { PageHeaderWrapper } from '@ant-design/pro-layout';
4 4 import AddModal from './components/AddModal';
5 5 import ChargeModal from './components/ChargeModal';
6   -import {getList, ListVO} from './api';
  6 +import {getList, ListVO, deleteApi} from './api';
7 7 import usePagination from '@/hooks/usePagination';
8 8  
9 9 const Column = Table.Column;
10 10 export default function Index() {
11   - const {list, loading, paginationConfig} = usePagination<ListVO>(getList, [], {});
  11 + const {list, loading, paginationConfig, setParams} = usePagination<ListVO>(getList, [], {});
12 12 const [current, setCurrent] = useState<{ visible: boolean, item: ListVO }>({visible: false, item: {}});
13 13 const [chargeInfo, setChargeInfo] = useState<{ visible: boolean, item: ListVO }>({visible: false, item: {}});
14   -
  14 + const data = [{id: 1, supplierName: "货拉拉", shopName: "不过承诺书可能单纯迪士尼才", amount: 3000, minAmount: 1500, roleName: "计划制定员", account: "15725173,16638183"}];
15 15 return (
16 16 <PageHeaderWrapper title="货拉拉账户配置">
17 17 <Card
18 18 extra={<Button type="primary" onClick={() => setCurrent({visible: true, item: {}})}>新增</Button>}
19 19 >
20   - <Table dataSource={list} rowKey="id" loading={loading} pagination={paginationConfig}>
  20 + <Table dataSource={data} rowKey="id" loading={loading} pagination={paginationConfig}>
21 21 <Column title="往来单位" dataIndex="supplierName" />
22 22 <Column title="签约门店" dataIndex="shopName" />
23 23 <Column title="当前余额(元)" dataIndex="amount" />
... ... @@ -27,19 +27,23 @@ export default function Index() {
27 27 <Column
28 28 title="操作"
29 29 render={r => (
30   - <>
  30 + <div style={{display: 'flex', flexWrap: 'wrap', alignItems: 'center'}}>
31 31 <a onClick={() => setChargeInfo({visible: true, item: r})}>预付款充值申请</a>
32 32 <Divider type="vertical" />
33 33 <a onClick={() => setCurrent({visible: true, item: r})}>编辑</a>
34 34 <Divider type="vertical" />
35 35 <Popconfirm
36 36 title="确认删除"
37   - onConfirm={() => {}}
  37 + onConfirm={() => {
  38 + deleteApi({id: r.id}).then(res => {
  39 + message.success('操作成功');
  40 + setParams({}, true);
  41 + }).catch(e => message.error(e.message));
  42 + }}
38 43 >
39 44 <a>删除</a>
40 45 </Popconfirm>
41   -
42   - </>
  46 + </div>
43 47 )}
44 48 />
45 49 </Table>
... ...