1) 更新

This commit is contained in:
zhangds 2022-08-03 14:06:07 +08:00
parent ac026ca21e
commit 6bcce4a42a
6 changed files with 104 additions and 23 deletions

View File

@ -421,13 +421,12 @@ export const getIsRequireApproval = (id, data) => {
// //蓝色兄弟映射商品 // //蓝色兄弟映射商品
export const getProductInfoSelect = (params) => { export const getProductInfoSelect = (params) => {
return req("get", baseurl + "/product/market/products", params); // return req("get", baseurl + "/product/market/products", params);
return req(
// return req( "get",
// "get", "https://marketapi.1688sup.com" + "/product/market/products",
// "https://marketapi.1688sup.com" + "/product/market/products", params
// params );
// );
}; };
// 上传 // 上传

View File

@ -152,12 +152,20 @@ function reducer(state, action) {
// / // /
const UseExchangeCodePop = (props) => { 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_info = useRef(null);
const code_rule = useRef(null); const code_rule = useRef(null);
const [state, dispatch] = useReducer(reducer, initData); const [state, dispatch] = useReducer(reducer, initData);
const [newGoodsBtnLoading, setNewGoodsBtnLoading] = useState(false); const [newGoodsBtnLoading, setNewGoodsBtnLoading] = useState(false);
const [newGoldLoading, setNewGoldLoading] = useState(false); const [newGoldLoading, setNewGoldLoading] = useState(false);
const [editTableBtn, setEditTableBtn] = useState(false);
const rulesForm = { const rulesForm = {
code_name: [{ type: "required", message: "请输入兑换码名称" }], code_name: [{ type: "required", message: "请输入兑换码名称" }],
issued: [ issued: [
@ -250,7 +258,6 @@ const UseExchangeCodePop = (props) => {
setNewGoldLoading(false); setNewGoldLoading(false);
} }
if (res.code === 200) { if (res.code === 200) {
sessionStorage.setItem("productsList", JSON.stringify(res.data.data));
if (type === "addProduct") { if (type === "addProduct") {
showProductPop({ showProductPop({
type: true, 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 ( return (
<div> <div>
<Drawer <Drawer
@ -447,7 +476,7 @@ const UseExchangeCodePop = (props) => {
</FormItem> </FormItem>
<FormItem labelname="" prop="range" id="range"> <FormItem labelname="" prop="range" id="range">
<BlockLoading <BlockLoading
loading={state.tableLoading} loading={editTableBtn}
iconSize={16} iconSize={16}
textSize={12} textSize={12}
icon="circle" icon="circle"
@ -457,7 +486,7 @@ const UseExchangeCodePop = (props) => {
headBackgroud="#f9fafc" headBackgroud="#f9fafc"
isShowPageBar={false} isShowPageBar={false}
spliteColor={"#fff"} spliteColor={"#fff"}
tableData={state.tempdata} tableData={exChangeTableData}
value={state.tempdata} value={state.tempdata}
Column={Column2} Column={Column2}
maxheight={200} maxheight={200}

View File

@ -318,7 +318,7 @@ function reducerPlanKey(state, action) {
} }
const UsePlanCardStep02 = forwardRef((props, ref) => { const UsePlanCardStep02 = forwardRef((props, ref) => {
const { showExchangeCodePop, time } = props; const { showExchangeCodePop } = props;
const exchangeColumn = [ const exchangeColumn = [
{ {
title: "兑换名称", title: "兑换名称",

View File

@ -126,11 +126,10 @@ const reducer = (state, action) => {
}; };
const UseProductForm = forwardRef((props, ref) => { const UseProductForm = forwardRef((props, ref) => {
const { productData } = props; const { productData, exChangeTableData } = props; //
const [model, dispatch] = useReducer(reducer, initState); // form const [model, dispatch] = useReducer(reducer, initState); // form
const [productOption, setProductOption] = useState([]); const [productOption, setProductOption] = useState([]);
const [cur_product, setCur_product] = useState({}); const [cur_product, setCur_product] = useState({});
const [productpic, setProductpic] = useState([]);
const [logoImg, setLogoImg] = useState([]); // logo const [logoImg, setLogoImg] = useState([]); // logo
const [describeImg, setDescribe_url] = useState([]); // const [describeImg, setDescribe_url] = useState([]); //
const [detail_url, setDetail_url] = useState([]); // const [detail_url, setDetail_url] = useState([]); //
@ -143,6 +142,10 @@ const UseProductForm = forwardRef((props, ref) => {
return { return {
key: item.id, key: item.id,
text: item.title, 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 = () => { const submit = () => {
if (form1.current.validator()) { if (form1.current.validator()) {
// logo
if (logoImg.length <= 0) {
Notify.error(`请上传图片`);
return false;
}
//
if (describeImg.length <= 0) {
Notify.error(`请上传图片`);
return false;
}
//
let param = { let param = {
...model, ...model,
describe_url: describeImg.map((item) => { describe_url: describeImg.map((item) => {
return item.src; return item.src;
}), }),
show_url: logoImg[0].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, () => ({ useImperativeHandle(ref, () => ({

View File

@ -18,22 +18,35 @@ import {
import UseProductForm from "@/components/UseProductForm/index"; import UseProductForm from "@/components/UseProductForm/index";
import KnockGold from "@/components/knockGold"; /* 立减金 */ import KnockGold from "@/components/knockGold"; /* 立减金 */
import { useEffect } from "react";
const UseProductPop = (props) => { const UseProductPop = (props) => {
const { title, closeDraw, productData, addIsType } = props; const {
title,
closeDraw,
productData,
addIsType,
getTableData,
exChangeTableData,
} = props;
const product = useRef(null); const product = useRef(null);
const knockGold = useRef(null); const knockGold = useRef(null);
const productSubmit = async () => { const productSubmit = async () => {
let visible = false;
if (addIsType === "addProduct") { if (addIsType === "addProduct") {
visible = await product.current.submit(); let res = await product.current.submit();
} else { if (res) {
visible = await knockGold.current.submit(); getTableData(res);
closeDraw();
}
} }
}; };
const closeDrawPop = () => { const closeDrawPop = () => {
closeDraw(); closeDraw();
}; };
useEffect(() => {
console.log("productData =>", productData);
console.log("exChangeTableData =>", exChangeTableData);
}, []);
return ( return (
<div> <div>
<Drawer <Drawer
@ -69,7 +82,11 @@ const UseProductPop = (props) => {
ref={knockGold} ref={knockGold}
/> />
) : ( ) : (
<UseProductForm productData={productData} ref={product} /> <UseProductForm
productData={productData}
exChangeTableData={exChangeTableData}
ref={product}
/>
)} )}
</Card> </Card>
</div> </div>

View File

@ -66,6 +66,7 @@ const UseOneCopy = () => {
const [direct_reseller_id, setDirect_reseller_id] = useState(23377); const [direct_reseller_id, setDirect_reseller_id] = useState(23377);
const [whiteStyle, setWhiteStyle] = useState(false); const [whiteStyle, setWhiteStyle] = useState(false);
const [newPlanTime, setNewPlanTime] = useState([]); const [newPlanTime, setNewPlanTime] = useState([]);
const [exChangeTableData, setExChangeTableData] = useState([]);
const [statePop, setStatePop] = useState({ const [statePop, setStatePop] = useState({
type: true, type: true,
@ -137,6 +138,14 @@ const UseOneCopy = () => {
setStatePop({ type: false }); 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 ( return (
<div className="plan-add"> <div className="plan-add">
<div className="plan-left"> <div className="plan-left">
@ -243,6 +252,7 @@ const UseOneCopy = () => {
direct_reseller_id={direct_reseller_id} direct_reseller_id={direct_reseller_id}
showProductPop={(e) => setProductPop(e)} showProductPop={(e) => setProductPop(e)}
closeDraw={() => closeDraw()} closeDraw={() => closeDraw()}
exChangeTableData={exChangeTableData}
></UseExchangeCodePop> ></UseExchangeCodePop>
) : null} ) : null}
@ -250,8 +260,10 @@ const UseOneCopy = () => {
<UseProductPop <UseProductPop
title={productPop.title} title={productPop.title}
productData={productPop.productData} productData={productPop.productData}
exChangeTableData={exChangeTableData}
addIsType={productPop.addIsType} addIsType={productPop.addIsType}
closeDraw={() => setProductPop({ type: false })} closeDraw={() => setProductPop({ type: false })}
getTableData={(e) => changeProductTable(e)}
></UseProductPop> ></UseProductPop>
) : null} ) : null}
</div> </div>