|
@@ -1,5 +1,13 @@
|
|
import { RootState } from "@/store";
|
|
import { RootState } from "@/store";
|
|
-import { Button, Checkbox, Form, Input, Popconfirm, Select } from "antd";
|
|
|
|
|
|
+import {
|
|
|
|
+ Button,
|
|
|
|
+ Checkbox,
|
|
|
|
+ Form,
|
|
|
|
+ Input,
|
|
|
|
+ Popconfirm,
|
|
|
|
+ Select,
|
|
|
|
+ Switch,
|
|
|
|
+} from "antd";
|
|
import React, {
|
|
import React, {
|
|
useCallback,
|
|
useCallback,
|
|
useEffect,
|
|
useEffect,
|
|
@@ -53,7 +61,7 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
if (id > 0) getInfoInAPIFu(id);
|
|
if (id > 0) getInfoInAPIFu(id);
|
|
else {
|
|
else {
|
|
setDirCode(Date.now() + "");
|
|
setDirCode(Date.now() + "");
|
|
- FormBoxRef.current.setFieldsValue({ topic: 3, display: 1 ,aaaaa:0});
|
|
|
|
|
|
+ FormBoxRef.current.setFieldsValue({ topic: 3, display: 1, aaaaa: 0 });
|
|
}
|
|
}
|
|
}, [getInfoInAPIFu, id]);
|
|
}, [getInfoInAPIFu, id]);
|
|
|
|
|
|
@@ -120,6 +128,7 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
fileName?: string;
|
|
fileName?: string;
|
|
filePath?: string;
|
|
filePath?: string;
|
|
id?: number;
|
|
id?: number;
|
|
|
|
+ done?: boolean;
|
|
};
|
|
};
|
|
|
|
|
|
// 上传附件的信息
|
|
// 上传附件的信息
|
|
@@ -130,6 +139,23 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
video: {} as FileListType,
|
|
video: {} as FileListType,
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // 上传附件图片的有无边框的选择
|
|
|
|
+ const upImgDoneFu = useCallback(
|
|
|
|
+ (val: boolean, id: number) => {
|
|
|
|
+ const newData = {
|
|
|
|
+ ...fileList,
|
|
|
|
+ img: fileList.img.map((v) => {
|
|
|
|
+ return {
|
|
|
|
+ ...v,
|
|
|
|
+ done: v.id === id ? val : v.done,
|
|
|
|
+ };
|
|
|
|
+ }),
|
|
|
|
+ };
|
|
|
|
+ setFileList(newData)
|
|
|
|
+ },
|
|
|
|
+ [fileList]
|
|
|
|
+ );
|
|
|
|
+
|
|
// 附件信息的校验
|
|
// 附件信息的校验
|
|
|
|
|
|
const fileCheckFu = useMemo(() => {
|
|
const fileCheckFu = useMemo(() => {
|
|
@@ -209,6 +235,7 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
const fd = new FormData();
|
|
const fd = new FormData();
|
|
// 把files添加进FormData对象(‘photo’为后端需要的字段)
|
|
// 把files添加进FormData对象(‘photo’为后端需要的字段)
|
|
fd.append("type", fileOneType);
|
|
fd.append("type", fileOneType);
|
|
|
|
+ fd.append("dirCode", dirCode);
|
|
fd.append("file", filesInfo);
|
|
fd.append("file", filesInfo);
|
|
|
|
|
|
e.target.value = "";
|
|
e.target.value = "";
|
|
@@ -225,7 +252,7 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
progressDom.style.width = "0%";
|
|
progressDom.style.width = "0%";
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- [fileOneType]
|
|
|
|
|
|
+ [dirCode, fileOneType]
|
|
);
|
|
);
|
|
|
|
|
|
// 附件图片的拖动
|
|
// 附件图片的拖动
|
|
@@ -272,8 +299,8 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
console.log("通过校验,点击确定");
|
|
console.log("通过校验,点击确定");
|
|
setCoverCheck(true);
|
|
setCoverCheck(true);
|
|
setTypeOk(true);
|
|
setTypeOk(true);
|
|
- if (typeCheck.length === 0) return MessageFu.warning("有表单不符号规则!");;
|
|
|
|
- if (cover === "") return MessageFu.warning("有表单不符号规则!");;
|
|
|
|
|
|
+ if (typeCheck.length === 0) return MessageFu.warning("有表单不符号规则!");
|
|
|
|
+ if (cover === "") return MessageFu.warning("有表单不符号规则!");
|
|
}, [cover, typeCheck.length]);
|
|
}, [cover, typeCheck.length]);
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -521,7 +548,7 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
<div className="fileBoxRow_r">
|
|
<div className="fileBoxRow_r">
|
|
<div className="upImgBox">
|
|
<div className="upImgBox">
|
|
<div
|
|
<div
|
|
- hidden={!!fileList.img.length && fileList.img.length >= 9}
|
|
|
|
|
|
+ hidden={!!fileList.img.length && fileList.img.length >= 30}
|
|
className="fileBoxRow_up"
|
|
className="fileBoxRow_up"
|
|
onClick={() => upFileFu("img")}
|
|
onClick={() => upFileFu("img")}
|
|
>
|
|
>
|
|
@@ -537,6 +564,17 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
onDragEnter={(e) => handleDragEnter(e, v)}
|
|
onDragEnter={(e) => handleDragEnter(e, v)}
|
|
onDragEnd={() => setDragImg(null)}
|
|
onDragEnd={() => setDragImg(null)}
|
|
>
|
|
>
|
|
|
|
+ {/* 选择有没有边框 */}
|
|
|
|
+ <div className="upImgDoneBox">
|
|
|
|
+ 边框:
|
|
|
|
+ <Switch
|
|
|
|
+ checkedChildren="有"
|
|
|
|
+ unCheckedChildren="无"
|
|
|
|
+ checked={v.done}
|
|
|
|
+ onChange={(val) => upImgDoneFu(val, v.id!)}
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+
|
|
{v.filePath ? (
|
|
{v.filePath ? (
|
|
<ImageLazy
|
|
<ImageLazy
|
|
noLook={dragImg ? true : false}
|
|
noLook={dragImg ? true : false}
|
|
@@ -679,7 +717,6 @@ function GoodsAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
请至少选择一个文件类型,并上传对应附件!
|
|
请至少选择一个文件类型,并上传对应附件!
|
|
</div>
|
|
</div>
|
|
|
|
|
|
-
|
|
|
|
<Form.Item
|
|
<Form.Item
|
|
label="展示状态"
|
|
label="展示状态"
|
|
name="display"
|
|
name="display"
|