|
@@ -1,28 +1,31 @@
|
|
import { MessageFu } from "@/utils/message";
|
|
import { MessageFu } from "@/utils/message";
|
|
-import { Button, Form, Input, Modal, Popconfirm, Radio } from "antd";
|
|
|
|
|
|
+import { Button, Form, Input, Popconfirm, Radio } from "antd";
|
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
import { PlusOutlined, CloseOutlined } from "@ant-design/icons";
|
|
import { PlusOutlined, CloseOutlined } from "@ant-design/icons";
|
|
import classNames from "classnames";
|
|
import classNames from "classnames";
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
|
|
|
|
import ImageLazy from "@/components/ImageLazy";
|
|
import ImageLazy from "@/components/ImageLazy";
|
|
|
|
+import { ImgListType } from "@/types";
|
|
|
|
+import WallLook from "../WallLook";
|
|
type Props = {
|
|
type Props = {
|
|
id: number;
|
|
id: number;
|
|
closeMoalFu: () => void;
|
|
closeMoalFu: () => void;
|
|
- upListFu: () => void;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-type ImgListType = {
|
|
|
|
- fileName?: string;
|
|
|
|
- filePath?: string;
|
|
|
|
- id?: number;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
// 上传附件的进度条
|
|
// 上传附件的进度条
|
|
const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
|
|
const UpAsyncLodingDom: any = document.querySelector("#UpAsyncLoding");
|
|
const progressDom: any = document.querySelector("#progress");
|
|
const progressDom: any = document.querySelector("#progress");
|
|
|
|
|
|
-function WallAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
|
|
|
|
+function WallAdd({ id, closeMoalFu }: Props) {
|
|
|
|
+ const getInfoFu = useCallback((id: number) => {
|
|
|
|
+ console.log("是编辑", id);
|
|
|
|
+ }, []);
|
|
|
|
+
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (id > 0) getInfoFu(id);
|
|
|
|
+ }, [getInfoFu, id]);
|
|
|
|
+
|
|
// 表单的ref
|
|
// 表单的ref
|
|
const FormBoxRef = useRef<any>({});
|
|
const FormBoxRef = useRef<any>({});
|
|
// 上传封面图的ref
|
|
// 上传封面图的ref
|
|
@@ -139,145 +142,152 @@ function WallAdd({ id, closeMoalFu, upListFu }: Props) {
|
|
if (imgList.length < imgNum) return;
|
|
if (imgList.length < imgNum) return;
|
|
}, [imgList.length, imgNum]);
|
|
}, [imgList.length, imgNum]);
|
|
|
|
|
|
|
|
+ // 点击预览效果
|
|
|
|
+ const [lookImg, setLookImg] = useState(false);
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<div className={styles.WallAdd}>
|
|
<div className={styles.WallAdd}>
|
|
- <div className="WallTableTitle">
|
|
|
|
- <div className="txt">{id > 0 ? "编辑海报" : "新增海报"}</div>
|
|
|
|
- <div className="main">
|
|
|
|
- <Form
|
|
|
|
- ref={FormBoxRef}
|
|
|
|
- name="basic"
|
|
|
|
- labelCol={{ span: 3 }}
|
|
|
|
- onFinish={onFinish}
|
|
|
|
- onFinishFailed={onFinishFailed}
|
|
|
|
- autoComplete="off"
|
|
|
|
|
|
+ <div className="main">
|
|
|
|
+ <Form
|
|
|
|
+ ref={FormBoxRef}
|
|
|
|
+ name="basic"
|
|
|
|
+ labelCol={{ span: 3 }}
|
|
|
|
+ onFinish={onFinish}
|
|
|
|
+ onFinishFailed={onFinishFailed}
|
|
|
|
+ autoComplete="off"
|
|
|
|
+ >
|
|
|
|
+ <Form.Item
|
|
|
|
+ label="名称"
|
|
|
|
+ name="name"
|
|
|
|
+ rules={[{ required: true, message: "请输名称!" }]}
|
|
|
|
+ getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
|
|
>
|
|
>
|
|
- <Form.Item
|
|
|
|
- label="名称"
|
|
|
|
- name="name"
|
|
|
|
- rules={[{ required: true, message: "请输名称!" }]}
|
|
|
|
- getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
|
|
|
|
- >
|
|
|
|
- <Input maxLength={25} showCount placeholder="请输入内容" />
|
|
|
|
- </Form.Item>
|
|
|
|
|
|
+ <Input maxLength={25} showCount placeholder="请输入内容" />
|
|
|
|
+ </Form.Item>
|
|
|
|
|
|
- <div className="myformBox">
|
|
|
|
- <div className="label">
|
|
|
|
- <span>*</span> 版式:
|
|
|
|
- </div>
|
|
|
|
- <div className="myformBoxR">
|
|
|
|
- <Radio.Group
|
|
|
|
- onChange={(e) => setImgNum(e.target.value)}
|
|
|
|
- value={imgNum}
|
|
|
|
- >
|
|
|
|
- <Radio value={1}>1</Radio>
|
|
|
|
- <Radio value={2}>2</Radio>
|
|
|
|
- <Radio value={4}>4</Radio>
|
|
|
|
- <Radio value={6}>6</Radio>
|
|
|
|
- <Radio value={8}>8</Radio>
|
|
|
|
- </Radio.Group>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div className="myformBox">
|
|
|
|
+ <div className="label">
|
|
|
|
+ <span>*</span> 版式:
|
|
</div>
|
|
</div>
|
|
|
|
+ <div className="myformBoxR">
|
|
|
|
+ <Radio.Group
|
|
|
|
+ onChange={(e) => setImgNum(e.target.value)}
|
|
|
|
+ value={imgNum}
|
|
|
|
+ >
|
|
|
|
+ <Radio value={1}>1</Radio>
|
|
|
|
+ <Radio value={2}>2</Radio>
|
|
|
|
+ <Radio value={4}>4</Radio>
|
|
|
|
+ <Radio value={6}>6</Radio>
|
|
|
|
+ <Radio value={8}>8</Radio>
|
|
|
|
+ </Radio.Group>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
|
|
- {/* 图片上传 */}
|
|
|
|
- <div className="myformBox myformBox0">
|
|
|
|
- <input
|
|
|
|
- id="upInput"
|
|
|
|
- type="file"
|
|
|
|
- accept=".png,.jpg,.jpeg"
|
|
|
|
- ref={myInput}
|
|
|
|
- onChange={(e) => handeUpPhoto(e)}
|
|
|
|
- />
|
|
|
|
|
|
+ {/* 图片上传 */}
|
|
|
|
+ <div className="myformBox myformBox0">
|
|
|
|
+ <input
|
|
|
|
+ id="upInput"
|
|
|
|
+ type="file"
|
|
|
|
+ accept=".png,.jpg,.jpeg"
|
|
|
|
+ ref={myInput}
|
|
|
|
+ onChange={(e) => handeUpPhoto(e)}
|
|
|
|
+ />
|
|
|
|
|
|
- <div className="label"></div>
|
|
|
|
- <div className="myformBoxR">
|
|
|
|
- <div className="fileBoxRow_r">
|
|
|
|
- <div className="upImgBox">
|
|
|
|
|
|
+ <div className="label"></div>
|
|
|
|
+ <div className="myformBoxR">
|
|
|
|
+ <div className="fileBoxRow_r">
|
|
|
|
+ <div className="upImgBox">
|
|
|
|
+ <div
|
|
|
|
+ hidden={imgList.length >= imgNum}
|
|
|
|
+ className="fileBoxRow_up"
|
|
|
|
+ onClick={() => myInput.current?.click()}
|
|
|
|
+ >
|
|
|
|
+ <PlusOutlined />
|
|
|
|
+ </div>
|
|
|
|
+ {imgList.map((v) => (
|
|
<div
|
|
<div
|
|
- hidden={imgList.length >= imgNum}
|
|
|
|
- className="fileBoxRow_up"
|
|
|
|
- onClick={() => myInput.current?.click()}
|
|
|
|
|
|
+ className="fileBoxRow_r_img"
|
|
|
|
+ key={v.id}
|
|
|
|
+ draggable="true"
|
|
|
|
+ onDragStart={() => setDragImg(v)}
|
|
|
|
+ onDragOver={(e) => handleDragOver(e, v)}
|
|
|
|
+ onDragEnter={(e) => handleDragEnter(e, v)}
|
|
|
|
+ onDragEnd={() => setDragImg(null)}
|
|
>
|
|
>
|
|
- <PlusOutlined />
|
|
|
|
- </div>
|
|
|
|
- {imgList.map((v) => (
|
|
|
|
- <div
|
|
|
|
- className="fileBoxRow_r_img"
|
|
|
|
- key={v.id}
|
|
|
|
- draggable="true"
|
|
|
|
- onDragStart={() => setDragImg(v)}
|
|
|
|
- onDragOver={(e) => handleDragOver(e, v)}
|
|
|
|
- onDragEnter={(e) => handleDragEnter(e, v)}
|
|
|
|
- onDragEnd={() => setDragImg(null)}
|
|
|
|
- >
|
|
|
|
- {v.filePath ? (
|
|
|
|
- <ImageLazy
|
|
|
|
- noLook={dragImg ? true : false}
|
|
|
|
- width={100}
|
|
|
|
- height={100}
|
|
|
|
- src={v.filePath}
|
|
|
|
- />
|
|
|
|
- ) : null}
|
|
|
|
|
|
+ {v.filePath ? (
|
|
|
|
+ <ImageLazy
|
|
|
|
+ noLook={dragImg ? true : false}
|
|
|
|
+ width={100}
|
|
|
|
+ height={100}
|
|
|
|
+ src={v.filePath}
|
|
|
|
+ />
|
|
|
|
+ ) : null}
|
|
|
|
|
|
- <Popconfirm
|
|
|
|
- title="删除后无法恢复,是否删除?"
|
|
|
|
- okText="删除"
|
|
|
|
- cancelText="取消"
|
|
|
|
- onConfirm={() => delImgListFu(v.id!)}
|
|
|
|
- >
|
|
|
|
- <div className="clearCover">
|
|
|
|
- <CloseOutlined />
|
|
|
|
- </div>
|
|
|
|
- </Popconfirm>
|
|
|
|
- </div>
|
|
|
|
- ))}
|
|
|
|
- </div>
|
|
|
|
- <div className="fileTit">
|
|
|
|
- {imgList.length && imgList.length >= 2 ? (
|
|
|
|
- <>
|
|
|
|
- 按住鼠标可拖动图片调整顺序。
|
|
|
|
- <br />
|
|
|
|
- </>
|
|
|
|
- ) : null}
|
|
|
|
- 建议尺寸:{12960 / imgNum}*1920
|
|
|
|
- <br />
|
|
|
|
- 支持png、jpg和jpeg的图片格式;最大支持30M。
|
|
|
|
- </div>
|
|
|
|
|
|
+ <Popconfirm
|
|
|
|
+ title="删除后无法恢复,是否删除?"
|
|
|
|
+ okText="删除"
|
|
|
|
+ cancelText="取消"
|
|
|
|
+ onConfirm={() => delImgListFu(v.id!)}
|
|
|
|
+ >
|
|
|
|
+ <div className="clearCover">
|
|
|
|
+ <CloseOutlined />
|
|
|
|
+ </div>
|
|
|
|
+ </Popconfirm>
|
|
|
|
+ </div>
|
|
|
|
+ ))}
|
|
|
|
+ </div>
|
|
|
|
+ <div className="fileTit">
|
|
|
|
+ {imgList.length && imgList.length >= 2 ? (
|
|
|
|
+ <>
|
|
|
|
+ 按住鼠标可拖动图片调整顺序。
|
|
|
|
+ <br />
|
|
|
|
+ </>
|
|
|
|
+ ) : null}
|
|
|
|
+ 建议尺寸:{12960 / imgNum}*1920
|
|
|
|
+ <br />
|
|
|
|
+ 支持png、jpg和jpeg的图片格式;最大支持30M。
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ </div>
|
|
|
|
|
|
- {/* 校验提示 */}
|
|
|
|
- <div
|
|
|
|
- className={classNames(
|
|
|
|
- "noUpThumb",
|
|
|
|
- imgList.length < imgNum && imgCheck ? "noUpThumbAc" : ""
|
|
|
|
- )}
|
|
|
|
- >
|
|
|
|
- 请上传 {imgNum} 张图片!
|
|
|
|
- </div>
|
|
|
|
|
|
+ {/* 校验提示 */}
|
|
|
|
+ <div
|
|
|
|
+ className={classNames(
|
|
|
|
+ "noUpThumb",
|
|
|
|
+ imgList.length < imgNum && imgCheck ? "noUpThumbAc" : ""
|
|
|
|
+ )}
|
|
|
|
+ >
|
|
|
|
+ 请上传 {imgNum} 张图片!
|
|
|
|
+ </div>
|
|
|
|
|
|
- {/* 确定和取消按钮 */}
|
|
|
|
- <br />
|
|
|
|
- <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
|
|
|
|
- <Button type="primary" htmlType="submit">
|
|
|
|
- 提交
|
|
|
|
- </Button>
|
|
|
|
-  
|
|
|
|
- <Button>预览效果</Button>
|
|
|
|
-  
|
|
|
|
- <Popconfirm
|
|
|
|
- title="放弃编辑后,信息将不会保存!"
|
|
|
|
- okText="放弃"
|
|
|
|
- cancelText="取消"
|
|
|
|
- onConfirm={closeMoalFu}
|
|
|
|
- >
|
|
|
|
- <Button>取消</Button>
|
|
|
|
- </Popconfirm>
|
|
|
|
- </Form.Item>
|
|
|
|
- </Form>
|
|
|
|
- </div>
|
|
|
|
|
|
+ {/* 确定和取消按钮 */}
|
|
|
|
+ <br />
|
|
|
|
+ <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
|
|
|
|
+ <Button type="primary" htmlType="submit">
|
|
|
|
+ 提交
|
|
|
|
+ </Button>
|
|
|
|
+  
|
|
|
|
+ <Button disabled={!imgList.length} onClick={() => setLookImg(true)}>
|
|
|
|
+ 预览效果
|
|
|
|
+ </Button>
|
|
|
|
+  
|
|
|
|
+ <Popconfirm
|
|
|
|
+ title="放弃编辑后,信息将不会保存!"
|
|
|
|
+ okText="放弃"
|
|
|
|
+ cancelText="取消"
|
|
|
|
+ onConfirm={closeMoalFu}
|
|
|
|
+ >
|
|
|
|
+ <Button>取消</Button>
|
|
|
|
+ </Popconfirm>
|
|
|
|
+ </Form.Item>
|
|
|
|
+ </Form>
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
|
|
+ {/* 点击预览效果出来的页面 */}
|
|
|
|
+ {lookImg ? (
|
|
|
|
+ <WallLook imgList={imgList} closeMoalFu={() => setLookImg(false)} />
|
|
|
|
+ ) : null}
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
}
|
|
}
|