fix: 修复复制优惠券立减金不能修改数据

This commit is contained in:
zhangds 2022-10-10 20:03:24 +08:00
parent cc51d072b1
commit e419a5dce9
1 changed files with 18 additions and 30 deletions

View File

@ -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="选择一项"