|
|
@ -23,6 +23,20 @@ function CreditScoreMgm() { |
|
|
|
const [resultData, setResultData] = useState([])//列表数据 |
|
|
|
const [detailData, setDetailData] = useState([])//使用记录列表 |
|
|
|
const [saveData, setSaveData] = useState({})//积分规则配置保存 |
|
|
|
const [flag, setFlag] = useState(1) |
|
|
|
const [payData, setPayData] = useState({})//充值规则配置 |
|
|
|
const [awardList, setAwardList] = useState([])//充值规则优惠券下拉 |
|
|
|
const [coupon, setCoupon] = useState([ |
|
|
|
{ |
|
|
|
"cid": "1", |
|
|
|
"couponId": "1817399802436513369", |
|
|
|
"num": 2 |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cid": "2", |
|
|
|
"couponId": "1817399802436513369", |
|
|
|
"num": 5 |
|
|
|
}])//充值规则配置 |
|
|
|
const [redeemData, setRedeemData] = useState([])//积分兑换配置列表 |
|
|
|
const [addData, setAddData] = useState({})//积分兑换添加数据 |
|
|
|
const [awardId, setAwardId] = useState('')//奖品名称下拉数据默认值 |
|
|
@ -393,6 +407,33 @@ function CreditScoreMgm() { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// 充值规则配置列表 |
|
|
|
const getRechargeRulesList = (e) => { |
|
|
|
ajax.getRechargeRulesList(e).then((e) => { |
|
|
|
if (e.status == 20000) { |
|
|
|
setPayVisible(true) |
|
|
|
setPayData(e.data) |
|
|
|
} |
|
|
|
}) |
|
|
|
}; |
|
|
|
// 充值规则配置修改 |
|
|
|
const getRechargeRulesUpdate = (e) => { |
|
|
|
ajax.getRechargeRulesUpdate(e).then((e) => { |
|
|
|
if (e.status == 20000) { |
|
|
|
message.success(e.message) |
|
|
|
return 1 |
|
|
|
} |
|
|
|
}) |
|
|
|
}; |
|
|
|
// 充值规则配置移除 |
|
|
|
const getRechargeRulesDel = (e) => { |
|
|
|
ajax.getRechargeRulesDel(e).then((e) => { |
|
|
|
if (e.status == 20000) { |
|
|
|
message.success(e.message) |
|
|
|
return 1 |
|
|
|
} |
|
|
|
}) |
|
|
|
}; |
|
|
|
// 获取下拉数据 |
|
|
|
const getSelectList = () => { |
|
|
|
ajax.getCreditScoreAward().then((e) => { |
|
|
@ -402,25 +443,18 @@ function CreditScoreMgm() { |
|
|
|
]) |
|
|
|
}) |
|
|
|
}; |
|
|
|
const acf = () => { |
|
|
|
{ |
|
|
|
fields?.map((item, index) => { |
|
|
|
return ( |
|
|
|
<div className="row-line" key={'items-' + index}> |
|
|
|
<div className="row">11</div> |
|
|
|
<div onClick={() => { |
|
|
|
let arr = fields |
|
|
|
arr.push(1) |
|
|
|
setFields(arr) |
|
|
|
} |
|
|
|
}>+</div> |
|
|
|
</div>) |
|
|
|
} |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
// 充值规则优惠券下拉 |
|
|
|
const getRechargeAwardList = () => { |
|
|
|
ajax.getRechargeAwardList().then((e) => { |
|
|
|
setAwardList([ |
|
|
|
//...searchSelectList, |
|
|
|
...e.data |
|
|
|
]) |
|
|
|
}) |
|
|
|
}; |
|
|
|
useEffect(() => { |
|
|
|
getSelectList(); |
|
|
|
getRechargeAwardList(); |
|
|
|
}, []); |
|
|
|
|
|
|
|
return ( |
|
|
@ -441,8 +475,7 @@ function CreditScoreMgm() { |
|
|
|
type="primary" |
|
|
|
style={{ width: '116px' }} |
|
|
|
onClick={() => { |
|
|
|
//getRule() |
|
|
|
setPayVisible(true) |
|
|
|
getRechargeRulesList() |
|
|
|
}} |
|
|
|
> |
|
|
|
充值规则配置 |
|
|
@ -728,75 +761,139 @@ function CreditScoreMgm() { |
|
|
|
</Modal> |
|
|
|
<Modal |
|
|
|
open={payVisible} |
|
|
|
width={550} |
|
|
|
title={'充值规则配置'} |
|
|
|
width={650} |
|
|
|
title={<div> |
|
|
|
充值规则配置 |
|
|
|
<div className="addrule-btn" onClick={() => { |
|
|
|
let arr = payData |
|
|
|
if (arr.list.length > 4) { |
|
|
|
message.error('最多添加五条规则!') |
|
|
|
return |
|
|
|
} |
|
|
|
arr.list[arr.list.length] = |
|
|
|
{ |
|
|
|
"rid": "", |
|
|
|
"recharge": '', |
|
|
|
"children": [ |
|
|
|
{ |
|
|
|
"cid": "", |
|
|
|
"couponId": "", |
|
|
|
"num": '' |
|
|
|
}, |
|
|
|
] |
|
|
|
} |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
}}>添加规则</div> |
|
|
|
</div>} |
|
|
|
className="pay-modal" |
|
|
|
onCancel={() => { |
|
|
|
setPayVisible(false); |
|
|
|
}} |
|
|
|
onOk={() => { }} |
|
|
|
> |
|
|
|
<div className="pay-box"> |
|
|
|
<div>规则</div> |
|
|
|
<div className="content"> |
|
|
|
<div className="row-title">充值 |
|
|
|
<InputNumber |
|
|
|
className="credit-inputnum" |
|
|
|
min={0} |
|
|
|
value={saveData?.deducting_points} |
|
|
|
onChange={(e) => { setSaveData({ ...saveData, deducting_points: e }) }} |
|
|
|
/> |
|
|
|
元,返优惠券 |
|
|
|
</div> |
|
|
|
<div className="row-box"> |
|
|
|
{fields.length != 0 ? |
|
|
|
fields?.map((item, index) => { |
|
|
|
return ( |
|
|
|
<div className="row-line" key={'items-' + index}> |
|
|
|
<Select |
|
|
|
getPopupContainer={(e) => e.parentNode} |
|
|
|
options={[]} |
|
|
|
//defaultValue={item.defaultValue} |
|
|
|
//placeholder={item.placeholder} |
|
|
|
/> |
|
|
|
<InputNumber |
|
|
|
className="credit-inputnum" |
|
|
|
min={0} |
|
|
|
value={saveData?.deducting_points} |
|
|
|
onChange={(e) => { setSaveData({ ...saveData, deducting_points: e }) }} |
|
|
|
/> |
|
|
|
张 |
|
|
|
{ |
|
|
|
index > 0 && index + 1 == fields.length ? |
|
|
|
<div className="add-btn del-btn" onClick={() => { |
|
|
|
let arr = fields |
|
|
|
arr.shift() |
|
|
|
setFields([...arr]) |
|
|
|
} |
|
|
|
}>—</div> |
|
|
|
|
|
|
|
: |
|
|
|
<div className="add-btn" onClick={() => { |
|
|
|
let arr = fields |
|
|
|
if (arr.length > 2) { |
|
|
|
message.error('最多添加三个优惠券!') |
|
|
|
return |
|
|
|
onOk={() => { console.log(payData);getRechargeRulesUpdate(payData) }} |
|
|
|
><> |
|
|
|
{flag > 0 && payData && payData.list?.length != 0 ? |
|
|
|
payData.list?.map((item, index) => { |
|
|
|
console.log(778, item) |
|
|
|
return <div className="pay-box"> |
|
|
|
<div className="title">规则{index + 1}</div> |
|
|
|
{index > 0 ? <div className="delrule-btn" onClick={() => { |
|
|
|
getRechargeRulesDel({ rid: item.rid }); |
|
|
|
let arr = payData |
|
|
|
arr.list.splice(index, 1); |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
}}>移除</div> : null} |
|
|
|
<div className="content"> |
|
|
|
<div className="row-title">充值 |
|
|
|
<InputNumber |
|
|
|
className="credit-inputnum" |
|
|
|
min={0} |
|
|
|
value={payData.list[index]?.recharge} |
|
|
|
onChange={(e) => { |
|
|
|
let arr = payData |
|
|
|
arr.list[index].recharge = e |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
}} |
|
|
|
/> |
|
|
|
元,返优惠券 |
|
|
|
</div> |
|
|
|
<div className="row-box"> |
|
|
|
{item && item.children?.length != 0 ? |
|
|
|
item.children?.map((res, index2) => { |
|
|
|
//console.log(809, res) |
|
|
|
return ( |
|
|
|
<div className="row-line" key={'items-' + index2}> |
|
|
|
<Select |
|
|
|
className="row-select" |
|
|
|
getPopupContainer={(e) => e.parentNode} |
|
|
|
options={awardList} |
|
|
|
fieldNames={{ label: "award", value: "awardId" }} |
|
|
|
defaultValue={payData.list[index]?.children[index2]?.couponId} |
|
|
|
onChange={(e) => { |
|
|
|
let arr = payData |
|
|
|
res.couponId = e |
|
|
|
arr.list[index].children[index2] = res |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
} |
|
|
|
} |
|
|
|
//placeholder={item.placeholder} |
|
|
|
/> |
|
|
|
<InputNumber |
|
|
|
className="credit-inputnum" |
|
|
|
min={0} |
|
|
|
value={payData.list[index]?.children[index2]?.num} |
|
|
|
onChange={(e) => { |
|
|
|
let arr = payData |
|
|
|
res.num = e |
|
|
|
arr.list[index].children[index2] = res |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
} |
|
|
|
} |
|
|
|
/>张 |
|
|
|
{ |
|
|
|
index2 > 0 && index2 + 1 == item.children.length ? |
|
|
|
<div className="add-btn del-btn" onClick={() => { |
|
|
|
getRechargeRulesDel({ cid: res.couponId }) |
|
|
|
let arr = payData |
|
|
|
arr.list[index].children.splice(index2, 1); |
|
|
|
console.log(847, arr) |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
} |
|
|
|
}>—</div> |
|
|
|
: |
|
|
|
<div className="add-btn" onClick={() => { |
|
|
|
let arr = payData |
|
|
|
//console.log(123124, item, item.children, res, arr.list[index]?.children) |
|
|
|
if (item.children.length > 2) { |
|
|
|
message.error('最多添加三个优惠券!') |
|
|
|
return |
|
|
|
} |
|
|
|
arr.list[index].children[item.children.length] = { |
|
|
|
"cid": "", |
|
|
|
"couponId": "", |
|
|
|
"num": '' |
|
|
|
} |
|
|
|
setFlag(flag + 1) |
|
|
|
setPayData(arr) |
|
|
|
} |
|
|
|
}>+</div> |
|
|
|
} |
|
|
|
arr.push(1) |
|
|
|
setFields([...arr]) |
|
|
|
} |
|
|
|
}>+</div> |
|
|
|
} |
|
|
|
</div> |
|
|
|
) |
|
|
|
}) |
|
|
|
: null |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
}) |
|
|
|
: null |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
}) : null |
|
|
|
} |
|
|
|
</> |
|
|
|
</Modal> |
|
|
|
</> |
|
|
|
) |
|
|
|