From 6bcce4a42a03b292d708a13f20689d3f40f509f6 Mon Sep 17 00:00:00 2001 From: zhangds Date: Wed, 3 Aug 2022 14:06:07 +0800 Subject: [PATCH] =?UTF-8?q?1)=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 13 ++++--- src/components/UseExchangeCodePop/index.jsx | 39 ++++++++++++++++++--- src/components/UsePlanCard/index.jsx | 2 +- src/components/UseProductForm/index.jsx | 32 ++++++++++++++--- src/components/UseProductPop/index.jsx | 29 +++++++++++---- src/pages/plan/copy/index.jsx | 12 +++++++ 6 files changed, 104 insertions(+), 23 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index 9dc85966..dba63a9b 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -421,13 +421,12 @@ export const getIsRequireApproval = (id, data) => { // //蓝色兄弟映射商品 export const getProductInfoSelect = (params) => { - return req("get", baseurl + "/product/market/products", params); - - // return req( - // "get", - // "https://marketapi.1688sup.com" + "/product/market/products", - // params - // ); + // return req("get", baseurl + "/product/market/products", params); + return req( + "get", + "https://marketapi.1688sup.com" + "/product/market/products", + params + ); }; // 上传 diff --git a/src/components/UseExchangeCodePop/index.jsx b/src/components/UseExchangeCodePop/index.jsx index 352535fb..e9a4f125 100644 --- a/src/components/UseExchangeCodePop/index.jsx +++ b/src/components/UseExchangeCodePop/index.jsx @@ -152,12 +152,20 @@ function reducer(state, action) { // 新建/编辑兑换弹窗 const UseExchangeCodePop = (props) => { - const { title, closeDraw, time, direct_reseller_id, showProductPop } = props; + const { + title, + closeDraw, + time, + direct_reseller_id, + showProductPop, + exChangeTableData, + } = props; const code_info = useRef(null); const code_rule = useRef(null); const [state, dispatch] = useReducer(reducer, initData); const [newGoodsBtnLoading, setNewGoodsBtnLoading] = useState(false); const [newGoldLoading, setNewGoldLoading] = useState(false); + const [editTableBtn, setEditTableBtn] = useState(false); const rulesForm = { code_name: [{ type: "required", message: "请输入兑换码名称" }], issued: [ @@ -250,7 +258,6 @@ const UseExchangeCodePop = (props) => { setNewGoldLoading(false); } if (res.code === 200) { - sessionStorage.setItem("productsList", JSON.stringify(res.data.data)); if (type === "addProduct") { showProductPop({ type: true, @@ -271,7 +278,29 @@ const UseExchangeCodePop = (props) => { } }); }; - const productEditShow = () => {}; + const productEditShow = (rowData) => { + if (direct_reseller_id > 0) { + setEditTableBtn(true); + let param = { + reseller_id: direct_reseller_id, + }; + getProductInfoSelect(param).then((res) => { + console.log("res =>", res); + setEditTableBtn(false); + if (res.code === 200) { + showProductPop({ + type: true, + title: "编辑商品", + productData: res.data.data, + rowData: rowData, + addIsType: "addProduct", + }); + } + }); + } else { + Notify.error(`请添加映射分销商`); + } + }; return (
{ { headBackgroud="#f9fafc" isShowPageBar={false} spliteColor={"#fff"} - tableData={state.tempdata} + tableData={exChangeTableData} value={state.tempdata} Column={Column2} maxheight={200} diff --git a/src/components/UsePlanCard/index.jsx b/src/components/UsePlanCard/index.jsx index ce68fb50..1d75d463 100644 --- a/src/components/UsePlanCard/index.jsx +++ b/src/components/UsePlanCard/index.jsx @@ -318,7 +318,7 @@ function reducerPlanKey(state, action) { } const UsePlanCardStep02 = forwardRef((props, ref) => { - const { showExchangeCodePop, time } = props; + const { showExchangeCodePop } = props; const exchangeColumn = [ { title: "兑换名称", diff --git a/src/components/UseProductForm/index.jsx b/src/components/UseProductForm/index.jsx index b3652e52..ba7b5ad8 100644 --- a/src/components/UseProductForm/index.jsx +++ b/src/components/UseProductForm/index.jsx @@ -126,11 +126,10 @@ const reducer = (state, action) => { }; const UseProductForm = forwardRef((props, ref) => { - const { productData } = props; + const { productData, exChangeTableData } = props; // 所有的商品数据 const [model, dispatch] = useReducer(reducer, initState); // form 表单数据 const [productOption, setProductOption] = useState([]); const [cur_product, setCur_product] = useState({}); - const [productpic, setProductpic] = useState([]); const [logoImg, setLogoImg] = useState([]); // 商品logo const [describeImg, setDescribe_url] = useState([]); // 商品图片 const [detail_url, setDetail_url] = useState([]); // 商品详情图 @@ -143,6 +142,10 @@ const UseProductForm = forwardRef((props, ref) => { return { key: item.id, text: item.title, + disabled: + exChangeTableData.findIndex((items) => { + return items.product_id === item.id; + }) > -1, }; }) ); @@ -279,16 +282,37 @@ const UseProductForm = forwardRef((props, ref) => { const submit = () => { if (form1.current.validator()) { + // logo 图片校验 + if (logoImg.length <= 0) { + Notify.error(`请上传图片`); + return false; + } + + // 商品图 + if (describeImg.length <= 0) { + Notify.error(`请上传图片`); + return false; + } + + // 图片校验 let param = { ...model, describe_url: describeImg.map((item) => { return item.src; }), show_url: logoImg[0].src, - detail_url: detail_url[0].src, + upstream: "直连天下", }; - console.log("验证通过...", param); + + // 商品详情图 + if (detail_url.length > 0) { + param.detail_url = detail_url[0].src; + } else { + param.detail_url = ""; + } + return param; } + return false; }; useImperativeHandle(ref, () => ({ diff --git a/src/components/UseProductPop/index.jsx b/src/components/UseProductPop/index.jsx index 8207f06f..e25f6bd1 100644 --- a/src/components/UseProductPop/index.jsx +++ b/src/components/UseProductPop/index.jsx @@ -18,22 +18,35 @@ import { import UseProductForm from "@/components/UseProductForm/index"; import KnockGold from "@/components/knockGold"; /* 立减金 */ +import { useEffect } from "react"; const UseProductPop = (props) => { - const { title, closeDraw, productData, addIsType } = props; + const { + title, + closeDraw, + productData, + addIsType, + getTableData, + exChangeTableData, + } = props; const product = useRef(null); const knockGold = useRef(null); const productSubmit = async () => { - let visible = false; if (addIsType === "addProduct") { - visible = await product.current.submit(); - } else { - visible = await knockGold.current.submit(); + let res = await product.current.submit(); + if (res) { + getTableData(res); + closeDraw(); + } } }; const closeDrawPop = () => { closeDraw(); }; + useEffect(() => { + console.log("productData =>", productData); + console.log("exChangeTableData =>", exChangeTableData); + }, []); return (
{ ref={knockGold} /> ) : ( - + )}
diff --git a/src/pages/plan/copy/index.jsx b/src/pages/plan/copy/index.jsx index 8a2acd6e..b2bced9e 100644 --- a/src/pages/plan/copy/index.jsx +++ b/src/pages/plan/copy/index.jsx @@ -66,6 +66,7 @@ const UseOneCopy = () => { const [direct_reseller_id, setDirect_reseller_id] = useState(23377); const [whiteStyle, setWhiteStyle] = useState(false); const [newPlanTime, setNewPlanTime] = useState([]); + const [exChangeTableData, setExChangeTableData] = useState([]); const [statePop, setStatePop] = useState({ type: true, @@ -137,6 +138,14 @@ const UseOneCopy = () => { setStatePop({ type: false }); }; + // 改变商品table + const changeProductTable = (e) => { + let new_data = exChangeTableData.slice(0); + new_data.push(e); + console.log("new_data =>", new_data); + setExChangeTableData(new_data); + }; + return (
@@ -243,6 +252,7 @@ const UseOneCopy = () => { direct_reseller_id={direct_reseller_id} showProductPop={(e) => setProductPop(e)} closeDraw={() => closeDraw()} + exChangeTableData={exChangeTableData} > ) : null} @@ -250,8 +260,10 @@ const UseOneCopy = () => { setProductPop({ type: false })} + getTableData={(e) => changeProductTable(e)} > ) : null}