Commit bf243c27 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

🐞fix: 修复采购报价BUG

parent b3ab0260
......@@ -203,7 +203,7 @@ const BidTable: React.FC<ReduxProps> = (props: any) => {
style={{ marginBottom: 0, display: 'none' }}
rules={[{
required: true,
message: ` `,
message: ``,
}]}
>
<InputNumber
......
......@@ -6,7 +6,6 @@ import { Space, Button, Tabs, message, Row, Col, Typography, Skeleton, Divider,
import { FilePdfOutlined } from '@ant-design/icons';
import RowLayout from './rowLayout';
import { Context, BidDetailContext } from '../context';
import { useBidTable } from '../../../effects/useBidTable';
import { PublicApi } from '@/services/api';
import ModalOperate from '../../../modalOperate';
import BidTable from '../bidTable';
......@@ -57,7 +56,9 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
const [visible, setVisible] = useState<boolean>(false);
const [loading, setLoading] = useState<boolean>(false);
const [disabled, setDisabled] = useState<boolean>(false);
const [rowSource, setRowSource] = useState<any>([]);
/** 当前为 contrast 并且轮数不等于当前报价轮数 */
const [bool, setBool] = useState<boolean>(false);
const [rowSource, setRowSource] = useState<any>({});
/** 当前tab的报价轮次 */
const [tabIdx, setTabIdx] = useState<string>(turn);
/** 当前报价单是否加密 */
......@@ -80,7 +81,8 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
}
/** 格式化数据 */
const formatting = (data: any) => {
const formatting = (data: any, index: number) => {
console.log(index, 10086)
const arr: any = data[0].awardInfoResponses.sort((a, b) => { return a.goodsId - b.goodsId }) || []
const params: any = [];
arr.forEach((i: any, index: number) => {
......@@ -125,16 +127,15 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
params.push(item);
})
const dataSoure = { ...soure }
dataSoure[idx] = [...params]
dataSoure[index] = [...params]
setSoure(dataSoure);
if (preview) {
redux(params)
console.log(params, data)
}
}
/** 点击比价 */
const offContrastPrice = async (num: string, key: number) => {
const offContrastPrice = async (num: string, key: number, i: number) => {
if (key === PRICECONTRAST_TYPE.UNENCRYPTED) {
handleFlag(true)
const params = {
......@@ -145,7 +146,7 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
if (res.code === 1000) {
const { data } = res;
if (data.length > 0) {
formatting(data);
formatting(data, i);
} else {
message.error('当前暂无比价信息');
setDisabled(true);
......@@ -165,8 +166,12 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
}
}
/** 获取报价会员信息 */
const fetchTableData = async (t: string) => {
/** 获取报价会员信息
* t: 轮次
* i: 当前tab 下标
*/
const fetchTableData = async (t: string, i?: number) => {
console.log(i)
const params = {
id,
turn: t,
......@@ -177,25 +182,33 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
return
}
const { data } = res.data;
const params = { ...rowSource };
params[i] = [...data]
if (data.length > 0) {
setEncrypt(data[0].isDecrypt);
setRowSource(data);
setRowSource(params);
/**
* 1. 比价的 需要 报价轮次不等于当前(表示已经报过假的) 并且preview 为 false 就要显示比价信息
* 2. preview 为 ture 表示查看详情的 立即调用比价接口
*/
const index = i ? i : idx
if (t !== turn && !preview) {
offContrastPrice(t, data[0].isDecrypt)
offContrastPrice(t, data[0].isDecrypt, index)
} else if (preview) {
offContrastPrice(t, data[0].isDecrypt)
offContrastPrice(t, data[0].isDecrypt, index)
}
} else {
const param = { ...soure }
param[i] = null,
setSoure(param);
setRowSource(params);
}
})
}
useEffect(() => {
if (turn) {
fetchTableData(turn);
fetchTableData(turn, idx);
handleTurn(turn)
}
}, [turn])
......@@ -204,12 +217,17 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
const getQuotedPriceInfo = (item: string) => {
const num = item.split('-')[0];
const index = item.split('-')[1];
setIdx(Number(index));
setTabIdx(num);
const params = { ...soure };
if (!preview && num !== turn) {
setBool(true)
} else {
setBool(false)
}
if (!params[index]) {
fetchTableData(num);
fetchTableData(num, Number(index));
}
setIdx(Number(index));
}
const handleSubmit = (type: string) => {
......@@ -236,7 +254,7 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
title='报价信息'
extra={
<>
{(tabIdx === turn && preview !== 'preview') &&
{(tabIdx === turn && !preview) &&
<Space>
<Button onClick={() => handleSubmit('next')}>发起下轮报价</Button>
{encrypt === PRICECONTRAST_TYPE.UNDECRYPTED &&
......@@ -246,7 +264,7 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
<Button
type='primary'
disabled={disabled}
onClick={() => offContrastPrice(tabIdx, encrypt)}
onClick={() => offContrastPrice(tabIdx, encrypt, idx)}
>
立即比价
</Button>
......@@ -262,7 +280,7 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
data-index={index}
tab={`第${chNum[item]}轮`}
>
{rowSource.length > 0 ? <RowLayout rowSource={rowSource} /> :
{(rowSource[idx] && rowSource[idx].length > 0 ) ? <RowLayout rowSource={rowSource[idx]} /> :
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
}
<Skeleton
......@@ -276,7 +294,7 @@ const ContrastLyout1: React.FC<IProps> = (props: any) => {
<Divider type='vertical' className={style.vertical} />
比价信息
</div>
<BidTable preview={preview} redux={reduxFetch} />
<BidTable preview={bool ? bool : preview} redux={reduxFetch} />
</>
)}
</Tabs.TabPane>
......
......@@ -115,12 +115,11 @@ const BidModal: React.FC<IProps> = (props: any) => {
urls: files,
priceParityInfos,
}
console.log(priceParityInfos, 962200)
// PublicApi.postPurchaseConfirmQuotedPriceSubmitContrastPrice(params).then(res => {
// if (res.code === 1000) {
// handleConfirm();
// }
// })
PublicApi.postPurchaseConfirmQuotedPriceSubmitContrastPrice(params).then(res => {
if (res.code === 1000) {
handleConfirm();
}
})
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
......
......@@ -83,7 +83,15 @@ const ContrastPrice = () => {
{
col: [
{ label: '单据时间', extra: format(data.createTime) },
{ label: '适用地市', extra: '-' },
{
label: '适用地市', extra: (
<div>
{data.areas.map((it: any, idx: number) => (
<p key={`areas${idx + 1}`}>{`${it.province}/${it.city}`}</p>
))}
</div>
)
},
]
},
])
......
......@@ -86,8 +86,8 @@ const DemandDetailed = () => {
{
label: '适用地市', extra: (
<div>
{areas.map((item: any, index: number) => (
<p key={`areas${index + 1}`}>{item}</p>
{data.areas.map((it: any, idx: number) => (
<p key={`areas${idx + 1}`}>{`${it.province}/${it.city}`}</p>
))}
</div>
)
......
......@@ -54,6 +54,7 @@ const AddForm = () => {
const explainInfo: any = { ...explain };
const fileInfo: any = { ...file };
basicInfo.id = params.purchaseInquiryId || params.id;
basicInfo.quotedPriceId = params.quotedPriceId
basicInfo.number = params.purchaseInquiryNo;
basicInfo.contacts = params.contacts;
basicInfo.purchaseInquiryNo = params.purchaseInquiryNo;
......@@ -118,6 +119,10 @@ const AddForm = () => {
}
});
} else {
console.log(basic)
if (basic.quotedPriceId) {
params.quotedPriceId = basic.quotedPriceId
}
params.purchaseInquiryId = id;
params.purchaseInquiryNo = number;
params.memberName = name;
......
......@@ -160,7 +160,7 @@ const OfferInfo: React.FC<IProps> = (props: any) => {
title: '金额(含税)',
key: 'taxPrice',
dataIndex: 'taxPrice',
render: (text: any, record: any) => <Text>{Number(record.purchaseCount) * Number(record.taxUnitPrice)}</Text>
render: (text: any, record: any) => <Text>{isNaN(Number(record.purchaseCount) * Number(record.taxUnitPrice)) ? 0 : Number(record.purchaseCount) * Number(record.taxUnitPrice)}</Text>
},
{
title: '操作',
......@@ -259,7 +259,7 @@ const OfferInfo: React.FC<IProps> = (props: any) => {
aCount = 1
}
if (name === 'edit') {
aCount = fetchdata.count ? (fetchdata.count + 1) : 1;
aCount = fetchdata.turn ? (fetchdata.count + 1) : 1;
}
form.setFieldsValue({
count: aCount
......
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