Commit ed78f259 authored by XieZhiXiong's avatar XieZhiXiong
parents e5d4e79b 8396f822
...@@ -405,7 +405,7 @@ const Add = () => { ...@@ -405,7 +405,7 @@ const Add = () => {
const _changeNumbers = (record: any, value: any) => { const _changeNumbers = (record: any, value: any) => {
let _val = value.replace(/^\D*(\d*(?:\.\d{0,3})?).*$/g, '$1'); let _val = value.replace(/^\D*(\d*(?:\.\d{0,3})?).*$/g, '$1');
let _dataSource = [...tabelSource]; let _dataSource = [...tabelSource];
const _i = _dataSource.findIndex((item) => item.billId === record.billId); const _i = _dataSource.findIndex((item) => `applyPayment${item.billNo}_${item.taxRate}` === `applyPayment${record.billNo}_${record.taxRate}`);
let _item = { ..._dataSource[_i] }; let _item = { ..._dataSource[_i] };
_item.applyPayment = Number(_val); _item.applyPayment = Number(_val);
_dataSource[_i] = _item; _dataSource[_i] = _item;
...@@ -416,15 +416,15 @@ const Add = () => { ...@@ -416,15 +416,15 @@ const Add = () => {
const handleRemove = (index: number, record: any) => { const handleRemove = (index: number, record: any) => {
const data = [...tabelSource]; const data = [...tabelSource];
data.splice(index, 1); data.splice(index, 1);
form.setFieldsValue({ [`applyPayment${record.billNo}_${record.billId}`]: null }); form.setFieldsValue({ [`applyPayment${record.billNo}_${record.taxRate}`]: null });
setTabelSource(data) setTabelSource(data)
} }
const handleRecordOk = (rows: any) => { const handleRecordOk = (rows: any) => {
const _documentTypeList = tabelSource.filter((item) => item.billType === documentType).map((item) => `${item.billType}_${item.billId}`) const _documentTypeList = tabelSource.filter((item) => item.billType === documentType).map((item) => `${item.billType}_${item.billId}_${item.taxRate}`)
let _flag = false; let _flag = false;
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
if (_documentTypeList.includes(`${rows[i].billType}_${rows[i].billId}`)) { if (_documentTypeList.includes(`${rows[i].billType}_${rows[i].billId}_${rows[i].taxRate}`)) {
_flag = true; _flag = true;
break; break;
} }
...@@ -519,7 +519,7 @@ const Add = () => { ...@@ -519,7 +519,7 @@ const Add = () => {
width: 150, width: 150,
render: (text: any, record: any, index: number) => ( render: (text: any, record: any, index: number) => (
<Form.Item <Form.Item
name={`applyPayment${record.billNo}_${record.billId}`} name={`applyPayment${record.billNo}_${record.taxRate}`}
style={{ margin: 0 }} style={{ margin: 0 }}
rules={[ rules={[
{ {
...@@ -662,7 +662,7 @@ const Add = () => { ...@@ -662,7 +662,7 @@ const Add = () => {
useEffect(() => { useEffect(() => {
if (!_isFunds) { if (!_isFunds) {
tabelSource.forEach((item) => { tabelSource.forEach((item) => {
form.setFieldsValue({ [`applyPayment${item.billNo}_${item.billId}`]: item.applyPayment || null }) form.setFieldsValue({ [`applyPayment${item.billNo}_${item.taxRate}`]: item.applyPayment || null })
}) })
} }
}, [tabelSource]) }, [tabelSource])
...@@ -670,7 +670,7 @@ const Add = () => { ...@@ -670,7 +670,7 @@ const Add = () => {
useEffect(() => { useEffect(() => {
if (!_isFunds) { if (!_isFunds) {
tabelSource.forEach((item) => { tabelSource.forEach((item) => {
form.setFieldsValue({ [`applyPayment${item.billNo}_${item.billId}`]: null }) form.setFieldsValue({ [`applyPayment${item.billNo}_${item.taxRate}`]: null })
}) })
} }
setTabelSource([]); setTabelSource([]);
...@@ -870,7 +870,7 @@ const Add = () => { ...@@ -870,7 +870,7 @@ const Add = () => {
/> />
<WriteOffDrawer visible={writeOffDrawer} record={writeOffData} editAble={true} onClose={() => { setWriteOffDrawer(false) }} onOk={_handleWriteOffOk} /> <WriteOffDrawer visible={writeOffDrawer} record={writeOffData} editAble={true} onClose={() => { setWriteOffDrawer(false) }} onOk={_handleWriteOffOk} />
<MemberDrawer visible={memberDrawerVisible} onClose={() => { setMemberDrawerVisible(false) }} onOk={_handleMemberOk} /> <MemberDrawer visible={memberDrawerVisible} onClose={() => { setMemberDrawerVisible(false) }} onOk={_handleMemberOk} />
<ContractDrawer visible={contractDrawerVisible} partyBMemberId={dataSource?.vendorMemberId} partyBRoleId={dataSource?.vendorRoleId} onClose={() => { setContractDrawerVisible(false) }} onOk={handleRecordOk} /> <ContractDrawer visible={contractDrawerVisible} applyType={form.getFieldValue('applyType')} partyBMemberId={dataSource?.vendorMemberId} partyBRoleId={dataSource?.vendorRoleId} onClose={() => { setContractDrawerVisible(false) }} onOk={handleRecordOk} />
<RequestFundsDrawer visible={requestFundsDrawerVisible} applyType={form.getFieldValue('applyType')} onClose={() => { setRequestFundsDrawerVisible(false) }} onOk={handleRecordOk} /> <RequestFundsDrawer visible={requestFundsDrawerVisible} applyType={form.getFieldValue('applyType')} onClose={() => { setRequestFundsDrawerVisible(false) }} onOk={handleRecordOk} />
<Prompt when={unsaved} message={intl.formatMessage({ id: 'common.tip.save.confirm' }, { default: '您还有未保存的内容,是否确定要离开?' })} /> <Prompt when={unsaved} message={intl.formatMessage({ id: 'common.tip.save.confirm' }, { default: '您还有未保存的内容,是否确定要离开?' })} />
</> </>
......
import React, { useRef, useState } from 'react'; import React, { useRef, useState, useEffect } from 'react';
import { Drawer, Button } from 'antd'; import { Drawer, Button,message } from 'antd';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
import StandardTable from '@/components/StandardTable'; import StandardTable from '@/components/StandardTable';
import { createFormActions } from '@formily/antd' import { createFormActions } from '@formily/antd'
...@@ -13,6 +13,7 @@ import { getIntl } from 'umi'; ...@@ -13,6 +13,7 @@ import { getIntl } from 'umi';
interface ContractDrawerProps { interface ContractDrawerProps {
visible: boolean, visible: boolean,
applyType: number,
partyBMemberId?: number, partyBMemberId?: number,
partyBRoleId?: number, partyBRoleId?: number,
onClose?: () => void, onClose?: () => void,
...@@ -22,13 +23,13 @@ const intl = getIntl(); ...@@ -22,13 +23,13 @@ const intl = getIntl();
const formActions = createFormActions(); const formActions = createFormActions();
const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProps) => { const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProps) => {
const { visible, partyBMemberId, partyBRoleId, onClose, onOk } = props; const { visible, applyType, partyBMemberId, partyBRoleId, onClose, onOk } = props;
const ref = useRef<any>({}) const ref = useRef<any>({})
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]) const [selectedRowKeys, setSelectedRowKeys] = useState<any>([])
const [selectedRows, setSelectedRows] = useState<any>([]) const [selectedRows, setSelectedRows] = useState<any>([])
const loadingTableData = async (params) => { const loadingTableData = async (params) => {
const _params = { ...params, partyBMemberId, partyBRoleId } const _params = { ...params, sourceType: applyType, partyBMemberId, partyBRoleId }
const { data } = await getSettleAccountsBusinessApplyAmountFindApplyAmountRosSourceContracts(_params) const { data } = await getSettleAccountsBusinessApplyAmountFindApplyAmountRosSourceContracts(_params)
return data; return data;
} }
...@@ -72,16 +73,17 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp ...@@ -72,16 +73,17 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
const handleSelectChange = (record, selected, selectedRow, nativeEvent) => { const handleSelectChange = (record, selected, selectedRow, nativeEvent) => {
let childArr = [...selectedRowKeys]; let childArr = [...selectedRowKeys];
let childRowArr = [...selectedRows] let childRowArr = [...selectedRows]
const _key = `contract_${record['billNo']}_${record['taxRate']}`
if (selected) { if (selected) {
childArr.push(record.billId); childArr.push(_key);
childRowArr.push(record); childRowArr.push(record);
} else { } else {
childArr.splice( childArr.splice(
childArr.findIndex((item) => item === record.billId), childArr.findIndex((item) => item === _key),
1 1
); );
childRowArr.splice( childRowArr.splice(
childRowArr.findIndex((item) => item.billId === record.billId), childRowArr.findIndex((item) => `contract_${item['billNo']}_${item['taxRate']}` === _key),
1 1
); );
} }
...@@ -94,17 +96,17 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp ...@@ -94,17 +96,17 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
let childRowArr = [...selectedRows]; let childRowArr = [...selectedRows];
if (selected) { if (selected) {
childArr = Array.from( childArr = Array.from(
new Set([...childArr, ...changeRows.map((item) => item.billId)]) new Set([...childArr, ...changeRows.map((item) => `contract_${item['billNo']}_${item['taxRate']}`)])
); );
childRowArr = Array.from( childRowArr = Array.from(
new Set([...childRowArr, ...changeRows]) new Set([...childRowArr, ...changeRows])
); );
} else { } else {
childArr = childArr.filter( childArr = childArr.filter(
(item) => !changeRows.some((e) => e.billId === item) (item) => !changeRows.some((e) => `contract_${e['billNo']}_${e['taxRate']}` === item)
); );
childRowArr = childRowArr.filter( childRowArr = childRowArr.filter(
(item) => !changeRows.some((e) => e.billId === item.billId) (item) => !changeRows.some((e) => `contract_${e['billNo']}_${e['taxRate']}` === `contract_${item['billNo']}_${item['taxRate']}`)
); );
} }
setSelectedRowKeys(childArr); setSelectedRowKeys(childArr);
...@@ -113,11 +115,20 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp ...@@ -113,11 +115,20 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
const _onOk = () => { const _onOk = () => {
const _rows = [...selectedRows] const _rows = [...selectedRows]
if(_rows.length <= 0){
message.error('请至少选择一条记录');
return;
}
setSelectedRows([]) setSelectedRows([])
setSelectedRowKeys([]) setSelectedRowKeys([])
onOk?.(_rows); onOk?.(_rows);
} }
useEffect(() => {
setSelectedRows([])
setSelectedRowKeys([])
}, [applyType, partyBMemberId])
return ( return (
<Drawer <Drawer
...@@ -143,7 +154,12 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp ...@@ -143,7 +154,12 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
fetchTableData={params => loadingTableData(params)} fetchTableData={params => loadingTableData(params)}
columns={columns} columns={columns}
currentRef={ref} currentRef={ref}
rowKey="billId" key={`contract_${partyBMemberId}_${applyType}`}
tableProps={{
rowKey: (record) => {
return `contract_${record['billNo']}_${record['taxRate']}`;
}
}}
rowSelection={{ rowSelection={{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onSelect: handleSelectChange, onSelect: handleSelectChange,
...@@ -177,6 +193,7 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp ...@@ -177,6 +193,7 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
'x-component-props': { 'x-component-props': {
placeholder: '请输入合同编号', placeholder: '请输入合同编号',
align: 'flex-start', align: 'flex-start',
allowClear: true,
}, },
}, },
} }
......
...@@ -56,6 +56,14 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) => ...@@ -56,6 +56,14 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) =>
setSelectedRow(record) setSelectedRow(record)
}; };
const _onOk = () => {
if (!selectedRow?.memberId) {
message.error('请选择一条记录');
return;
}
onOk?.(selectedRow);
}
return ( return (
<Drawer <Drawer
...@@ -70,7 +78,7 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) => ...@@ -70,7 +78,7 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) =>
<Button onClick={onClose} style={{ marginRight: 8 }}> <Button onClick={onClose} style={{ marginRight: 8 }}>
{intl.formatMessage({ id: 'balance.quxiao' })} {intl.formatMessage({ id: 'balance.quxiao' })}
</Button> </Button>
<Button onClick={() => { onOk?.(selectedRow) }} type="primary"> <Button onClick={_onOk} type="primary">
{'确定'} {'确定'}
</Button> </Button>
</div> </div>
...@@ -101,13 +109,14 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) => ...@@ -101,13 +109,14 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) =>
grid: true grid: true
}, },
properties: { properties: {
memberName: { name: {
type: 'string', type: 'string',
"x-component": 'Search', "x-component": 'Search',
'x-component-props': { 'x-component-props': {
placeholder: '请输入会员名称', placeholder: '请输入会员名称',
advanced: false, advanced: false,
align: 'flex-start', align: 'flex-start',
allowClear: true,
}, },
}, },
} }
......
import React, { useRef, useState } from 'react'; import React, { useRef, useState, useEffect } from 'react';
import { Drawer, Button } from 'antd'; import { Drawer, Button, message } from 'antd';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
import StandardTable from '@/components/StandardTable'; import StandardTable from '@/components/StandardTable';
import { createFormActions } from '@formily/antd' import { createFormActions } from '@formily/antd'
...@@ -88,16 +88,17 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun ...@@ -88,16 +88,17 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
const handleSelectChange = (record, selected, selectedRow, nativeEvent) => { const handleSelectChange = (record, selected, selectedRow, nativeEvent) => {
let childArr = [...selectedRowKeys]; let childArr = [...selectedRowKeys];
let childRowArr = [...selectedRows] let childRowArr = [...selectedRows]
const _key = `requestFunds_${record['billNo']}_${record['taxRate']}`
if (selected) { if (selected) {
childArr.push(record.billId); childArr.push(_key);
childRowArr.push(record); childRowArr.push(record);
} else { } else {
childArr.splice( childArr.splice(
childArr.findIndex((item) => item === record.billId), childArr.findIndex((item) => item === _key),
1 1
); );
childRowArr.splice( childRowArr.splice(
childRowArr.findIndex((item) => item.billId === record.billId), childRowArr.findIndex((item) => `requestFunds_${item['billNo']}_${item['taxRate']}` === _key),
1 1
); );
} }
...@@ -110,17 +111,17 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun ...@@ -110,17 +111,17 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
let childRowArr = [...selectedRows]; let childRowArr = [...selectedRows];
if (selected) { if (selected) {
childArr = Array.from( childArr = Array.from(
new Set([...childArr, ...changeRows.map((item) => item.billId)]) new Set([...childArr, ...changeRows.map((item) => `requestFunds_${item['billNo']}_${item['taxRate']}`)])
); );
childRowArr = Array.from( childRowArr = Array.from(
new Set([...childRowArr, ...changeRows]) new Set([...childRowArr, ...changeRows])
); );
} else { } else {
childArr = childArr.filter( childArr = childArr.filter(
(item) => !changeRows.some((e) => e.billId === item) (item) => !changeRows.some((e) => `requestFunds_${e['billNo']}_${e['taxRate']}` === item)
); );
childRowArr = childRowArr.filter( childRowArr = childRowArr.filter(
(item) => !changeRows.some((e) => e.billId === item.billId) (item) => !changeRows.some((e) => `requestFunds_${e['billNo']}_${e['taxRate']}` === `requestFunds_${item['billNo']}_${item['taxRate']}`)
); );
} }
setSelectedRowKeys(childArr); setSelectedRowKeys(childArr);
...@@ -129,11 +130,20 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun ...@@ -129,11 +130,20 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
const _onOk = () => { const _onOk = () => {
const _rows = [...selectedRows] const _rows = [...selectedRows]
if (_rows.length <= 0) {
message.error('请至少选择一条记录');
return;
}
setSelectedRows([]) setSelectedRows([])
setSelectedRowKeys([]) setSelectedRowKeys([])
onOk?.(_rows); onOk?.(_rows);
} }
useEffect(() => {
setSelectedRows([])
setSelectedRowKeys([])
}, [applyType])
return ( return (
<Drawer <Drawer
...@@ -156,10 +166,15 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun ...@@ -156,10 +166,15 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
> >
<StandardTable <StandardTable
keepAlive={false} keepAlive={false}
key={`requestFunds_${applyType}`}
tableProps={{
rowKey: (record) => {
return `requestFunds_${record['billNo']}_${record['taxRate']}`;
}
}}
fetchTableData={params => loadingTableData(params)} fetchTableData={params => loadingTableData(params)}
columns={columns} columns={columns}
currentRef={ref} currentRef={ref}
rowKey="billId"
rowSelection={{ rowSelection={{
selectedRowKeys: selectedRowKeys, selectedRowKeys: selectedRowKeys,
onSelect: handleSelectChange, onSelect: handleSelectChange,
...@@ -193,6 +208,7 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun ...@@ -193,6 +208,7 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
'x-component-props': { 'x-component-props': {
placeholder: '请输入单据号', placeholder: '请输入单据号',
align: 'flex-start', align: 'flex-start',
allowClear: true,
}, },
}, },
} }
......
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