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