Commit 010ac2c3 authored by marsandheart's avatar marsandheart

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

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