Commit 5368354a authored by 卢均锐's avatar 卢均锐

feat: 采购竞价 增加规则&报价数字输入框限制

parent 13aa9fff
......@@ -32,6 +32,10 @@ const BidRules: React.FC<Iprops> = (props: any) => {
const [isMinPrice, setIsMinPrice] = useState<boolean>(true)
const [isOpenPurchase, setIsOpenPurchase] = useState<boolean>(false)
const [isOpenRanking, setIsOpenRanking] = useState<boolean>(false)
const [startingPrice, setStartingPrice] = useState<any>('');
const [targetPrice, setTargetPrice] = useState<any>('');
const [minPrice, setMinPrice] = useState<any>('');
const [allowPurchaseCount, setAllowPurchaseCount] = useState<any>('');
const [form] = Form.useForm();
useEffect(() => {
currentRef.current = {
......@@ -72,6 +76,10 @@ const BidRules: React.FC<Iprops> = (props: any) => {
fetchdata.isMinPrice != undefined && setIsMinPrice(!!fetchdata.isMinPrice);
setIsOpenPurchase(!!fetchdata.isOpenPurchase);
setIsOpenRanking(!!fetchdata.isOpenRanking);
setStartingPrice(fetchdata.startingPrice);
setTargetPrice(fetchdata.targetPrice);
setMinPrice(fetchdata.minPrice);
setAllowPurchaseCount(fetchdata.allowPurchaseCount);
form.setFieldsValue({
biddingTime: [fetchdata.biddingStartTime ? moment(fetchdata.biddingStartTime) : '', fetchdata.biddingEndTime ? moment(fetchdata.biddingEndTime) : ''],
isStartingPrice: !!fetchdata.isStartingPrice,
......@@ -104,9 +112,9 @@ const BidRules: React.FC<Iprops> = (props: any) => {
label='竞价时间'
name='biddingTime'
rules={[
{ required: true, message: '请选择竞价时间' }, () => ({
{ required: true, message: '请选择竞价时间' }, () => ({
async validator(_, value) {
let _exVal = await exRef.current.signUpTime();
let _exVal = await exRef.current.signUpTime();
if (_exVal[1] && moment(value[0]).isBefore(_exVal[1])) {
return Promise.reject(new Error('竞价开始时间需要晚于报名截止时间'));
}
......@@ -159,7 +167,11 @@ const BidRules: React.FC<Iprops> = (props: any) => {
})
]}
>
<Input addonBefore={'¥'} />
<Input addonBefore={'¥'} value={startingPrice} onChange={(e) => {
let _val = e.target.value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
setStartingPrice(_val);
form.setFieldsValue({ startingPrice: _val });
}} />
</Form.Item>)}
<Form.Item
label={<Tooltip placement="right" title='期望成交价格'>目标价<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip>}
......@@ -192,7 +204,11 @@ const BidRules: React.FC<Iprops> = (props: any) => {
})
]}
>
<Input addonBefore={'¥'} />
<Input addonBefore={'¥'} value={targetPrice} onChange={(e) => {
let _val = e.target.value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
setTargetPrice(_val);
form.setFieldsValue({ targetPrice: _val });
}} />
</Form.Item>)}
<Form.Item
label={<Tooltip placement="right" title='每次报价降价幅度须大于或等于最小价差'>最小价差<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip>}
......@@ -225,7 +241,11 @@ const BidRules: React.FC<Iprops> = (props: any) => {
})
]}
>
<Input addonBefore={'¥'} />
<Input addonBefore={'¥'} value={minPrice} onChange={(e) => {
let _val = e.target.value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
setMinPrice(_val);
form.setFieldsValue({ minPrice: _val });
}}/>
</Form.Item>)}
<Form.Item
label={<Tooltip placement="right" title='允许每个供应商最多可以报价的次数'>允许报价次数<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip>}
......@@ -252,7 +272,11 @@ const BidRules: React.FC<Iprops> = (props: any) => {
})
]}
>
<Input />
<Input value={allowPurchaseCount} onChange={(e) => {
let _val = e.target.value.replace(/[^\d]/g, '').replace(/^0{1,}/g, '');
setAllowPurchaseCount(_val);
form.setFieldsValue({ allowPurchaseCount: _val });
}} />
</Form.Item>
<Form.Item
label={<Tooltip placement="right" title='选择公开当前最低报价,竞价过程中将供应商所报当前最低价在竞价页面即时公开。'>公开当前最低报价<QuestionCircleOutlined style={{ marginLeft: '5px' }} /></Tooltip>}
......
......@@ -73,22 +73,24 @@ const DetailBottomDrawer: React.FC<DetailBottomDrawerProps> = (props: any) => {
]
const _changeTax = (record: any, value: any) => {
let _val = value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1');
let _dataSource = [...dataSource2];
const _i = _dataSource.findIndex((item) => item.id === record.id);
let _item = { ..._dataSource[_i] };
_item.taxRate = value;
_item.isTax = value != 0 ? 1 : 0;
_item.taxRate = _val;
_item.isTax = _val != 0 ? 1 : 0;
_dataSource[_i] = _item;
setDataSource(_dataSource);
setDataSource2(_dataSource)
}
const _changeUnitPrice = (record: any, value: any) => {
let _val = value.replace(/^\D*(\d*(?:\.\d{0,3})?).*$/g, '$1');
let _dataSource = [...dataSource2];
const _i = _dataSource.findIndex((item) => item.id === record.id);
let _item = { ..._dataSource[_i] };
_item.unitPrice = value;
_item.price = _calcTotal(value, _dataSource[_i].purchaseCount);
_item.unitPrice = _val;
_item.price = _calcTotal(_val, _dataSource[_i].purchaseCount);
_dataSource[_i] = _item;
setDataSource(_dataSource);
setDataSource2(_dataSource)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment