diff --git a/src/components/UploadButton/index.js b/src/components/UploadButton/index.js new file mode 100644 index 0000000..024bdbb --- /dev/null +++ b/src/components/UploadButton/index.js @@ -0,0 +1,43 @@ +import { Button, Upload } from "antd"; +import { useState } from "react"; + +/** + * 上传按钮组件 + * @param {Object} props + * @param {string} [props.action] - 上传地址,默认从环境变量获取 + * @param {function} [props.onSuccess] - 上传成功回调 (response) => void + * @param {Object} [props.uploadProps] - 透传给 antd Upload 的其他属性 + * @param {string} [props.children] - 按钮文字,默认"上传" + * @param {Object} [props.buttonProps] - 透传给 antd Button 的其他属性 + */ +export default function UploadButton({ + action = `${window.process.env.app.API_HOST}/safetyEval/file/upload`, + onSuccess, + uploadProps, + children = "上传", + buttonProps, +}) { + const [uploading, setUploading] = useState(false); + + return ( + { + if (info.file.status === "uploading") { + setUploading(true); + } else if (info.file.status === "done") { + setUploading(false); + onSuccess?.(info.file.response?.data, info.file); + } else if (info.file.status === "error") { + setUploading(false); + } + }} + {...uploadProps} + > + + + ); +} \ No newline at end of file diff --git a/src/pages/Container/Layout/index.jsx b/src/pages/Container/Layout/index.jsx index 8b18bc5..5c4b0a6 100644 --- a/src/pages/Container/Layout/index.jsx +++ b/src/pages/Container/Layout/index.jsx @@ -42,7 +42,7 @@ function saveState(tabs, activeKey) { sessionStorage.setItem(ACTIVE_KEY, activeKey || ""); } -export default function SimulatedLayout({ children }) { +export default function SimulatedLayout({ children, history }) { const [collapsed, setCollapsed] = useState(false); const [state, setState] = useState(loadState); const currentPath = window.location.pathname; diff --git a/src/pages/Container/Layout/menuConfig.js b/src/pages/Container/Layout/menuConfig.js index 2391ec3..d0c1fab 100644 --- a/src/pages/Container/Layout/menuConfig.js +++ b/src/pages/Container/Layout/menuConfig.js @@ -1,4 +1,4 @@ -import React from "react"; +import React from "react"; import { DashboardOutlined, FileProtectOutlined, @@ -29,6 +29,16 @@ const menuItems = [ label: "监管端", icon: , children: [ + { + key: "/safetyEval/container/Supervision/Dashboard", + label: "机构端首页", + icon: , + }, + { + key: "/safetyEval/container/Supervision/Cockpit", + label: "监管端首页", + icon: , + }, { key: "/safetyEval/container/Supervision/BasicInfo", label: "基础信息管理", diff --git a/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx b/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx index ebdd776..17625b7 100644 --- a/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx +++ b/src/pages/Container/QualApplication/FilingForm/components/BasicInfoStep.jsx @@ -82,7 +82,11 @@ export default function BasicInfoStep({ form, disabled }) { - + @@ -118,7 +122,11 @@ export default function BasicInfoStep({ form, disabled }) { - + diff --git a/src/pages/Container/QualApplication/FilingForm/components/EquipmentStep.jsx b/src/pages/Container/QualApplication/FilingForm/components/EquipmentStep.jsx index 6626270..9ee9ca1 100644 --- a/src/pages/Container/QualApplication/FilingForm/components/EquipmentStep.jsx +++ b/src/pages/Container/QualApplication/FilingForm/components/EquipmentStep.jsx @@ -1,6 +1,7 @@ -import { Button, Image, Space, Table, Upload } from "antd"; +import { Button, Image, Space, Table } from "antd"; import { useState } from "react"; +import UploadButton from "~/components/UploadButton"; import OrgEquipmentSelectModal from "./OrgEquipmentSelectModal"; export default function EquipmentStep({ @@ -55,20 +56,10 @@ export default function EquipmentStep({ ) : ( !disabled && ( - { - if (info.file.status === "done") { - const data = info.file.response?.data; - if (data) { - onUploadCalibration?.(record, data); - } - } - }} - > - - + onUploadCalibration?.(record, data)} + buttonProps={{ children: "上传报告" }} + /> ) )} diff --git a/src/pages/Container/QualApplication/FilingForm/components/MaterialStep.jsx b/src/pages/Container/QualApplication/FilingForm/components/MaterialStep.jsx index 4e024ad..f610234 100644 --- a/src/pages/Container/QualApplication/FilingForm/components/MaterialStep.jsx +++ b/src/pages/Container/QualApplication/FilingForm/components/MaterialStep.jsx @@ -1,5 +1,6 @@ -import { Button, Image, Space, Table, Tag, Upload } from "antd"; +import { Button, Image, Space, Table, Tag } from "antd"; import { useState } from "react"; +import UploadButton from "~/components/UploadButton"; export default function MaterialStep({ materials = [], @@ -59,20 +60,9 @@ export default function MaterialStep({ ) : ( !disabled && ( - { - if (info.file.status === "done") { - const data = info.file.response?.data; - if (data) { - onUpload?.(record, data); - } - } - }} - > - - + onUpload?.(record, data)} + /> ) )} diff --git a/src/pages/Container/QualApplication/FilingForm/index.js b/src/pages/Container/QualApplication/FilingForm/index.js index cb63da9..7130c10 100644 --- a/src/pages/Container/QualApplication/FilingForm/index.js +++ b/src/pages/Container/QualApplication/FilingForm/index.js @@ -357,21 +357,7 @@ function FilingFormPage(props) { title={MODE_TITLE[mode] || "资质备案表单"} history={props.history} previous - extra={ - - } + >