Compare commits
No commits in common. "7121437b4dbee03ba6ccfb355a23885cc0300ef1" and "2ef8e75130abeeccd39d71440270b12b040c952a" have entirely different histories.
7121437b4d
...
2ef8e75130
|
|
@ -10,7 +10,7 @@ module.exports = {
|
||||||
javaGitBranch: "<branch-name>",
|
javaGitBranch: "<branch-name>",
|
||||||
// 本地联调 safetyEval-service(context-path: /safetyEval,默认端口 8095)
|
// 本地联调 safetyEval-service(context-path: /safetyEval,默认端口 8095)
|
||||||
// 可通过环境变量覆盖: SAFETY_EVAL_API_HOST=http://192.168.x.x:8095
|
// 可通过环境变量覆盖: SAFETY_EVAL_API_HOST=http://192.168.x.x:8095
|
||||||
API_HOST: "http://127.0.0.1",
|
API_HOST: "http://192.168.0.152",
|
||||||
},
|
},
|
||||||
production: {
|
production: {
|
||||||
// 应用后端分支名称,部署上线需要
|
// 应用后端分支名称,部署上线需要
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -16,30 +16,7 @@ function parseAttachmentUrls(urls, defaultName = "附件.pdf") {
|
||||||
if (!urls) {
|
if (!urls) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const raw = String(urls).trim();
|
return String(urls)
|
||||||
|
|
||||||
// JSON 数组字符串:如 '[{"url":"...","uid":"...","name":"...","status":"done"}]'
|
|
||||||
if (raw.startsWith("[") && raw.endsWith("]")) {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(raw);
|
|
||||||
if (Array.isArray(parsed)) {
|
|
||||||
return parsed
|
|
||||||
.filter((item) => item?.url)
|
|
||||||
.map((item) => ({
|
|
||||||
name: item.name || `${defaultName.replace(".pdf", "")}1`,
|
|
||||||
fileName: item.fileName || item.name || `${defaultName.replace(".pdf", "")}1`,
|
|
||||||
url: item.url,
|
|
||||||
uid: item.uid || undefined,
|
|
||||||
status: item.status || "done",
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
} catch (_) {
|
|
||||||
// JSON 解析失败,回退到逗号分隔处理
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 旧格式:逗号分隔的 URL 字符串
|
|
||||||
return raw
|
|
||||||
.split(",")
|
.split(",")
|
||||||
.map((url) => url.trim())
|
.map((url) => url.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { apiPostDelete, safeAction } from "../enterpriseInfo/http";
|
|
||||||
|
|
||||||
export const staffChangeLogStaffList = declareRequest(
|
export const staffChangeLogStaffList = declareRequest(
|
||||||
"staffChangeLogLoading",
|
"staffChangeLogLoading",
|
||||||
|
|
@ -15,7 +14,7 @@ export const staffChangeLogList = declareRequest(
|
||||||
|
|
||||||
export const staffChangeLogRemove = declareRequest(
|
export const staffChangeLogRemove = declareRequest(
|
||||||
"staffChangeLogLoading",
|
"staffChangeLogLoading",
|
||||||
safeAction(async ({ id }) => apiPostDelete("/safetyEval/org-personnel-change/delete", id)),
|
"Post > @/safetyEval/org-personnel-change/delete",
|
||||||
);
|
);
|
||||||
|
|
||||||
export const staffResignationAudit = declareRequest(
|
export const staffResignationAudit = declareRequest(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { apiPost, apiPostDelete, safeAction } from "../enterpriseInfo/http";
|
|
||||||
|
|
||||||
export const staffInfoList = declareRequest(
|
export const staffInfoList = declareRequest(
|
||||||
"staffInfoLoading",
|
"staffInfoLoading",
|
||||||
|
|
@ -25,13 +24,10 @@ export const staffInfoEdit = declareRequest(
|
||||||
|
|
||||||
export const staffInfoRemove = declareRequest(
|
export const staffInfoRemove = declareRequest(
|
||||||
"staffInfoLoading",
|
"staffInfoLoading",
|
||||||
safeAction(async ({ id }) => apiPostDelete("/safetyEval/org-personnel/delete", id)),
|
"Post > @/safetyEval/org-personnel/delete",
|
||||||
);
|
);
|
||||||
|
|
||||||
export const staffInfoResetPassword = declareRequest(
|
export const staffInfoResetPassword = declareRequest(
|
||||||
"staffInfoLoading",
|
"staffInfoLoading",
|
||||||
safeAction(async ({ id }) => {
|
"Get > /safetyEval/org-personnel/reset-password",
|
||||||
const url = `/safetyEval/org-personnel/reset-password?id=${encodeURIComponent(id)}`;
|
|
||||||
return apiPost(url, {});
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
@ -1,24 +1,18 @@
|
||||||
import { Image, Modal } from "antd";
|
import { Image, Modal } from "antd";
|
||||||
|
|
||||||
function resolveUrl(raw) {
|
|
||||||
if (!raw) return "";
|
|
||||||
const u = String(raw);
|
|
||||||
if (/^https?:\/\//i.test(u)) return u;
|
|
||||||
const base = window.fileUrl || "";
|
|
||||||
return base ? `${base}${u}` : u;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getFilePreviewType(url = "", fileName = "") {
|
export function getFilePreviewType(url = "", fileName = "") {
|
||||||
const hint = `${fileName || ""} ${url || ""}`.toLowerCase();
|
const hint = `${fileName || ""} ${url || ""}`.toLowerCase();
|
||||||
if (/\.(jpe?g|png|gif|webp|bmp)(\?|#|$)/i.test(hint)) {
|
if (/\.(jpe?g|png|gif|webp|bmp)(\?|#|$)/i.test(hint)) {
|
||||||
return "image";
|
return "image";
|
||||||
}
|
}
|
||||||
return "other";
|
if (/\.pdf(\?|#|$)/i.test(hint)) {
|
||||||
|
return "pdf";
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FilePreviewContent({ url, fileName, style }) {
|
export function FilePreviewContent({ url, fileName, style }) {
|
||||||
const resolved = resolveUrl(url);
|
if (!url) {
|
||||||
if (!resolved) {
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
minHeight: 120,
|
minHeight: 120,
|
||||||
|
|
@ -35,16 +29,24 @@ export function FilePreviewContent({ url, fileName, style }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const type = getFilePreviewType(resolved, fileName);
|
const type = getFilePreviewType(url, fileName);
|
||||||
if (type === "image") {
|
if (type === "image") {
|
||||||
return <Image src={resolved} alt={fileName || "预览"} style={{ maxHeight: 480, ...style }} />;
|
return <Image src={url} alt={fileName || "预览"} style={{ maxHeight: 480, ...style }} />;
|
||||||
|
}
|
||||||
|
if (type === "pdf") {
|
||||||
|
return (
|
||||||
|
<iframe
|
||||||
|
title={fileName || "PDF 预览"}
|
||||||
|
src={url}
|
||||||
|
style={{ width: "100%", height: 480, border: "none", ...style }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
minHeight: 120,
|
minHeight: 120,
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
background: "#fafafa",
|
background: "#fafafa",
|
||||||
|
|
@ -52,8 +54,7 @@ export function FilePreviewContent({ url, fileName, style }) {
|
||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span style={{ marginBottom: 8 }}>此文件类型不支持内嵌预览</span>
|
暂不支持在线预览,请使用「新窗口打开」
|
||||||
<span>请点击下方「新窗口打开」按钮在浏览器中查看</span>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -66,9 +67,6 @@ export default function FilePreviewModal({
|
||||||
width = 720,
|
width = 720,
|
||||||
onCancel,
|
onCancel,
|
||||||
}) {
|
}) {
|
||||||
const resolved = resolveUrl(url);
|
|
||||||
const isImageFile = resolved && /\.(jpe?g|png|gif|webp|bmp)(\?|#|$)/i.test(resolved.toLowerCase());
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
open={open}
|
open={open}
|
||||||
|
|
@ -76,11 +74,11 @@ export default function FilePreviewModal({
|
||||||
title={title}
|
title={title}
|
||||||
width={width}
|
width={width}
|
||||||
cancelText="关闭"
|
cancelText="关闭"
|
||||||
okText={resolved ? (isImageFile ? "新窗口打开" : "重新打开") : "关闭"}
|
okText={url ? "新窗口打开" : "关闭"}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
onOk={() => {
|
onOk={() => {
|
||||||
if (resolved) {
|
if (url) {
|
||||||
window.open(resolved, "_blank");
|
window.open(url, "_blank");
|
||||||
}
|
}
|
||||||
onCancel?.();
|
onCancel?.();
|
||||||
}}
|
}}
|
||||||
|
|
@ -100,7 +98,7 @@ export default function FilePreviewModal({
|
||||||
{fileName}
|
{fileName}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<FilePreviewContent url={resolved} fileName={fileName} />
|
<FilePreviewContent url={url} fileName={fileName} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
||||||
|
|
@ -4,29 +4,20 @@ import { Button, Image } from "antd";
|
||||||
const isImage = (url) =>
|
const isImage = (url) =>
|
||||||
/\.(png|jpe?g|gif|bmp|webp|svg)(\?.*)?$/i.test(url || "");
|
/\.(png|jpe?g|gif|bmp|webp|svg)(\?.*)?$/i.test(url || "");
|
||||||
|
|
||||||
function resolveUrl(raw) {
|
|
||||||
if (!raw) return "";
|
|
||||||
const u = String(raw);
|
|
||||||
if (/^https?:\/\//i.test(u)) return u;
|
|
||||||
const base = window.fileUrl || "";
|
|
||||||
return base ? `${base}${u}` : u;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function PreviewUrlButton({ url, children = "预览", ...btnProps }) {
|
export default function PreviewUrlButton({ url, children = "预览", ...btnProps }) {
|
||||||
const [previewImage, setPreviewImage] = useState("");
|
const [previewImage, setPreviewImage] = useState("");
|
||||||
const resolved = resolveUrl(url);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
disabled={!resolved}
|
disabled={!url}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (isImage(resolved)) {
|
if (isImage(url)) {
|
||||||
setPreviewImage(resolved);
|
setPreviewImage(url);
|
||||||
} else {
|
} else {
|
||||||
window.open(resolved, "_blank");
|
window.open(url);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
{...btnProps}
|
{...btnProps}
|
||||||
|
|
|
||||||
|
|
@ -72,12 +72,7 @@ function PersonnelChangePage(props) {
|
||||||
okText: "是",
|
okText: "是",
|
||||||
cancelText: "否",
|
cancelText: "否",
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
const id = record.id ?? record.staffId;
|
const res = await props.staffInfoRemove?.({ id: record.staffId || record.id });
|
||||||
if (!id) {
|
|
||||||
message.error("缺少人员ID,无法删除");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const res = await props.staffInfoRemove?.({ id });
|
|
||||||
if (res?.success !== false) {
|
if (res?.success !== false) {
|
||||||
message.success("删除成功");
|
message.success("删除成功");
|
||||||
handleSearch();
|
handleSearch();
|
||||||
|
|
@ -102,10 +97,6 @@ function PersonnelChangePage(props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const openResignView = async (record) => {
|
const openResignView = async (record) => {
|
||||||
if (!record?.resignApplyId) {
|
|
||||||
message.warning("该人员暂无离职申请记录");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const res = await props.staffResignationInfo({ id: record.resignApplyId });
|
const res = await props.staffResignationInfo({ id: record.resignApplyId });
|
||||||
setResignInfo(res?.data || {});
|
setResignInfo(res?.data || {});
|
||||||
|
|
@ -192,7 +183,7 @@ function PersonnelChangePage(props) {
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<TableAction>
|
<TableAction>
|
||||||
<Button type="link" size="small" onClick={() => openResignView(record)}>
|
<Button type="link" size="small" onClick={() => openResignView(record)}>
|
||||||
查看离职状态
|
查看
|
||||||
</Button>
|
</Button>
|
||||||
{record.resignApplyId && Number(record.resignAuditStatus) === 0 && (
|
{record.resignApplyId && Number(record.resignAuditStatus) === 0 && (
|
||||||
<Button type="link" size="small" onClick={() => openResignAudit(record)}>
|
<Button type="link" size="small" onClick={() => openResignAudit(record)}>
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,12 @@ function StaffCertificatePage(props) {
|
||||||
<ControlWrapper.Input label="证书作业类别名称" placeholder="请输入证书作业类别名称" allowClear />
|
<ControlWrapper.Input label="证书作业类别名称" placeholder="请输入证书作业类别名称" allowClear />
|
||||||
</Form.Item>,
|
</Form.Item>,
|
||||||
]}
|
]}
|
||||||
onReset={(values) => {
|
onReset={() => {
|
||||||
router.query = { ...values, current: 1, size: 10 };
|
router.query = { ...router.query, current: 1, size: 10 };
|
||||||
handleSearch();
|
handleSearch();
|
||||||
}}
|
}}
|
||||||
onFinish={(values) => {
|
onFinish={() => {
|
||||||
router.query = { ...values, current: 1, size: 10 };
|
router.query = { ...router.query, current: 1, size: 10 };
|
||||||
handleSearch();
|
handleSearch();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { Button, DatePicker, Form, Image, Input, message, Modal, Row, Col, Select, Table, Upload } from "antd";
|
import {
|
||||||
import { UploadOutlined } from "@ant-design/icons";
|
Button,
|
||||||
|
DatePicker,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
message,
|
||||||
|
Modal,
|
||||||
|
Row,
|
||||||
|
Col,
|
||||||
|
Select,
|
||||||
|
Table,
|
||||||
|
} from "antd";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
||||||
|
|
@ -319,14 +329,10 @@ function StaffFormModal({
|
||||||
const [detailLoading, setDetailLoading] = useState(false);
|
const [detailLoading, setDetailLoading] = useState(false);
|
||||||
const [deptPositionOptions, setDeptPositionOptions] = useState([]);
|
const [deptPositionOptions, setDeptPositionOptions] = useState([]);
|
||||||
const [positionLoading, setPositionLoading] = useState(false);
|
const [positionLoading, setPositionLoading] = useState(false);
|
||||||
const [uploadFileList, setUploadFileList] = useState([]);
|
|
||||||
const [previewImage, setPreviewImage] = useState("");
|
|
||||||
const watchedDeptId = Form.useWatch("deptId", form);
|
const watchedDeptId = Form.useWatch("deptId", form);
|
||||||
const wasOpenRef = useRef(false);
|
const wasOpenRef = useRef(false);
|
||||||
const inflightDeptRef = useRef(null);
|
const inflightDeptRef = useRef(null);
|
||||||
|
|
||||||
const isImage = (url) => /\.(png|jpe?g|gif|bmp|webp|svg)(\?.*)?$/i.test(url || "");
|
|
||||||
|
|
||||||
const loadPositionsByDept = async (deptId) => {
|
const loadPositionsByDept = async (deptId) => {
|
||||||
const id = deptId;
|
const id = deptId;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
|
@ -363,8 +369,6 @@ function StaffFormModal({
|
||||||
if (!currentId) {
|
if (!currentId) {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
setDeptPositionOptions([]);
|
setDeptPositionOptions([]);
|
||||||
setUploadFileList([]);
|
|
||||||
setPreviewImage("");
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
registerEngineerFlag: 2,
|
registerEngineerFlag: 2,
|
||||||
});
|
});
|
||||||
|
|
@ -372,8 +376,6 @@ function StaffFormModal({
|
||||||
}
|
}
|
||||||
if (!open) {
|
if (!open) {
|
||||||
setDeptPositionOptions([]);
|
setDeptPositionOptions([]);
|
||||||
setUploadFileList([]);
|
|
||||||
setPreviewImage("");
|
|
||||||
}
|
}
|
||||||
wasOpenRef.current = open;
|
wasOpenRef.current = open;
|
||||||
}, [open, currentId, form]);
|
}, [open, currentId, form]);
|
||||||
|
|
@ -410,8 +412,6 @@ function StaffFormModal({
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
setDeptPositionOptions([]);
|
setDeptPositionOptions([]);
|
||||||
setUploadFileList([]);
|
|
||||||
setPreviewImage("");
|
|
||||||
onCancel();
|
onCancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -661,46 +661,6 @@ function StaffFormModal({
|
||||||
label="申报专业能力证明材料"
|
label="申报专业能力证明材料"
|
||||||
maxCount={5}
|
maxCount={5}
|
||||||
/>
|
/>
|
||||||
<Form.Item
|
|
||||||
name="proofMaterialUrl"
|
|
||||||
label="申报专业能力证明材料"
|
|
||||||
valuePropName="fileList"
|
|
||||||
getValueFromEvent={(e) => {
|
|
||||||
if (Array.isArray(e)) return e;
|
|
||||||
return e?.fileList;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Upload
|
|
||||||
action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`}
|
|
||||||
headers={{ token: sessionStorage.getItem("token") }}
|
|
||||||
maxCount={5}
|
|
||||||
fileList={uploadFileList}
|
|
||||||
onChange={(info) => {
|
|
||||||
setUploadFileList(info.fileList);
|
|
||||||
}}
|
|
||||||
onPreview={(file) => {
|
|
||||||
const src = file.url || file.response?.data?.url || file.thumbUrl;
|
|
||||||
if (!src) return;
|
|
||||||
if (isImage(src)) {
|
|
||||||
setPreviewImage(src);
|
|
||||||
} else {
|
|
||||||
window.open(src, "_blank");
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button icon={<UploadOutlined />}>上传文件</Button>
|
|
||||||
</Upload>
|
|
||||||
</Form.Item>
|
|
||||||
<Image
|
|
||||||
style={{ display: "none" }}
|
|
||||||
preview={{
|
|
||||||
visible: !!previewImage,
|
|
||||||
src: previewImage,
|
|
||||||
onVisibleChange: (visible) => {
|
|
||||||
if (!visible) setPreviewImage("");
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item name="currentAddress" label="现住地址">
|
<Form.Item name="currentAddress" label="现住地址">
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ import {
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
|
import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
|
||||||
import AttachmentUpload from "~/components/AttachmentUpload";
|
import AttachmentUpload from "~/components/AttachmentUpload";
|
||||||
import { UploadOutlined } from "@ant-design/icons";
|
|
||||||
import PreviewUrlButton from "~/components/PreviewUrlButton";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout";
|
||||||
import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
|
import SearchForm from "@cqsjjb/jjb-react-admin-component/SearchForm";
|
||||||
|
|
@ -293,51 +291,6 @@ function AddModal({ open, staffOptions, requestAdd, onCancel, onSuccess }) {
|
||||||
<Input.TextArea rows={2} placeholder="请输入备注" />
|
<Input.TextArea rows={2} placeholder="请输入备注" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<AttachmentUpload name="reportFileUrl" label="离职通知报告" maxCount={1} accept=".pdf" />
|
<AttachmentUpload name="reportFileUrl" label="离职通知报告" maxCount={1} accept=".pdf" />
|
||||||
<Form.Item
|
|
||||||
name="reportFileUrl"
|
|
||||||
label="离职通知报告"
|
|
||||||
rules={[{ required: true, message: "请上传离职通知报告" }]}
|
|
||||||
>
|
|
||||||
<Upload
|
|
||||||
action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`}
|
|
||||||
maxCount={1}
|
|
||||||
accept=".pdf"
|
|
||||||
showUploadList={{
|
|
||||||
showPreviewIcon: true,
|
|
||||||
showRemoveIcon: true,
|
|
||||||
showDownloadIcon: false,
|
|
||||||
}}
|
|
||||||
onPreview={() => {
|
|
||||||
const url = form.getFieldValue("reportFileUrl");
|
|
||||||
if (url) window.open(url);
|
|
||||||
}}
|
|
||||||
onChange={(info) => {
|
|
||||||
if (info.file.status === "uploading") {
|
|
||||||
setUploading(true);
|
|
||||||
} else {
|
|
||||||
setUploading(false);
|
|
||||||
if (info.file.status === "done") {
|
|
||||||
const data = info.file.response?.data;
|
|
||||||
if (data) {
|
|
||||||
const url = data.url || data;
|
|
||||||
form.setFieldsValue({ reportFileUrl: url });
|
|
||||||
} else {
|
|
||||||
message.error("上传失败,未获取到文件地址");
|
|
||||||
}
|
|
||||||
} else if (info.file.status === "error") {
|
|
||||||
message.error(`${info.file.name} 上传失败`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onRemove={() => {
|
|
||||||
form.setFieldsValue({ reportFileUrl: "" });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button loading={uploading} icon={<UploadOutlined />}>
|
|
||||||
上传文件
|
|
||||||
</Button>
|
|
||||||
</Upload>
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|
@ -393,13 +346,6 @@ function ViewModal({ open, currentId, requestDetail, onCancel }) {
|
||||||
<a href={info.reportFileUrl} target="_blank" rel="noopener noreferrer">
|
<a href={info.reportFileUrl} target="_blank" rel="noopener noreferrer">
|
||||||
查看
|
查看
|
||||||
</a>
|
</a>
|
||||||
{info.reportFileUrl ? (
|
|
||||||
<PreviewUrlButton url={info.reportFileUrl}>
|
|
||||||
查看文件
|
|
||||||
</PreviewUrlButton>
|
|
||||||
) : (
|
|
||||||
"-"
|
|
||||||
)}
|
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
||||||
|
|
@ -30,18 +30,13 @@ const menuItems = [
|
||||||
icon: <DashboardOutlined />,
|
icon: <DashboardOutlined />,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
key: "/safetyEval/container/Institution/Dashboard",
|
key: "/safetyEval/container/Supervision/Dashboard",
|
||||||
label: "机构端首页",
|
label: "机构端首页",
|
||||||
icon: <DashboardOutlined />,
|
icon: <DashboardOutlined />,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: "/safetyEval/container/Supervision/Dashboard",
|
|
||||||
label: "监管端首页",
|
|
||||||
icon: <PieChartOutlined />,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: "/safetyEval/container/Supervision/Cockpit",
|
key: "/safetyEval/container/Supervision/Cockpit",
|
||||||
label: "监管端驾驶舱",
|
label: "监管端首页",
|
||||||
icon: <PieChartOutlined />,
|
icon: <PieChartOutlined />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,6 @@ function parseQueryId(location) {
|
||||||
return new URLSearchParams(search).get("id");
|
return new URLSearchParams(search).get("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolvePreviewUrl(raw) {
|
|
||||||
if (!raw) return "";
|
|
||||||
const u = String(raw);
|
|
||||||
if (/^https?:\/\//i.test(u)) return u;
|
|
||||||
const base = window.fileUrl || "";
|
|
||||||
return base ? `${base}${u}` : u;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isImageUrl(url) {
|
|
||||||
return /\.(jpe?g|png|gif|webp|bmp)(\?|#|$)/i.test(String(url || "").toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
function MaterialsTab({ materialGroups, loading, onPreview }) {
|
function MaterialsTab({ materialGroups, loading, onPreview }) {
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Spin />;
|
return <Spin />;
|
||||||
|
|
@ -236,18 +224,7 @@ function RegisteredOrgDetailPage(props) {
|
||||||
<MaterialsTab
|
<MaterialsTab
|
||||||
materialGroups={materialGroups}
|
materialGroups={materialGroups}
|
||||||
loading={extrasLoading}
|
loading={extrasLoading}
|
||||||
onPreview={(record) => {
|
onPreview={setFilePreview}
|
||||||
const url = resolvePreviewUrl(record?.previewUrl);
|
|
||||||
if (!url) {
|
|
||||||
message.warning("该材料暂无可预览的附件");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isImageUrl(url)) {
|
|
||||||
setFilePreview(record);
|
|
||||||
} else {
|
|
||||||
window.open(url, "_blank");
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -275,7 +252,7 @@ function RegisteredOrgDetailPage(props) {
|
||||||
open={!!filePreview}
|
open={!!filePreview}
|
||||||
title="文件预览"
|
title="文件预览"
|
||||||
fileName={filePreview?.name}
|
fileName={filePreview?.name}
|
||||||
url={resolvePreviewUrl(filePreview?.previewUrl)}
|
url={filePreview?.previewUrl}
|
||||||
onCancel={() => setFilePreview(null)}
|
onCancel={() => setFilePreview(null)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,53 +11,23 @@ export function resolveUploadFileId(_files) {
|
||||||
return DEFAULT_UPLOAD_FILE_URL;
|
return DEFAULT_UPLOAD_FILE_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 多附件:序列化为 JSON 数组字符串,与后端格式保持一致 */
|
/** 多附件:逗号拼接 URL */
|
||||||
export function resolveUploadFileIds(files) {
|
export function resolveUploadFileIds(files) {
|
||||||
if (!files?.length) {
|
if (!files?.length) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const valid = files
|
const urls = files.map((file) => file?.url || file?.response?.url).filter(Boolean);
|
||||||
.filter((file) => file?.url)
|
if (!urls.length) {
|
||||||
.map((file) => ({
|
|
||||||
url: file.url,
|
|
||||||
uid: file.uid || undefined,
|
|
||||||
name: file.name || file.fileName || "附件",
|
|
||||||
status: file.status || "done",
|
|
||||||
}));
|
|
||||||
if (!valid.length) {
|
|
||||||
return DEFAULT_UPLOAD_FILE_URL;
|
return DEFAULT_UPLOAD_FILE_URL;
|
||||||
}
|
}
|
||||||
return JSON.stringify(valid);
|
return urls.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseUploadFileList(urls, defaultName = "附件.pdf") {
|
export function parseUploadFileList(urls, defaultName = "附件.pdf") {
|
||||||
if (!urls) {
|
if (!urls) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const raw = String(urls).trim();
|
return String(urls)
|
||||||
|
|
||||||
// JSON 数组字符串:如 '[{"url":"...","uid":"...","name":"...","status":"done"}]'
|
|
||||||
if (raw.startsWith("[") && raw.endsWith("]")) {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(raw);
|
|
||||||
if (Array.isArray(parsed)) {
|
|
||||||
return parsed
|
|
||||||
.filter((item) => item?.url)
|
|
||||||
.map((item) => ({
|
|
||||||
name: item.name || `${defaultName.replace(".pdf", "")}1`,
|
|
||||||
fileName: item.fileName || item.name || `${defaultName.replace(".pdf", "")}1`,
|
|
||||||
url: item.url,
|
|
||||||
uid: item.uid || undefined,
|
|
||||||
status: item.status || "done",
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
} catch (_) {
|
|
||||||
// JSON 解析失败,回退到逗号分隔处理
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 旧格式:逗号分隔的 URL 字符串
|
|
||||||
return raw
|
|
||||||
.split(",")
|
.split(",")
|
||||||
.map((url) => url.trim())
|
.map((url) => url.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue