From 850b34545adb67c09677239999ffa04c2fda9b6e Mon Sep 17 00:00:00 2001 From: zhangds Date: Fri, 21 Oct 2022 16:11:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UseGoodsScopePop/index.jsx | 6 ++-- src/components/UseProductPop/index.jsx | 35 +++++++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/components/UseGoodsScopePop/index.jsx b/src/components/UseGoodsScopePop/index.jsx index 9e1dfe83..9398dc55 100644 --- a/src/components/UseGoodsScopePop/index.jsx +++ b/src/components/UseGoodsScopePop/index.jsx @@ -32,16 +32,14 @@ const UseGoodsScopePop = forwardRef((props, ref) => { // 新建商品数据处理 const format_product_model = () => { let new_tableData = tableData; - - let form_model = productEl.current.state.form_data; - form_model.type = 1; + let form_model = productEl.current.getFormModel(); form_model.upstream = "直连天下"; + form_model.type = 1; form_model.all_budget = mulNum( Number(form_model.contract_price), Number(form_model.quantity) ); form_model.effectDate = "-"; - if (product_title === "编辑商品") { if (table_index !== -1) { form_model.checked = false; diff --git a/src/components/UseProductPop/index.jsx b/src/components/UseProductPop/index.jsx index 49383c66..b5b1f538 100644 --- a/src/components/UseProductPop/index.jsx +++ b/src/components/UseProductPop/index.jsx @@ -163,18 +163,31 @@ const UseProductPop = forwardRef((props, ref) => { quantity: model.quantity, show_url: model.show_url[0].src, describe_url: model.describe_url.map((item) => item.src), - detail_url: model.detail_url[0].src, + detail_url: model.detail_url[0] ? model.detail_url[0].src : "", account_type: model.account_type, map_product_name: model.product_name, - type: 1, }; }; - const submit = () => { - // 校验 - let param = getFormModel(); - console.log("param =>", param); - return false; + const submit = async () => { + let visible = false; + // 第一步: 表单校验 + if (formEl.current.validator()) { + // 图片校验 + if (model.show_url.length <= 0) { + Notify.error(`请上传商品Logo`); + return; + } + + if (model.describe_url.length <= 0) { + Notify.error(`请上传商品Logo`); + return; + } + + visible = true; + } + + return visible; }; const onProductChange = (e) => { @@ -183,14 +196,12 @@ const UseProductPop = forwardRef((props, ref) => { // 当前选中的商品数据 let cur_product = state.productDataAll.find((item) => { - return item.id == e.key; + return item.id === e.key; }); - console.log("cur_product =>", cur_product); // 获取商品logo和图片 let picItem = window.goods.find((item) => { - return item.id == cur_product.product_category_id; + return Number(item.id) === Number(cur_product.product_category_id); }); - console.log("picItem =>", picItem); setModel({ product_id: cur_product.id, official_price: cur_product.official_price, @@ -204,7 +215,7 @@ const UseProductPop = forwardRef((props, ref) => { if (picItem) { let goodsArr = []; const productItem = picItem.products.find( - (item) => item.id == cur_product.id + (item) => Number(item.id) === Number(cur_product.id) ); productItem?.pic.map((item, index) => { goodsArr.push({