Commit 74f63f36 authored by Bill's avatar Bill

fix: 结算开票订单类型为退货时开票bug

parent 0b7c7d58
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -57,10 +57,11 @@ const SettlementList = () => {
const handleShow = (record) => {
document.body.parentNode.style.overflowY = "hidden";
setVisible(true)
console.log(record);
setActiveData({
id: record.id,
type: record.invoiceStatus,
settlementOrderType: record.settlementOrderType,
settlementOrderType: record.settlementOrderType || 5,
// payRoleId: record.payRoleId,
// payMemberId: record.payMemberId
})
......
......@@ -13,7 +13,7 @@ import {
} from '@formily/antd'
import InvoiceArray from './InvoiceArray';
import { Button, Table } from 'antd';
import { createFormActions } from '@formily/antd';
import { createFormActions, FormMegaLayout, FormSlot, createVirtualBox } from '@formily/antd';
import { PublicApi } from '@/services/api';
import { InvoiceInfoProps, ProveListProps } from '../../common/type';
import { Moment } from 'moment';
......@@ -35,7 +35,7 @@ interface Iprops {
}
interface SubmitProps {
list: {
[key: string]: {
number: string,
remark: string,
invoiceDate: Moment
......@@ -53,10 +53,31 @@ const columns = [
{title: '备注', dataIndex:'remark'},
]
const InvoiceComponent = createVirtualBox('InvoiceComponent', ({ infos }) => {
return (
<div >
<InvoiceInfo infos={infos} />
</div>
)
})
const TabelHeader = createVirtualBox('TabelHeader', ({ infos }) => {
return (
<div >
<div className={styles.formHeader}>
<div className={styles.invoiceNum}>发票号码<span style={{color: "#ff4d4f"}}>*</span></div>
<div className={styles.invoiceDate}>开票日期<span style={{color: "#ff4d4f"}}>*</span></div>
<div>备注</div>
</div>
</div>
)
})
const InvoiceDrawer: React.FC<Iprops> = (props) => {
const { visible, title, onCancel, width, type, id, settlementOrderType} = props;
const [invoiceInfo, setInvoiceInfo] = useState<any[]>([]);
const [submitLoading, setSubmitLoading] = useState<boolean>(false)
const [submitLoading, setSubmitLoading] = useState<boolean>(false);
const isEdit = type === TypeEnum.edit;
const handleSubmit = () => {
// // 如果当前type==0为开票, 1为查看,那么直接关闭
if(type === TypeEnum.edit) {
......@@ -68,28 +89,38 @@ const InvoiceDrawer: React.FC<Iprops> = (props) => {
}
const handleForm = (value: SubmitProps) => {
if(typeof value.list === 'undefined' || value.list.length === 0) {
console.log(value);
const keys = Object.keys(value);
if(keys.length === 0) {
message.error({
content: '请添加发票信息'
})
return;
}
const proveList = value.list.map((item, key) => { return {number: item.number, remark: item.remark, invoiceDate: item.invoiceDate.format('YYYY-MM-DD')} })
let res = {}
keys.map((item) => {
const array = value[item];
res[item] = array.map((_row) => {
const { number, remark, invoiceDate } = _row;
return {number: number, remark: remark, invoiceDate: invoiceDate.format('YYYY-MM-DD')}
})
})
if(settlementOrderType === 5) {
console.log(value);
const postDataList = {
receiptInvoiceId: parseInt(id),
addList: invoiceInfo.map((_item) => {
addList: invoiceInfo.map((_item, key) => {
const { kindName, typeName, ...rest } = _item;
return {
...rest,
kind: kindName == '增值税普通发票' ? 1 : 2,
type: typeName == '企业' ? 1 : 2,
proveList: []
proveList: res[`list-${key}`]
}
})
}
console.log(postDataList);
PublicApi.postSettleAccountsMemberSettlementInvoiceByReturn(postDataList)
.then(({code, data}) => {
if(code === 1000) {
......@@ -104,7 +135,7 @@ const InvoiceDrawer: React.FC<Iprops> = (props) => {
const { kindName, typeName, ...rest } = invoiceInfo[0]
const postData = {
...rest,
proveList: proveList,
proveList: res[`list-0`],
kind: kindName == '增值税普通发票' ? 1 : 2,
type: typeName == '企业' ? 1 : 2,
receiptInvoiceId: parseInt(id)
......@@ -124,17 +155,16 @@ const InvoiceDrawer: React.FC<Iprops> = (props) => {
useEffect(() => {
if(props.visible) {
console.log(settlementOrderType)
if(settlementOrderType === 5) {
PublicApi.getSettleAccountsMemberSettlementGetReturnInvoiceProveDetail({id: id})
.then(({code, data}) => {
if (code === 1000) {
console.log(data);
setInvoiceInfo(data)
}
})
return ;
}
///settle/accounts/member/settlement/getInvoiceProveDetail
PublicApi.getSettleAccountsMemberSettlementGetInvoiceProveDetail({id: id})
.then((data) => {
if(data.code === 1000) {
......@@ -161,51 +191,34 @@ const InvoiceDrawer: React.FC<Iprops> = (props) => {
)
}
return (
<Drawer
getContainer={false}
destroyOnClose
visible={visible}
bodyStyle={{overflow: 'auto'}}
title={title}
width={width}
onClose={onCancel}
footer={renderFooter()}
>
<div style={{display: 'flex', flexDirection: 'column'}}>
const renderOnly = () => {
return (
<SchemaForm onSubmit={handleForm} actions={formActions} components={{ InvoiceArray, Input, DatePicker }} >
{
invoiceInfo.map((item, unique) => {
const infos = item;
const tableList = item?.proveList?.map((item, key) => ({...item, id: key}));
return (
<div key={unique}>
<InvoiceInfo infos={infos} />
<InvoiceComponent infos={infos} />
{
type === TypeEnum.edit
isEdit
? (
<>
<div className={styles.formHeader}>
<div className={styles.invoiceNum}>发票号码<span style={{color: "#ff4d4f"}}>*</span></div>
<div className={styles.invoiceDate}>开票日期<span style={{color: "#ff4d4f"}}>*</span></div>
<div>备注</div>
</div>
{/* getPopupContainer={triggerNode => { console.log(triggerNode, triggerNode.parentElement); return triggerNode.parentNode}} */}
<SchemaForm onSubmit={handleForm} actions={formActions} components={{ InvoiceArray, Input, DatePicker }} name={`form-${unique}`}>
{/* <Field name="infoId" x-component="Input" display={false} default={unique} /> */}
<Field
name="list"
type="array"
x-component="InvoiceArray"
>
<Field type="object">
<Field name="number" x-component="Input" x-rules={[{required: true, message: '请填写发票号'}]} />
<Field name="invoiceDate" x-component-props={{
getPopupContainer: (triggernode) => triggernode.parentElement
}} x-component="DatePicker" x-rules={[{required: true, message: '请选择发票日期'}]} />
<Field name="remark" x-component="Input" x-component-props={{style: {width: '240px'}}} />
</Field>
<TabelHeader />
<Field
name={`list-${unique}`}
type="array"
x-component="InvoiceArray"
>
<Field type="object">
<Field name="number" x-component="Input" x-rules={[{required: true, message: '请填写发票号'}]} />
<Field name="invoiceDate" x-component-props={{
getPopupContainer: (triggernode) => triggernode.parentElement
}} x-component="DatePicker" x-rules={[{required: true, message: '请选择发票日期'}]} />
<Field name="remark" x-component="Input" x-component-props={{style: {width: '240px'}}} />
</Field>
</SchemaForm>
</Field>
</>
)
: (
......@@ -221,6 +234,25 @@ const InvoiceDrawer: React.FC<Iprops> = (props) => {
)
})
}
</SchemaForm>
)
}
return (
<Drawer
getContainer={false}
destroyOnClose
visible={visible}
bodyStyle={{overflow: 'auto'}}
title={title}
width={width}
onClose={onCancel}
footer={renderFooter()}
>
<div style={{display: 'flex', flexDirection: 'column'}}>
{
renderOnly()
}
</div>
</Drawer>
......
......@@ -144,7 +144,6 @@ const CorporateAccount = () => {
///settle/accounts/corporate/account/getDetail
async function fetchData() {
const { data } = await PublicApi.getSettleAccountsCorporateAccountGetDetail();
console.log(data);
// setDatas(data);
setConfigs(
[
......
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