4.23 调接口

This commit is contained in:
jl-zhoujl2
2022-04-23 22:07:05 +08:00
parent 1ef607a57b
commit 94792e8b83

View File

@ -2,12 +2,12 @@ import React, { useEffect, useState } from 'react';
import logo from '@/images/opening/logo.svg';
import styles from './style.less';
import './style.less';
import { Affix, Anchor, BackTop, Button, Checkbox, Col, Collapse, DatePicker, Descriptions, Divider, Form, Input, InputNumber, Layout, message, Modal, PageHeader, Radio, Row, Select, Space, Spin, Tag, Timeline, Tooltip, Typography } from 'antd';
import { Anchor, BackTop, Button, Collapse, Descriptions, Form, Input, message, PageHeader, Space, Spin, Typography } from 'antd';
import { btnAuthority } from '@/utils/authority';
import { ArrowUpOutlined, CaretRightOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { ArrowUpOutlined, CaretRightOutlined } from '@ant-design/icons';
import { isNotEmpty } from '@/utils/CommonUtils';
import ExtendUpload from '@/utils/ExtendUpload';
import { getPublicData } from '../service';
import { getPublicData, savePublicData } from '../service';
const layout = {
labelCol: {
@ -22,59 +22,6 @@ const validateMessages = {
required: '请填写当前项内容',
};
const defaultData = {
data: {
"project": {
"id": "",
"projectName": "",
"projectScale": "",
"tenderContent": "",
"tenderCode": "",
"readonly": false
},
"sections": [
{
"id": "",
"projectId": "",
"bidSectBizNum": "",
"bidSectCode": "",
"bidSectName": "",
"suppliers": [
{
"id": "",
"projectId": "",
"sectionId": "",
"assessRoomId": "",
"assessRoomSort": 0,
"companyId": "",
"companyName": "",
"sort": "",
"quality": "",
"evaluationStatus": "",
"winCandidateQualification": "",
"timeLimit": 0,
"pmName": "",
"pmCode": "",
"pmCeritficates": ""
}
]
}
],
"anno": {
"id": "",
"annoNature": 0,
"hasCtpsp": false,
"ctpspFileid": "",
"status": 0
},
"tenderer": {
"id": "",
"code": "",
"name": ""
}
}
}
const PublicPlatform: React.FC<{}> = () => {
//loading
const [loading, setLoading] = useState<boolean>(false);
@ -84,6 +31,8 @@ const PublicPlatform: React.FC<{}> = () => {
const [initialData, setInitialData] = useState<any>({});
//只读状态readOnly 默认只读
const [readOnly, setReadOnly] = useState<boolean>(true);
//公示or公告 true-公示 false-公告
const [annoType, setAnnoType] = useState<boolean>(false);
const { TextArea } = Input;
const { Panel } = Collapse;
@ -144,8 +93,6 @@ const PublicPlatform: React.FC<{}> = () => {
</Form.Item>
)
}
//公示-标段(包)遍历
const sectionsRender = (sections: any[] | null, readonly: boolean) => {
if (isNotEmpty(sections)) {
@ -177,7 +124,6 @@ const PublicPlatform: React.FC<{}> = () => {
}
return null;
}
//公示-中标候选人遍历
const suppliersRender = (suppliers: any[] | null, readonly: boolean) => {
if (isNotEmpty(suppliers)) {
@ -213,38 +159,60 @@ const PublicPlatform: React.FC<{}> = () => {
//公告&公示信息
const annoRender = (anno: any, readonly: boolean) => {
if (isNotEmpty(anno)) {
return returnUpload("ctpspFileid", "PDF公示文件", readonly, anno.ctpspFileid, [{ required: !readonly }])
return returnUpload("ctpspFileId", "PDF公示文件", readonly, anno.ctpspFileId, [{ required: !readonly }])
}
return null;
}
//保存方法
const onSave = () => {
form.validateFields()
.then(values => {
console.log('success', values)
/*
values:
{
username: 'username',
password: 'password',
setLoading(true);
console.log('success', values);
const data = JSON.parse(JSON.stringify(initialData));//深拷贝
console.log('init', data);
//项目
if (isNotEmpty(data?.project)) {
data.project.projectScale = values.projectScale;
data.project.tenderContent = values.tenderContent;
}
*/
//投标人
if (isNotEmpty(data?.tenderer)) {
data.tenderer.name = values.name;
data.tenderer.code = values.code;
}
//公告&公示
if (isNotEmpty(data?.anno)) {
data.anno.ctpspFileId = values.ctpspFileId;
}
//标段 中标候选人公示
if (isNotEmpty(data?.sections)) {
for (const item of data?.sections) {
if (isNotEmpty(item.suppliers)) {
for (const val of item.suppliers) {
const formData: any = form.getFieldValue(val.id);
val.pmName = formData.pmName;
val.pmCode = formData.pmCode;
val.pmCeritficates = formData.pmCeritficates;
val.quality = formData.quality;
val.evaluationStatus = formData.evaluationStatus;
val.winCandidateQualification = formData.winCandidateQualification;
val.timeLimit = formData.timeLimit;
}
}
}
}
//保存数据
savePublicData(data).then(res => {
if (res?.code == 200 && res?.success) {
message.success('保存成功');
}
}).finally(() => {
setLoading(false);
})
})
.catch(errorInfo => {
console.log('error', errorInfo)
/*
errorInfo:
{
values: {
username: 'username',
password: 'password',
},
errorFields: [
{ name: ['password'], errors: ['Please input your Password!'] },
],
outOfDate: false,
}
*/
});
};
@ -260,15 +228,19 @@ const PublicPlatform: React.FC<{}> = () => {
};
useEffect(() => {
setLoading(true);
//获取公共服务平台数据
getPublicData('1516966126268026880').then(res => {
if (res?.code == 200) {
const data = res?.data
const data = res?.data;
setInitialData(data);
if (isNotEmpty(data.anno)) {
setReadOnly(data.anno.status != 1 && data.anno.status != 4)
setAnnoType(data.anno.annoNature === 201);
setReadOnly(data.anno.status != 1 && data.anno.status != 4);
}
}
}).finally(() => {
setLoading(false);
})
}, []);
@ -284,8 +256,8 @@ const PublicPlatform: React.FC<{}> = () => {
<PageHeader
title={
<Space>
<Button type='primary' key='save' onClick={() => onSave()}></Button>
<Button key='close' onClick={() => { }}></Button>
<Button type='primary' key='save' hidden={btnAuthority(['ebtp-agency-project-manager', 'ebtp-purchase'])} onClick={() => onSave()}></Button>
<Button key='close' onClick={() => window.close()}></Button>
</Space>
}
/>
@ -296,7 +268,7 @@ const PublicPlatform: React.FC<{}> = () => {
title={<Text strong></Text>}
/>
<div style={{ height: innerHeight - 180, overflowY: 'auto' }} ref={setContainer}>
<Form {...layout} form={form} scrollToFirstError name="public-platform" className="noticeFile-label" validateMessages={validateMessages}>
<Form {...layout} form={form} scrollToFirstError name="public-platform" validateMessages={validateMessages}>
<Collapse
defaultActiveKey={['1', '2', '3', '4']}
expandIcon={({ isActive }) => <CaretRightOutlined rotate={isActive ? 90 : 0} />}
@ -308,25 +280,18 @@ const PublicPlatform: React.FC<{}> = () => {
>
{projectRender(initialData?.project, initialData?.tenderer, readOnly)}
</Panel>
<Panel
{annoType && <Panel
header={<Text strong></Text>}
id="panel2"
key="2"
>
{sectionsRender(initialData?.sections, readOnly)}
</Panel>
</Panel>}
<Panel
header={<Text strong></Text>}
header={<Text strong>{annoType ? "公示信息" : "公告信息"}</Text>}
id="panel3"
key="3"
>
</Panel>
<Panel
header={<Text strong></Text>}
id="panel4"
key="4"
>
{annoRender(initialData?.anno, readOnly)}
</Panel>
</Collapse>
@ -338,9 +303,8 @@ const PublicPlatform: React.FC<{}> = () => {
{container && (
<Anchor getContainer={() => container} style={{ overflow: 'hidden' }} onClick={handleClick}>
<Link href="#panel1" title="项目信息" />
<Link href="#panel2" title="中标候选人信息" />
<Link href="#panel3" title="公告信息" />
<Link href="#panel4" title="公示信息" />
{annoType && <Link href="#panel2" title="中标候选人信息" />}
<Link href="#panel3" title={annoType ? "公示信息" : "公告信息"} />
</Anchor>
)}
</div>