💊 fix: 优惠券不允许开启云闪付

This commit is contained in:
wangsongsole 2023-08-01 09:15:57 +08:00
parent 5c6edcefa4
commit 1338f0c5ff
2 changed files with 87 additions and 94 deletions

View File

@ -1,10 +1,10 @@
import React, { forwardRef, useRef } from 'react';
import { Card, Drawer, Button } from 'zent';
import KnockGold from '@/components/knockGold'; /* 立减金 */
import RedPackets from '@/components/redPackets'; /* 红包 */
import { mulNum } from '@/tools/number';
import { knockGoldFun, redPacketsFun } from '@/tools/index';
import UseProductPop from '../UseProductPop'; //
import React, { forwardRef, useRef } from "react"
import { Card, Drawer, Button } from "zent"
import KnockGold from "@/components/knockGold" /* 立减金 */
import RedPackets from "@/components/redPackets" /* 红包 */
import { mulNum } from "@/tools/number"
import { knockGoldFun, redPacketsFun } from "@/tools/index"
import UseProductPop from "../UseProductPop" //
const UseGoodsScopePop = forwardRef((props, ref) => {
const {
@ -19,121 +19,114 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
directResellerId,
productType,
checkedProduct
} = props;
} = props
// ref
// useImperativeHandle(ref, () => ({
// getProductData,
// }));
const productEl = useRef(null);
const knockGold_el = useRef(null);
const redPackets_el = useRef(null);
const productEl = useRef(null)
const knockGold_el = useRef(null)
const redPackets_el = useRef(null)
//
const format_product_model = () => {
let new_tableData = tableData;
let form_model = productEl.current.getFormModel();
form_model.upstream = '直连天下';
form_model.type = 1;
form_model.stock = form_model.quantity;
form_model.all_budget = mulNum(
Number(form_model.contract_price),
Number(form_model.quantity)
);
form_model.effectDate = '-';
if (product_title === '编辑商品') {
let new_tableData = tableData
let form_model = productEl.current.getFormModel()
form_model.upstream = "直连天下"
form_model.type = 1
form_model.stock = form_model.quantity
form_model.all_budget = mulNum(Number(form_model.contract_price), Number(form_model.quantity))
form_model.effectDate = "-"
if (product_title === "编辑商品") {
if (table_index !== -1) {
let ck = new_tableData[table_index].checked;
new_tableData[table_index] = form_model;
new_tableData[table_index].checked = ck;
let ck = new_tableData[table_index].checked
new_tableData[table_index] = form_model
new_tableData[table_index].checked = ck
}
} else {
new_tableData.push(form_model);
new_tableData.push(form_model)
}
return new_tableData;
};
return new_tableData
}
//
const format_knockGold_model = () => {
let new_tableData = tableData;
let form_model = knockGold_el.current.state.form_data;
let table_obj = knockGoldFun(form_model);
if (product_title === '编辑立减金') {
let new_tableData = tableData
let form_model = knockGold_el.current.state.form_data
let table_obj = knockGoldFun(form_model)
if (product_title === "编辑立减金") {
if (table_index !== -1) {
let ck = new_tableData[table_index].checked;
new_tableData[table_index] = table_obj;
new_tableData[table_index].only = form_model;
new_tableData[table_index].checked = ck;
let ck = new_tableData[table_index].checked
new_tableData[table_index] = table_obj
new_tableData[table_index].only = form_model
new_tableData[table_index].checked = ck
}
} else {
new_tableData.push(table_obj);
new_tableData.push(table_obj)
}
return new_tableData;
};
return new_tableData
}
//
const format_redPackets_model = () => {
let new_tableData = tableData;
let form_model = redPackets_el.current.state.form_data;
let table_obj = redPacketsFun(form_model);
table_obj.only.copy = false;
if (product_title === '编辑红包') {
let new_tableData = tableData
let form_model = redPackets_el.current.state.form_data
let table_obj = redPacketsFun(form_model)
table_obj.only.copy = false
if (product_title === "编辑红包") {
if (table_index !== -1) {
let ck = new_tableData[table_index].checked;
new_tableData[table_index] = table_obj;
new_tableData[table_index].only = form_model;
new_tableData[table_index].checked = ck;
let ck = new_tableData[table_index].checked
new_tableData[table_index] = table_obj
new_tableData[table_index].only = form_model
new_tableData[table_index].checked = ck
}
} else {
new_tableData.push(table_obj);
new_tableData.push(table_obj)
}
return new_tableData;
};
return new_tableData
}
//
const submitPop = async () => {
try {
// //
let visible = false;
if (type === 'addProduct') {
visible = await productEl.current.submit();
} else if (type === 'addKnockGold') {
visible = await knockGold_el.current.submit();
let visible = false
if (type === "addProduct") {
visible = await productEl.current.submit()
} else if (type === "addKnockGold") {
visible = await knockGold_el.current.submit()
} else {
visible = await redPackets_el.current.submit();
visible = await redPackets_el.current.submit()
}
if (visible) {
// // table
let form_data = {};
if (type === 'addProduct') {
form_data = format_product_model();
} else if (type === 'addKnockGold') {
form_data = format_knockGold_model();
let form_data = {}
if (type === "addProduct") {
form_data = format_product_model()
} else if (type === "addKnockGold") {
form_data = format_knockGold_model()
} else {
form_data = format_redPackets_model();
form_data = format_redPackets_model()
}
submit(form_data);
onClose();
submit(form_data)
onClose()
}
} catch (err) {
console.log('err =>', err);
console.log("err =>", err)
}
};
}
/* 切换组件 */
function SwitchComponents() {
switch (type) {
case 'addKnockGold':
case "addKnockGold":
return (
<KnockGold
className='addKnockGold'
data={productData}
ref={knockGold_el}
/>
);
case 'addProduct':
<KnockGold className="addKnockGold" data={productData} ref={knockGold_el} ysf={true} />
)
case "addProduct":
return (
<UseProductPop
ref={productEl}
@ -142,26 +135,27 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
directResellerId={directResellerId}
productType={productType}
/>
);
case 'redPackets':
return <RedPackets ref={redPackets_el} data={productData} />;
)
case "redPackets":
return <RedPackets ref={redPackets_el} data={productData} />
default:
break;
break
}
}
return (
<Drawer
className='draw'
width={'86%'}
className="draw"
width={"86%"}
title={product_title}
footer={
<div style={{ textAlign: 'center' }}>
<div style={{ textAlign: "center" }}>
<Button
type='primary'
type="primary"
onClick={(e) => {
submitPop();
}}>
submitPop()
}}
>
提交
</Button>
<Button onClick={(e) => onClose()}>取消</Button>
@ -169,16 +163,15 @@ const UseGoodsScopePop = forwardRef((props, ref) => {
}
visible={drawerVisible}
onClose={(e) => onClose()}
maskClosable={false}>
<div className='draw2'>
<Card
className='borderNone'
style={{ width: '95%', margin: '10px auto' }}>
maskClosable={false}
>
<div className="draw2">
<Card className="borderNone" style={{ width: "95%", margin: "10px auto" }}>
{SwitchComponents()}
</Card>
</div>
</Drawer>
);
});
)
})
export default UseGoodsScopePop;
export default UseGoodsScopePop

View File

@ -761,7 +761,7 @@ export default class addKnockGold extends Component {
>
<RadioButton value={"1"}>支付宝</RadioButton>
<RadioButton value={"2"}>微信</RadioButton>
<RadioButton value={"3"}>云闪付</RadioButton>
{!this.props.ysf && <RadioButton value={"3"}>云闪付</RadioButton>}
</RadioGroup>
</FormItem>
<FormItem labelname="立减金平台批次号" prop="channel_activity_id" id="batch_number">