EVAL_TYPE_MAP[s] || s || "",
+ },
+ { title: "报告完成日期", dataIndex: "planEndDate", width: 130 },
{
title: "项目状态",
dataIndex: "status",
width: 100,
fixed: "right",
- render: (s) => {s},
+ render: (phase) => {
+ const color =
+ phase === "延期"
+ ? "error"
+ : phase === "正常"
+ ? "success"
+ : undefined;
+ return {phase || "-"};
+ },
},
]}
pagination={false}
diff --git a/src/pages/Container/SafetyEvalBusiness/EvalProject/List/index.js b/src/pages/Container/SafetyEvalBusiness/EvalProject/List/index.js
index 0435cad..079758d 100644
--- a/src/pages/Container/SafetyEvalBusiness/EvalProject/List/index.js
+++ b/src/pages/Container/SafetyEvalBusiness/EvalProject/List/index.js
@@ -7,9 +7,12 @@ import {
Select,
Space,
Tag,
+ Modal,
+ message,
} from "antd";
import {
PlusOutlined,
+ DeleteOutlined,
} from "@ant-design/icons";
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
@@ -66,6 +69,18 @@ const EvalProject = (props) => {
getData(pagination);
};
+ const handleDelete = (record) => {
+ Modal.confirm({
+ title: "确认删除",
+ content: "确定要删除这个项目吗?",
+ onOk: async () => {
+ await props.evalProjectDelete({ data: [record.id] });
+ message.success("删除成功");
+ getData();
+ },
+ });
+ };
+
const columns = [
{ title: "序号", width: 60, render: (_, __, index) => index + 1 },
{
@@ -97,7 +112,7 @@ const EvalProject = (props) => {
},
{
title: "操作",
- width: 100,
+ width: 160,
fixed: "right",
render: (_, record) => (
@@ -108,6 +123,15 @@ const EvalProject = (props) => {
>
查看
+
),
},
diff --git a/src/pages/Container/SafetyEvalBusiness/EvalProject/ProjectDocLibrary/index.js b/src/pages/Container/SafetyEvalBusiness/EvalProject/ProjectDocLibrary/index.js
new file mode 100644
index 0000000..8d0c17b
--- /dev/null
+++ b/src/pages/Container/SafetyEvalBusiness/EvalProject/ProjectDocLibrary/index.js
@@ -0,0 +1,347 @@
+import React, { useState, useEffect } from "react";
+import {
+ Form,
+ Table,
+ Button,
+ Input,
+ Select,
+ Space,
+ Modal,
+ Upload,
+ message,
+ Flex,
+} from "antd";
+import { PlusOutlined, UploadOutlined } from "@ant-design/icons";
+import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
+import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
+import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper";
+import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd";
+import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace";
+import { MATERIAL_TYPE_OPTIONS, MATERIAL_TYPE_MAP } from "~/enumerate/constant";
+import { Connect } from "@cqsjjb/jjb-dva-runtime";
+import { tools } from "@cqsjjb/jjb-common-lib";
+
+import AttachmentUpload from "~/components/AttachmentUpload";
+
+const { router } = tools;
+
+const ProjectDocLibrary = (props) => {
+ const [searchForm] = Form.useForm();
+ const [uploadForm] = Form.useForm();
+ const [dataSource, setDataSource] = useState([]);
+ const [total, setTotal] = useState(0);
+ const [uploadModalOpen, setUploadModalOpen] = useState(false);
+ const [projectList, setProjectList] = useState([]);
+ const [docViewerVisible, setDocViewerVisible] = useState(false);
+ const [currentDocs, setCurrentDocs] = useState([]);
+
+ const { evalProjectDocLoading, evalProjectDocSaveLoading } = props.safetyEvalBusiness;
+
+ const getData = async (pagination) => {
+ const params = {
+ ...router.query,
+ current: pagination?.current || router.query.current || 1,
+ size: pagination?.size || router.query.size || 10,
+ };
+ const res = await props.evalProjectDocPage(params);
+ if (res?.success !== false) {
+ setDataSource(res?.data || []);
+ setTotal(res?.total || 0);
+ }
+ };
+
+ const getProjectList = async () => {
+ const res = await props.evalProjectPage({ current: 1, size: 999 });
+ if (res?.success !== false) {
+ setProjectList(res?.data || []);
+ }
+ };
+
+ useEffect(() => {
+ searchForm.setFieldsValue(router.query);
+ getData();
+ }, []);
+
+ const handleSearch = (values) => {
+ router.query = { ...router.query, ...values, current: 1, size: 10 };
+ getData();
+ };
+
+ const handleReset = (values) => {
+ searchForm.resetFields();
+ router.query = { ...values, current: 1, size: 10 };
+ getData();
+ };
+
+ const handlePageChange = (pagination) => {
+ router.query = {
+ ...router.query,
+ current: pagination.current,
+ size: pagination.pageSize,
+ };
+ getData(pagination);
+ };
+
+ const handleOpenUpload = () => {
+ uploadForm.resetFields();
+ getProjectList();
+ setUploadModalOpen(true);
+ };
+
+ const handleUploadSubmit = async () => {
+ const values = await uploadForm.validateFields();
+ await props.evalProjectDocSave({
+ projectId: values.projectId,
+ projectDocUrl: values.file.map((item) => ({
+ project_doc_url: item.url,
+ materialName: item.name,
+ materialType: values.materialType,
+ })),
+ });
+ message.success("上传成功");
+ setUploadModalOpen(false);
+ getData();
+ };
+
+ const columns = [
+ { title: "项目编号", dataIndex: "projectNo", width: 130 },
+ {
+ title: "项目名称",
+ dataIndex: "projectName",
+ ellipsis: true,
+ width: 200,
+ },
+ { title: "企业名称", dataIndex: "customerName", ellipsis: true, width: 180 },
+ { title: "评价类型", dataIndex: "evalTypeName", width: 120 },
+ {
+ title: "上传文档数量",
+ width: 110,
+ render: (_, record) => {
+ const map = record.projectDocUrlMap || {};
+ const count = Object.values(map).reduce((sum, arr) => sum + (arr?.length || 0), 0);
+ return {count};
+ },
+ },
+ {
+ title: "操作",
+ width: 100,
+ fixed: "right",
+ render: (_, record) => (
+
+ ),
+ },
+ ];
+
+ return (
+ } onClick={handleOpenUpload}>
+ 上传资料
+
+ }
+ >
+
+ 按项目归集企业和机构上传的资料,先选择项目,再查看项目文档。
+
+
+
+
+ ,
+
+
+ ,
+ ]}
+ onFinish={handleSearch}
+ onReset={handleReset}
+ style={{ marginBottom: 16 }}
+ />
+
+ `共 ${total} 条`,
+ }}
+ onChange={handlePageChange}
+ />
+
+ setUploadModalOpen(false)}
+ onOk={handleUploadSubmit}
+ confirmLoading={evalProjectDocSaveLoading}
+ width={700}
+ destroyOnHide={true}
+ >
+
+
+
+
+
+
+
+
+
+
+ setDocViewerVisible(false)}
+ footer={null}
+ width={700}
+ destroyOnHide={true}
+ >
+ {currentDocs.map(([type, docs]) => (
+
+
{MATERIAL_TYPE_MAP[type] || type}
+
(
+
+ ),
+ },
+ ]}
+ />
+
+ ))}
+ {currentDocs.length === 0 && (
+ 暂无文档
+ )}
+
+
+ );
+};
+
+/** 上传按钮字段组件 - 上传后回填 url */
+const UploadButtonField = ({ value, onChange }) => {
+ const [uploading, setUploading] = useState(false);
+
+ return (
+
+ );
+};
+
+const UploadButtonInner = ({ value, onChange, uploading, setUploading }) => {
+ return (
+
+ {value && (
+
+ {value.split("/").pop()}
+
+ )}
+ {
+ const ext = "." + file.name.split(".").pop().toLowerCase();
+ if (ext === ".gif") {
+ message.error("不支持 GIF 格式图片上传");
+ return Upload.LIST_IGNORE;
+ }
+ return true;
+ }}
+ onChange={(info) => {
+ if (info.file.status === "uploading") {
+ setUploading(true);
+ } else if (info.file.status === "done") {
+ setUploading(false);
+ const url = info.file.response?.data;
+ if (url) {
+ onChange?.(url);
+ }
+ } else if (info.file.status === "error") {
+ setUploading(false);
+ message.error("上传失败");
+ }
+ }}
+ >
+ } loading={uploading} size="small">
+ 选择文件
+
+
+
+ );
+};
+
+export default Connect(
+ [NS_SAFETY_EVAL_BUSINESS],
+ true,
+)(AntdTableFuncControl(ProjectDocLibrary));
\ No newline at end of file