import {BarsOutlined, UploadOutlined} from "@ant-design/icons"
import {
Button,
Card,
Checkbox,
Col,
Collapse,
DatePicker, Drawer,
Form, Image,
Input, List,
message,
Modal, Popover,
Radio,
Row,
Spin,
Upload
} from "antd"
import React, {useEffect, useRef, useState} from "react"
import style from './style.less'
import {GetNoticeMsg, GetNoticeUsablePackage, creatNotice, getChooseRoom,addNotice,getPageInfo} from '../service'
import moment from "moment";
import request from '@/utils/request';
import FileDown from '@/utils/Download';
import Weboffice from "@/pages/webOffice/weboffice";
import {existingProblem} from "@/pages/Evaluation/expert/ReviewResults/Jury/service";
import {commonMessage} from "@/utils/MessageUtils";
//
interface NoticeManageComponents {
modalVisible: boolean;
titleName: string;
onCancel: () => void;
type: string;
tpId: string;
pkId: string;
SX: () => void;
noticeTitle:String;
noticeContent:String;
noticeFile:String;
}
const layout = {
labelCol: {span: 7},
wrapperCol: {span: 10},
};
const NoticeManageComponents: React.FC = (props) => {
const {Panel} = Collapse;
const {titleName, modalVisible, onCancel, type, tpId, pkId, SX} = props;
const [form] = Form.useForm();
const [spinning, setSping] = useState();//加载遮罩
const [TpPackageId, setTpPackageId] = useState([]); //标包信息
const [editInformation, setEditInformation] = useState(false);//是否可编
const [editInformation4Change, setEditInformation4Change] = useState(false);//是否可编
const [annoNature, setAnnoNature] = useState(1);
const [TpPackageName, setTpPackageName] = useState("招标");
const [choiceHallType, setChoiceHallType] = useState(false);//选择开标大厅窗口状态
const [choiceHallData, setChoiceHallData] = useState([]);//选择开标大厅窗口状态
const [docFileCode, setDocFileCode] = useState("");//文档id
const [docBtnName, setDocBtnName] = useState();//文档按钮文字
const [docReadOnly, setDocReadOnly] = useState("false");//是否可编辑
const [docSaveBtn, setDocSaveBtn] = useState("compact");//保存按钮是否展示
/*weboffice 相关*/
const WebofficeRef = useRef(null);
const onRef = (ref) => {
/* this.child= ref;*/
}
/*拉取数据 beg*/
useEffect(() => {
Int();
form.resetFields();//清除form中数据
}, [pkId, type]);
const Int = () => {
setSping(true);
if (type == "cease") {
return;
} else if (type == "new") {//==========================================================新建
setSping(false);
setDocBtnName("新建");
setAnnoNature(1);//公告类型
setEditInformation(false);//可编辑
} else if (type == "edit" || type == "change") {//==========================================================编辑
getPageInfo(pkId).then(res => {
if (res != null && res.message == "success") {
const data = res.data
form.setFieldsValue({
"id":pkId,
"noticeTitle": data.noticeTitle,
"noticeContent": data.noticeContent,
"noticeFile": data.noticeFile,
});
setDocBtnName("编辑");
//setDocFileCode(data.contentFileId);
setSping(false);
} else {
onCancel();
message.error('程序出错,请您稍后再试');
}
}
);
setAnnoNature(1);//公告类型
setEditInformation(false);//可编辑
}
};
/*拉取数据 end*/
/*提交数据*/
const onFinish = async (data: any) => {
form.validateFields().then(res => {
const fromData = {
"noticeTitle": form.getFieldValue("noticeTitle"),
"noticeContent": form.getFieldValue("noticeContent"),
"noticeFile": form.getFieldValue("noticeFile"),
"id": pkId,
}
addNotice(fromData).then(res => {
if (res != null && res.message == "success") {
message.success("成功");
setSping(true);
onCancel();
SX();
} else {
message.error("失败");
setSping(true);
onCancel();
}
});
}).catch(res => {
message.warn("您有未填写的选项!")
});
}
/*提交数据*/
const onSave = async (data: any) => {
form.validateFields().then(res => {
const fromData = {
"noticeTitle": form.getFieldValue("noticeTitle"),
"noticeContent": form.getFieldValue("noticeContent"),
"noticeFile": form.getFieldValue("noticeFile"),
}
addNotice(fromData).then(res => {
if (res != null && res.message == "success") {
message.success("成功");
setSping(true);
onCancel();
SX();
} else {
message.error("失败");
setSping(true);
onCancel();
}
});
}).catch(res => {
message.warn("您有未填写的选项!")
});
}
const renderFooter = () => {
if (type == "read") {
return (
<>
>
);
} else if(type == "edit"){
return (
<>
>
);
}else if(type == "new"){
return (
<>
>
);
}
}
// const getChooseRoomList = (day: any) => {
// let param = "";
// if (day == "") {
// param = moment().format("yyyy-MM-DD");
// } else {
// param = day;
// }
// getChooseRoom(param).then(res => {
// if (res != null && res.message == "success") {
// setChoiceHallData(res.data)
// setChoiceHallType(true);
// } else {
// message.error('程序出错,请您稍后再试');
// }
// })
// }
// const DatePickeronChange = (date: any, dateString: any) => {
// getChooseRoomList(dateString);
// }
// const confirmChooseRoom = (data: any) => {
// setChoiceHallType(false);
// form.setFieldsValue({
// "openhallId": data.id,
// "openhallIdTime": data.openDate
// });
// }
return (
onCancel()}
width={1000}
bodyStyle={{padding: '32px 40px 48px', height: "600px", overflowY: 'auto'}}
footer={renderFooter()}
>
{/*
*/}
)
}
export default NoticeManageComponents