2021-01-16 11:29:42 +08:00
|
|
|
|
import {BarsOutlined, UploadOutlined} from "@ant-design/icons"
|
2020-12-23 11:14:35 +08:00
|
|
|
|
import {Button, Card, Checkbox, Col, Collapse, Form, Input, message, Modal, Row, Spin, Upload} from "antd"
|
2021-01-16 11:29:42 +08:00
|
|
|
|
import React, {useEffect, useRef, useState} from "react"
|
2020-12-23 11:14:35 +08:00
|
|
|
|
import style from './style.less'
|
|
|
|
|
import {GetfileUsablePackage, GetfileMsg, creatfile, creatNotice} from "../service";
|
2021-01-16 11:29:42 +08:00
|
|
|
|
import Weboffice from "@/pages/webOffice/weboffice";
|
2020-12-23 11:14:35 +08:00
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
import {deleteFileObjId, getFileBidList, SnowflakeID} from "@/services/untilService";
|
2020-12-23 11:14:35 +08:00
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
interface BiddingDocumentProps {
|
|
|
|
|
modalVisible: boolean;
|
|
|
|
|
titleName: string;
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
type: string;
|
|
|
|
|
tpId: string;
|
|
|
|
|
pkId: string;
|
|
|
|
|
SX: () => void;
|
|
|
|
|
}
|
2020-12-23 11:14:35 +08:00
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
const layout = {
|
|
|
|
|
labelCol: {span: 7},
|
|
|
|
|
wrapperCol: {span: 10},
|
|
|
|
|
};
|
|
|
|
|
const BiddingDocument: React.FC<BiddingDocumentProps> = (props) => {
|
|
|
|
|
const {Panel} = Collapse;
|
|
|
|
|
const {titleName, modalVisible, onCancel, type, tpId, pkId, SX} = props;
|
|
|
|
|
const [TpPackageId, setTpPackageId] = useState<any[]>([]); //标包信息
|
|
|
|
|
const [spinning, setSping] = useState<boolean>();//加载遮罩
|
|
|
|
|
const [editInformation, setEditInformation] = useState<boolean>(false);//是否可编
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const [docFileCode, setDocFileCode] = useState<string>("");//文档id
|
|
|
|
|
const [docBtnName, setDocBtnName] = useState<any>("");//文档按钮文字
|
|
|
|
|
const [docReadOnly, setDocReadOnly] = useState<string>("false");//是否可编辑
|
|
|
|
|
const [docSaveBtn, setDocSaveBtn] = useState<string>("compact");//保存按钮是否展示
|
|
|
|
|
const [UploadList, setUploadList] = useState<any>(); //存upload列表
|
|
|
|
|
const [UploadID, setUploadID] = useState<any>(); //upload 业务id
|
2020-12-23 11:14:35 +08:00
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
/*weboffice 相关*/
|
|
|
|
|
const WebofficeRef = useRef<Weboffice>(null);
|
|
|
|
|
const onRef = (ref) => {
|
|
|
|
|
/* this.child= ref;*/
|
|
|
|
|
}
|
2020-12-23 11:14:35 +08:00
|
|
|
|
|
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
SnowflakeID().then(res => {
|
|
|
|
|
Int();
|
|
|
|
|
});
|
2020-12-23 11:14:35 +08:00
|
|
|
|
form.resetFields();//清除form中数据
|
2021-01-16 11:29:42 +08:00
|
|
|
|
}, [type, pkId]);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
UploadMethod();
|
|
|
|
|
}, [UploadID]);
|
2020-12-23 11:14:35 +08:00
|
|
|
|
const Int = () => {
|
|
|
|
|
setSping(true);
|
2021-01-16 11:29:42 +08:00
|
|
|
|
if (type == "cease") {
|
|
|
|
|
return;
|
|
|
|
|
} else if (type == "new") {//==========================================================新建
|
|
|
|
|
GetfileUsablePackage(tpId).then(res => {
|
|
|
|
|
if (res != null && res.message == "success") {
|
|
|
|
|
let thisData = [];
|
|
|
|
|
if (res.data.length == 0) {
|
|
|
|
|
message.warn("没有可关联的标包!")
|
|
|
|
|
onCancel();
|
|
|
|
|
}
|
2020-12-23 11:14:35 +08:00
|
|
|
|
for (const item of res.data) {
|
|
|
|
|
thisData.push({"label": item.bsName, "value": item.bsId})
|
|
|
|
|
}
|
2021-01-16 11:29:42 +08:00
|
|
|
|
SnowflakeID().then(res => {
|
|
|
|
|
setUploadID(res.id);
|
|
|
|
|
});
|
2020-12-23 11:14:35 +08:00
|
|
|
|
setTpPackageId(thisData);
|
2021-01-16 11:29:42 +08:00
|
|
|
|
setDocReadOnly("false")
|
|
|
|
|
setDocSaveBtn("compact")
|
|
|
|
|
setDocBtnName("新建")
|
|
|
|
|
} else {
|
|
|
|
|
message.error('程序出错,请您稍后再试:'+res.message);
|
2020-12-23 11:14:35 +08:00
|
|
|
|
onCancel();
|
|
|
|
|
}
|
|
|
|
|
setSping(false);
|
|
|
|
|
setEditInformation(false);//可编辑
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
} else if (type == "edit") {//=========================================================修改
|
|
|
|
|
let thisData1:any [];
|
|
|
|
|
GetfileUsablePackage(tpId).then(res => {
|
|
|
|
|
if (res != null && res.message == "success") {
|
|
|
|
|
let thisData2 = [];
|
2020-12-23 11:14:35 +08:00
|
|
|
|
for (const item of res.data) {
|
2021-01-16 11:29:42 +08:00
|
|
|
|
thisData2.push({"label": item.bsName, "value": item.bsId})
|
2020-12-23 11:14:35 +08:00
|
|
|
|
}
|
2021-01-16 11:29:42 +08:00
|
|
|
|
thisData1=thisData2;
|
|
|
|
|
} else {
|
|
|
|
|
message.error('程序出错,请您稍后再试:'+res.message);
|
2020-12-23 11:14:35 +08:00
|
|
|
|
onCancel();
|
|
|
|
|
}
|
2021-01-16 11:29:42 +08:00
|
|
|
|
GetfileMsg(pkId).then(res => {
|
|
|
|
|
if (res != null && res.message == "success") {
|
|
|
|
|
const data = res.data;
|
|
|
|
|
let defPak=[];
|
|
|
|
|
for (const item of data.sections) {
|
|
|
|
|
thisData1.push({"label": item.bsName, "value": item.bsId})
|
|
|
|
|
defPak.push(item.bsId);
|
|
|
|
|
}
|
|
|
|
|
setTpPackageId(thisData1);
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
"documentName": data.documentName,
|
|
|
|
|
"documentSetId": data.documentSetId,
|
|
|
|
|
"sectionIds":defPak,
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
setUploadID(data.documentSetId);
|
|
|
|
|
setSping(false);
|
|
|
|
|
setEditInformation(false);//可编辑
|
|
|
|
|
setDocFileCode(data.contentFileId);
|
|
|
|
|
setDocReadOnly("false")
|
|
|
|
|
setDocSaveBtn("compact")
|
|
|
|
|
setDocBtnName("编辑")
|
|
|
|
|
} else {
|
|
|
|
|
message.error('程序出错,请您稍后再试:'+res.message);
|
|
|
|
|
onCancel();
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-12-23 11:14:35 +08:00
|
|
|
|
});
|
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
} else if (type == "read") {//=========================================================查看
|
|
|
|
|
GetfileMsg(pkId).then(res => {
|
|
|
|
|
if (res != null && res.message == "success") {
|
2020-12-23 11:14:35 +08:00
|
|
|
|
const data = res.data;
|
2021-01-16 11:29:42 +08:00
|
|
|
|
let thisData1 = [];
|
|
|
|
|
let defPak=[];
|
|
|
|
|
for (const item of data.sections) {
|
|
|
|
|
thisData1.push({"label": item.bsName, "value": item.bsId})
|
|
|
|
|
defPak.push(item.bsId);
|
2020-12-23 11:14:35 +08:00
|
|
|
|
}
|
|
|
|
|
setTpPackageId(thisData1);
|
|
|
|
|
form.setFieldsValue({
|
2021-01-16 11:29:42 +08:00
|
|
|
|
"documentName": data.documentName,
|
|
|
|
|
"documentSetId": data.documentSetId,
|
|
|
|
|
"sectionIds":defPak,
|
2020-12-23 11:14:35 +08:00
|
|
|
|
},
|
|
|
|
|
)
|
2021-01-16 11:29:42 +08:00
|
|
|
|
|
|
|
|
|
|
2020-12-23 11:14:35 +08:00
|
|
|
|
setSping(false);
|
|
|
|
|
setEditInformation(true)
|
2021-01-16 11:29:42 +08:00
|
|
|
|
setDocFileCode(data.contentFileId);
|
|
|
|
|
setUploadID(data.documentSetId);
|
|
|
|
|
setDocReadOnly("true")
|
|
|
|
|
setDocSaveBtn("none")
|
|
|
|
|
setDocBtnName("查看")
|
|
|
|
|
} else {
|
|
|
|
|
message.error('程序出错,请您稍后再试:'+res.message);
|
2020-12-23 11:14:35 +08:00
|
|
|
|
onCancel();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-01-16 11:29:42 +08:00
|
|
|
|
/*upload*/
|
2020-12-23 11:14:35 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-01-16 11:29:42 +08:00
|
|
|
|
const onFinish = async (values: any) => {
|
|
|
|
|
form.validateFields().then(res => {
|
|
|
|
|
if (type == "new") {//==========================================================新建
|
|
|
|
|
if (WebofficeRef.current!.uninitialized == true) {//
|
|
|
|
|
message.warn("您未编辑office文件!");
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
if (WebofficeRef.current!.uploadDOCType != "success") {
|
|
|
|
|
message.warn("您未保存office文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (type == "edit") {//=========================================================修改
|
|
|
|
|
if (WebofficeRef.current!.uninitialized == false) {//
|
|
|
|
|
if (WebofficeRef.current!.uploadDOCType != "success") {
|
|
|
|
|
message.warn("您未保存office文件!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const packageMsg = [];
|
|
|
|
|
for (const item of TpPackageId) {//包数据
|
|
|
|
|
for (const item1 of form.getFieldValue("sectionIds"))
|
|
|
|
|
if (item.value == item1)
|
|
|
|
|
packageMsg.push({"bsId": item.value, "bsName": item.label})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fromData = {
|
|
|
|
|
"tpId": tpId,
|
|
|
|
|
"documentName": form.getFieldValue("documentName"),
|
|
|
|
|
"documentSetId": UploadID,
|
|
|
|
|
"sections": packageMsg,
|
|
|
|
|
"contentFileId": WebofficeRef.current!.DocfileCode,
|
|
|
|
|
"id": pkId
|
|
|
|
|
}
|
|
|
|
|
setSping(true);
|
|
|
|
|
creatfile(type, fromData).then(res => {
|
|
|
|
|
if (res != null && res.message == "success") {
|
|
|
|
|
message.success("成功");
|
|
|
|
|
setSping(true);
|
|
|
|
|
onCancel();
|
|
|
|
|
SX();
|
|
|
|
|
} else {
|
|
|
|
|
message.error("保存失败:"+res.message);
|
|
|
|
|
setSping(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}).catch(res => {
|
|
|
|
|
message.warn("您有未填写的选项!")
|
|
|
|
|
})
|
2020-12-23 11:14:35 +08:00
|
|
|
|
};
|
|
|
|
|
const renderFooter = () => {
|
2021-01-16 11:29:42 +08:00
|
|
|
|
if (type == "read") {
|
2020-12-23 11:14:35 +08:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2021-01-16 11:29:42 +08:00
|
|
|
|
<Button onClick={onCancel}>确认</Button>
|
2020-12-23 11:14:35 +08:00
|
|
|
|
</>
|
|
|
|
|
);
|
2021-01-16 11:29:42 +08:00
|
|
|
|
} else {
|
2020-12-23 11:14:35 +08:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2021-01-16 11:29:42 +08:00
|
|
|
|
<Button onClick={onFinish}>确认</Button>
|
2020-12-23 11:14:35 +08:00
|
|
|
|
<Button onClick={onCancel}>取消</Button>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-16 11:29:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const UploadMethod = () => {
|
|
|
|
|
getFileBidList(UploadID).then(res => {
|
|
|
|
|
setUploadList(res)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const UploadOnchange = async (file:any) => {
|
|
|
|
|
let fileMsg = file.file;
|
|
|
|
|
if (fileMsg.status === 'removed') {
|
|
|
|
|
await deleteFileObjId(fileMsg.uid)
|
|
|
|
|
setUploadList(file.fileList)
|
|
|
|
|
}
|
|
|
|
|
if (fileMsg.status === 'done') {
|
|
|
|
|
message.success("上传成功");
|
|
|
|
|
await UploadMethod();
|
|
|
|
|
} else if (fileMsg.status === 'error') {
|
|
|
|
|
message.error("上传失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
mask={true}
|
|
|
|
|
destroyOnClose
|
|
|
|
|
title={titleName}
|
|
|
|
|
visible={modalVisible}
|
|
|
|
|
onCancel={() => onCancel()}
|
|
|
|
|
className="返回"
|
|
|
|
|
width={1000}
|
|
|
|
|
bodyStyle={{padding: '32px 40px 48px', height: "600px", overflowY: 'auto'}}
|
|
|
|
|
footer={renderFooter()}
|
|
|
|
|
>
|
|
|
|
|
<Spin spinning={spinning}>
|
|
|
|
|
<Card>
|
|
|
|
|
<Form
|
|
|
|
|
{...layout}
|
|
|
|
|
name="basic"
|
|
|
|
|
form={form}
|
|
|
|
|
>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="文件名称"
|
|
|
|
|
name="documentName"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '当前项不可为空',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Input readOnly={editInformation}/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="关联标段"
|
|
|
|
|
name="sectionIds"
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '当前项不可为空',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Checkbox.Group
|
|
|
|
|
|
|
|
|
|
options={TpPackageId}
|
|
|
|
|
style={{width: '100%'}}
|
|
|
|
|
disabled={editInformation}
|
|
|
|
|
>
|
|
|
|
|
</Checkbox.Group>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label="招标文件附件"
|
|
|
|
|
name="documentSetId"
|
|
|
|
|
>
|
|
|
|
|
<div className={style.bidding}>
|
|
|
|
|
<div className="uploadTotal">
|
|
|
|
|
<Upload
|
|
|
|
|
{...UploadMethod}
|
|
|
|
|
action={'/api/core-service-ebtp-updownload/v1/attachment/upload'}
|
|
|
|
|
data={{"businessId": UploadID}}
|
|
|
|
|
fileList={UploadList}
|
|
|
|
|
onChange={UploadOnchange}
|
|
|
|
|
>
|
|
|
|
|
<Button type="primary" disabled={editInformation} className="upload"><UploadOutlined/>上传</Button>
|
|
|
|
|
</Upload>
|
|
|
|
|
<p className="uploadLabel">最大能上传100M文件!</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
<Collapse defaultActiveKey={['1']} ghost expandIcon={() => <BarsOutlined/>}>
|
|
|
|
|
<Panel header="招标文件内容" key="1">
|
|
|
|
|
<Card style={{textAlign: "center"}}>
|
|
|
|
|
<div>
|
|
|
|
|
{docBtnName != "" ?
|
|
|
|
|
<Weboffice memberBtnName={docBtnName} readonly={docReadOnly} btnStyle={docSaveBtn} btnName={"保存"}
|
|
|
|
|
DocfileCode={docFileCode} ref={WebofficeRef} onRef={onRef}/>
|
|
|
|
|
: null
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
</Panel>
|
|
|
|
|
</Collapse>
|
|
|
|
|
</Card>
|
|
|
|
|
</Spin>
|
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
)
|
2020-12-23 11:14:35 +08:00
|
|
|
|
}
|
|
|
|
|
export default BiddingDocument
|