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) => {
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
);
};
// 上传

View File

@ -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 (
<div>
<Drawer
@ -447,7 +476,7 @@ const UseExchangeCodePop = (props) => {
</FormItem>
<FormItem labelname="" prop="range" id="range">
<BlockLoading
loading={state.tableLoading}
loading={editTableBtn}
iconSize={16}
textSize={12}
icon="circle"
@ -457,7 +486,7 @@ const UseExchangeCodePop = (props) => {
headBackgroud="#f9fafc"
isShowPageBar={false}
spliteColor={"#fff"}
tableData={state.tempdata}
tableData={exChangeTableData}
value={state.tempdata}
Column={Column2}
maxheight={200}

View File

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

View File

@ -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, () => ({

View File

@ -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 (
<div>
<Drawer
@ -69,7 +82,11 @@ const UseProductPop = (props) => {
ref={knockGold}
/>
) : (
<UseProductForm productData={productData} ref={product} />
<UseProductForm
productData={productData}
exChangeTableData={exChangeTableData}
ref={product}
/>
)}
</Card>
</div>

View File

@ -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 (
<div className="plan-add">
<div className="plan-left">
@ -243,6 +252,7 @@ const UseOneCopy = () => {
direct_reseller_id={direct_reseller_id}
showProductPop={(e) => setProductPop(e)}
closeDraw={() => closeDraw()}
exChangeTableData={exChangeTableData}
></UseExchangeCodePop>
) : null}
@ -250,8 +260,10 @@ const UseOneCopy = () => {
<UseProductPop
title={productPop.title}
productData={productPop.productData}
exChangeTableData={exChangeTableData}
addIsType={productPop.addIsType}
closeDraw={() => setProductPop({ type: false })}
getTableData={(e) => changeProductTable(e)}
></UseProductPop>
) : null}
</div>