diff --git a/src/pages/Tender/supplier/PurchaserResponseDocumentList/components/PurchaserResponseDocumentList.tsx b/src/pages/Tender/supplier/PurchaserResponseDocumentList/components/PurchaserResponseDocumentList.tsx new file mode 100644 index 0000000..3a8f6cb --- /dev/null +++ b/src/pages/Tender/supplier/PurchaserResponseDocumentList/components/PurchaserResponseDocumentList.tsx @@ -0,0 +1,407 @@ +import React, { useEffect, useRef, useState } from 'react'; +import '@/utils/lq.style.less'; +import { Button, Input, Form, Modal, Select, DatePicker, message } from 'antd'; +import ProTable from '@ant-design/pro-table'; +import { getProId } from '@/utils/session'; +import ExtendUpload from '@/utils/ExtendUpload'; +import moment from 'moment'; +import { getPageList, insertDocument, supplierUpdateDocument } from '../service'; +import { saveDateTimeFormatter } from "@/utils/DateUtils"; + +const { Option } = Select; +const { TextArea } = Input; + +const layoutForm = { + labelCol: { span: 6 }, + wrapperCol: { span: 18 }, +}; + +interface Supplier { + id: string; + name: string; +} + +interface State { + visible: boolean; + whetherReadonly: boolean; + supplierFileId: string; + supplierSupplementaryFileId: string; + suppliers: Supplier[]; + selectedSupplier: string; + replyDeadline: string; + subject: string; + content: string; + attachment: string; +} + +const PurchaserResponseDocumentList: React.FC = () => { + const [form] = Form.useForm(); + const actionRef = useRef(); + const [state, setState] = useState({ + visible: false, + whetherReadonly: false, + supplierFileId: '', + supplierSupplementaryFileId: '', + suppliers: [ + { id: '1', name: '杭州安恒信息技术股份有限公司' }, + { id: '2', name: '浪潮天元通信信息系统有限公司' }, + { id: '3', name: '河南软信科技有限公司' }, + { id: '4', name: '浙江省邮电工程建设有限公司' }, + { id: '5', name: '无锡市德科立光电子技术股份有限公司' }, + ], + selectedSupplier: '', + replyDeadline: '', + subject: '', + content: '', + attachment: '', + }); + const [isReplyMode, setIsReplyMode] = useState(false); // 新增:控制回复模式 + + useEffect(() => { + // 可以在这里添加初始化逻辑 + }, []); + + const columns = [ + { + title: '序号', + valueType: 'index', + }, + { + title: '主题', + dataIndex: 'subject', + }, + { + title: '指定供应商', + dataIndex: 'supplierName', + }, + { + title: '指定供应商id', + dataIndex: 'supplierId', + hideInTable: true // 隐藏该列 + }, + { + title: '内容', + dataIndex: 'content', + hideInTable: true // 隐藏该列 + }, + { + title: '应答截止时间', + dataIndex: 'replyDeadline', + }, + { + title: '状态', + dataIndex: 'status', + render: (_, record) => { + const statusMap = { + '1': '未回复', + '2': '未回复', + '3': '已回复', + }; + return statusMap[record.status] || '-'; // 默认显示未知状态,防止映射失败 + }, + }, + { + title: '操作', + width: 240, // 增加列宽以容纳三个按钮 + valueType: 'option', + render: (_, record) => ( +
{/* 使用Tailwind CSS类优化布局 */} + {record.status === '3' ? ( + + ) : ( + <> + + + )} +
+ ), + } + ]; + + const view = (data: any) => { + const selectedSupplierObj = state.suppliers.find( + (supplier) => supplier.id === data.supplierId + ); + + setState({ + ...state, + visible: true, + whetherReadonly: true, + selectedSupplier: data.supplierId, + replyDeadline: data.replyDeadline, + subject: data.subject, + content: data.content, + attachment: data.attachment, + }); + + form.setFieldsValue({ + ...data, + replyDeadline: moment(data.replyDeadline), + selectedSupplier: selectedSupplierObj + ? { value: selectedSupplierObj.id, label: selectedSupplierObj.name } + : undefined, + }); + + setIsReplyMode(false); // 查看模式下不启用回复模式 + }; + + const edit = (data: any) => { + const selectedSupplierObj = state.suppliers.find( + (supplier) => supplier.id === data.supplierId + ); + + setState({ + ...state, + visible: true, + whetherReadonly: false, + selectedSupplier: data.supplierId, + replyDeadline: data.replyDeadline, + subject: data.subject, + content: data.content, + attachment: data.attachment, + }); + + form.setFieldsValue({ + ...data, + replyDeadline: moment(data.replyDeadline), + selectedSupplier: selectedSupplierObj + ? { value: selectedSupplierObj.id, label: selectedSupplierObj.name } + : undefined, + }); + + setIsReplyMode(true); // 回复模式下启用 + }; + + const handleCancel = () => { + setState({ + ...state, + visible: false, + whetherReadonly: false, + }); + form.resetFields(); + setIsReplyMode(false); // 重置回复模式 + }; + + const handleSubmit = async () => { + try { + const values = await form.validateFields(); + + values.replyDeadline = saveDateTimeFormatter(moment(values.replyDeadline)); + if (values.selectedSupplier) { + values.supplierId = values.selectedSupplier.value; + values.supplierName = values.selectedSupplier.label; + delete values.selectedSupplier; + } + console.log(values); + if (values.id) { + await supplierUpdateDocument(values).then((r: any) => { + if (r?.code == 200) { + message.success('修改成功'); + } else { + message.error('修改失败'); + } + }); + } else { + await insertDocument(values).then((r: any) => { + if (r?.code == 200) { + message.success('新增成功'); + } else { + message.error('新增失败'); + } + }); + } + handleCancel(); + actionRef.current?.reload(); + } catch (error) { + console.log("错误失败!"); + console.error(error); + } + }; + + const onFinish = (values: any) => { + message.success('保存成功'); + setState({ + ...state, + visible: false, + }); + actionRef.current.reload(); + }; + + const handleAdd = () => { + setState({ + ...state, + visible: true, + whetherReadonly: false, + selectedSupplier: '', + replyDeadline: '', + subject: '', + content: '', + attachment: '', + }); + form.resetFields(); + setIsReplyMode(false); // 新增模式下不启用回复模式 + }; + + const createForm = () => { + const modalHeight = innerHeight * 96 / 100; + return ( + + 取消 + + ] : [ + , + + ]} + > +
+ + + + + + + + + + + + + + + +