From 5c6328a49c179b2e3df94fa778a996d92e0cb2cb Mon Sep 17 00:00:00 2001 From: zhangds Date: Mon, 5 Sep 2022 18:33:24 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=89=20=E5=A2=9E=E5=8A=A0=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UseGoodsScopePop/index copy.jsx | 96 +++++++++++++++++++ src/components/UseGoodsScopePop/index.jsx | 13 +-- 2 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 src/components/UseGoodsScopePop/index copy.jsx diff --git a/src/components/UseGoodsScopePop/index copy.jsx b/src/components/UseGoodsScopePop/index copy.jsx new file mode 100644 index 00000000..8183eb36 --- /dev/null +++ b/src/components/UseGoodsScopePop/index copy.jsx @@ -0,0 +1,96 @@ +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 _ from "lodash"; + +const UseGoodsScopePop = forwardRef((props, ref) => { + const { product_title, drawerVisible, onClose, type, productData, submit } = + props; + + // 如果需要 通过ref 控制此组件 放开注释 + // useImperativeHandle(ref, () => ({ + // submit: submitPop, + // })); + + const product_el = useRef(null); + const knockGold_el = useRef(null); + + // 提交数据 + const submitPop = async () => { + let scope_table_data = []; + let temp = null; + let concatData = []; + + // 第一步:判断是立减金还是新建商品 + let visible = false; + if (type === "addProduct") { + visible = await product_el.current.submit(); + } else { + visible = await knockGold_el.current.submit(); + } + + try { + if (visible) { + scope_table_data = sessionStorage.getItem("productData"); + if (scope_table_data) { + scope_table_data = JSON.parse(scope_table_data); + } + // 第二步: 数据格式化 + if (type === "addProduct") { + } + console.log("提交数据 =>", scope_table_data); + + // submit(JSON.parse(scope_table_data)); + onClose(); + } + } catch (err) { + console.log("err =>", err); + } + }; + + return ( + + + + + } + visible={drawerVisible} + onClose={(e) => onClose()} + maskClosable={false} + > +
+ + {type === "addKnockGold" ? ( + + ) : ( + + )} + +
+
+ ); +}); + +export default UseGoodsScopePop; diff --git a/src/components/UseGoodsScopePop/index.jsx b/src/components/UseGoodsScopePop/index.jsx index 8183eb36..3575fa00 100644 --- a/src/components/UseGoodsScopePop/index.jsx +++ b/src/components/UseGoodsScopePop/index.jsx @@ -1,6 +1,8 @@ import React, { forwardRef, useImperativeHandle, useRef } from "react"; import { Card, Drawer, Button } from "zent"; +import { deWeightThree } from "@/utils"; + import Productform from "@/pages/plan/product/add"; /* 商品 */ import KnockGold from "@/components/knockGold"; /* 立减金 */ @@ -21,9 +23,6 @@ const UseGoodsScopePop = forwardRef((props, ref) => { // 提交数据 const submitPop = async () => { let scope_table_data = []; - let temp = null; - let concatData = []; - // 第一步:判断是立减金还是新建商品 let visible = false; if (type === "addProduct") { @@ -34,16 +33,12 @@ const UseGoodsScopePop = forwardRef((props, ref) => { try { if (visible) { + // 第二步:数据格式化 scope_table_data = sessionStorage.getItem("productData"); if (scope_table_data) { scope_table_data = JSON.parse(scope_table_data); } - // 第二步: 数据格式化 - if (type === "addProduct") { - } - console.log("提交数据 =>", scope_table_data); - - // submit(JSON.parse(scope_table_data)); + console.log("所有数据:", scope_table_data); onClose(); } } catch (err) {