1) 优惠券弹窗

This commit is contained in:
zhangds 2022-09-20 14:29:02 +08:00
parent e1d0f8292b
commit ae7b20d473
1 changed files with 62 additions and 71 deletions

View File

@ -1,9 +1,9 @@
import React, { forwardRef, useImperativeHandle, useRef } from "react"
import { Card, Drawer, Button } from "zent"
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { Card, Drawer, Button } from "zent";
import Productform from "@/pages/plan/product/add" /* 商品 */
import KnockGold from "@/components/knockGold" /* 立减金 */
import { divNum } from "@/tools/number"
import Productform from "@/pages/plan/product/add"; /* 商品 */
import KnockGold from "@/components/knockGold"; /* 立减金 */
import { divNum } from "@/tools/number";
const UseGoodsScopePop = forwardRef((props, ref) => {
const {
@ -14,124 +14,113 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
productData,
submit,
tableData,
table_index
} = props
table_index,
} = props;
// ref
// useImperativeHandle(ref, () => ({
// submit: submitPop,
// }));
const product_el = useRef(null)
const knockGold_el = useRef(null)
const product_el = useRef(null);
const knockGold_el = useRef(null);
//
const format_product_model = () => {
let new_tableData = tableData
let new_tableData = tableData;
let form_model = product_el.current.state.form_data
form_model.type = 1
form_model.upstream = "直连天下"
let form_model = product_el.current.state.form_data;
form_model.type = 1;
form_model.upstream = "直连天下";
form_model.all_budget =
Number(form_model.contract_price) * Number(form_model.quantity)
form_model.effectDate = "-"
Number(form_model.contract_price) * Number(form_model.quantity);
form_model.effectDate = "-";
if (product_title === "编辑商品") {
if (table_index !== -1) {
<<<<<<< HEAD
form_model.checked = false;
new_tableData[table_index] = form_model;
=======
form_model.checked = false
new_tableData[table_index] = form_model
console.log("new_tableData =>", new_tableData)
>>>>>>> a888b0572236c8400347da365ad0e0619445cca7
}
} else {
new_tableData.push(form_model)
new_tableData.push(form_model);
}
return new_tableData
}
return new_tableData;
};
//
const format_knockGold_model = () => {
let new_tableData = tableData
let table_obj = {}
let form_model = knockGold_el.current.state.form_data
table_obj.type = 2 //
table_obj.upstream = String(form_model.channel) === "1" ? "支付宝" : "微信" //
let new_tableData = tableData;
let table_obj = {};
let form_model = knockGold_el.current.state.form_data;
table_obj.type = 2; //
table_obj.upstream = String(form_model.channel) === "1" ? "支付宝" : "微信"; //
table_obj.only = form_model //
table_obj.product_id = form_model.channel_activity_id //
table_obj.product_name = form_model.batch_goods_name //
table_obj.official_price = form_model.reduce_amount //
table_obj.contract_price = form_model.price //
table_obj.only = form_model; //
table_obj.product_id = form_model.channel_activity_id; //
table_obj.product_name = form_model.batch_goods_name; //
table_obj.official_price = form_model.reduce_amount; //
table_obj.contract_price = form_model.price; //
table_obj.quantity = parseInt(
divNum(form_model.all_budget, form_model.reduce_amount)
) //
table_obj.channel_activity_id = form_model.channel_activity_id //
table_obj.all_budget = Number(form_model.all_budget) //
table_obj.effectDate = `${form_model.time_limit.effect_time.end_time}${form_model.time_limit.effect_time.start_time}` //
table_obj.createDate = "" //
); //
table_obj.channel_activity_id = form_model.channel_activity_id; //
table_obj.all_budget = Number(form_model.all_budget); //
table_obj.effectDate = `${form_model.time_limit.effect_time.end_time}${form_model.time_limit.effect_time.start_time}`; //
table_obj.createDate = ""; //
if (product_title === "编辑立减金") {
if (table_index !== -1) {
table_obj.checked = false
new_tableData[table_index] = table_obj
new_tableData[table_index].only = form_model
table_obj.checked = false;
new_tableData[table_index] = table_obj;
new_tableData[table_index].only = form_model;
}
} else {
new_tableData.push(table_obj)
new_tableData.push(table_obj);
}
return new_tableData
}
return new_tableData;
};
//
const submitPop = async () => {
try {
//
let visible = false
let visible = false;
if (type === "addProduct") {
visible = await product_el.current.submit()
visible = await product_el.current.submit();
} else {
visible = await knockGold_el.current.submit()
visible = await knockGold_el.current.submit();
}
if (visible) {
// table
let form_data = {}
let form_data = {};
if (type === "addProduct") {
form_data = format_product_model()
form_data = format_product_model();
} else {
form_data = format_knockGold_model()
form_data = format_knockGold_model();
}
<<<<<<< HEAD
submit(form_data);
onClose();
=======
console.log("form_data 1=>", form_data)
submit(form_data)
onClose()
>>>>>>> a888b0572236c8400347da365ad0e0619445cca7
}
} catch (err) {
console.log("err =>", err)
console.log("err =>", err);
}
}
};
return (
<Drawer
className='draw'
className="draw"
width={"86%"}
title={product_title}
footer={
<div style={{ textAlign: "center" }}>
<Button
type='primary'
type="primary"
onClick={(e) => {
submitPop()
}}>
submitPop();
}}
>
提交
</Button>
<Button onClick={(e) => onClose()}>取消</Button>
@ -139,14 +128,16 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
}
visible={drawerVisible}
onClose={(e) => onClose()}
maskClosable={false}>
<div className='draw2'>
maskClosable={false}
>
<div className="draw2">
<Card
className='borderNone'
style={{ width: "95%", margin: "10px auto" }}>
className="borderNone"
style={{ width: "95%", margin: "10px auto" }}
>
{type === "addKnockGold" ? (
<KnockGold
className='addKnockGold'
className="addKnockGold"
data={productData}
ref={knockGold_el}
/>
@ -156,7 +147,7 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
</Card>
</div>
</Drawer>
)
})
);
});
export default UseGoodsScopePop
export default UseGoodsScopePop;