fix: 修复复制优惠券立减金不能修改数据
This commit is contained in:
parent
cc51d072b1
commit
e419a5dce9
|
@ -185,7 +185,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
tableHeight: 500,
|
||||
page: 1,
|
||||
dataCount: 0,
|
||||
rankoptions: [],
|
||||
rankOptions: [],
|
||||
rank: [],
|
||||
newGoodsBtnLoading: false,
|
||||
newGoldLoading: false,
|
||||
|
@ -207,7 +207,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
payment_direction: ["对私账户", "对公账户", "预付款扣除"],
|
||||
isState: sessionStorage.getItem("isState"), // 是否编辑和复制
|
||||
coupon_batch_id: "",
|
||||
isEdit: false,
|
||||
oldProduct: {}, // 旧数据,为编辑做准备
|
||||
id: "",
|
||||
status: -1,
|
||||
|
@ -232,21 +231,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
const form_rule_el = useRef(null);
|
||||
|
||||
const isEditFun = () => {
|
||||
// 是否是编辑
|
||||
if (state.isState === "2") {
|
||||
setState({
|
||||
isEdit: true,
|
||||
});
|
||||
}
|
||||
|
||||
// 是否审核失败
|
||||
if (editData.approval_status === 2) {
|
||||
setState({
|
||||
isEdit: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
// 编辑/新增/复制
|
||||
useEffect(() => {
|
||||
(async function init() {
|
||||
|
@ -260,7 +244,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
await getPlanList().then((arr) => {
|
||||
// 1.2 优惠券管理判断是新增还是编辑
|
||||
if (editData && editData !== "") {
|
||||
isEditFun();
|
||||
// 1.3 设置归属计划数据
|
||||
let plan_row = arr.find(
|
||||
(item) => item.text === editData.plan_title
|
||||
|
@ -308,7 +291,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
} else {
|
||||
if (editData && editData !== "") {
|
||||
console.log("editData =>", editData);
|
||||
setState({
|
||||
id: editData.id,
|
||||
status: editData.status,
|
||||
|
@ -357,6 +339,10 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
// 商品范围
|
||||
// 商品的数组
|
||||
let goods_arr = editData.product.legal.map((item) => {
|
||||
// 如果是复制 删除id !!!!!!!!
|
||||
if (state.isState === "1") {
|
||||
delete item.id;
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
type: 1,
|
||||
|
@ -368,11 +354,16 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
|
||||
// 立减金
|
||||
let lj_arr = editData.product.reduce.map((item) => {
|
||||
// 如果是复制 删除id !!!!!!!!
|
||||
if (state.isState === "1") {
|
||||
delete item.id;
|
||||
}
|
||||
|
||||
let table_obj = {};
|
||||
table_obj.type = 2; // 类型
|
||||
table_obj.upstream = String(item.channel) === "1" ? "支付宝" : "微信"; // 上游平台
|
||||
|
||||
table_obj.only = item; // 存储就数据 编辑好用
|
||||
table_obj.only = item; // 存储老数据 编辑好用
|
||||
table_obj.product_id = item.channel_activity_id; // 商品编号
|
||||
table_obj.product_name = item.batch_goods_name; // 商品名
|
||||
table_obj.official_price = item.reduce_amount; // 官方价
|
||||
|
@ -384,7 +375,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
table_obj.create_time = item.create_time; // 创建时间
|
||||
return table_obj;
|
||||
});
|
||||
|
||||
let scope_data = goods_arr.concat(lj_arr);
|
||||
scope_data = _.map(scope_data, (o) => {
|
||||
o.checked = true;
|
||||
|
@ -399,7 +389,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
|
||||
setState({
|
||||
rankoptions: arr,
|
||||
rankOptions: arr,
|
||||
rank: arr,
|
||||
tableData: scope_data,
|
||||
});
|
||||
|
@ -576,7 +566,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
});
|
||||
setState({
|
||||
rank: [],
|
||||
rankoptions: [],
|
||||
rankOptions: [],
|
||||
tableData: [],
|
||||
});
|
||||
};
|
||||
|
@ -906,6 +896,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
table_index: index,
|
||||
});
|
||||
} else {
|
||||
// 如果是复制删除id
|
||||
setState({
|
||||
product_title: "编辑商品",
|
||||
productData: rowData,
|
||||
|
@ -1021,7 +1012,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
// 格式化商品范围
|
||||
setState({
|
||||
tableData: new_table,
|
||||
rankoptions: select_opt,
|
||||
rankOptions: select_opt,
|
||||
rank: select_arr,
|
||||
});
|
||||
} catch (err) {
|
||||
|
@ -1043,7 +1034,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
selectionFun(new_table);
|
||||
setState({
|
||||
tableData: new_table,
|
||||
rankoptions: select_opt,
|
||||
rankOptions: select_opt,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1202,7 +1193,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
width={"130px"}
|
||||
alignment={"left"}
|
||||
front="满"
|
||||
disabled={state.isEdit}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
|
@ -1230,7 +1220,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
alignment={"left"}
|
||||
front="减"
|
||||
unit="元"
|
||||
disabled={state.isEdit}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
|
@ -1244,7 +1233,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
onClearItem={() => {
|
||||
setForm_rule_data({ quantity: "" });
|
||||
}}
|
||||
disabled={state.isQuantity || state.isEdit}
|
||||
disabled={state.isQuantity}
|
||||
value={form_rule_data.quantity}
|
||||
placeholder={"请输入"}
|
||||
labelWidth={"0px"}
|
||||
|
@ -1288,7 +1277,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
countShow={false}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
disabled={state.isEdit}
|
||||
/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
|
@ -1298,7 +1286,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
|||
<FormItem labelname="商品范围" prop="rank" id="rank">
|
||||
<div className="goods-boxs">
|
||||
<Select
|
||||
options={state.rankoptions}
|
||||
options={state.rankOptions}
|
||||
multiple
|
||||
value={state.rank}
|
||||
placeholder="选择一项"
|
||||
|
|
Loading…
Reference in New Issue