Commit 8396f822 authored by 卢均锐's avatar 卢均锐

fix: [19587,19608] 新增请款单-选择合同增加请款类型筛选

-修复rowKey问题
parent 4df95c5d
......@@ -405,7 +405,7 @@ const Add = () => {
const _changeNumbers = (record: any, value: any) => {
let _val = value.replace(/^\D*(\d*(?:\.\d{0,3})?).*$/g, '$1');
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] };
_item.applyPayment = Number(_val);
_dataSource[_i] = _item;
......@@ -416,15 +416,15 @@ const Add = () => {
const handleRemove = (index: number, record: any) => {
const data = [...tabelSource];
data.splice(index, 1);
form.setFieldsValue({ [`applyPayment${record.billNo}_${record.billId}`]: null });
form.setFieldsValue({ [`applyPayment${record.billNo}_${record.taxRate}`]: null });
setTabelSource(data)
}
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;
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;
break;
}
......@@ -519,7 +519,7 @@ const Add = () => {
width: 150,
render: (text: any, record: any, index: number) => (
<Form.Item
name={`applyPayment${record.billNo}_${record.billId}`}
name={`applyPayment${record.billNo}_${record.taxRate}`}
style={{ margin: 0 }}
rules={[
{
......@@ -662,7 +662,7 @@ const Add = () => {
useEffect(() => {
if (!_isFunds) {
tabelSource.forEach((item) => {
form.setFieldsValue({ [`applyPayment${item.billNo}_${item.billId}`]: item.applyPayment || null })
form.setFieldsValue({ [`applyPayment${item.billNo}_${item.taxRate}`]: item.applyPayment || null })
})
}
}, [tabelSource])
......@@ -670,7 +670,7 @@ const Add = () => {
useEffect(() => {
if (!_isFunds) {
tabelSource.forEach((item) => {
form.setFieldsValue({ [`applyPayment${item.billNo}_${item.billId}`]: null })
form.setFieldsValue({ [`applyPayment${item.billNo}_${item.taxRate}`]: null })
})
}
setTabelSource([]);
......@@ -870,7 +870,7 @@ const Add = () => {
/>
<WriteOffDrawer visible={writeOffDrawer} record={writeOffData} editAble={true} onClose={() => { setWriteOffDrawer(false) }} onOk={_handleWriteOffOk} />
<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} />
<Prompt when={unsaved} message={intl.formatMessage({ id: 'common.tip.save.confirm' }, { default: '您还有未保存的内容,是否确定要离开?' })} />
</>
......
import React, { useRef, useState } from 'react';
import { Drawer, Button } from 'antd';
import React, { useRef, useState, useEffect } from 'react';
import { Drawer, Button,message } from 'antd';
import { ColumnType } from 'antd/lib/table/interface';
import StandardTable from '@/components/StandardTable';
import { createFormActions } from '@formily/antd'
......@@ -13,6 +13,7 @@ import { getIntl } from 'umi';
interface ContractDrawerProps {
visible: boolean,
applyType: number,
partyBMemberId?: number,
partyBRoleId?: number,
onClose?: () => void,
......@@ -22,13 +23,13 @@ const intl = getIntl();
const formActions = createFormActions();
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 [selectedRowKeys, setSelectedRowKeys] = useState<any>([])
const [selectedRows, setSelectedRows] = useState<any>([])
const loadingTableData = async (params) => {
const _params = { ...params, partyBMemberId, partyBRoleId }
const _params = { ...params, sourceType: applyType, partyBMemberId, partyBRoleId }
const { data } = await getSettleAccountsBusinessApplyAmountFindApplyAmountRosSourceContracts(_params)
return data;
}
......@@ -72,16 +73,17 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
const handleSelectChange = (record, selected, selectedRow, nativeEvent) => {
let childArr = [...selectedRowKeys];
let childRowArr = [...selectedRows]
const _key = `contract_${record['billNo']}_${record['taxRate']}`
if (selected) {
childArr.push(record.billId);
childArr.push(_key);
childRowArr.push(record);
} else {
childArr.splice(
childArr.findIndex((item) => item === record.billId),
childArr.findIndex((item) => item === _key),
1
);
childRowArr.splice(
childRowArr.findIndex((item) => item.billId === record.billId),
childRowArr.findIndex((item) => `contract_${item['billNo']}_${item['taxRate']}` === _key),
1
);
}
......@@ -94,17 +96,17 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
let childRowArr = [...selectedRows];
if (selected) {
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(
new Set([...childRowArr, ...changeRows])
);
} else {
childArr = childArr.filter(
(item) => !changeRows.some((e) => e.billId === item)
(item) => !changeRows.some((e) => `contract_${e['billNo']}_${e['taxRate']}` === item)
);
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);
......@@ -113,11 +115,20 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
const _onOk = () => {
const _rows = [...selectedRows]
if(_rows.length <= 0){
message.error('请至少选择一条记录');
return;
}
setSelectedRows([])
setSelectedRowKeys([])
onOk?.(_rows);
}
useEffect(() => {
setSelectedRows([])
setSelectedRowKeys([])
}, [applyType, partyBMemberId])
return (
<Drawer
......@@ -143,8 +154,12 @@ const ContractDrawer: React.FC<ContractDrawerProps> = (props: ContractDrawerProp
fetchTableData={params => loadingTableData(params)}
columns={columns}
currentRef={ref}
key={`contract_${partyBMemberId}`}
rowKey="billId"
key={`contract_${partyBMemberId}_${applyType}`}
tableProps={{
rowKey: (record) => {
return `contract_${record['billNo']}_${record['taxRate']}`;
}
}}
rowSelection={{
selectedRowKeys: selectedRowKeys,
onSelect: handleSelectChange,
......
......@@ -56,6 +56,14 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) =>
setSelectedRow(record)
};
const _onOk = () => {
if (!selectedRow?.memberId) {
message.error('请选择一条记录');
return;
}
onOk?.(selectedRow);
}
return (
<Drawer
......@@ -70,7 +78,7 @@ const MemberDrawer: React.FC<MemberDrawerProps> = (props: MemberDrawerProps) =>
<Button onClick={onClose} style={{ marginRight: 8 }}>
{intl.formatMessage({ id: 'balance.quxiao' })}
</Button>
<Button onClick={() => { onOk?.(selectedRow) }} type="primary">
<Button onClick={_onOk} type="primary">
{'确定'}
</Button>
</div>
......
import React, { useRef, useState } from 'react';
import { Drawer, Button } from 'antd';
import React, { useRef, useState, useEffect } from 'react';
import { Drawer, Button, message } from 'antd';
import { ColumnType } from 'antd/lib/table/interface';
import StandardTable from '@/components/StandardTable';
import { createFormActions } from '@formily/antd'
......@@ -88,16 +88,17 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
const handleSelectChange = (record, selected, selectedRow, nativeEvent) => {
let childArr = [...selectedRowKeys];
let childRowArr = [...selectedRows]
const _key = `requestFunds_${record['billNo']}_${record['taxRate']}`
if (selected) {
childArr.push(record.billId);
childArr.push(_key);
childRowArr.push(record);
} else {
childArr.splice(
childArr.findIndex((item) => item === record.billId),
childArr.findIndex((item) => item === _key),
1
);
childRowArr.splice(
childRowArr.findIndex((item) => item.billId === record.billId),
childRowArr.findIndex((item) => `requestFunds_${item['billNo']}_${item['taxRate']}` === _key),
1
);
}
......@@ -110,17 +111,17 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
let childRowArr = [...selectedRows];
if (selected) {
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(
new Set([...childRowArr, ...changeRows])
);
} else {
childArr = childArr.filter(
(item) => !changeRows.some((e) => e.billId === item)
(item) => !changeRows.some((e) => `requestFunds_${e['billNo']}_${e['taxRate']}` === item)
);
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);
......@@ -129,11 +130,20 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
const _onOk = () => {
const _rows = [...selectedRows]
if (_rows.length <= 0) {
message.error('请至少选择一条记录');
return;
}
setSelectedRows([])
setSelectedRowKeys([])
onOk?.(_rows);
}
useEffect(() => {
setSelectedRows([])
setSelectedRowKeys([])
}, [applyType])
return (
<Drawer
......@@ -157,12 +167,11 @@ const RequestFundsDrawer: React.FC<RequestFundsDrawerProps> = (props: RequestFun
<StandardTable
keepAlive={false}
key={`requestFunds_${applyType}`}
rowKey="billId"
// tableProps={{
// rowKey: (record) => {
// return `requestFunds_${applyType}_${record['billNo']}_${record['billId']}_${record['billAmount']}_${record['billTime']}`;
// }
// }}
tableProps={{
rowKey: (record) => {
return `requestFunds_${record['billNo']}_${record['taxRate']}`;
}
}}
fetchTableData={params => loadingTableData(params)}
columns={columns}
currentRef={ref}
......
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