Commit d48280b4 authored by Bill's avatar Bill

对接发票以及对公账号配置

parent d7d44e14
......@@ -26,14 +26,15 @@ const router = {
path: '/balanced/receipt/add',
name: 'receiptAdd',
component: '@/pages/platformSettlement/receipt/info',
hidePageHeader: true
hidePageHeader: true,
hideInMenu: true,
},
{
path: '/balanced/receipt/detail',
name: 'receiptDetail',
component: '@/pages/platformSettlement/receipt/info',
hidePageHeader: true
hidePageHeader: true,
hideInMenu: true,
}
]
}
......
......@@ -2,10 +2,10 @@ import React, { useState, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import styles from './index.less'
import { FormOutlined } from '@ant-design/icons';
import { Button, Input, Space } from 'antd';
// import bank from '@/assets/imgs/bank.png';
// import bank_account from '@/assets/imgs/bank_account.png';
// import company from '@/assets/imgs/company.png';
import { Button, Input, Space, Popconfirm } from 'antd';
import bank from '@/asserts/bank.png';
import bank_account from '@/asserts/bank_account.png';
import company from '@/asserts/company.png';
import { PublicApi } from '@/services/api';
import { getAuth } from '@/utils/auth';
import { Prompt } from 'umi'
......@@ -19,40 +19,10 @@ interface Config {
cacheValue: string,
changeEdit?: any,
pattern?: any,
message?: string
message?: string,
dataIndex: string
}
const CONFIGS: Config[] = [
{
name: '账号名称',
image: null,
value: '',
cacheValue: '',
isEdit: false,
canEdit: false
},
{
name: '银行账号',
image: null,
value: '',
cacheValue: '',
isEdit: false,
canEdit: true,
pattern: /^([1-9]{1})(\d{14}|\d{18})$/,
message: '请输入正确的银行账号'
},
{
name: '开户行',
image: null,
value: '',
cacheValue: '',
isEdit: false,
canEdit: true,
pattern: /^[\u4e00-\u9fa5]{0,50}|[0-9a-zA-Z]{0,100}$/,
message: '最多50个汉字'
},
]
const ItemRender: React.FC<Config> = (props) => {
const { isEdit, name, canEdit, value, image, changeEdit, pattern, message } = props;
const [validError, setValidError] = useState(false);
......@@ -101,7 +71,9 @@ const ItemRender: React.FC<Config> = (props) => {
: <div>
<Space>
<Button type="primary" onClick={() => handleConfirm(name)} >确定</Button>
<Button onClick={() => handleCancel(name)}>取消</Button>
<Popconfirm title="确定取消吗?" onConfirm={() => handleCancel(name)}>
<Button >取消</Button>
</Popconfirm>
</Space>
</div>
: null
......@@ -114,8 +86,9 @@ const ItemRender: React.FC<Config> = (props) => {
}
const CorporateAccount = () => {
const [configs, setConfigs] = useState<Config[]>(CONFIGS);
const [unsaved, setUnsaved] = useState<Boolean>(false)
const [configs, setConfigs] = useState<Config[]>([]);
const [datas, setDatas] = useState<any>({});
const [unsaved, setUnsaved] = useState<boolean>(false)
const changeEdit = (name: string, res: any, type: string) => {
let temp = [...configs];
const index = temp.findIndex((row) => row.name === name);
......@@ -126,6 +99,8 @@ const CorporateAccount = () => {
...target,
...res,
}
setConfigs(temp);
} else if(type == 'cancel') {
setUnsaved(false);
temp[index] = {
......@@ -133,26 +108,76 @@ const CorporateAccount = () => {
...res,
value: type == 'cancel' ? target.cacheValue : target.value,
}
setConfigs(temp);
} else if(type == 'confirm') {
setUnsaved(false);
temp[index] = {
...target,
...res,
cacheValue: type == 'confirm' ? target.value : target.cacheValue
const postData = {
...datas,
[target.dataIndex]: target.value
}
///settle/accounts/platform/config/updatePlatformAccountConfig
PublicApi.postSettleAccountsPlatformConfigUpdatePlatformAccountConfig(postData)
.then((data) => {
if(data.code == 1000) {
setDatas(postData);
temp[index] = {
...target,
...res,
cacheValue: type == 'confirm' ? target.value : target.cacheValue
}
setConfigs(temp);
}
})
}
setConfigs(temp);
}
useEffect(() => {
const { memberId } = getAuth() || {};
// 进行基础赋值, fetchData
// async function fetchData() {
// const res = await PublicApi.getSettleAccountsCorporateAccountConfig({memberId: memberId});
// console.log(res);
// }
// fetchData();
async function fetchData() {
const { data } = await PublicApi.getSettleAccountsPlatformConfigGetPlatformAccountConfig();
setDatas(data);
setConfigs(
[
{
name: '账号名称',
pattern: /.+/,
message: '请填写账号名称',
dataIndex: 'name',
image: company,
value: data.name,
cacheValue: data.name,
isEdit: false,
canEdit: true
},
{
name: '银行账号',
dataIndex: 'bankAccount',
image: bank_account,
value: data.bankAccount,
cacheValue: data.bankAccount,
isEdit: false,
canEdit: true,
pattern: /^([1-9]{1})(\d{14}|\d{18})$/,
message: '请输入正确的银行账号'
},
{
name: '开户行',
dataIndex: 'bankDeposit',
image: bank,
value: data.bankDeposit,
cacheValue: data.bankDeposit,
isEdit: false,
canEdit: true,
pattern: /^[\u4e00-\u9fa5]{0,50}|[0-9a-zA-Z]{0,100}$/,
message: '最多50个汉字'
},
]
)
}
fetchData();
}, [])
......
......@@ -12,30 +12,17 @@ import styles from './index.less';
import { history, Link } from 'umi';
import { PublicApi } from '@/services/api'
interface iProps {
}
enum Kind {
common = 1, // 增值税普通发票(默认
special = 2 // 增值税专用发票
}
enum ItemIpropType {
business = 1, //企业
person = 2 // 个人
}
interface ReceiptProps {
id: number,
kind: Kind,
type: ItemIpropType,
kindName: string,
typeName: string,
invoiceTitle: string,
taxNo: string,
bankOfDeposit: string,
account: string,
addres: string,
address: string,
tel: string
isDefault: number
defaultName: string
}
interface ItemIprops extends ReceiptProps {
......@@ -47,9 +34,9 @@ interface ItemIprops extends ReceiptProps {
* @param props ItemIprops
*/
const ReceiptItem: React.FC<ItemIprops> = (props: ItemIprops) => {
const { id, kind, type, invoiceTitle, taxNo, bankOfDeposit, account, addres, tel, isDefault } = props;
const { id, kindName, typeName, invoiceTitle, taxNo, bankOfDeposit, account, address, tel, defaultName } = props;
const handleRouterPush = () => {
history.push(`/balance/receipt/detail?id=${id}`);
history.push(`/balanced/receipt/detail?id=${id}`);
}
const handleDelete = (id: number | string) => {
props.onRemove(id);
......@@ -71,11 +58,11 @@ const ReceiptItem: React.FC<ItemIprops> = (props: ItemIprops) => {
</div>
<Row className={styles.row}>
<Col span={6}>开具类型</Col>
<Col span={18}>{type == 1 ? '企业' : '个人'}</Col>
<Col span={18}>{typeName}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>发票种类</Col>
<Col span={18}>{kind == 1 ? '增值税普通发票' : '增值税专用发票'}</Col>
<Col span={18}>{kindName }</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>发票抬头</Col>
......@@ -95,7 +82,7 @@ const ReceiptItem: React.FC<ItemIprops> = (props: ItemIprops) => {
</Row>
<Row className={styles.row}>
<Col span={6}>地址</Col>
<Col span={18}>{addres}</Col>
<Col span={18}>{address}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>电话</Col>
......@@ -103,7 +90,7 @@ const ReceiptItem: React.FC<ItemIprops> = (props: ItemIprops) => {
</Row>
<Row>
<Col span={6}>是否默认</Col>
<Col span={18}><Switch disabled checked={isDefault ? true : false}/></Col>
<Col span={18}><Switch disabled checked={defaultName == '是' ? true : false}/></Col>
</Row>
</div>
)
......@@ -113,14 +100,11 @@ const ReceiptItem: React.FC<ItemIprops> = (props: ItemIprops) => {
/**
* 发票列表
*/
const Receipt: React.FC<iProps> = () => {
const Receipt: React.FC<{}> = () => {
const [list, setList] = useState<ReceiptProps[]>([]);
const fetchData = async () => {
// /settle/platform/config/getPlatformInvoiceList
// const { data } = await PublicApi.getSettlePlatformConfigGetPlatformInvoiceList();
// return data;
// PublicApi.getSettlePla
return []
const { data } = await PublicApi.getSettleAccountsPlatformConfigGetPlatformInvoiceList();
return data;
}
useEffect(() => {
fetchData().then((data) => {
......@@ -129,24 +113,23 @@ const Receipt: React.FC<iProps> = () => {
}, [])
const handleRouterAdd = () => {
history.push('/balance/receipt/add')
history.push('/balanced/receipt/add')
}
// 删除发票
const remove = async (id: number | string) => {
console.log(id);
// const res = await PublicApi.postSettleAccountsInvoiceMessageDelete({id});
// if(res.code == 1000) {
// const newList = list.filter((item) => item.id !== id);
// setList(newList);
// }
const res = await PublicApi.postSettleAccountsPlatformConfigDeletePlatformInvoice({id: id.toString()});
if(res.code == 1000) {
const newList = list.filter((item) => item.id !== id);
setList(newList);
}
}
return (
<div>
<Row gutter={24}>
{
list.map((item) => {
list.map((item: ReceiptProps) => {
return (
<Col span={8} key={item.id} className={styles.margin}>
<ReceiptItem onRemove={remove} {...item}/>
......
......@@ -91,7 +91,7 @@ const schema = {
{pattern: /^([1-9]{1})(\d{14}|\d{18})$/, message: '请填写正确的银行账号'}
]
},
addres: {
address: {
type: 'text',
title: '地址',
'x-component': 'textarea',
......@@ -129,10 +129,9 @@ const Info: React.FC = () => {
const handleSubmit = (value) => {
console.log(value);
// return value;
const serviceActions = isAdd
? PublicApi.postSettleAccountsInvoiceMessageAdd
: PublicApi.postSettleAccountsInvoiceMessageUpdate
? PublicApi.postSettleAccountsPlatformConfigAddPlatformInvoice
: PublicApi.postSettleAccountsPlatformConfigUpdatePlatformInvoice
let tempData = {...value, isDefault: value.isDefault ? 1 : 0};
const postData = isAdd ? tempData : {...tempData, id};
......@@ -141,7 +140,7 @@ const Info: React.FC = () => {
serviceActions(postData).then((data) => {
setSubmitLoading(false);
if(data.code === 1000) {
history.push('/memberCenter/balance/settleRules/receiptList')
history.push('/balanced/receipt')
}
})
}
......@@ -149,7 +148,7 @@ const Info: React.FC = () => {
useEffect(() => {
if(id) {
async function fetchData() {
const { data } = await PublicApi.getSettleAccountsInvoiceMessageDetails({id});
const { data } = await PublicApi.getSettleAccountsPlatformConfigGetPlatformInvoiceDetail({id});
setInitialValue(data)
}
fetchData()
......@@ -158,7 +157,7 @@ const Info: React.FC = () => {
}, [id])
const handleCancel = () => {
history.push('/memberCenter/balance/settleRules/receiptList')
history.push('/balanced/receipt')
}
return (
......
......@@ -6,7 +6,8 @@ import * as ProductApi from './ProductApi'
import * as TemplateApi from './TemplateApi'
import * as PayApi from './PayApi'
import * as SearchApi from './SearchApi'
import * as OrderApi from './OrderApi'
import * as OrderApi from './OrderApi';
import * as SettleApi from './SettleApi';
/**
* 可在这里写入自定义的接口
......@@ -26,4 +27,5 @@ export const PublicApi = {
...PayApi,
...SearchApi,
...OrderApi,
...SettleApi
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment