fix: 修复编辑不能编辑
This commit is contained in:
parent
1abd810f1a
commit
ad7b1e5201
|
@ -209,7 +209,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
examinePopShow: false,
|
examinePopShow: false,
|
||||||
payType: 3,
|
payType: 3,
|
||||||
payment_direction: ["对私账户", "对公账户", "预付款扣除"],
|
payment_direction: ["对私账户", "对公账户", "预付款扣除"],
|
||||||
isState: sessionStorage.getItem("isState"), // 是否编辑和复制
|
|
||||||
coupon_batch_id: "",
|
coupon_batch_id: "",
|
||||||
oldProduct: {}, // 旧数据,为编辑做准备
|
oldProduct: {}, // 旧数据,为编辑做准备
|
||||||
id: "",
|
id: "",
|
||||||
|
@ -217,6 +216,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
statusDisabled: false, // 3未开始、1进行中、2暂停中,有数据的审核驳回
|
statusDisabled: false, // 3未开始、1进行中、2暂停中,有数据的审核驳回
|
||||||
productType: 1,
|
productType: 1,
|
||||||
checkedProduct: [],
|
checkedProduct: [],
|
||||||
|
KeyPcType: sessionStorage.getItem("KeyPcType"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// 基础信息
|
// 基础信息
|
||||||
|
@ -243,6 +243,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
// 编辑/新增/复制
|
// 编辑/新增/复制
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async function init() {
|
(async function init() {
|
||||||
|
let KeyPcType = sessionStorage.getItem("KeyPcType");
|
||||||
|
console.log("KeyPcType UseCouponAddEdit 1编辑 2复制 3新增 =>", KeyPcType);
|
||||||
// 第一步:1.判断组件是否是 优惠券管理 couponType
|
// 第一步:1.判断组件是否是 优惠券管理 couponType
|
||||||
if (couponType === 0) {
|
if (couponType === 0) {
|
||||||
// 如果是编辑
|
// 如果是编辑
|
||||||
|
@ -277,14 +279,14 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
editFun();
|
editFun();
|
||||||
|
|
||||||
// 1.7 复制
|
// 1.7 复制
|
||||||
if (state.isState === "1") {
|
if (state.KeyPcType === "2") {
|
||||||
setForm_info_data({
|
setForm_info_data({
|
||||||
title: `${editData.title}_${editData.copy_count + 1}`,
|
title: `${editData.title}_${editData.copy_count + 1}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.8 编辑
|
// 1.8 编辑
|
||||||
if (state.isState === "2") {
|
if (state.KeyPcType === "1") {
|
||||||
setState({
|
setState({
|
||||||
oldProduct: editData.product,
|
oldProduct: editData.product,
|
||||||
});
|
});
|
||||||
|
@ -349,7 +351,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
// 商品的数组
|
// 商品的数组
|
||||||
let goods_arr = editData.product.legal.map((item) => {
|
let goods_arr = editData.product.legal.map((item) => {
|
||||||
// 如果是复制 删除id !!!!!!!!
|
// 如果是复制 删除id !!!!!!!!
|
||||||
if (state.isState === "1") {
|
if (state.KeyPcType === "2") {
|
||||||
delete item.id;
|
delete item.id;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -367,7 +369,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
// 立减金
|
// 立减金
|
||||||
let lj_arr = editData.product.reduce.map((item) => {
|
let lj_arr = editData.product.reduce.map((item) => {
|
||||||
// 如果是复制 删除id !!!!!!!!
|
// 如果是复制 删除id !!!!!!!!
|
||||||
if (state.isState === "1") {
|
if (state.KeyPcType === "2") {
|
||||||
delete item.id;
|
delete item.id;
|
||||||
}
|
}
|
||||||
let table_obj = knockGoldFun(item);
|
let table_obj = knockGoldFun(item);
|
||||||
|
@ -412,7 +414,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
// 状态不可修改
|
// 状态不可修改
|
||||||
const statusDisabledFun = (status) => {
|
const statusDisabledFun = (status) => {
|
||||||
// 第一步判断是否是复制:
|
// 第一步判断是否是复制:
|
||||||
if (state.isState === "1") {
|
if (state.KeyPcType === "2") {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if ([1, 2, 3].includes(status)) {
|
if ([1, 2, 3].includes(status)) {
|
||||||
|
@ -598,8 +600,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAuditSubmit = () => {
|
const onAuditSubmit = () => {
|
||||||
// 1新增 2编辑
|
// 3新增 1编辑
|
||||||
if (state.isState === "2") {
|
if (state.KeyPcType === "1") {
|
||||||
let param = {
|
let param = {
|
||||||
payment_direction: state.payment_direction[state.payType - 1],
|
payment_direction: state.payment_direction[state.payType - 1],
|
||||||
title: form_info_data.title,
|
title: form_info_data.title,
|
||||||
|
@ -696,7 +698,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// 复制id
|
// 复制id
|
||||||
if (state.isState === "1") {
|
if (state.KeyPcType === "2") {
|
||||||
param.copy_code_batch_id = editData.id;
|
param.copy_code_batch_id = editData.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,7 +843,8 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
|
|
||||||
// 获取已经选择的商品数据(禁用商品选择)
|
// 获取已经选择的商品数据(禁用商品选择)
|
||||||
const getCheckedProduct = () => {
|
const getCheckedProduct = () => {
|
||||||
let arr = state.tableData.map((item) => item.product_id);
|
console.log("已选 =>", state.tableData);
|
||||||
|
let arr = state.tableData.map((item) => Number(item.product_id));
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -917,7 +920,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
});
|
});
|
||||||
// 如果是复制删除 code_batch_id 如果是计划中的创建中数据
|
// 如果是复制删除 code_batch_id 如果是计划中的创建中数据
|
||||||
let plan_status = sessionStorage.getItem("plan_status");
|
let plan_status = sessionStorage.getItem("plan_status");
|
||||||
if (state.isState === "1" || plan_status === "0") {
|
if (state.KeyPcType === "2" || plan_status === "0") {
|
||||||
delete rowData.code_batch_id;
|
delete rowData.code_batch_id;
|
||||||
}
|
}
|
||||||
setState({
|
setState({
|
||||||
|
@ -1044,7 +1047,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeFalse = () => {
|
const timeFalse = () => {
|
||||||
if (state.isState === "1") {
|
if (state.KeyPcType === "2") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1123,7 +1126,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
options={state.plan_OPTIONS}
|
options={state.plan_OPTIONS}
|
||||||
value={form_info_data.plan_id}
|
value={form_info_data.plan_id}
|
||||||
disabled={
|
disabled={
|
||||||
state.isState === "2" || state.isState === "1" ? true : false
|
state.KeyPcType === "2" || state.KeyPcType === "1"
|
||||||
|
? true
|
||||||
|
: false
|
||||||
}
|
}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
changePlan(e);
|
changePlan(e);
|
||||||
|
@ -1141,7 +1146,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
|
||||||
options={state.key_OPTIONS}
|
options={state.key_OPTIONS}
|
||||||
value={form_info_data.key_batch_id}
|
value={form_info_data.key_batch_id}
|
||||||
disabled={
|
disabled={
|
||||||
state.isState === "2" || state.isState === "1" ? true : false
|
state.KeyPcType === "2" || state.KeyPcType === "1"
|
||||||
|
? true
|
||||||
|
: false
|
||||||
}
|
}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setForm_info_data({ key_batch_id: e });
|
setForm_info_data({ key_batch_id: e });
|
||||||
|
|
|
@ -164,6 +164,7 @@ const UseProductPop = forwardRef((props, ref) => {
|
||||||
setState({
|
setState({
|
||||||
productDataAll: req.data,
|
productDataAll: req.data,
|
||||||
});
|
});
|
||||||
|
console.log("所有商品数据 =>", req.data);
|
||||||
let optArr = req.data.map((item) => {
|
let optArr = req.data.map((item) => {
|
||||||
return {
|
return {
|
||||||
key: item.id,
|
key: item.id,
|
||||||
|
|
|
@ -249,7 +249,7 @@ const UseCouponList = () => {
|
||||||
|
|
||||||
/* 新建/复制/编辑/兑换码 */
|
/* 新建/复制/编辑/兑换码 */
|
||||||
const addCodeFunction = (type, param) => {
|
const addCodeFunction = (type, param) => {
|
||||||
console.log(param);
|
let KeyPcType = "3";
|
||||||
sessionStorage.setItem("knockGold_effectDate", JSON.stringify({}));
|
sessionStorage.setItem("knockGold_effectDate", JSON.stringify({}));
|
||||||
let activerou = [
|
let activerou = [
|
||||||
{
|
{
|
||||||
|
@ -280,6 +280,7 @@ const UseCouponList = () => {
|
||||||
"datetime",
|
"datetime",
|
||||||
JSON.stringify([param.begin_time, param.end_time])
|
JSON.stringify([param.begin_time, param.end_time])
|
||||||
);
|
);
|
||||||
|
KeyPcType = "2";
|
||||||
} else if (type === 2) {
|
} else if (type === 2) {
|
||||||
activerou[0].pagetitle = "编辑";
|
activerou[0].pagetitle = "编辑";
|
||||||
activerou[0].items[1].name = `编辑:${param.title}`;
|
activerou[0].items[1].name = `编辑:${param.title}`;
|
||||||
|
@ -289,15 +290,16 @@ const UseCouponList = () => {
|
||||||
"datetime",
|
"datetime",
|
||||||
JSON.stringify([param.begin_time, param.end_time])
|
JSON.stringify([param.begin_time, param.end_time])
|
||||||
);
|
);
|
||||||
|
KeyPcType = "1";
|
||||||
} else {
|
} else {
|
||||||
|
KeyPcType = "3";
|
||||||
sessionStorage.setItem("datetime", ``);
|
sessionStorage.setItem("datetime", ``);
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionStorage.setItem("code_id", param?.id);
|
sessionStorage.setItem("code_id", param?.id);
|
||||||
sessionStorage.setItem("isState", type);
|
|
||||||
sessionStorage.setItem("breaknav", JSON.stringify(activerou));
|
sessionStorage.setItem("breaknav", JSON.stringify(activerou));
|
||||||
sessionStorage.setItem("pathname2", "/home/coupon-add-edit");
|
sessionStorage.setItem("pathname2", "/home/coupon-add-edit");
|
||||||
sessionStorage.setItem("keyType", "2");
|
sessionStorage.setItem("keyType", "2");
|
||||||
|
sessionStorage.setItem("KeyPcType", KeyPcType); // 1编辑 2复制 3新增
|
||||||
history.push("/home/coupon-add-edit");
|
history.push("/home/coupon-add-edit");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,9 @@ const UseKeyAddEdit = () => {
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
let planItem = sessionStorage.getItem("plan_item");
|
let planItem = sessionStorage.getItem("plan_item");
|
||||||
|
let KeyPcType = sessionStorage.getItem("KeyPcType");
|
||||||
|
console.log("KeyPcType UseKeyAddEdit 1编辑 2复制 3新增 =>", KeyPcType);
|
||||||
|
|
||||||
if (planItem) {
|
if (planItem) {
|
||||||
let planObj = JSON.parse(planItem);
|
let planObj = JSON.parse(planItem);
|
||||||
setModel({
|
setModel({
|
||||||
|
@ -539,6 +542,7 @@ const UseKeyAddEdit = () => {
|
||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
const rowEditClick = (row, rowIndex) => {
|
const rowEditClick = (row, rowIndex) => {
|
||||||
|
console.log("编辑 -01");
|
||||||
if (state.keyType === 1) {
|
if (state.keyType === 1) {
|
||||||
setState({
|
setState({
|
||||||
draw_title: "编辑兑换码",
|
draw_title: "编辑兑换码",
|
||||||
|
|
Loading…
Reference in New Issue