bug修护
parent
c4861a858d
commit
8d08ce35fc
|
|
@ -13,7 +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 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";
|
||||||
|
|
@ -222,6 +221,12 @@ function AddModal({ open, staffOptions, requestAdd, onCancel, onSuccess }) {
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
|
if (!values.reportFileUrl?.length) {
|
||||||
|
form.setFields([
|
||||||
|
{ name: "reportFileUrl", errors: ["请上传离职通知报告"] },
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
values.applyTime =
|
values.applyTime =
|
||||||
values.applyTime?.format?.("YYYY-MM-DD HH:mm:ss") || values.applyTime;
|
values.applyTime?.format?.("YYYY-MM-DD HH:mm:ss") || values.applyTime;
|
||||||
|
|
@ -292,52 +297,12 @@ function AddModal({ open, staffOptions, requestAdd, onCancel, onSuccess }) {
|
||||||
<Form.Item name="remark" label="备注">
|
<Form.Item name="remark" label="备注">
|
||||||
<Input.TextArea rows={2} placeholder="请输入备注" />
|
<Input.TextArea rows={2} placeholder="请输入备注" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<AttachmentUpload name="reportFileUrl" label="离职通知报告" maxCount={1} accept=".pdf" />
|
<AttachmentUpload
|
||||||
<Form.Item
|
|
||||||
name="reportFileUrl"
|
name="reportFileUrl"
|
||||||
label="离职通知报告"
|
label="离职通知报告"
|
||||||
rules={[{ required: true, message: "请上传离职通知报告" }]}
|
maxCount={1}
|
||||||
>
|
accept=".pdf"
|
||||||
<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>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue