|
|
@ -27,8 +27,8 @@ function CouponRules() { |
|
|
|
|
|
|
|
const [formData, setFormData] = useSetState({ |
|
|
|
name: defaultParams ? defaultParams.name : '', |
|
|
|
status: defaultParams ? defaultParams.status : '', |
|
|
|
coupon_type: defaultParams ? defaultParams.coupon_type : '', |
|
|
|
status: defaultParams ? defaultParams.status : '0', |
|
|
|
coupon_type: defaultParams ? defaultParams.coupon_type : '0', |
|
|
|
}) |
|
|
|
const [operatorOptions, setOperatorOptions] = useState([]) // 运营商下拉框 |
|
|
|
const [departOptions, setDepartOptions] = useState([]) |
|
|
@ -43,7 +43,7 @@ function CouponRules() { |
|
|
|
const [loading, setLoading] = useState(false) // 等待状态 |
|
|
|
const [pageData, setPageData] = useSetState({ // 分页参数 |
|
|
|
pn: defaultParams?.pn || 1, |
|
|
|
size:defaultParams?.page_size || 20, |
|
|
|
page_size:defaultParams?.page_size || 20, |
|
|
|
}) |
|
|
|
|
|
|
|
const [dataSource, setDataSource] = useState([]) |
|
|
@ -136,6 +136,7 @@ function CouponRules() { |
|
|
|
if (res.status == 20000) { |
|
|
|
message.success(res.message) |
|
|
|
setIsTakedownModalOpen(false) |
|
|
|
getCouponList(params.current) |
|
|
|
} else { |
|
|
|
message.error(res.message) |
|
|
|
} |
|
|
@ -151,6 +152,7 @@ function CouponRules() { |
|
|
|
if (res.status == 20000) { |
|
|
|
message.success(res.message) |
|
|
|
setDeleteModalOpen(false) |
|
|
|
getCouponList(params.current) |
|
|
|
} else { |
|
|
|
message.error(res.message) |
|
|
|
} |
|
|
@ -230,7 +232,7 @@ function CouponRules() { |
|
|
|
} |
|
|
|
setPageData({ |
|
|
|
pn: pn, |
|
|
|
size: pageSize, |
|
|
|
page_size: pageSize, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -239,7 +241,7 @@ function CouponRules() { |
|
|
|
// console.log(current,pageSize) |
|
|
|
setPageData({ |
|
|
|
pn: current, |
|
|
|
size: pageSize, |
|
|
|
page_size: pageSize, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -247,7 +249,7 @@ function CouponRules() { |
|
|
|
const search = () => { |
|
|
|
setPageData({ |
|
|
|
pn: 1, |
|
|
|
size: 20 |
|
|
|
page_size: 20 |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
@ -277,7 +279,7 @@ function CouponRules() { |
|
|
|
return |
|
|
|
} |
|
|
|
let submitData = {...currentCouponInfo} |
|
|
|
if(submitData.effective_date == 2 ){ |
|
|
|
if(submitData.effective_date == 2 ){ // 领取之日起 |
|
|
|
if(customDay== 0 && customHour == 0 && customMinute == 0){ |
|
|
|
message.error('有效日期需要设置时间范围') |
|
|
|
return |
|
|
@ -287,7 +289,7 @@ function CouponRules() { |
|
|
|
} |
|
|
|
if(currentCouponId){ // 编辑 |
|
|
|
|
|
|
|
ajax.handleCouponEdit({...currentCouponInfo ,id: currentCouponId }).then(res => { |
|
|
|
ajax.handleCouponEdit({...submitData ,id: currentCouponId }).then(res => { |
|
|
|
if (res.status == 20000) { |
|
|
|
message.success(res.message) |
|
|
|
setShowEdit(false) |
|
|
@ -303,7 +305,7 @@ function CouponRules() { |
|
|
|
|
|
|
|
}) |
|
|
|
}else{ // 新增 |
|
|
|
ajax.handleCouponInsert(currentCouponInfo).then(res => { |
|
|
|
ajax.handleCouponInsert(submitData).then(res => { |
|
|
|
if (res.status == 20000) { |
|
|
|
message.success(res.message) |
|
|
|
// getCouponList() |
|
|
@ -324,25 +326,64 @@ function CouponRules() { |
|
|
|
|
|
|
|
const validateParams = ()=>{ |
|
|
|
let flag = true |
|
|
|
for(let key in validateRules){ |
|
|
|
if(!currentCouponInfo[key] && !validateRules[key].relation){ |
|
|
|
message.error(validateRules[key].tip) |
|
|
|
flag =false |
|
|
|
break |
|
|
|
}else if(validateRules[key].relation){ // 受制约的字段 |
|
|
|
if(currentCouponInfo[validateRules[key].relation] == validateRules[key].value && !currentCouponInfo[key]){ |
|
|
|
message.error(validateRules[key].tip) |
|
|
|
flag =falsesetcurrentCouponId |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
// for(let key in validateRules){ |
|
|
|
// if(!currentCouponInfo[key] && !validateRules[key].relation){ |
|
|
|
// message.error(validateRules[key].tip) |
|
|
|
// flag =false |
|
|
|
// break |
|
|
|
// }else if(validateRules[key].relation){ // 受制约的字段 |
|
|
|
// if(currentCouponInfo[validateRules[key].relation] == validateRules[key].value && !currentCouponInfo[key]){ |
|
|
|
// message.error(validateRules[key].tip) |
|
|
|
// flag =falsesetcurrentCouponId |
|
|
|
// break |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// name: {tip: "优惠券名称不能为空"}, |
|
|
|
// mode: {tip: "模式不能为空"}, |
|
|
|
// type: {tip: "优惠券类型不能为空"}, |
|
|
|
// // value: {tip: "面值不能为空"}, |
|
|
|
// // value_condition: {tip: "使用条件不能为空"}, |
|
|
|
// hour : {tip: "欠费时长不能为空"}, |
|
|
|
// effective_date: {tip: "有效日期不能为空"}, |
|
|
|
// effctive_value: {tip: "固定日期不能为空", relation: 'effective_date' , value: 1}, |
|
|
|
// // effctive_value2: {tip: "自领取日起时间范围不能为空", relation: 'effective_date' , value: 2 }, |
|
|
|
// terminal: {tip: "终端不能为空"}, |
|
|
|
// // use_scope: {tip: "使用范围不能为空",condition: ''}, |
|
|
|
// // use_content: {tip: "路段不能为空" , condition : ''}, |
|
|
|
// illustrate: {tip: "使用说明不能为空"} |
|
|
|
if(!currentCouponInfo.name){ |
|
|
|
message.error('优惠券名称不能为空') |
|
|
|
return false |
|
|
|
} |
|
|
|
if(!currentCouponInfo.mode){ |
|
|
|
message.error('模式不能为空') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
if(currentCouponInfo.mode == '2' && !currentCouponInfo.partner){ |
|
|
|
message.error('合作方不能为空') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
if(!currentCouponInfo.type){ |
|
|
|
message.error('优惠券类型不能为空') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
if(!currentCouponInfo.hour){ |
|
|
|
message.error('欠费时长不能为空') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(currentCouponInfo.use_scope == 1 && currentCouponInfo.use_content == ''){ |
|
|
|
message.error('路段不能为空') |
|
|
|
flag =false |
|
|
|
return false |
|
|
|
}else if(currentCouponInfo.use_scope == 2 && currentCouponInfo.use_content == ''){ |
|
|
|
message.error('商户不能为空') |
|
|
|
flag =false |
|
|
|
return false |
|
|
|
} |
|
|
|
return flag |
|
|
|
} |
|
|
@ -351,11 +392,15 @@ function CouponRules() { |
|
|
|
setCurrentCouponInfo({}) |
|
|
|
setSelectedKeys([]) |
|
|
|
setTargetKeys([]) |
|
|
|
setCustomDay(0) |
|
|
|
setCustomHour(0) |
|
|
|
setCustomMinute(0) |
|
|
|
} |
|
|
|
|
|
|
|
const hideRightPanel = ()=>{ |
|
|
|
setShowEdit(false); |
|
|
|
setCurrentCouponInfo({}) |
|
|
|
// setCurrentCouponInfo({}) |
|
|
|
resetCurrentCouponInfo() |
|
|
|
setCurrentCouponId('') |
|
|
|
setJustCheck(false) |
|
|
|
} |
|
|
@ -588,7 +633,7 @@ function CouponRules() { |
|
|
|
<div className="op-btn" onClick={()=>{clickDropDown("2",record)}}>修改</div> |
|
|
|
<div className="op-btn" onClick={()=>{clickDropDown("3",record)}}>下架</div> |
|
|
|
</div> |
|
|
|
}else{ // 关联活动了 |
|
|
|
}else{ // 没有关联活动 可以删除 |
|
|
|
content = <div> |
|
|
|
<div className="op-btn" onClick={()=>{clickDropDown("1",record)}}>查看</div> |
|
|
|
<div className="op-btn" onClick={()=>{clickDropDown("2",record)}}>修改</div> |
|
|
@ -619,7 +664,7 @@ function CouponRules() { |
|
|
|
// showTotal={() => `共 ${total_records} 条`} |
|
|
|
total={resultData.total} |
|
|
|
current={pageData.pn} |
|
|
|
pageSize={pageData.size} |
|
|
|
pageSize={pageData.page_size} |
|
|
|
pageSizeOptions={dictionary?.pageSizeOptions} |
|
|
|
onChange={onChangePn} |
|
|
|
onShowSizeChange={onShowSizeChange} |
|
|
@ -674,7 +719,7 @@ function CouponRules() { |
|
|
|
required={true} |
|
|
|
disabled={justCheck} |
|
|
|
yisaData={sysConfig.coupon?.length ? sysConfig.coupon.slice(1,4) : []} |
|
|
|
defaultValue={ currentCouponInfo.type || null } |
|
|
|
defaultValue={ currentCouponInfo.type || '1' } |
|
|
|
placeholder="" |
|
|
|
hasUnlimited={ false } |
|
|
|
showClose={true} |
|
|
@ -804,7 +849,7 @@ function CouponRules() { |
|
|
|
disabled={justCheck} |
|
|
|
yisaData={[{label: '全部', value: 0},{label: '按车场', value: 1},{label: '按商户', value: 2}]} |
|
|
|
// defaultValue={ currentCouponInfo.use_scope || null } |
|
|
|
defaultValue={ 1 } |
|
|
|
defaultValue={ 0 } |
|
|
|
placeholder="" |
|
|
|
hasUnlimited={ false } |
|
|
|
showClose={true} |
|
|
|