This commit is contained in:
zhangds 2022-09-07 12:22:15 +08:00
commit a79f5628df
3 changed files with 1003 additions and 949 deletions

View File

@ -88,8 +88,8 @@ const tableColumn = [
},
{
title: "类型",
name: "type",
prop: "type",
name: "goods_type",
prop: "goods_type",
type: "slot",
width: "auto",
},
@ -136,7 +136,7 @@ const rule_rules = {
};
const UseCouponAddEdit = forwardRef((props, ref) => {
const { type = 0 } = props; // type 0 1key ()
const { type = 0, isAuditButton = true } = props; // type 0 1key ()
useEffect(() => {
if (type === 0) {
@ -187,7 +187,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
showScopePop: false,
scopePopType: "",
productData: [],
selectGoodsScopeData: [],
});
//
@ -234,9 +233,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
let el_setup2 = form_rule_el.current.validator();
// console.log("el_setup2 =>", el_setup2);
// console.log(" =>", form_rule_data);
//
console.log("用户商品范围 =>", state.selectGoodsScopeData);
};
const onReturn = () => {};
@ -263,47 +259,63 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
};
const onPageChange = () => {};
const onCountChange = () => {};
const selectionFun = (e) => {
console.log("e =>", e);
let arr = [];
_.map(e, (item) => {
let obj = {};
obj.key = item.product_id;
obj.text = item.product_name;
arr.push(obj);
return obj;
});
setState({ selectGoodsScopeData: arr });
};
const onRankChange = () => {};
const addProduct = (type) => {
// id
const direct_reseller_ids = 23329;
if (direct_reseller_ids <= 0) {
Notify.error(`请添加映射分销商`);
return;
//
const clearStorageData = () => {
if (state.tableData.length <= 0) {
sessionStorage.setItem("productData", "");
sessionStorage.setItem("knockGoldData", "");
}
// :
if (type === "addProduct") {
setState({
product_title: "新建商品",
addProductBtnLoading: true,
scopePopType: "addProduct",
});
//
let product_data = state.tableData.filter((item) => item.goods_type === 1);
if (product_data.length <= 0) {
sessionStorage.setItem("productData", "");
} else {
setState({
product_title: "新增立减金",
addGoldBtnLoading: true,
scopePopType: "addKnockGold",
});
sessionStorage.setItem("productData", JSON.stringify(product_data));
}
//
let param = {
reseller_id: direct_reseller_ids,
};
//
let knockGold_data = state.tableData.filter(
(item) => item.goods_type === 2
);
if (knockGold_data.length <= 0) {
sessionStorage.setItem("knockGoldData", "");
} else {
sessionStorage.setItem("knockGoldData", JSON.stringify(knockGold_data));
}
};
const addProduct = (type) => {
try {
// id
const direct_reseller_ids = 23329;
if (direct_reseller_ids <= 0) {
Notify.error(`请添加映射分销商`);
return;
}
//
clearStorageData();
// :
if (type === "addProduct") {
setState({
product_title: "新建商品",
addProductBtnLoading: true,
scopePopType: "addProduct",
});
} else {
setState({
product_title: "新增立减金",
addGoldBtnLoading: true,
scopePopType: "addKnockGold",
});
}
//
let param = {
reseller_id: direct_reseller_ids,
};
getProductInfoSelect(param).then((res) => {
setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
handelResponse(
@ -320,11 +332,11 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}
);
});
// !!!!!!!!!!!!!! 使 productsList
setState({ productData: null });
} catch (err) {
setState({ addProductBtnLoading: false, addGoldBtnLoading: false });
}
// !!!!!!!!!!!!!! 使 productsList
setState({ productData: null });
};
const renderOptionList = (options, renderOption) => {
return (
@ -374,25 +386,77 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
});
};
const selectionFun = (e) => {
let arr = [];
_.map(e, (res) => {
let obj = {};
obj.key = res;
obj.text = res.product_name;
arr.push(obj);
return obj;
});
setState({ rank: arr });
};
const onRankChange = (e) => {
let new_table_data = state.tableData.map((item) => {
item.checked =
e.findIndex((checks) => {
return checks.key === item;
}) > -1;
return item;
});
setState({ tableData: new_table_data, rank: e });
};
//
const scopePopSubmit = (data) => {
try {
//
let data_new = data;
data_new.key_batch_id = form_info_data.key_batch_id.key;
data_new.effectDate = `${form_info_data.date_time[0]}${form_info_data.date_time[1]}`;
let new_table = state.tableData;
new_table.push(data_new);
//
let select_opt = [];
new_table.map((item) => {
let obj = {};
obj.key = item; //
obj.text = item.product_name;
select_opt.push(obj);
});
//
setState({
tableData: new_table,
rankoptions: [],
rankoptions: select_opt,
});
} catch (err) {
console.log("err =>", err);
}
};
//
const deleteGoodsScope = (index) => {
let new_table = state.tableData;
if (index === 0) {
new_table = [];
} else {
new_table = new_table.splice(index, 1);
}
let select_opt = [];
new_table.map((item) => {
let obj = {};
obj.key = item; //
obj.text = item.product_name;
select_opt.push(obj);
});
selectionFun(new_table);
setState({
tableData: new_table,
rankoptions: select_opt,
});
};
return (
<div className="coupon-box">
<Card style={{ margin: "10px auto" }} title={state.setup1_title}>
@ -603,33 +667,41 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}
countChange={(e) => onCountChange(e)}
checkChange={(data) => selectionFun(data)}
ComponentHandler={(com, rowData) => {
ComponentHandler={(com, rowData, rowIndex) => {
if (com === "opearo") {
return (
<div>
<span className="grid-link">编辑</span>
<span style={{ color: "red" }} className="grid-link">
<span
style={{ color: "red" }}
className="grid-link"
onClick={() => deleteGoodsScope(rowIndex)}
>
删除
</span>
</div>
);
}
if (com === "type") {
return <span>{rowData.type === 1 ? "商品" : "立减金"}</span>;
if (com === "goods_type") {
return (
<span>{rowData.goods_type === 1 ? "商品" : "立减金"}</span>
);
}
}}
/>
</Card>
<div className="step-btn-group">
<Button type="primary" onClick={() => submit()}>
提交审核
</Button>
<Button type="normal" onClick={() => onReturn()}>
取消
</Button>
</div>
{isAuditButton ? (
<div className="step-btn-group">
<Button type="primary" onClick={() => submit()}>
提交审核
</Button>
<Button type="normal" onClick={() => onReturn()}>
取消
</Button>
</div>
) : null}
<UseGoodsScopePop
product_title={state.product_title}

View File

@ -136,7 +136,7 @@ const rule_rules = {
};
const UseCouponAddEdit = forwardRef((props, ref) => {
const { type = 0 } = props; // type 0 1key ()
const { type = 0, isAuditButton = true } = props; // type 0 1key ()
useEffect(() => {
if (type === 0) {
@ -387,7 +387,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
};
const selectionFun = (e) => {
console.log("e =>", e);
let arr = [];
_.map(e, (res) => {
let obj = {};
@ -417,8 +416,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
let data_new = data;
let new_table = state.tableData;
new_table.push(data_new);
console.log("table_data =>", new_table);
//
let select_opt = [];
new_table.map((item) => {
@ -440,7 +437,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
//
const deleteGoodsScope = (index) => {
console.log(index);
let new_table = state.tableData;
if (index === 0) {
new_table = [];
@ -696,14 +692,16 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
/>
</Card>
<div className="step-btn-group">
<Button type="primary" onClick={() => submit()}>
提交审核
</Button>
<Button type="normal" onClick={() => onReturn()}>
取消
</Button>
</div>
{isAuditButton ? (
<div className="step-btn-group">
<Button type="primary" onClick={() => submit()}>
提交审核
</Button>
<Button type="normal" onClick={() => onReturn()}>
取消
</Button>
</div>
) : null}
<UseGoodsScopePop
product_title={state.product_title}

File diff suppressed because it is too large Load Diff