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