1) 优惠券弹窗
This commit is contained in:
parent
e1d0f8292b
commit
ae7b20d473
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue