Commit 0cfef8dc authored by Bill's avatar Bill

对接发票接口

parent 271b7458
......@@ -6,98 +6,115 @@
import React, { useRef } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Card, Button } from 'antd';
import { Card, Button, Modal, DatePicker, Tag, Space } from 'antd';
import NiceForm from '@/components/NiceForm';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema, createFormActions } from '@formily/antd';
import { StandardTable } from 'god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { schema } from './schema';
import ModalContainer from '../../components/ModalContainer';
import ConfirmAccount from '../../components/ConfirmAccount';
import Voucher from '../../components/Voucher';
const formActions = createFormActions();
const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
name: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
align: 'flex-left',
tip: '输入通知单号、通知单摘要进行搜索',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 6,
},
properties: {
name: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '加工企业名称(全部)',
allowClear: true,
},
},
time: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '单据时间(全部)',
allowClear: true,
},
},
outerStatus: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '外部状态(全部)',
allowClear: true,
},
},
innerStatus: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '内部状态(全部)',
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
},
},
},
},
},
};
const formActions = createFormActions();
const SettlementList = () => {
const ref = useRef<any>({})
const fetchListData = async (params) => {
return {}
return {
data: [{id: 1}],
totalCount: 1
}
}
const columns = [
{title: '结算单号', dataIndex: 'num'},
{title: '结算日期', dataIndex: 'num'},
{title: '结算方式', dataIndex: 'num'},
{title: '总单数', dataIndex: 'num'},
{title: '代收金额', dataIndex: 'num'},
{title: '佣金', dataIndex: 'num'},
{title: '结算金额', dataIndex: 'num'},
{title: '结算日期', dataIndex: 'num'},
{title: '支付方式', dataIndex: 'payMethod'},
{
title: '结算状态', dataIndex: 'status',
render: (text, record) => {
return (
<Tag>待对账</Tag>
)
}
},
{
title: '操作',
render: (text, record) => {
return (
<>
<ModalContainer>
{
({visible, show, cancel}) => {
return (
<>
<Modal width={400} title="确认对账完成" visible={visible} onCancel={cancel} onOk={() => handleConfirm(cancel)}>
<ConfirmAccount />
</Modal>
<div onClick={show}>确认对账完成</div>
</>
)
}
}
</ModalContainer>
<ModalContainer>
{
({visible, show, cancel}) => {
return (
<>
<Modal width={548} title="查看付款凭证" onCancel={cancel} visible={visible} footer={null}>
<Voucher />
</Modal>
<div onClick={show}>查看付款凭证</div>
</>
)
}
}
</ModalContainer>
<ModalContainer>
{
({visible, show, cancel}) => {
return (
<>
<Modal width={548} title="确认付款凭证" onCancel={cancel} visible={visible}
footer={(
<Space>
<Button>取消</Button>
<Button>确认未到款</Button>
<Button>确认到款</Button>
</Space>
)}
>
<Voucher />
</Modal>
<div onClick={show}>确认付款凭证</div>
</>
)
}
}
</ModalContainer>
</>
)
}
}
]
/**
* 确认对账
* @param cancel 关闭回调函数
*/
const handleConfirm = (cancel) => {
console.log(123)
cancel();
}
return (
<PageHeaderWrapper>
......@@ -106,11 +123,12 @@ const SettlementList = () => {
tableProps={{
rowKey: 'id',
}}
columns={[]}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
<NiceForm
components={{DatePicker}}
actions={formActions}
expressionScope={{}}
effects={($, actions) => {
......
......@@ -15,99 +15,23 @@ import { ISchema, createFormActions } from '@formily/antd';
import { StandardTable } from 'god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { detailSchema } from './schema'
const formActions = createFormActions();
const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
},
properties: {
ctl: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{exportBtn}}',
},
},
search: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
},
},
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
colStyle: {
marginLeft: 20,
},
},
properties: {
name: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '加工企业名称(全部)',
allowClear: true,
},
},
time: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '单据时间(全部)',
allowClear: true,
},
},
outerStatus: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '外部状态(全部)',
allowClear: true,
},
},
innerStatus: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '内部状态(全部)',
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
},
},
},
},
},
};
const columns = [
{title: '单据号', dataIndex: 'no'},
{title: '单据摘要', dataIndex: 'desc'},
{title: '单据类型', dataIndex: 'type'},
{title: '单据时间', dataIndex: 'time'},
{title: '总箱数', dataIndex: 'box'},
{title: '总重量', dataIndex: 'weight'},
{title: '总体积', dataIndex: 'volumn'},
{title: '接单金额', dataIndex: 'price'},
{title: '支付时间', dataIndex: 'payTime'},
{title: '结算金额', dataIndex: 'payPrice'},
]
const logisticsDetail: React.FC = () => {
const ref = useRef<any>({});
......@@ -125,7 +49,8 @@ const logisticsDetail: React.FC = () => {
title={
<AvatarWrap
info={{
name: "通知单号:"
aloneTxt: '单',
name: "结算单号:"
}}
extra={(
<span style={{ fontSize: 12, fontWeight: 'normal' }}>{"TPTY12"}</span>
......@@ -155,7 +80,7 @@ const logisticsDetail: React.FC = () => {
tableProps={{
rowKey: 'id',
}}
columns={[]}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
......@@ -175,7 +100,7 @@ const logisticsDetail: React.FC = () => {
// fetchSelectOptions,
// );
}}
schema={schema}
schema={detailSchema}
onSubmit={values => ref.current.reload(values)}
/>
}
......
......@@ -15,99 +15,22 @@ import { ISchema, createFormActions } from '@formily/antd';
import { StandardTable } from 'god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { detailSchema } from './schema'
const formActions = createFormActions();
const columns = [
{title: '单据号', dataIndex: 'no'},
{title: '单据摘要', dataIndex: 'desc'},
{title: '单据类型', dataIndex: 'type'},
{title: '单据时间', dataIndex: 'time'},
{title: '单据总额', dataIndex: 'total'},
{title: '收货批次', dataIndex: 'batch'},
{title: '收货时间', dataIndex: 'receiveTime'},
{title: '收货数量', dataIndex: 'receiveCount'},
{title: '加工单价', dataIndex: 'unitPrice'},
{title: '结算金额', dataIndex: 'payPrice'},
]
const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
},
properties: {
ctl: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{exportBtn}}',
},
},
search: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
},
},
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
colStyle: {
marginLeft: 20,
},
},
properties: {
name: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '加工企业名称(全部)',
allowClear: true,
},
},
time: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '单据时间(全部)',
allowClear: true,
},
},
outerStatus: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '外部状态(全部)',
allowClear: true,
},
},
innerStatus: {
type: 'string',
default: undefined,
enum: [],
'x-component-props': {
placeholder: '内部状态(全部)',
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
},
},
},
},
},
},
},
};
const ProductNoticeSettlementDetail: React.FC = () => {
const ref = useRef<any>({});
......@@ -155,7 +78,7 @@ const ProductNoticeSettlementDetail: React.FC = () => {
tableProps={{
rowKey: 'id',
}}
columns={[]}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
......@@ -175,7 +98,7 @@ const ProductNoticeSettlementDetail: React.FC = () => {
// fetchSelectOptions,
// );
}}
schema={schema}
schema={detailSchema}
onSubmit={values => ref.current.reload(values)}
/>
}
......
/*
* @Author: Bill
* @Date: 2020-10-22 09:52:10
* @Description: 应收账款结算 schema集合
*/
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema, createFormActions } from '@formily/antd';
/**
* 应收账款 index.tsx 列表页schema
*/
export const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
name: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
align: 'flex-left',
tip: '输入通知单号、通知单摘要进行搜索',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 6,
},
properties: {
startTime: {
type: 'string',
'x-component': 'DatePicker',
'x-component-props': {
allowClear: true
}
},
endTime: {
type: 'string',
'x-component': 'DatePicker',
'x-component-props': {
allowClear: true
}
},
status: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '结算状态(全部)',
allowClear: true,
},
},
// submit: {
// 'x-component': 'Submit',
// 'x-mega-props': {
// span: 1,
// },
// 'x-component-props': {
// children: '查询',
// },
// },
},
},
},
},
},
};
/**
* 应收账款管理--物流单结算明细详情, 生产通知单结算明细
*/
export const detailSchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
grid: true,
},
properties: {
ctl: {
type: 'object',
'x-component': 'Children',
'x-component-props': {
children: '{{exportBtn}}',
},
},
search: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '搜索',
},
},
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
colStyle: {
marginLeft: 20,
},
},
properties: {
orderTime: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '下单时间(全部)',
allowClear: true,
},
},
payTime: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '支付时间(全部)',
allowClear: true,
},
},
// submit: {
// 'x-component': 'Submit',
// 'x-mega-props': {
// span: 1,
// },
// 'x-component-props': {
// children: '查询',
// },
// },
},
},
},
},
},
};
\ No newline at end of file
......@@ -4,7 +4,7 @@
* @Description: switch 组件
*/
import React from 'react';
import React, { useEffect } from 'react';
import { Radio } from 'antd';
const SchemaRadio = (props) => {
......@@ -15,6 +15,16 @@ const SchemaRadio = (props) => {
props.mutators.change(checked)
}
useEffect(() => {
const componentProps = props.props['x-component-props'] || {};
const defaultValue = componentProps.default || {};
if(typeof props.initialValue == 'undefined') {
props.mutators.change(defaultValue)
} else {
props.mutators.change(props.initialValue)
}
}, [props.initialValue])
return (
<Radio.Group onChange={handleChange} value={props.value || componentProps.default}>
{
......
......@@ -3,14 +3,22 @@
@margin-right: 16px;
@color: #909399;
.container {
background: #fff;
margin-bottom: @margin-bottom;
padding: @margin-bottom;
.error {
margin: 0 66px;
color: #ff4d4f;
}
}
.item {
display: flex;
flex-direction: row;
align-items: center;
background-color: #fff;
font-size: @font-size;
padding: @margin-bottom;
margin-bottom: @margin-bottom;
.image {
width: 48px;
......
......@@ -6,7 +6,9 @@ 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 config from 'config/config';
import { PublicApi } from '@/services/api';
import { getAuth } from '@/utils/auth';
import { Prompt } from 'umi'
interface Config {
name: string,
......@@ -16,96 +18,123 @@ interface Config {
canEdit: boolean,
cacheValue: string,
changeEdit?: any,
pattern?: any,
message?: string
}
const CONFIGS: Config[] = [
{
name: '账号名称',
image: company,
value: '广州市数商云网络科技有限公司',
cacheValue: '广州市数商云网络科技有限公司',
value: '',
cacheValue: '',
isEdit: false,
canEdit: false
},
{
name: '银行账号',
image: bank_account,
value: '6214 7812 3456 7891 1234',
cacheValue: '6214 7812 3456 7891 1234',
value: '',
cacheValue: '',
isEdit: false,
canEdit: true
canEdit: true,
pattern: /^([1-9]{1})(\d{14}|\d{18})$/,
message: '请输入正确的银行账号'
},
{
name: '开户行',
image: bank,
value: '中国建设银行广州市分行营业部',
cacheValue: '中国建设银行广州市分行营业部',
value: '',
cacheValue: '',
isEdit: false,
canEdit: true
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 } = props;
const { isEdit, name, canEdit, value, image, changeEdit, pattern, message } = props;
const [validError, setValidError] = useState(false);
// const [inputValue, setInputValue] = useState(value);
const handleClick = (name:string) => {
changeEdit(name, { isEdit: true }, 'change')
}
// 内容修改
const handleChange = (value:string, name: string) => {
if(!pattern.test(value)) {
setValidError(true)
} else {
setValidError(false)
}
changeEdit(name, {value: value}, 'change')
}
// 取消按钮
const handleCancel = (name: string) => {
setValidError(false);
changeEdit(name, { isEdit: false }, 'cancel')
}
// 确定提交
const handleConfirm = (name: string) => {
if(validError) {
return
}
changeEdit(name, { isEdit: false }, 'confirm');
}
return (
<div className={styles.item}>
<div className={styles.image}>
<img src={image} className={styles.img} />
<div className={styles.container}>
<div className={styles.item}>
<div className={styles.image}>
<img src={image} className={styles.img} />
</div>
<div className={styles.itemName}>{name}</div>
<div className={styles.itemValue}>
{isEdit ? <Input value={value} style={{width: '300px'}} onChange={(e) => handleChange(e.target.value, name)}/> : value}
</div>
{
canEdit
? !isEdit
? <div className={styles.edit} style={{width: '300px'}} onClick={() => handleClick(name)} >
<FormOutlined />
</div>
: <div>
<Space>
<Button type="primary" onClick={() => handleConfirm(name)} >确定</Button>
<Button onClick={() => handleCancel(name)}>取消</Button>
</Space>
</div>
: null
}
</div>
<div className={styles.itemName}>{name}</div>
<div className={styles.itemValue}>
{isEdit ? <Input value={value} onChange={(e) => handleChange(e.target.value, name)}/> : value}
</div>
{
canEdit
? !isEdit
? <div className={styles.edit} onClick={() => handleClick(name)} >
<FormOutlined />
</div>
: <div>
<Space>
<Button type="primary" onClick={() => handleConfirm(name)} >确定</Button>
<Button onClick={() => handleCancel(name)}>取消</Button>
</Space>
</div>
: null
}
<div className={styles.error}>{validError ? message : ''}</div>
</div>
)
}
const CorporateAccount = () => {
const [configs, setConfigs] = useState<Config[]>(CONFIGS);
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);
const target = temp[index];
if(type == 'change') {
setUnsaved(true);
temp[index] = {
...target,
...res,
}
} else if(type == 'cancel') {
setUnsaved(false);
temp[index] = {
...target,
...res,
value: type == 'cancel' ? target.cacheValue : target.value,
}
} else if(type == 'confirm') {
setUnsaved(false);
temp[index] = {
...target,
...res,
......@@ -117,18 +146,26 @@ const CorporateAccount = () => {
}
useEffect(() => {
const { memberId } = getAuth() || {};
// 进行基础赋值, fetchData
async function fetchData() {
const res = await PublicApi.getSettleAccountsCorporateAccountConfig({memberId: memberId});
console.log(res);
}
fetchData();
}, [])
return (
<PageHeaderWrapper>
{
configs.map((item: Config, key) => {
return (
<ItemRender key={item.name} {...item} changeEdit={changeEdit}/>
<ItemRender key={item.name} {...item} changeEdit={changeEdit} />
)
})
}
<Prompt when={unsaved} message="信息还未保存,确定离开吗?"></Prompt>
</PageHeaderWrapper>
)
}
......
......@@ -6,64 +6,98 @@
import React, { useState, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Row, Col, Switch } from 'antd';
import { Row, Col, Switch, Popconfirm } from 'antd';
import { FormOutlined, DeleteOutlined, PlusOutlined } from '@ant-design/icons'
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 ItemIprops {
onRemove: any
onRemove: (id: number | string) => void,
id: number,
kind: Kind,
type: ItemIpropType,
invoiceTitle: string,
taxNo: string,
bankOfDeposit: string,
account: string,
addres: string,
tel: string
isDefault: number
}
const ReceiptItem: React.FC<ItemIprops> = (props) => {
const { id, kind, type, invoiceTitle, taxNo, bankOfDeposit, account, addres, tel, isDefault } = props;
const handleRouterPush = () => {
history.push('/memberCenter/balance/settleRules/receiptList/detail');
history.push(`/memberCenter/balance/settleRules/receiptList/detail?id=${id}`);
}
const handleDelete = (id) => {
console.log(props);
const handleDelete = (id: number | string) => {
props.onRemove(id);
}
return (
<div className={styles.item}>
<div className={styles.controller}>
<div className={styles.edit} onClick={handleRouterPush}><FormOutlined /></div>
<div className={styles.remove} onClick={() => handleDelete(1)}><DeleteOutlined /></div>
<div className={styles.remove}>
<Popconfirm
title="确定删除这条信息吗?"
onConfirm={() => handleDelete(id)}
okText="确定"
cancelText="取消"
>
<DeleteOutlined />
</Popconfirm>
</div>
</div>
<Row className={styles.row}>
<Col span={6}>发票品类</Col>
<Col span={18}>增值税</Col>
<Col span={6}>开具类型</Col>
<Col span={18}>{type == 1 ? '企业' : '个人'}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>发票种类</Col>
<Col span={18}>{kind == 1 ? '增值税普通发票' : '增值税专用发票'}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>发票抬头</Col>
<Col span={18}>广州市数商云网络科技有限公司</Col>
<Col span={18}>{invoiceTitle}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>纳税号</Col>
<Col span={18}>914401050651605264E</Col>
<Col span={18}>{taxNo}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>账号</Col>
<Col span={18}>6214 71612 3456 71691 1234</Col>
<Col span={18}>{account}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>开户行</Col>
<Col span={18}>中国建设银行广州市分行营业部</Col>
<Col span={18}>{bankOfDeposit}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>地址</Col>
<Col span={18}>广州市海珠区新港东路234号中州中心</Col>
<Col span={18}>{addres}</Col>
</Row>
<Row className={styles.row}>
<Col span={6}>电话</Col>
<Col span={18}>136 7627 2729</Col>
<Col span={18}>{tel}</Col>
</Row>
<Row>
<Col span={6}>是否默认</Col>
<Col span={18}><Switch disabled checked={true}/></Col>
<Col span={18}><Switch disabled checked={isDefault ? true : false}/></Col>
</Row>
</div>
)
......@@ -71,13 +105,15 @@ const ReceiptItem: React.FC<ItemIprops> = (props) => {
const Receipt: React.FC<iProps> = () => {
const [list, setList] = useState([]);
const fetchData = async () => {
const { data } = await PublicApi.getSettleAccountsInvoiceMessageList();
return data;
}
useEffect(() => {
// fetchData
async function fetchData() {
}
// fetchData()
fetchData().then((data) => {
setList(data);
})
}, [])
const handleRouterAdd = () => {
......@@ -85,18 +121,23 @@ const Receipt: React.FC<iProps> = () => {
}
// 删除发票
const remove = (id: number) => {
const remove = async (id: number) => {
console.log(id);
const res = await PublicApi.postSettleAccountsInvoiceMessageDelete({id});
if(res.code == 1000) {
const newList = list.filter((item) => item.id !== id);
setList(newList);
}
}
return (
<PageHeaderWrapper>
<Row gutter={24}>
{
[1,].map((item) => {
list.map((item) => {
return (
<Col span={8} key={item} className={styles.margin}>
<ReceiptItem onRemove={remove}/>
<Col span={8} key={item.id} className={styles.margin}>
<ReceiptItem onRemove={remove} {...item}/>
</Col>
)
})
......
......@@ -11,6 +11,9 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Card, Switch, Button } from 'antd';
import SchemaSwitch from '../../components/SchemaSwitch';
import SchemaRadio from '../../components/SchemaRadio';
import { PublicApi } from '@/services/api';
import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi';
const formActions = createFormActions();
......@@ -26,9 +29,9 @@ const schema = {
labelAlign: 'left',
},
properties: {
consignor: {
type: {
type: 'string',
title: '发货人',
title: '开具类型',
'x-component': 'SchemaRadio',
'x-component-props': {
default: 1,
......@@ -41,9 +44,9 @@ const schema = {
{required: true, message: '请选择发货人'}
]
},
type: {
kind: {
type: 'string',
title: '发种类',
title: '发种类',
'x-component': 'SchemaRadio',
'x-component-props': {
default: 1,
......@@ -54,64 +57,55 @@ const schema = {
},
'x-rules': [
{required: true, message: '请选择发种类'}
{required: true, message: '请选择发种类'}
]
},
invoiceTitle: {
type: 'string',
title: '发票抬头',
'x-rules': [
{required: true, message: '请填写发票抬头'}
{required: true, message: '请填写发票抬头'},
{limitByte: true, maxByte: 40 }
],
},
taxNumber: {
taxNo: {
type: 'string',
title: '纳税号',
'x-rules': [
{required: true, message: '请填写发票抬头'}
{required: true, message: '请填写纳税号'},
{limitByte: true, maxByte: 20, allowChineseTransform: false }
]
},
depositBank: {
bankOfDeposit: {
type: 'string',
title: '开户行',
'x-rules': [
{limitByte: true, maxByte: 40 }
]
},
account: {
type: 'string',
title: '账号'
title: '账号',
'x-rules': [
{pattern: /^([1-9]{1})(\d{14}|\d{18})$/, message: '请填写正确的银行账号'}
]
},
address: {
addres: {
type: 'text',
title: '地址',
'x-component': 'textarea'
'x-component': 'textarea',
'x-rules': [
{limitByte: true, maxByte: 80 }
]
},
phoneLayout: {
type: 'object',
'x-mega-props': {
wrapperCol: 24
},
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
columns: 3,
label: '电话',
wrapperCol: 24
},
properties: {
areaCode: {
type: 'string',
enum: [],
'x-component-props': {
}
},
phone: {
type: 'string',
'x-mega-props': {
span: 2
}
}
}
tel: {
type: 'string',
title: '电话号码',
'x-rules': [
{limitByte: true, maxByte: 80 },
{pattern: /^0\d{2,3}-?\d{7,8}$/, message: '请填写正确的电话号码'}
]
},
isDefault: {
type: 'object',
......@@ -126,21 +120,46 @@ const schema = {
const Info: React.FC = () => {
const [initialValue, setInitialValue] = useState({});
const { id, preview } = usePageStatus();
const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const isEdit = id && !preview;
const isAdd = !id && !preview;
const isView = id && preview;
const handleSubmit = (value) => {
console.log(value);
// return value;
const serviceActions = isAdd
? PublicApi.postSettleAccountsInvoiceMessageAdd
: PublicApi.postSettleAccountsInvoiceMessageUpdate
let tempData = {...value, isDefault: value.isDefault ? 1 : 0};
const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true);
setUnsaved(false);
serviceActions(postData).then((data) => {
setSubmitLoading(false);
if(data.code === 1000) {
history.push('/memberCenter/balance/settleRules/receiptList')
}
})
}
useEffect(() => {
async function fetchData() {
setInitialValue({
consignor: 2,
type: 2,
address: 'fuck you',
isDefault: true
})
if(id) {
async function fetchData() {
const { data } = await PublicApi.getSettleAccountsInvoiceMessageDetails({id});
setInitialValue(data)
}
fetchData()
}
fetchData();
}, [])
;
}, [id])
const handleCancel = () => {
history.push('/memberCenter/balance/settleRules/receiptList')
}
return (
<PageHeaderWrapper>
......@@ -154,11 +173,12 @@ const Info: React.FC = () => {
schema={schema}
>
<FormButtonGroup offset={4}>
<Submit >提交</Submit>
<Button >取消</Button>
<Submit loading={submitLoading}>提交</Submit>
<Button onClick={handleCancel}>取消</Button>
</FormButtonGroup>
</NiceForm>
</Card>
</Card>
<Prompt when={unsaved} message={"内容未保存,确定要离开?"} />
</PageHeaderWrapper>
)
......
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