fix: 兑换码无法显示select

This commit is contained in:
zhangds 2022-09-29 15:18:27 +08:00
parent df8b667bf8
commit 41d07e3771
4 changed files with 643 additions and 605 deletions

View File

@ -203,7 +203,9 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
plan_id: "", plan_id: "",
key_batch_id: "", key_batch_id: "",
title: "", title: "",
date_time: JSON.parse(sessionStorage.getItem("datetime")), date_time: sessionStorage.getItem("datetime")
? JSON.parse(sessionStorage.getItem("datetime"))
: "",
}); });
const form_info_el = useRef(null); const form_info_el = useRef(null);
@ -217,21 +219,43 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
}); });
const form_rule_el = useRef(null); const form_rule_el = useRef(null);
const isEditFun = () => {
//
if (sessionStorage.getItem("isState") === "2") {
setState({
isEdit: true,
});
}
//
if (editData.approval_status === 2) {
setState({
isEdit: false,
});
}
};
// // // //
useEffect(() => { useEffect(() => {
(async function init() { (async function init() {
// 1. couponType // 1. couponType
console.log("couponType =>", couponType);
console.log("editData =>", editData);
let isState = sessionStorage.getItem("isState");
setState({
isState: isState,
});
if (couponType === 0) { if (couponType === 0) {
sessionStorage.setItem("keyType", 2);
// 1.1 // 1.1
await getPlanList().then((arr) => { await getPlanList().then((arr) => {
console.log("arr =>1", arr);
// 1.2 // 1.2
if (editData && editData !== "") { if (editData && editData !== "") {
isEditFun();
// 1.3 // 1.3
let plan_row = arr.find( let plan_row = arr.find(
(item) => item.text === editData.plan_title (item) => item.text === editData.plan_title
); );
if ( if (
plan_row && plan_row &&
plan_row !== undefined && plan_row !== undefined &&
@ -258,23 +282,15 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
// 1.6 // 1.6
editFun(); editFun();
let isState = sessionStorage.getItem("isState");
if (isState) {
setState({
isState: isState,
});
}
// 1.7 // 1.7
if (isState && isState === "1") { if (state.isState === "1") {
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 (isState && isState === "2") { if (state.isState === "2") {
setState({ isEdit: true });
setState({ setState({
oldProduct: editData.product, oldProduct: editData.product,
}); });
@ -282,7 +298,6 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
} }
}); });
} else { } else {
// 1.3
if (editData && editData !== "") { if (editData && editData !== "") {
editFun(); editFun();
} }
@ -300,19 +315,22 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
end_time: editData.end_time, end_time: editData.end_time,
}) })
); );
// //
setForm_info_data({ setForm_info_data({
title: editData.title, title: editData.title,
date_time: [editData.begin_time, editData.end_time], date_time: [editData.begin_time, editData.end_time],
}); });
// //
setForm_rule_data({ setForm_rule_data({
full: editData.full, full: editData.full,
reduce: editData.reduce, reduce: editData.reduce,
quantity: editData.quantity, quantity: editData.quantity,
budget: editData.budget, budget: mulNum(Number(editData.reduce), Number(editData.quantity)),
restrict: editData.restrict, restrict: editData.restrict,
}); });
// //
// //
let goods_arr = editData.product.legal.map((item) => { let goods_arr = editData.product.legal.map((item) => {
@ -362,12 +380,14 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
rank: arr, rank: arr,
tableData: scope_data, tableData: scope_data,
}); });
} catch (err) {} } catch (err) {
console.log(err);
}
}; };
const getPlanList = () => { const getPlanList = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
queryPlans({ status: "3,4,5" }).then((res) => { queryPlans({ bind_object: "2" }).then((res) => {
handelResponse(res, (req, msg) => { handelResponse(res, (req, msg) => {
let arr = req.map((item) => { let arr = req.map((item) => {
return { return {
@ -1009,7 +1029,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
renderOptionList={renderOptionList} renderOptionList={renderOptionList}
options={state.plan_OPTIONS} options={state.plan_OPTIONS}
value={form_info_data.plan_id} value={form_info_data.plan_id}
disabled={state.isEdit} disabled={state.isState === "2" ? true : false}
onChange={(e) => { onChange={(e) => {
changePlan(e); changePlan(e);
}} }}
@ -1025,7 +1045,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
renderOptionList={renderOptionList} renderOptionList={renderOptionList}
options={state.key_OPTIONS} options={state.key_OPTIONS}
value={form_info_data.key_batch_id} value={form_info_data.key_batch_id}
disabled={state.isEdit} disabled={state.isState === "2" ? true : false}
onChange={(e) => { onChange={(e) => {
setForm_info_data({ key_batch_id: e }); setForm_info_data({ key_batch_id: e });
}} }}
@ -1060,7 +1080,7 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
defaultTime: [moment().format("HH:mm:ss"), "23:59:59"], defaultTime: [moment().format("HH:mm:ss"), "23:59:59"],
}} }}
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
disabled={[state.isEdit, false]} disabled={[state.isState === "2" ? true : false, false]}
value={form_info_data.date_time} value={form_info_data.date_time}
onChange={(e) => { onChange={(e) => {
onChangeCombinedDate(e); onChangeCombinedDate(e);
@ -1250,13 +1270,13 @@ const UseCouponAddEdit = forwardRef((props, ref) => {
> >
编辑 编辑
</span> </span>
<span {/* <span
style={{ color: "red" }} style={{ color: "red" }}
className="grid-link" className="grid-link"
onClick={() => deleteGoodsScope(rowIndex)} onClick={() => deleteGoodsScope(rowIndex)}
> >
删除 删除
</span> </span> */}
</div> </div>
); );
} }

File diff suppressed because it is too large Load Diff

View File

@ -129,7 +129,6 @@ export default class add extends React.Component {
this.setState({ curstep: 2 }); this.setState({ curstep: 2 });
//转译 //转译
req.keys = this.tranFormData(req); req.keys = this.tranFormData(req);
console.log("req.keys =>", req.keys);
for (let i = 0; i < req.keys.length; i++) { for (let i = 0; i < req.keys.length; i++) {
this.addNewkey(); this.addNewkey();
} }
@ -145,7 +144,6 @@ export default class add extends React.Component {
this.refs["step2-" + i].submit(); this.refs["step2-" + i].submit();
} }
}, 500); }, 500);
console.log("详情 =>", req);
} else { } else {
this.addNewkey(); this.addNewkey();
} }

View File

@ -1596,7 +1596,7 @@ export default class acclist extends React.Component {
}} }}
maskClosable={false} maskClosable={false}
> >
{this.props.keyType === 1 ? ( {this.state.keyType === 1 ? (
<div className="draw"> <div className="draw">
<Card <Card
style={{ width: "95%", margin: "10px auto" }} style={{ width: "95%", margin: "10px auto" }}