From e419a5dce9a12fc0a73d3538ff5dc3d73ab82f76 Mon Sep 17 00:00:00 2001 From: zhangds Date: Mon, 10 Oct 2022 20:03:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E7=AB=8B=E5=87=8F=E9=87=91=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UseCouponAddEdit/index.jsx | 48 +++++++++-------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/src/components/UseCouponAddEdit/index.jsx b/src/components/UseCouponAddEdit/index.jsx index 075b98ec..329a9176 100644 --- a/src/components/UseCouponAddEdit/index.jsx +++ b/src/components/UseCouponAddEdit/index.jsx @@ -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} /> @@ -1230,7 +1220,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => { alignment={"left"} front="减" unit="元" - disabled={state.isEdit} /> @@ -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} /> @@ -1298,7 +1286,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {