|
@@ -1,4 +1,4 @@
|
|
-import React, { useCallback, useRef } from "react";
|
|
|
|
|
|
+import React, { useCallback, useRef, useState } from "react";
|
|
import styles from "./index.module.scss";
|
|
import styles from "./index.module.scss";
|
|
import {
|
|
import {
|
|
Button,
|
|
Button,
|
|
@@ -16,6 +16,8 @@ import dayjs from "dayjs";
|
|
import TextArea from "antd/es/input/TextArea";
|
|
import TextArea from "antd/es/input/TextArea";
|
|
import Z1upImgs from "@/components/Z1upImgs";
|
|
import Z1upImgs from "@/components/Z1upImgs";
|
|
import Z2upVideos from "@/components/Z2upVideos";
|
|
import Z2upVideos from "@/components/Z2upVideos";
|
|
|
|
+import { MessageFu } from "@/utils/message";
|
|
|
|
+import Z3upFiles from "@/components/Z3upFiles";
|
|
|
|
|
|
const { RangePicker } = DatePicker;
|
|
const { RangePicker } = DatePicker;
|
|
|
|
|
|
@@ -30,6 +32,12 @@ const eeeeArr = [
|
|
},
|
|
},
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+type LinkType = {
|
|
|
|
+ id: number;
|
|
|
|
+ name: string;
|
|
|
|
+ link: string;
|
|
|
|
+};
|
|
|
|
+
|
|
type Props = {
|
|
type Props = {
|
|
pageType: { txt: string; id: number };
|
|
pageType: { txt: string; id: number };
|
|
closeFu: () => void;
|
|
closeFu: () => void;
|
|
@@ -39,36 +47,80 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
// 表单的ref
|
|
// 表单的ref
|
|
const FormBoxRef = useRef<FormInstance>(null);
|
|
const FormBoxRef = useRef<FormInstance>(null);
|
|
|
|
|
|
|
|
+ // 图片数组的ref
|
|
|
|
+ const imgsRef = useRef<any>(null);
|
|
|
|
+
|
|
|
|
+ // 视频数组的ref
|
|
|
|
+ const videosRef = useRef<any>(null);
|
|
|
|
+
|
|
|
|
+ // 有关 项目链接
|
|
|
|
+ const [linkArr, setLinkArr] = useState<LinkType[]>([]);
|
|
|
|
+
|
|
|
|
+ const addLinkFu = useCallback(() => {
|
|
|
|
+ if (linkArr.length >= 10) return;
|
|
|
|
+ setLinkArr([...linkArr, { id: Date.now(), name: "", link: "" }]);
|
|
|
|
+ }, [linkArr]);
|
|
|
|
+
|
|
|
|
+ const delLinkFu = useCallback(
|
|
|
|
+ (id: number) => {
|
|
|
|
+ setLinkArr(linkArr.filter((v) => v.id !== id));
|
|
|
|
+ },
|
|
|
|
+ [linkArr]
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ const linkChangeFu = useCallback(
|
|
|
|
+ (id: number, val: string, type: "name" | "link") => {
|
|
|
|
+ setLinkArr(
|
|
|
|
+ linkArr.map((v) => ({
|
|
|
|
+ ...v,
|
|
|
|
+ [type]: v.id === id ? val.replace(/\s+/g, "") : v[type],
|
|
|
|
+ }))
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ [linkArr]
|
|
|
|
+ );
|
|
|
|
+
|
|
// 没有通过校验
|
|
// 没有通过校验
|
|
const onFinishFailed = useCallback(() => {}, []);
|
|
const onFinishFailed = useCallback(() => {}, []);
|
|
|
|
|
|
// 通过校验点击确定
|
|
// 通过校验点击确定
|
|
- const onFinish = useCallback(async (value: any) => {
|
|
|
|
- console.log("通过校验", value);
|
|
|
|
-
|
|
|
|
- if (value.ffff) {
|
|
|
|
- console.log(
|
|
|
|
- "修改日期格式",
|
|
|
|
- dayjs(value.ffff[0]).format("YYYY-MM-DD"),
|
|
|
|
- dayjs(value.ffff[1]).format("YYYY-MM-DD")
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
+ const onFinish = useCallback(
|
|
|
|
+ async (value: any) => {
|
|
|
|
+ console.log("通过校验", value);
|
|
|
|
|
|
- // 获取图片地址
|
|
|
|
- const imgsRes = imgsRef.current.imgIdsRes();
|
|
|
|
|
|
+ if (value.ffff) {
|
|
|
|
+ console.log(
|
|
|
|
+ "修改日期格式",
|
|
|
|
+ dayjs(value.ffff[0]).format("YYYY-MM-DD"),
|
|
|
|
+ dayjs(value.ffff[1]).format("YYYY-MM-DD")
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
- console.log("获取图片地址", imgsRes);
|
|
|
|
|
|
+ // 获取图片地址
|
|
|
|
+ const imgsRes = imgsRef.current.imgIdsRes();
|
|
|
|
|
|
- // 获取视频地址
|
|
|
|
- const videosRes = videosRef.current.videoIdsRes();
|
|
|
|
- console.log("获取视频地址", videosRes);
|
|
|
|
- }, []);
|
|
|
|
|
|
+ console.log("获取图片地址", imgsRes);
|
|
|
|
|
|
- // 图片数组的ref
|
|
|
|
- const imgsRef = useRef<any>(null);
|
|
|
|
|
|
+ // 获取视频地址
|
|
|
|
+ const videosRes = videosRef.current.videoIdsRes();
|
|
|
|
+ console.log("获取视频地址", videosRes);
|
|
|
|
|
|
- // 视频数组的ref
|
|
|
|
- const videosRef = useRef<any>(null);
|
|
|
|
|
|
+ // 检查链接填写完整情况
|
|
|
|
+ const linkArrFlag = linkArr.some((v) => !v.name || !v.link);
|
|
|
|
+
|
|
|
|
+ if (linkArrFlag) return MessageFu.warning("请完整填写 项目链接 !");
|
|
|
|
+
|
|
|
|
+ console.log("项目链接", linkArr);
|
|
|
|
+
|
|
|
|
+ // 项目成功
|
|
|
|
+ const filesRes = filesRef.current.filesIdRes();
|
|
|
|
+ console.log("获取项目成果文件", filesRes);
|
|
|
|
+ },
|
|
|
|
+ [linkArr]
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 项目成功的 ref
|
|
|
|
+ const filesRef = useRef<any>(null);
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.A1Add}>
|
|
<div className={styles.A1Add}>
|
|
@@ -77,7 +129,6 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
scrollToFirstError={true}
|
|
scrollToFirstError={true}
|
|
ref={FormBoxRef}
|
|
ref={FormBoxRef}
|
|
name="basic"
|
|
name="basic"
|
|
- labelCol={{ span: 2 }}
|
|
|
|
onFinish={onFinish}
|
|
onFinish={onFinish}
|
|
onFinishFailed={onFinishFailed}
|
|
onFinishFailed={onFinishFailed}
|
|
autoComplete="off"
|
|
autoComplete="off"
|
|
@@ -93,7 +144,7 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
disabled={pageType.txt === "edit"}
|
|
disabled={pageType.txt === "edit"}
|
|
maxLength={30}
|
|
maxLength={30}
|
|
showCount
|
|
showCount
|
|
- placeholder="请输入内容,最多30字;不能重复"
|
|
|
|
|
|
+ placeholder="请输入内容,不能重复"
|
|
/>
|
|
/>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
@@ -107,7 +158,7 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
style={{ width: 600 }}
|
|
style={{ width: 600 }}
|
|
maxLength={30}
|
|
maxLength={30}
|
|
showCount
|
|
showCount
|
|
- placeholder="请输入内容,最多30字"
|
|
|
|
|
|
+ placeholder="请输入内容"
|
|
/>
|
|
/>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
@@ -116,7 +167,7 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
style={{ width: 600 }}
|
|
style={{ width: 600 }}
|
|
maxLength={30}
|
|
maxLength={30}
|
|
showCount
|
|
showCount
|
|
- placeholder="请输入内容,最多30字"
|
|
|
|
|
|
+ placeholder="请输入内容"
|
|
/>
|
|
/>
|
|
</Form.Item>
|
|
</Form.Item>
|
|
|
|
|
|
@@ -148,7 +199,7 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
<TextArea
|
|
<TextArea
|
|
style={{ width: 600 }}
|
|
style={{ width: 600 }}
|
|
autoSize
|
|
autoSize
|
|
- placeholder="请输入内容,最多500字"
|
|
|
|
|
|
+ placeholder="请输入内容"
|
|
showCount
|
|
showCount
|
|
maxLength={500}
|
|
maxLength={500}
|
|
/>
|
|
/>
|
|
@@ -169,7 +220,7 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
<div className="e_rowR">
|
|
<div className="e_rowR">
|
|
<Z1upImgs
|
|
<Z1upImgs
|
|
max={50}
|
|
max={50}
|
|
- isLook={false}
|
|
|
|
|
|
+ isLook={pageType.txt === "look"}
|
|
ref={imgsRef}
|
|
ref={imgsRef}
|
|
fileCheck={false}
|
|
fileCheck={false}
|
|
size={10}
|
|
size={10}
|
|
@@ -187,7 +238,7 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
<div className="e_rowR">
|
|
<div className="e_rowR">
|
|
<Z2upVideos
|
|
<Z2upVideos
|
|
max={10}
|
|
max={10}
|
|
- isLook={false}
|
|
|
|
|
|
+ isLook={pageType.txt === "look"}
|
|
ref={videosRef}
|
|
ref={videosRef}
|
|
fileCheck={false}
|
|
fileCheck={false}
|
|
size={500}
|
|
size={500}
|
|
@@ -197,6 +248,75 @@ function A1Add({ pageType, closeFu }: Props) {
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+ <div className="e_row">
|
|
|
|
+ <div className="e_rowL e_rowL2">
|
|
|
|
+ <span> </span>项目链接:
|
|
|
|
+ </div>
|
|
|
|
+ <div className="e_rowR">
|
|
|
|
+ <div className="erLinkTop">
|
|
|
|
+ <Button onClick={addLinkFu} disabled={linkArr.length >= 10}>
|
|
|
|
+ 新 增
|
|
|
|
+ </Button>
|
|
|
|
+ <span className="e_rowRtit"> 最多支持10条链接</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div className="erLinkMain">
|
|
|
|
+ {linkArr.map((v) => (
|
|
|
|
+ <div className="erLinkRow" key={v.id}>
|
|
|
|
+ <Input
|
|
|
|
+ value={v.name}
|
|
|
|
+ onChange={(e) =>
|
|
|
|
+ linkChangeFu(v.id, e.target.value, "name")
|
|
|
|
+ }
|
|
|
|
+ style={{ width: 240 }}
|
|
|
|
+ maxLength={10}
|
|
|
|
+ showCount
|
|
|
|
+ placeholder="请输入链接标题"
|
|
|
|
+ />
|
|
|
|
+  
|
|
|
|
+ <Input
|
|
|
|
+ value={v.link}
|
|
|
|
+ onChange={(e) =>
|
|
|
|
+ linkChangeFu(v.id, e.target.value, "link")
|
|
|
|
+ }
|
|
|
|
+ style={{ width: 800 }}
|
|
|
|
+ maxLength={100}
|
|
|
|
+ showCount
|
|
|
|
+ placeholder="请输入链接"
|
|
|
|
+ />
|
|
|
|
+  
|
|
|
|
+ <Popconfirm
|
|
|
|
+ title="删除后无法恢复,是否删除?"
|
|
|
|
+ okText="删除"
|
|
|
|
+ cancelText="取消"
|
|
|
|
+ onConfirm={() => delLinkFu(v.id)}
|
|
|
|
+ okButtonProps={{ loading: false }}
|
|
|
|
+ >
|
|
|
|
+ <Button>删除</Button>
|
|
|
|
+ </Popconfirm>
|
|
|
|
+ </div>
|
|
|
|
+ ))}
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <br />
|
|
|
|
+
|
|
|
|
+ <div className="e_row">
|
|
|
|
+ <div className="e_rowL e_rowL2">
|
|
|
|
+ <span> </span>项目成果:
|
|
|
|
+ </div>
|
|
|
|
+ <div className="e_rowR">
|
|
|
|
+ <Z3upFiles
|
|
|
|
+ max={10}
|
|
|
|
+ isLook={pageType.txt === "look"}
|
|
|
|
+ ref={filesRef}
|
|
|
|
+ fileCheck={false}
|
|
|
|
+ dirCode="aaaaaaaaa"
|
|
|
|
+ myUrl="cms/goods/upload"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
{/* 确定和取消按钮 */}
|
|
{/* 确定和取消按钮 */}
|
|
<div className="A1AddBtn">
|
|
<div className="A1AddBtn">
|
|
{pageType.txt === "look" ? (
|
|
{pageType.txt === "look" ? (
|