3.10 工程代码同步master
This commit is contained in:
@ -1,13 +1,20 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
|
||||
import { Button, Descriptions, Form, Input, InputNumber, message, Radio, Spin } from 'antd';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import ProTable, { ProColumns } from '@ant-design/pro-table';
|
||||
import { Button, Descriptions, Form, Input, message, Radio, Spin } from 'antd';
|
||||
import styles from './indexStyles.less';
|
||||
import '@/assets/xsy_style.less'
|
||||
import { getPage, saveData, } from './services';
|
||||
import { getProId } from '@/utils/session';
|
||||
import { getProId, getProMethod } from '@/utils/session';
|
||||
import { getURLInformation } from '@/utils/CommonUtils'
|
||||
import { btnAuthority } from '@/utils/authority';
|
||||
|
||||
const costConfig: React.FC<{}> = () => {
|
||||
const roomType = getURLInformation('roomType');//预审1 后审2
|
||||
const [proId, proIdSet] = useState<any>();//项目id
|
||||
// const [control, controlSet] = useState<any>();//控制显隐
|
||||
const [showName, showNameSet] = useState<any>({ sec: '', bsf: '', bzj: '', fwf: '', bsfdf: '' });//字段名
|
||||
useEffect(() => {
|
||||
getShouName();
|
||||
proIdSet(getProId());
|
||||
getCostData();
|
||||
}, []);
|
||||
@ -16,76 +23,115 @@ const costConfig: React.FC<{}> = () => {
|
||||
let maxStatus = 0;
|
||||
let max = 0;
|
||||
let maxSendOUt = false;
|
||||
getPage({ proId: getProId() }).then((res) => {
|
||||
let controlT = true;
|
||||
getPage({ proId: getProId(), roomType: roomType }).then((res) => {
|
||||
if (res != undefined) {
|
||||
if (res.data != undefined && res.data.voList != undefined) {
|
||||
// if (res.data != undefined && res.data.voList != undefined) {
|
||||
// data = res.data.voList;
|
||||
// }
|
||||
// if (res.data != undefined && res.data.maxAmount != undefined && res.data.maxAmount != null && res.data.maxAmount != {} && res.data.maxAmount.amount != null) {
|
||||
// maxStatus = 1;
|
||||
// max = res.data.maxAmount.amount;
|
||||
// maxSendOUt = res.data.maxAmount.sendOut != 0
|
||||
// }
|
||||
if (res.code == 200) {
|
||||
data = res.data.voList;
|
||||
}
|
||||
if (res.data != undefined && res.data.maxAmount != undefined && res.data.maxAmount != null && res.data.maxAmount != {} && res.data.maxAmount.amount != null) {
|
||||
maxStatus = 1;
|
||||
max = res.data.maxAmount.amount;
|
||||
data.length > 0 ? controlT = false : null
|
||||
maxSendOUt = res.data.maxAmount.sendOut != 0
|
||||
if (res.data.maxAmount.chargeType === '2') {
|
||||
maxStatus = 1;
|
||||
}
|
||||
if (res.data.maxAmount.amount != null) {
|
||||
max = res.data.maxAmount.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (res.code == 200) {
|
||||
// data = res.data.voList;
|
||||
// maxStatus = 1;
|
||||
// max = res.data.maxAmount.amount;
|
||||
// maxSendOUt = res.data.maxAmount.sendOut != 0
|
||||
// }
|
||||
console.log(data);
|
||||
setMax(max);
|
||||
setRadioMax(maxStatus);
|
||||
setCostData(data);
|
||||
setSpin(false);
|
||||
// controlSet(controlT);
|
||||
maxSendOutSet(maxSendOUt);
|
||||
if (ref.current) {
|
||||
ref.current.reload();
|
||||
}
|
||||
allSendSet(!res.data?.saveButtonState);
|
||||
})
|
||||
}
|
||||
const ref = useRef<ActionType>();
|
||||
function getShouName() {
|
||||
const method = getProMethod();
|
||||
let showNameT: any = { sec: '', bsf: '', bzj: '', fwf: '', bsfdf: '' }//标段名称 标书费 保证金 服务费
|
||||
if (method === 'procurement_mode_1' || method === 'procurement_mode_2') {//招标
|
||||
showNameT = { sec: '标段名称', bsf: '标书费', bzj: '投标保证金', fwf: '中标', bsfdf: '标书封顶费用' }
|
||||
} else if (method === 'procurement_mode_4') {//招募
|
||||
showNameT = { sec: '包件名称', bsf: '招募文件费用', bzj: '保证金', fwf: '中选', bsfdf: '招募文件封顶费用' }
|
||||
} else {//谈判类
|
||||
showNameT = { sec: '采购包名称', bsf: '采购文件费用', bzj: '保证金', fwf: '中选', bsfdf: '采购文件封顶费用' }
|
||||
}
|
||||
showNameSet(showNameT);
|
||||
}
|
||||
const [costData, setCostData] = useState<any>([{}]);
|
||||
const [spin, setSpin] = useState<boolean>(true);
|
||||
const [radioMax, setRadioMax] = useState<number>();//是否设置封顶
|
||||
const [max, setMax] = useState<any>();//封顶费用
|
||||
const [maxSendOut, maxSendOutSet] = useState<any>(true);//封顶费用是否可编辑
|
||||
|
||||
const [allSend, allSendSet] = useState<any>(true);//保存按钮是否显示
|
||||
const [form] = Form.useForm();
|
||||
const FormItem = Form.Item;
|
||||
function moreThan0(val: any) {
|
||||
if (val != "--" && val != "++" && val !== "" && val != undefined && !(parseInt(val) < 0)) { return true } else { return false }
|
||||
// if (val != "--" && val != "++" && val !== "" && val != undefined && !(parseInt(val) < 0)) { return true } else { return false }
|
||||
if (val != "--" && val != "++" && val !== 'e' && val != undefined && !(val < 0)) { return true } else { return false }
|
||||
}
|
||||
const columns: ProColumns<any>[] = [
|
||||
{ title: '序号', valueType: 'index', },
|
||||
{ title: '相关标段', dataIndex: 'sectionName', },
|
||||
{ title: '序号', valueType: 'index', width: 50 },
|
||||
{ title: showName.sec, dataIndex: 'sectionName', },
|
||||
{
|
||||
title: '标书费(线上支付)', dataIndex: 'expenses1Amount',
|
||||
title: showName.bsf + '(元)', dataIndex: 'expenses1Amount',
|
||||
render: (_, record) => {
|
||||
return (
|
||||
<><Input
|
||||
readOnly={returnDisabled(record.sendOut)}
|
||||
style={{ width: '80%' }}
|
||||
allowClear
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder="请输入标书费"
|
||||
defaultValue={record.expenses1Amount}
|
||||
onBlur={(event) => { record.expenses1Amount = event.target.value; }}
|
||||
/> 元</>
|
||||
<Form form={form}>
|
||||
<FormItem
|
||||
name={`expenses1Amount${record.key}`}
|
||||
rules={[
|
||||
{ pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确数值(最多2位小数)' },
|
||||
{ pattern: /^.{0,21}$/, message: '超长' }
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
readOnly={returnDisabled(record.sendOut)}
|
||||
style={{ width: '80%', maxWidth: '300px' }}
|
||||
placeholder={`请输入${showName.bsf}`}
|
||||
defaultValue={record.expenses1Amount}
|
||||
onBlur={(event) => record.expenses1Amount = event.target.value}
|
||||
/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '投标保证金(线下支付)', dataIndex: 'expenses5Amount',
|
||||
title: showName.bzj + '(元)', dataIndex: 'expenses5Amount', hideInTable: roomType === '1',
|
||||
render: (_, record) => {
|
||||
return (
|
||||
<><Input readOnly={returnDisabled(record.sendOut)} style={{ width: '80%' }} allowClear defaultValue={record.expenses5Amount} onBlur={(event) => {
|
||||
record.expenses5Amount = event.target.value;
|
||||
}} placeholder="请输入投标保证金" /> 元</>
|
||||
<Form form={form}>
|
||||
<FormItem
|
||||
name={`expenses5Amount${record.key}`}
|
||||
rules={[
|
||||
{ pattern: /^[0-9]+(\.[0-9]{1,2})?$/, message: '请输入正确数值(最多2位小数)' },
|
||||
{ pattern: /^.{0,21}$/, message: '超长' }
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
readOnly={returnDisabled(record.sendOut)}
|
||||
style={{ width: '80%' }}
|
||||
defaultValue={record.expenses5Amount}
|
||||
placeholder={`请输入${showName.bzj}`}
|
||||
onBlur={(event) => record.expenses5Amount = event.target.value}
|
||||
/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '中标服务费', dataIndex: 'expenses4Amount', width: '28%',
|
||||
title: `${showName.fwf}服务费`, dataIndex: 'expenses4Amount', width: '28%', hideInTable: roomType === '1',
|
||||
render: (_, record) => {
|
||||
return (
|
||||
<>
|
||||
@ -93,42 +139,48 @@ const costConfig: React.FC<{}> = () => {
|
||||
const value = event.target.value;
|
||||
if (value != undefined) {
|
||||
const data = [...costData];
|
||||
const now = data[data.findIndex(item => item.sectionName === record.sectionName)];
|
||||
const now = data[data.findIndex(item => item.sectionId === record.sectionId)];
|
||||
now.expenses4Type = value;
|
||||
setCostData(data);
|
||||
}
|
||||
}} value={parseInt(record.expenses4Type)}>
|
||||
<Radio className={styles.radioStyle} value={2}>定额收取:
|
||||
{parseInt(record.expenses4Type) == 2 ? <>
|
||||
<Input readOnly={returnDisabled(record.sendOut) || parseInt(record.expenses4Type) != 2} size="small" style={{ width: '50%' }}
|
||||
defaultValue={record.expenses4Amount}
|
||||
onBlur={(event) => { record.expenses4Amount = event.target.value }}
|
||||
{parseInt(record.expenses4Type) == 2 ? <>
|
||||
<Input readOnly={returnDisabled(record.sendOut) || parseInt(record.expenses4Type) != 2} type="text" size="small" style={{ width: '50%' }}
|
||||
value={record.expenses4Amount}
|
||||
onChange={(event) => {
|
||||
let val = event.target.value;
|
||||
!Number(val) && val !== '0' && val !== '0.' ? val = val.substring(0, val.length - 1) : null;
|
||||
const data = [...costData];
|
||||
data[data.findIndex(item => item.key === record.key)].expenses4Amount = val;
|
||||
setCostData(data);
|
||||
}}
|
||||
placeholder="请输入收取金额" /> 元</> : null}
|
||||
</Radio>
|
||||
<Radio className={styles.radioStyle} value={3}>按中标金额收取</Radio>
|
||||
<Radio className={styles.radioStyle} value={3}>按{showName.fwf}金额收取</Radio>
|
||||
</Radio.Group><br />
|
||||
中标服务费支付方式:
|
||||
{showName.fwf}服务费支付方式:
|
||||
<Radio.Group disabled={returnDisabled(record.sendOut)} style={{ display: "block" }} onChange={(event) => {
|
||||
const value = event.target.value;
|
||||
if (value != undefined) {
|
||||
const data = [...costData];
|
||||
const now = data[data.findIndex(item => item.sectionName === record.sectionName)];
|
||||
const now = data[data.findIndex(item => item.sectionId === record.sectionId)];
|
||||
now.payment4Method = value;
|
||||
setCostData(data);
|
||||
}
|
||||
}} value={record.payment4Method}>
|
||||
<Radio value={'0'}>线上支付</Radio>
|
||||
<Radio value={'1'}>线下支付</Radio>
|
||||
<Radio value={'2'}>线下支付</Radio>
|
||||
</Radio.Group>
|
||||
</>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '状态', dataIndex: 'sendOut', width: '8%',
|
||||
title: '状态', dataIndex: 'sendOut', width: '100px',
|
||||
valueEnum: {
|
||||
0: { text: '未发送', status: 'Processing' },
|
||||
1: { text: '已发送', status: 'Success' },
|
||||
0: { text: '未发送', },
|
||||
1: { text: '已发送', },
|
||||
},
|
||||
},
|
||||
];
|
||||
@ -136,118 +188,74 @@ const costConfig: React.FC<{}> = () => {
|
||||
let pass = true;
|
||||
let index = 1;
|
||||
for (const item of data) {
|
||||
if (radioMax == 1 && !moreThan0(max)) {
|
||||
if (radioMax == 1 && (!moreThan0(max) || max == '')) {
|
||||
pass = false;
|
||||
message.error('封顶费用不能为空,不能小于0!');
|
||||
break;
|
||||
}
|
||||
if (!checkFive(max)) {
|
||||
if (!checkTwo(max)) {
|
||||
pass = false;
|
||||
message.error('封顶费用小数位不能超过4位!');
|
||||
message.error('封顶费用小数位不能超过2位!');
|
||||
break;
|
||||
}
|
||||
if (!moreThan0(item.expenses1Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,标书费不能为空,不能小于0!`);
|
||||
break;
|
||||
}
|
||||
if (!checkFive(item.expenses1Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,标书费小数位不能超过4位`);
|
||||
break;
|
||||
}
|
||||
if (!moreThan0(item.expenses5Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,投标保证金不能为空,不能小于0!`);
|
||||
break;
|
||||
}
|
||||
if (!checkFive(item.expenses5Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,投标保证金小数位不能超过4位`);
|
||||
break;
|
||||
}
|
||||
if (parseInt(item.expenses4Type) != 2 && parseInt(item.expenses4Type) != 3) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,请选择中标服务费收取方式!`);
|
||||
break;
|
||||
}
|
||||
if (parseInt(item.expenses4Type) == 2 && !moreThan0(item.expenses4Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,中标服务费不能为空,不能小于0!`);
|
||||
break;
|
||||
}
|
||||
if (parseInt(item.expenses4Type) == 2 && !checkFive(item.expenses4Type)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,中标服务费小数位不能超过4位`);
|
||||
break;
|
||||
}
|
||||
if (parseInt(item.payment4Method) !== 0 && parseInt(item.payment4Method) !== 1) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,请选择支付方式!`);
|
||||
break;
|
||||
//一行填了一个就全校验
|
||||
// const oneRow = item.expenses1Amount != null || item.expenses5Amount != null || item.expenses4Type != null || item.expenses4Amount != null || item.payment4Method != null;
|
||||
|
||||
if (roomType === '2') {//后审
|
||||
if (item.expenses1Amount != null && !moreThan0(item.expenses1Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,${showName.bsf}不能小于0!`);
|
||||
break;
|
||||
}
|
||||
if (item.expenses1Amount != null && !checkTwo(item.expenses1Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,${showName.bsf}小数位不能超过2位`);
|
||||
break;
|
||||
}
|
||||
if (item.expenses5Amount != null && !moreThan0(item.expenses5Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,${showName.bzj}不能小于0!`);
|
||||
break;
|
||||
}
|
||||
if (item.expenses5Amount != null && !checkTwo(item.expenses5Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,${showName.bzj}小数位不能超过2位`);
|
||||
break;
|
||||
}
|
||||
if (item.expenses4Type == 2 && !moreThan0(item.expenses4Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,${showName.fwf}服务费不能小于0!`);
|
||||
break;
|
||||
}
|
||||
if ((parseInt(item.expenses4Type) == 2 || parseInt(item.expenses4Type) == 3) && (item.payment4Method == null || item.payment4Method == '')) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,请选择${showName.fwf}服务费支付方式!`);
|
||||
break;
|
||||
}
|
||||
if (item.expenses4Type != null && parseInt(item.expenses4Type) == 2 && !checkTwo(item.expenses4Amount)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,${showName.fwf}服务费小数位不能超过2位`);
|
||||
break;
|
||||
}
|
||||
if (item.payment4Method != null && item.payment4Method != '' && (parseInt(item.expenses4Type) != 2 && parseInt(item.expenses4Type) != 3)) {
|
||||
pass = false;
|
||||
message.error(`第${index}行,请选择${showName.fwf}服务费收取方式!`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
function checkFive(money: any) {//检查小数点后4位 不能超4位
|
||||
function checkTwo(money: any) {//检查小数点后2位 不能超2位
|
||||
let pass = true
|
||||
let x = String(money).indexOf('.') + 1; //小数点的位置
|
||||
let y = String(money).length - x; //小数的位数
|
||||
y > 4 ? pass = false : null;
|
||||
y > 2 && x != 0 ? pass = false : null;
|
||||
return pass
|
||||
}
|
||||
//表格按钮
|
||||
const tools = [
|
||||
<Descriptions column={4} style={{ height: 30 }}>
|
||||
<Descriptions.Item label="是否设置封顶费用" >
|
||||
<Radio.Group name="radiogroup" disabled={maxSendOut} onChange={(e) => {
|
||||
e.target.value == 0 ? setMax(null) : setMax('');
|
||||
setRadioMax(e.target.value)
|
||||
}} value={radioMax}>
|
||||
<Radio value={1}>是</Radio>
|
||||
<Radio value={0}>否</Radio>
|
||||
</Radio.Group>
|
||||
</Descriptions.Item>
|
||||
{radioMax == 1 ?
|
||||
<Descriptions.Item label="封顶费用(元)">
|
||||
<Input
|
||||
readOnly={maxSendOut}
|
||||
size="small"
|
||||
type="number"
|
||||
style={{ width: "150px", margin: '0px' }}
|
||||
defaultValue={max}
|
||||
onBlur={(event) => { setMax(event.target.value) }}
|
||||
placeholder='小数点后最多4位'
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
: null
|
||||
}
|
||||
</Descriptions>,
|
||||
<Button type="primary" onClick={async () => {
|
||||
setSpin(true);
|
||||
let pass = true;
|
||||
pass = checkEmpty(costData);
|
||||
if (pass) {
|
||||
let maxAmount = {
|
||||
projectId: proId, amount: radioMax == 0 ? null : max,
|
||||
};
|
||||
let voList = costData;
|
||||
let allData = { maxAmount, voList }
|
||||
let success = false;
|
||||
await saveData(allData).then((res) => {
|
||||
if (res.code === 200) {
|
||||
success = true;
|
||||
}
|
||||
});
|
||||
if (success) {
|
||||
message.success('保存成功');
|
||||
}
|
||||
getCostData();
|
||||
}
|
||||
setSpin(false);
|
||||
}}>保存</Button>
|
||||
];
|
||||
|
||||
const returnDisabled = (val: any) => {
|
||||
let dis = true;
|
||||
val == 0 ? dis = false : null;
|
||||
@ -255,16 +263,78 @@ const costConfig: React.FC<{}> = () => {
|
||||
}
|
||||
return (
|
||||
<Spin spinning={spin}>
|
||||
<ProTable
|
||||
columns={columns}
|
||||
dataSource={costData}
|
||||
search={false}
|
||||
bordered
|
||||
toolBarRender={() => tools}
|
||||
tableAlertRender={false}
|
||||
options={false}
|
||||
pagination={{ defaultPageSize: 20 }}
|
||||
/>
|
||||
<div className='pd1624 xsy-config-table'>
|
||||
<div style={{ height: 48, width: '100%', paddingBottom: '16px' }}>
|
||||
<Descriptions column={4} style={{ height: 32, float: 'left', width: '80%' }}>
|
||||
<Descriptions.Item label={`是否设置${showName.bsfdf}`} >
|
||||
<Radio.Group name="radiogroup" disabled={maxSendOut} onChange={(e) => {
|
||||
e.target.value == 0 ? setMax(null) : setMax('');
|
||||
setRadioMax(e.target.value)
|
||||
}} value={radioMax}>
|
||||
<Radio value={1}>是</Radio>
|
||||
<Radio value={0}>否</Radio>
|
||||
</Radio.Group>
|
||||
</Descriptions.Item>
|
||||
{radioMax == 1 ?
|
||||
<Descriptions.Item label={`${showName.bsfdf}(元)`} span={2}>
|
||||
<Input
|
||||
readOnly={maxSendOut}
|
||||
size="small"
|
||||
type="text"
|
||||
style={{ width: "150px", margin: '0px' }}
|
||||
value={max}
|
||||
onChange={(event) => {
|
||||
let val = event.target.value;
|
||||
!Number(val) || val.length > 11 ? val = val.substring(0, val.length - 1) : null;
|
||||
setMax(val);
|
||||
}}
|
||||
placeholder='小数点后最多2位'
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
: null
|
||||
}
|
||||
</Descriptions>
|
||||
<Button type="primary" hidden={allSend || btnAuthority(['ebtp-agency-project-manager', 'ebtp-purchase'])} style={{ float: 'right' }} onClick={async () => {
|
||||
setSpin(true);
|
||||
let pass = true;
|
||||
pass && await form.validateFields().catch((errorInfo) => {
|
||||
pass = false;
|
||||
message.error(errorInfo.errorFields[0].errors);
|
||||
})
|
||||
if (pass) {
|
||||
pass = checkEmpty(costData);
|
||||
} else {
|
||||
setSpin(false);
|
||||
}
|
||||
if (pass) {
|
||||
let maxAmount = {
|
||||
projectId: proId, amount: radioMax == 0 ? null : max,
|
||||
};
|
||||
let voList = costData;
|
||||
let allData = { maxAmount, voList, roomType: roomType }
|
||||
let success = await saveData(allData).then((res) => {
|
||||
setCostData([]);
|
||||
return res.success
|
||||
});
|
||||
if (success) {
|
||||
message.success('保存成功');
|
||||
}
|
||||
getCostData();
|
||||
} else {
|
||||
setSpin(false);
|
||||
}
|
||||
}}>保存</Button>
|
||||
</div>
|
||||
<ProTable
|
||||
columns={columns}
|
||||
dataSource={costData}
|
||||
search={false}
|
||||
// toolBarRender={() => tools}
|
||||
tableAlertRender={false}
|
||||
options={false}
|
||||
pagination={{ defaultPageSize: 20, showSizeChanger: false, }}
|
||||
/>
|
||||
</div>
|
||||
</Spin>
|
||||
)
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ import request from '@/utils/request';
|
||||
|
||||
//查询
|
||||
export async function getPage(params?: any) {
|
||||
console.log(params);
|
||||
return request(`/api/biz-service-ebtp-expenses/v1/bizbidexpenses/getlistByProjId/${params.proId}`);
|
||||
return request(`/api/biz-service-ebtp-expenses/v1/bizbidexpenses/getlistByProjId/${params.proId}?roomType=${params.roomType}`);
|
||||
};
|
||||
|
||||
//保存
|
||||
|
Reference in New Issue
Block a user