Revert "风险预警"

This reverts commit 0d01e0ba41.
dev-tmp1
tangjie 2026-08-13 16:39:24 +08:00
parent 0d01e0ba41
commit d1e73094b0
2 changed files with 56 additions and 108 deletions

View File

@ -4,20 +4,57 @@ import { PlusOutlined } from "@ant-design/icons";
const isImage = (url) =>
/\.(png|jpe?g|gif|bmp|webp|svg)(\?.*)?$/i.test(url || "");
function UploadWithAddon({ addon, disabled, maxCount, accept, fileList, onChange, id }) {
export default function AttachmentUpload({ name, label, disabled = false, maxCount, accept, extra ,rules, style }) {
const [previewImage, setPreviewImage] = useState("");
return (
<>
<div style={{ display: "flex", alignItems: "flex-start", gap: 12 }}>
<Form.Item
name={name}
label={label}
extra={extra}
style={style}
valuePropName="fileList"
rules={rules}
getValueProps={(value) => {
if (Array.isArray(value)) {
return { fileList: value };
}
if (typeof value === "string" && value) {
try {
const parsed = JSON.parse(value);
if (Array.isArray(parsed)) {
return { fileList: parsed };
}
} catch {}
return {
fileList: value.split(",").map((item) => ({
url: item,
uid: item,
status: "done",
name: "附件",
})),
};
}
return { fileList: [] };
}}
getValueFromEvent={({ fileList }) => {
return (
fileList?.map((file) => ({
url: file.response?.data?.url || file.url,
uid: file.uid,
status: file.status,
name: file.name,
percent: file.percent,
})) || []
);
}}
>
<Upload
id={id}
disabled={disabled}
listType="picture-card"
fileList={fileList}
onChange={onChange}
headers={{
token: sessionStorage.getItem("token"),
token: sessionStorage.getItem('token')
}}
maxCount={maxCount}
accept={accept}
@ -53,87 +90,17 @@ function UploadWithAddon({ addon, disabled, maxCount, accept, fileList, onChange
<div style={{ marginTop: 8 }}>上传附件</div>
</button>
</Upload>
{addon ? (
<div style={{ height: 102, display: "flex", alignItems: "center" }}>
{addon}
</div>
) : null}
</div>
{previewImage && (
<Image
style={{ display: "none" }}
preview={{
visible: !!previewImage,
src: previewImage,
onVisibleChange: (visible) => {
if (!visible) setPreviewImage("");
},
}}
/>
)}
</Form.Item>
{previewImage && <Image
style={{ display: "none" }}
preview={{
visible: !!previewImage,
src: previewImage,
onVisibleChange: (visible) => {
if (!visible) setPreviewImage("");
},
}}
/>}
</>
);
}
export default function AttachmentUpload({
name,
label,
disabled = false,
maxCount,
accept,
extra,
rules,
style,
addon,
}) {
return (
<Form.Item
name={name}
label={label}
extra={extra}
style={style}
valuePropName="fileList"
rules={rules}
getValueProps={(value) => {
if (Array.isArray(value)) {
return { fileList: value };
}
if (typeof value === "string" && value) {
try {
const parsed = JSON.parse(value);
if (Array.isArray(parsed)) {
return { fileList: parsed };
}
} catch {}
return {
fileList: value.split(",").map((item) => ({
url: item,
uid: item,
status: "done",
name: "附件",
})),
};
}
return { fileList: [] };
}}
getValueFromEvent={({ fileList }) => {
return (
fileList?.map((file) => ({
url: file.response?.data?.url || file.url,
uid: file.uid,
status: file.status,
name: file.name,
percent: file.percent,
})) || []
);
}}
>
<UploadWithAddon
addon={addon}
disabled={disabled}
maxCount={maxCount}
accept={accept}
/>
</Form.Item>
);
}

View File

@ -1,5 +1,5 @@
import React, { useState, useEffect } from "react";
import { Form, Button, Flex, Typography, Steps, Tag, Card, Table, message, Popover, Image, Checkbox } from "antd";
import { Form, Button, Flex, Typography, Steps, Tag, Card, Table, message, Popover, Image } from "antd";
import { CheckCircleFilled, DownloadOutlined } from "@ant-design/icons";
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace";
@ -160,17 +160,6 @@ const RectificationNoticePanel = ({ readOnly }) => (
accept=".pdf,.doc,.docx,.xls,.xlsx,.png,.jpg,.jpeg"
disabled={readOnly}
extra="支持 PDF、Word、Excel、PNG、JPG 格式,最多上传 10 个文件"
addon={
<Form.Item
name="checkbox"
noStyle
valuePropName="checked"
getValueFromEvent={(e) => (e.target.checked ? 1 : 0)}
getValueProps={(v) => ({ checked: Number(v) === 1 })}
>
<Checkbox disabled={readOnly}>是否存在重大隐患</Checkbox>
</Form.Item>
}
/>
</div>
);
@ -246,13 +235,7 @@ const SurveyContent = ({ readOnly, ...props }) => {
STAGES.forEach((s) => {
values[s.key] = map[s.key] || [];
});
const noticeItem = (res?.data || []).find(
(item) => item.attachTypeCode === "RECTIFICATION_NOTICE",
);
form.setFieldsValue({
...values,
checkbox: Number(noticeItem?.checkbox) === 1 ? 1 : 0,
});
form.setFieldsValue(values);
}
};
@ -323,8 +306,6 @@ const SurveyContent = ({ readOnly, ...props }) => {
projectId,
attachTypeCode: s.key,
fileUrl: JSON.stringify(fileList),
checkbox:
s.key === "RECTIFICATION_NOTICE" ? Number(values.checkbox) || 0 : 0,
});
}
const res = await props.evalSurveySaveAttach(payload);