风险预警
parent
35aaacbb8d
commit
0d01e0ba41
|
|
@ -4,11 +4,89 @@ import { PlusOutlined } from "@ant-design/icons";
|
||||||
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 || "");
|
||||||
|
|
||||||
export default function AttachmentUpload({ name, label, disabled = false, maxCount, accept, extra ,rules, style }) {
|
function UploadWithAddon({ addon, disabled, maxCount, accept, fileList, onChange, id }) {
|
||||||
const [previewImage, setPreviewImage] = useState("");
|
const [previewImage, setPreviewImage] = useState("");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div style={{ display: "flex", alignItems: "flex-start", gap: 12 }}>
|
||||||
|
<Upload
|
||||||
|
id={id}
|
||||||
|
disabled={disabled}
|
||||||
|
listType="picture-card"
|
||||||
|
fileList={fileList}
|
||||||
|
onChange={onChange}
|
||||||
|
headers={{
|
||||||
|
token: sessionStorage.getItem("token"),
|
||||||
|
}}
|
||||||
|
maxCount={maxCount}
|
||||||
|
accept={accept}
|
||||||
|
action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`}
|
||||||
|
beforeUpload={(file) => {
|
||||||
|
if (!accept) return true;
|
||||||
|
const rules = accept.split(",").map((e) => e.trim().toLowerCase());
|
||||||
|
const ext = "." + file.name.split(".").pop().toLowerCase();
|
||||||
|
const matchExt = rules.includes(ext);
|
||||||
|
const matchMime = rules.some((r) => {
|
||||||
|
if (r.endsWith("/*")) {
|
||||||
|
const prefix = r.slice(0, -1);
|
||||||
|
return file.type && file.type.toLowerCase().startsWith(prefix);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (!matchExt && !matchMime) {
|
||||||
|
message.error(`仅支持 ${accept} 格式文件`);
|
||||||
|
return Upload.LIST_IGNORE;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}}
|
||||||
|
onPreview={(file) => {
|
||||||
|
if (isImage(file.url || file.thumbUrl)) {
|
||||||
|
setPreviewImage(file.url || file.thumbUrl);
|
||||||
|
} else {
|
||||||
|
window.open(file.url || file.thumbUrl);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<button style={{ border: 0, background: "none" }} type="button">
|
||||||
|
<PlusOutlined />
|
||||||
|
<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("");
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AttachmentUpload({
|
||||||
|
name,
|
||||||
|
label,
|
||||||
|
disabled = false,
|
||||||
|
maxCount,
|
||||||
|
accept,
|
||||||
|
extra,
|
||||||
|
rules,
|
||||||
|
style,
|
||||||
|
addon,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={name}
|
name={name}
|
||||||
label={label}
|
label={label}
|
||||||
|
|
@ -50,57 +128,12 @@ export default function AttachmentUpload({ name, label, disabled = false, maxCou
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Upload
|
<UploadWithAddon
|
||||||
|
addon={addon}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
listType="picture-card"
|
|
||||||
headers={{
|
|
||||||
token: sessionStorage.getItem('token')
|
|
||||||
}}
|
|
||||||
maxCount={maxCount}
|
maxCount={maxCount}
|
||||||
accept={accept}
|
accept={accept}
|
||||||
action={`${window.process.env.app.API_HOST}/safetyEval/file/upload`}
|
/>
|
||||||
beforeUpload={(file) => {
|
|
||||||
if (!accept) return true;
|
|
||||||
const rules = accept.split(",").map((e) => e.trim().toLowerCase());
|
|
||||||
const ext = "." + file.name.split(".").pop().toLowerCase();
|
|
||||||
const matchExt = rules.includes(ext);
|
|
||||||
const matchMime = rules.some((r) => {
|
|
||||||
if (r.endsWith("/*")) {
|
|
||||||
const prefix = r.slice(0, -1);
|
|
||||||
return file.type && file.type.toLowerCase().startsWith(prefix);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
if (!matchExt && !matchMime) {
|
|
||||||
message.error(`仅支持 ${accept} 格式文件`);
|
|
||||||
return Upload.LIST_IGNORE;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}}
|
|
||||||
onPreview={(file) => {
|
|
||||||
if (isImage(file.url || file.thumbUrl)) {
|
|
||||||
setPreviewImage(file.url || file.thumbUrl);
|
|
||||||
} else {
|
|
||||||
window.open(file.url || file.thumbUrl);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button style={{ border: 0, background: "none" }} type="button">
|
|
||||||
<PlusOutlined />
|
|
||||||
<div style={{ marginTop: 8 }}>上传附件</div>
|
|
||||||
</button>
|
|
||||||
</Upload>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{previewImage && <Image
|
|
||||||
style={{ display: "none" }}
|
|
||||||
preview={{
|
|
||||||
visible: !!previewImage,
|
|
||||||
src: previewImage,
|
|
||||||
onVisibleChange: (visible) => {
|
|
||||||
if (!visible) setPreviewImage("");
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Form, Button, Flex, Typography, Steps, Tag, Card, Table, message, Popover, Image } from "antd";
|
import { Form, Button, Flex, Typography, Steps, Tag, Card, Table, message, Popover, Image, Checkbox } from "antd";
|
||||||
import { CheckCircleFilled, DownloadOutlined } from "@ant-design/icons";
|
import { CheckCircleFilled, DownloadOutlined } from "@ant-design/icons";
|
||||||
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
import { Connect } from "@cqsjjb/jjb-dva-runtime";
|
||||||
import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace";
|
import { NS_SAFETY_EVAL_BUSINESS } from "~/enumerate/namespace";
|
||||||
|
|
@ -160,6 +160,17 @@ const RectificationNoticePanel = ({ readOnly }) => (
|
||||||
accept=".pdf,.doc,.docx,.xls,.xlsx,.png,.jpg,.jpeg"
|
accept=".pdf,.doc,.docx,.xls,.xlsx,.png,.jpg,.jpeg"
|
||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
extra="支持 PDF、Word、Excel、PNG、JPG 格式,最多上传 10 个文件"
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -235,7 +246,13 @@ const SurveyContent = ({ readOnly, ...props }) => {
|
||||||
STAGES.forEach((s) => {
|
STAGES.forEach((s) => {
|
||||||
values[s.key] = map[s.key] || [];
|
values[s.key] = map[s.key] || [];
|
||||||
});
|
});
|
||||||
form.setFieldsValue(values);
|
const noticeItem = (res?.data || []).find(
|
||||||
|
(item) => item.attachTypeCode === "RECTIFICATION_NOTICE",
|
||||||
|
);
|
||||||
|
form.setFieldsValue({
|
||||||
|
...values,
|
||||||
|
checkbox: Number(noticeItem?.checkbox) === 1 ? 1 : 0,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -306,6 +323,8 @@ const SurveyContent = ({ readOnly, ...props }) => {
|
||||||
projectId,
|
projectId,
|
||||||
attachTypeCode: s.key,
|
attachTypeCode: s.key,
|
||||||
fileUrl: JSON.stringify(fileList),
|
fileUrl: JSON.stringify(fileList),
|
||||||
|
checkbox:
|
||||||
|
s.key === "RECTIFICATION_NOTICE" ? Number(values.checkbox) || 0 : 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const res = await props.evalSurveySaveAttach(payload);
|
const res = await props.evalSurveySaveAttach(payload);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue