Commit 010ac2c3 authored by marsandheart's avatar marsandheart

fix bug 产品重复添加现在给与提示

parent a6a0885f
......@@ -101,15 +101,22 @@ const InsuredInfo = (props) => {
showLoading();
await sleep(500);
hideLoading();
const newTableData = tableData.filter((ele) => ele.key !== key);
setTableData(newTableData);
};
const addTableData = async (product) => {
const key = `add-${product.id}`;
if (tableData.some((t) => t.key === key)) {
alert('该产品已添加过,请勿重复添加');
return;
}
showLoading();
await sleep(500);
hideLoading();
const key = String(tableData.length + 1);
setSelectedDataKey(key);
setTableData([
...tableData,
......@@ -189,7 +196,7 @@ const InsuredInfo = (props) => {
<span>付款账号:622********3042</span>
</div>
<div className={styles.premLine}>
<span>原保费:680元</span>
<span>原保费:860元</span>
<span>
下一期保费:<span className={styles.actText}>{tableData.length * 180 + 500}</span>
</span>
......
......@@ -90,9 +90,9 @@ export default function(props) {
} else {
showLoading();
setTimeout(() => {
setProductId(id);
hideLoading();
}, Math.random() * 1000);
setProductId(id);
}, Math.random() * 500);
}
};
......@@ -104,6 +104,7 @@ export default function(props) {
const selectedProduct = productList.find((p) => p.id === productId);
if (selectedProduct) {
addTableData(selectedProduct);
setProductId('');
}
close();
};
......
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