|
@@ -1,15 +1,15 @@
|
|
|
-import ImageLazy from "@/components/ImageLazy";
|
|
|
|
|
|
|
+// import ImageLazy from "@/components/ImageLazy";
|
|
|
import {
|
|
import {
|
|
|
getExhibitInfoAPI,
|
|
getExhibitInfoAPI,
|
|
|
- exhibitUploadAPI,
|
|
|
|
|
|
|
+ // exhibitUploadAPI,
|
|
|
exhibitionSaveAPI,
|
|
exhibitionSaveAPI,
|
|
|
} from "@/store/action/exhibit";
|
|
} from "@/store/action/exhibit";
|
|
|
import { ExhibitTableType } from "@/types/api/exhibit";
|
|
import { ExhibitTableType } from "@/types/api/exhibit";
|
|
|
import { Button, Form, Input, Modal, Popconfirm } from "antd";
|
|
import { Button, Form, Input, Modal, Popconfirm } from "antd";
|
|
|
import TextArea from "antd/es/input/TextArea";
|
|
import TextArea from "antd/es/input/TextArea";
|
|
|
-import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
|
|
-import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons";
|
|
|
|
|
-import classNames from "classnames";
|
|
|
|
|
|
|
+import React, { useCallback, useEffect, useRef } from "react";
|
|
|
|
|
+// import { PlusOutlined, CloseCircleOutlined } from "@ant-design/icons";
|
|
|
|
|
+// import classNames from "classnames";
|
|
|
import "./index.css";
|
|
import "./index.css";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
import { MessageFu } from "@/utils/message";
|
|
|
|
|
|
|
@@ -20,8 +20,8 @@ type Props = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 上传附件的进度条
|
|
// 上传附件的进度条
|
|
|
-const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
|
|
|
|
|
-const progressDom: any = document.querySelector("#progress");
|
|
|
|
|
|
|
+// const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
|
|
|
|
|
+// const progressDom: any = document.querySelector("#progress");
|
|
|
|
|
|
|
|
function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
// 设置表单初始数据(区分编辑和新增)
|
|
// 设置表单初始数据(区分编辑和新增)
|
|
@@ -33,7 +33,7 @@ function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
// 回显表单信息
|
|
// 回显表单信息
|
|
|
FormBoxRef.current.setFieldsValue(res.data);
|
|
FormBoxRef.current.setFieldsValue(res.data);
|
|
|
// 回显展馆封面
|
|
// 回显展馆封面
|
|
|
- setCover(res.data.thumb);
|
|
|
|
|
|
|
+ // setCover(res.data.thumb);
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -41,47 +41,47 @@ function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
}, [getInfoByIdFu, id]);
|
|
}, [getInfoByIdFu, id]);
|
|
|
|
|
|
|
|
// 封面图
|
|
// 封面图
|
|
|
- const [coverCheck, setCoverCheck] = useState(false);
|
|
|
|
|
- const [cover, setCover] = useState("");
|
|
|
|
|
|
|
+ // const [coverCheck, setCoverCheck] = useState(false);
|
|
|
|
|
+ // const [cover, setCover] = useState("");
|
|
|
|
|
|
|
|
- const myInput = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
|
+ // const myInput = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
|
|
// 上传封面图
|
|
// 上传封面图
|
|
|
- const handeUpPhoto = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
- if (e.target.files) {
|
|
|
|
|
- // 拿到files信息
|
|
|
|
|
- const filesInfo = e.target.files[0];
|
|
|
|
|
- // 校验格式
|
|
|
|
|
- const type = ["image/jpeg", "image/png"];
|
|
|
|
|
- if (!type.includes(filesInfo.type)) {
|
|
|
|
|
- e.target.value = "";
|
|
|
|
|
- return MessageFu.warning("只支持jpg、png格式!");
|
|
|
|
|
- }
|
|
|
|
|
- // 校验大小
|
|
|
|
|
- if (filesInfo.size > 20 * 1024 * 1024) {
|
|
|
|
|
- e.target.value = "";
|
|
|
|
|
- return MessageFu.warning("最大支持20M!");
|
|
|
|
|
- }
|
|
|
|
|
- // 创建FormData对象
|
|
|
|
|
- const fd = new FormData();
|
|
|
|
|
- // 把files添加进FormData对象(‘photo’为后端需要的字段)
|
|
|
|
|
- fd.append("file", filesInfo);
|
|
|
|
|
-
|
|
|
|
|
- e.target.value = "";
|
|
|
|
|
-
|
|
|
|
|
- const res: any = await exhibitUploadAPI(fd);
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- MessageFu.success("上传成功!");
|
|
|
|
|
- setCover(res.data.filePath);
|
|
|
|
|
- }
|
|
|
|
|
- UpAsyncLodingDom.style.opacity = 0;
|
|
|
|
|
- progressDom.style.width = "0%";
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ // const handeUpPhoto = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
+ // if (e.target.files) {
|
|
|
|
|
+ // // 拿到files信息
|
|
|
|
|
+ // const filesInfo = e.target.files[0];
|
|
|
|
|
+ // // 校验格式
|
|
|
|
|
+ // const type = ["image/jpeg", "image/png"];
|
|
|
|
|
+ // if (!type.includes(filesInfo.type)) {
|
|
|
|
|
+ // e.target.value = "";
|
|
|
|
|
+ // return MessageFu.warning("只支持jpg、png格式!");
|
|
|
|
|
+ // }
|
|
|
|
|
+ // // 校验大小
|
|
|
|
|
+ // if (filesInfo.size > 20 * 1024 * 1024) {
|
|
|
|
|
+ // e.target.value = "";
|
|
|
|
|
+ // return MessageFu.warning("最大支持20M!");
|
|
|
|
|
+ // }
|
|
|
|
|
+ // // 创建FormData对象
|
|
|
|
|
+ // const fd = new FormData();
|
|
|
|
|
+ // // 把files添加进FormData对象(‘photo’为后端需要的字段)
|
|
|
|
|
+ // fd.append("file", filesInfo);
|
|
|
|
|
+
|
|
|
|
|
+ // e.target.value = "";
|
|
|
|
|
+
|
|
|
|
|
+ // const res: any = await exhibitUploadAPI(fd);
|
|
|
|
|
+ // if (res.code === 0) {
|
|
|
|
|
+ // MessageFu.success("上传成功!");
|
|
|
|
|
+ // setCover(res.data.filePath);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // UpAsyncLodingDom.style.opacity = 0;
|
|
|
|
|
+ // progressDom.style.width = "0%";
|
|
|
|
|
+ // }
|
|
|
|
|
+ // };
|
|
|
|
|
|
|
|
// 没有通过校验
|
|
// 没有通过校验
|
|
|
const onFinishFailed = useCallback(() => {
|
|
const onFinishFailed = useCallback(() => {
|
|
|
- setCoverCheck(true);
|
|
|
|
|
|
|
+ // setCoverCheck(true);
|
|
|
// return MessageFu.warning("有表单不符号规则!");
|
|
// return MessageFu.warning("有表单不符号规则!");
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
@@ -89,13 +89,13 @@ function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
const onFinish = useCallback(
|
|
const onFinish = useCallback(
|
|
|
async (values: ExhibitTableType) => {
|
|
async (values: ExhibitTableType) => {
|
|
|
console.log("----通过校验", values);
|
|
console.log("----通过校验", values);
|
|
|
- setCoverCheck(true);
|
|
|
|
|
- if (cover === "") return;
|
|
|
|
|
|
|
+ // setCoverCheck(true);
|
|
|
|
|
+ // if (cover === "") return;
|
|
|
|
|
|
|
|
const obj: ExhibitTableType = {
|
|
const obj: ExhibitTableType = {
|
|
|
...values,
|
|
...values,
|
|
|
id: id,
|
|
id: id,
|
|
|
- thumb: cover,
|
|
|
|
|
|
|
+ // thumb: cover,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const res = await exhibitionSaveAPI(obj);
|
|
const res = await exhibitionSaveAPI(obj);
|
|
@@ -108,7 +108,7 @@ function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
closeFu();
|
|
closeFu();
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- [closeFu, cover, id, upList]
|
|
|
|
|
|
|
+ [closeFu, id, upList]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -148,7 +148,7 @@ function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
|
|
{/* -----上传封面图片 */}
|
|
{/* -----上传封面图片 */}
|
|
|
- <div className="upThumbBox">
|
|
|
|
|
|
|
+ {/* <div className="upThumbBox">
|
|
|
<input
|
|
<input
|
|
|
id="upInput"
|
|
id="upInput"
|
|
|
type="file"
|
|
type="file"
|
|
@@ -197,7 +197,7 @@ function ExhibitEdit({ id, closeFu, upList }: Props) {
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
|
+ </div> */}
|
|
|
|
|
|
|
|
<Form.Item
|
|
<Form.Item
|
|
|
label="联系电话"
|
|
label="联系电话"
|