shaogen1995 2 年之前
父节点
当前提交
579ae5edfd

+ 8 - 3
src/components/Z1upImgs/index.tsx

@@ -1,4 +1,4 @@
-import React, { useCallback, useRef, useState } from "react";
+import React, { useCallback, useEffect, useRef, useState } from "react";
 import styles from "./index.module.scss";
 import {
   PlusOutlined,
@@ -32,6 +32,7 @@ type Props = {
   formatTxt?: string; //上传图片提示
   sizeTxt?: string; //后面的建议尺寸信息
   fromData?: any;
+  lookData: FileImgListType[]; //编辑或者 查看 回显
 };
 
 function Z1upImgs(
@@ -47,11 +48,16 @@ function Z1upImgs(
     formatTxt = "png、jpg和jpeg",
     sizeTxt,
     fromData,
+    lookData,
   }: Props,
   ref: any
 ) {
   const [fileList, setFileList] = useState<FileImgListType[]>([]);
 
+  useEffect(() => {
+    if (lookData) setFileList(lookData);
+  }, [lookData]);
+
   const myInput = useRef<HTMLInputElement>(null);
 
   // 上传图片
@@ -76,7 +82,6 @@ function Z1upImgs(
         // 把files添加进FormData对象(‘photo’为后端需要的字段)
         fd.append("type", "img");
         fd.append("dirCode", dirCode);
-        fd.append("typePath", "1");
         fd.append("file", filesInfo);
 
         if (fromData) {
@@ -113,7 +118,7 @@ function Z1upImgs(
 
   // 让父组件调用,拿到 附件信息
   const imgIdsRes = useCallback(() => {
-    return fileList;
+    return fileList.map((v) => v.id).join(",");
   }, [fileList]);
 
   // 可以让父组件调用子组件的方法

+ 9 - 4
src/components/Z2upVideos/index.tsx

@@ -1,4 +1,4 @@
-import React, { useCallback, useRef, useState } from "react";
+import React, { useCallback, useEffect, useRef, useState } from "react";
 import styles from "./index.module.scss";
 import { forwardRef, useImperativeHandle } from "react";
 import { FileImgListType } from "@/types";
@@ -28,6 +28,7 @@ type Props = {
   format?: string[]; //上传视频格式
   formatTxt?: string; //上传视频提示
   fromData?: any;
+  lookData: FileImgListType[]; //编辑或者 查看 回显
 };
 
 function Z2upVideos(
@@ -41,11 +42,16 @@ function Z2upVideos(
     format = ["video/mp4"],
     formatTxt = "mp4",
     fromData,
+    lookData,
   }: Props,
   ref: any
 ) {
   const [fileList, setFileList] = useState<FileImgListType[]>([]);
 
+  useEffect(() => {
+    if (lookData) setFileList(lookData);
+  }, [lookData]);
+
   const myInput = useRef<HTMLInputElement>(null);
 
   // 上传视频
@@ -68,9 +74,8 @@ function Z2upVideos(
         // 创建FormData对象
         const fd = new FormData();
         // 把files添加进FormData对象(‘photo’为后端需要的字段)
-        fd.append("type", "img");
+        fd.append("type", "video");
         fd.append("dirCode", dirCode);
-        fd.append("typePath", "1");
         fd.append("file", filesInfo);
 
         if (fromData) {
@@ -107,7 +112,7 @@ function Z2upVideos(
 
   // 让父组件调用,拿到 附件信息
   const videoIdsRes = useCallback(() => {
-    return fileList;
+    return fileList.map((v) => v.id).join(",");
   }, [fileList]);
 
   // 可以让父组件调用子组件的方法

+ 4 - 1
src/components/Z3upFiles/index.module.scss

@@ -7,13 +7,16 @@
 
     .Z3files {
       width: 500px;
+      padding-top: 6px;
 
       .Z3filesRow {
         display: flex;
-        margin-top: 10px;
+        margin-top: 5px;
         justify-content: space-between;
         align-items: center;
         font-size: 16px;
+        border-bottom: 1px solid var(--themeColor);
+        padding-bottom: 5px;
 
         .Z3files1 {
           width: calc(100% - 130px);

+ 9 - 5
src/components/Z3upFiles/index.tsx

@@ -1,4 +1,4 @@
-import React, { useCallback, useRef, useState } from "react";
+import React, { useCallback, useEffect, useRef, useState } from "react";
 import styles from "./index.module.scss";
 import { FileImgListType } from "@/types";
 import { API_upFile } from "@/store/action/layout";
@@ -24,14 +24,19 @@ type Props = {
   dirCode: string; //文件的code码
   myUrl: string;
   fromData?: any;
+  lookData: FileImgListType[]; //编辑或者 查看 回显
 };
 
 function Z3upFiles(
-  { max, isLook, fileCheck, dirCode, myUrl, fromData }: Props,
+  { max, isLook, fileCheck, dirCode, myUrl, fromData, lookData }: Props,
   ref: any
 ) {
   const [fileList, setFileList] = useState<FileImgListType[]>([]);
 
+  useEffect(() => {
+    if (lookData) setFileList(lookData);
+  }, [lookData]);
+
   const myInput = useRef<HTMLInputElement>(null);
 
   // 上传文件
@@ -43,9 +48,8 @@ function Z3upFiles(
         // 创建FormData对象
         const fd = new FormData();
         // 把files添加进FormData对象(‘photo’为后端需要的字段)
-        fd.append("type", "img");
+        fd.append("type", "doc");
         fd.append("dirCode", dirCode);
-        fd.append("typePath", "1");
         fd.append("file", filesInfo);
 
         if (fromData) {
@@ -82,7 +86,7 @@ function Z3upFiles(
 
   // 让父组件调用,拿到 附件信息
   const filesIdRes = useCallback(() => {
-    return fileList;
+    return fileList.map((v) => v.id).join(",");
   }, [fileList]);
 
   // 可以让父组件调用子组件的方法

+ 37 - 1
src/pages/A1Project/A1Add/index.module.scss

@@ -56,7 +56,8 @@
 
         .e_rowR {
           width: calc(100% - 130px);
-          .lookNoneOne{
+
+          .lookNoneOne {
             position: relative;
             left: 10px;
             top: 4px;
@@ -89,10 +90,18 @@
     .A1AddMainLook {
       height: 100%;
 
+      #basic_name_help{
+        display: none !important;
+      }
+
       .ant-row {
         pointer-events: none;
       }
 
+      .ant-input-textarea {
+        width: 1100px !important;
+      }
+
       .ant-form-item-control-input {
         pointer-events: none;
 
@@ -172,7 +181,34 @@
           padding-left: 12px;
         }
 
+        .e_rowRML {
+          margin-top: -10px;
+        }
+
       }
+
+
+      // 查看的 项目 链接 的特殊  处理
+
+      .lookErLink {
+        padding-top: 5px;
+        display: flex;
+
+        .lookErLink1 {
+          width: 160px;
+          text-align: right;
+          margin-right: 10px;
+        }
+
+        .lookErLink2 {
+          overflow: hidden;
+          text-overflow: ellipsis;
+          white-space: nowrap;
+
+          width: calc(100% - 200px);
+        }
+      }
+
     }
 
 

+ 206 - 105
src/pages/A1Project/A1Add/index.tsx

@@ -19,20 +19,13 @@ import Z2upVideos from "@/components/Z2upVideos";
 import { MessageFu } from "@/utils/message";
 import Z3upFiles from "@/components/Z3upFiles";
 import classNames from "classnames";
+import { useSelector } from "react-redux";
+import { RootState } from "@/store";
+import { A2_APIaddProject, A2_APIgetInfoById } from "@/store/action/A1Project";
+import { A1TableType, FileImgListType } from "@/types";
 
 const { RangePicker } = DatePicker;
 
-const eeeeArr = [
-  {
-    value: "项目状态1",
-    label: "项目状态1",
-  },
-  {
-    value: "项目状态2",
-    label: "项目状态2",
-  },
-];
-
 type LinkType = {
   id: number;
   name: string;
@@ -43,14 +36,63 @@ type Props = {
   pageType: { txt: string; id: number };
   closeFu: () => void;
   addFu: () => void;
-  editFu: () => void;
+  editFu: (val: string) => void;
 };
 
 function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
-  useEffect(() => {
-    console.log("进来编辑和新增项目的页面~~~~~~~");
+  const [lookInfo, setLookInfo] = useState({} as A1TableType);
+
+  const [lookFile, setLookFile] = useState([] as FileImgListType[]);
+
+  const [isOk, setIsOk] = useState(false);
+
+  const getInfoFu = useCallback(async (id: number) => {
+    const res = await A2_APIgetInfoById(id);
+    if (res.code === 0) {
+      const info = res.data.entity;
+      setLookInfo(info);
+
+      setDirCode(info.dirCode);
+
+      const file = res.data.file || [];
+      setLookFile(file);
+
+      setLinkArr(JSON.parse(info.linkJson));
+
+      const province = info.province ? info.province.split("-") : "";
+
+      const dateScope = info.dateScope ? info.dateScope.split(" 至 ") : "";
+
+      FormBoxRef.current?.setFieldsValue({
+        ...info,
+        province,
+        dateScope: [dayjs(dateScope[0]), dayjs(dateScope[1])],
+      });
+
+      // 回显的时候闪动 问题
+      setIsOk(true);
+    }
   }, []);
 
+  useEffect(() => {
+    if (!pageType.id) {
+      // 新增
+      setIsOk(true);
+      setDirCode(Date.now() + "");
+    } else {
+      // 编辑
+      getInfoFu(pageType.id);
+    }
+  }, [getInfoFu, pageType.id]);
+
+  // 从仓库 获取 项目状态的下拉框 数据
+  const statusArr = useSelector(
+    (state: RootState) => state.A2Dict.A2Tab1_1Obj.status
+  );
+
+  // 上传附件的code码
+  const [dirCode, setDirCode] = useState("");
+
   // 表单的ref
   const FormBoxRef = useRef<FormInstance>(null);
 
@@ -93,46 +135,55 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
   // 通过校验点击确定
   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")
-        );
+      //  项目周期的处理
+      let dateScope = "";
+      if (value.dateScope && value.dateScope.length >= 1) {
+        dateScope =
+          dayjs(value.dateScope[0]).format("YYYY-MM-DD") +
+          " 至 " +
+          dayjs(value.dateScope[1]).format("YYYY-MM-DD");
       }
 
+      // 项目地点的处理
+      let province = "";
+      if (value.province && value.province.length)
+        province = value.province.join("-");
+
       // 获取图片地址
       const imgsRes = imgsRef.current.imgIdsRes();
 
-      console.log("获取图片地址", imgsRes);
-
       // 获取视频地址
       const videosRes = videosRef.current.videoIdsRes();
-      console.log("获取视频地址", videosRes);
 
       // 检查链接填写完整情况
       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);
-
-      if (pageType.txt === "add") {
-        MessageFu.success("新增成功!");
-        addFu();
-      } else if (pageType.txt === "edit") {
-        MessageFu.success("编辑成功!");
-        editFu();
+
+      const obj = {
+        ...value,
+        id: pageType.txt === "add" ? null : pageType.id,
+        dateScope,
+        fileIds: imgsRes + "," + videosRes + "," + filesRes,
+        linkJson: JSON.stringify(linkArr),
+        province,
+        dirCode,
+      };
+      const res = await A2_APIaddProject(obj);
+      if (res.code === 0) {
+        if (pageType.txt === "add") {
+          MessageFu.success("新增成功!");
+          addFu();
+        } else if (pageType.txt === "edit") {
+          MessageFu.success("编辑成功!");
+          editFu(value.num + " - " + value.name);
+        }
+        closeFu();
       }
-      closeFu();
     },
-    [addFu, closeFu, editFu, linkArr, pageType.txt]
+    [addFu, closeFu, dirCode, editFu, linkArr, pageType.id, pageType.txt]
   );
 
   // 项目成功的 ref
@@ -156,7 +207,7 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
         >
           <Form.Item
             label="项目编号"
-            name="aaaa"
+            name="num"
             rules={[{ required: true, message: "请输入项目编号!" }]}
             getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
           >
@@ -165,13 +216,19 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
               disabled={pageType.txt === "edit"}
               maxLength={30}
               showCount
-              placeholder="请输入内容,不能重复"
+              placeholder={
+                isOk
+                  ? pageType.txt === "look"
+                    ? "(空)"
+                    : "请输入内容,不能重复"
+                  : ""
+              }
             />
           </Form.Item>
 
           <Form.Item
             label="项目名称"
-            name="bbbb"
+            name="name"
             rules={[{ required: true, message: "请输入项目名称!" }]}
             getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
           >
@@ -179,57 +236,73 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
               style={{ width: 600 }}
               maxLength={30}
               showCount
-              placeholder="请输入内容"
+              placeholder={
+                isOk ? (pageType.txt === "look" ? "(空)" : "请输入内容") : ""
+              }
             />
           </Form.Item>
 
-          <Form.Item label="建设单位" name="cccc">
+          <Form.Item label="建设单位" name="unit">
             <Input
               style={{ width: 600 }}
               maxLength={30}
               showCount
-              placeholder={pageType.txt === "look" ? "(空)" : "请输入内容"}
+              placeholder={
+                isOk ? (pageType.txt === "look" ? "(空)" : "请输入内容") : ""
+              }
             />
           </Form.Item>
 
-          <Form.Item label="项目地点" name="dddd">
+          <Form.Item label="项目地点" name="province">
             <Cascader
               style={{ width: 300 }}
               options={mapDataAll}
-              placeholder={pageType.txt === "look" ? "(空)" : "请选择省/市"}
+              placeholder={
+                isOk ? (pageType.txt === "look" ? "(空)" : "请选择省/市") : ""
+              }
             />
           </Form.Item>
 
           <Form.Item
             label="项目状态"
-            name="eeee"
+            name="statusId"
             rules={[{ required: true, message: "请选择项目状态!" }]}
           >
             <Select
-              placeholder="请选择"
+              placeholder={
+                isOk ? (pageType.txt === "look" ? "(空)" : "请选择") : ""
+              }
               style={{ width: 300 }}
-              options={eeeeArr}
+              options={statusArr.map((v) => ({ value: v.id, label: v.name }))}
             />
           </Form.Item>
 
           {pageType.txt === "look" ? (
             <div className="e_row">
               <div className="e_rowL">
-                <span> </span>项目日期:
+                <span> </span>项目周期:
+              </div>
+              <div className="e_rowR e_rowRLook">
+                {isOk
+                  ? lookInfo.dateScope
+                    ? lookInfo.dateScope
+                    : "(空)"
+                  : ""}
               </div>
-              <div className="e_rowR e_rowRLook">日期日期日期日期</div>
             </div>
           ) : (
-            <Form.Item label="项目日期" name="ffff">
+            <Form.Item label="项目周期" name="dateScope">
               <RangePicker style={{ width: 300 }} />
             </Form.Item>
           )}
 
-          <Form.Item label="项目简介" name="gggg">
+          <Form.Item label="项目简介" name="description">
             <TextArea
               style={{ width: 600 }}
               autoSize
-              placeholder={pageType.txt === "look" ? "(空)" : "请输入内容"}
+              placeholder={
+                isOk ? (pageType.txt === "look" ? "(空)" : "请输入内容") : ""
+              }
               showCount
               maxLength={500}
             />
@@ -240,10 +313,16 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
               <div className="e_rowL">
                 <span> </span>项目金额:
               </div>
-              <div className="e_rowR e_rowRLook">1000000 ¥</div>
+              <div className="e_rowR e_rowRLook">
+                {isOk
+                  ? lookInfo.amount
+                    ? lookInfo.amount + "¥"
+                    : "(空)"
+                  : ""}
+              </div>
             </div>
           ) : (
-            <Form.Item label="项目金额" name="hhhh">
+            <Form.Item label="项目金额" name="amount">
               <InputNumber
                 style={{ width: 300 }}
                 addonAfter="¥"
@@ -254,7 +333,7 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
           )}
 
           <div className="e_row">
-            <div className="e_rowL">
+            <div className="e_rowL e_rowRML">
               <span> </span>项目图片:
             </div>
             <div className="e_rowR">
@@ -265,14 +344,15 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
                 fileCheck={false}
                 size={10}
                 isCoverShow={true}
-                dirCode="aaaaaaaaa"
-                myUrl="cms/goods/upload"
+                dirCode={dirCode}
+                myUrl="cms/project/upload"
+                lookData={lookFile.filter((v) => v.type === "img")}
               />
             </div>
           </div>
 
           <div className="e_row">
-            <div className="e_rowL e_rowL2">
+            <div className="e_rowL e_rowL2 e_rowRML">
               <span> </span>项目视频:
             </div>
             <div className="e_rowR">
@@ -282,8 +362,9 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
                 ref={videosRef}
                 fileCheck={false}
                 size={500}
-                dirCode="aaaaaaaaa"
-                myUrl="cms/goods/upload"
+                dirCode={dirCode}
+                myUrl="cms/project/upload"
+                lookData={lookFile.filter((v) => v.type === "video")}
               />
             </div>
           </div>
@@ -294,9 +375,9 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
             </div>
             <div className="e_rowR">
               {pageType.txt === "look" && linkArr.length <= 0 ? (
-                <div className="lookNoneOne">(空)</div>
+                <div className="lookNoneOne">{isOk ? "(空)" : ""}</div>
               ) : (
-                <div className="erLinkTop">
+                <div className="erLinkTop" hidden={pageType.txt === "look"}>
                   <Button onClick={addLinkFu} disabled={linkArr.length >= 10}>
                     新&emsp;增
                   </Button>
@@ -304,43 +385,62 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
                 </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="请输入链接标题"
-                    />
-                    &emsp;
-                    <Input
-                      value={v.link}
-                      onChange={(e) =>
-                        linkChangeFu(v.id, e.target.value, "link")
-                      }
-                      style={{ width: 800 }}
-                      maxLength={100}
-                      showCount
-                      placeholder="请输入链接"
-                    />
-                    &emsp;
-                    <Popconfirm
-                      title="删除后无法恢复,是否删除?"
-                      okText="删除"
-                      cancelText="取消"
-                      onConfirm={() => delLinkFu(v.id)}
-                      okButtonProps={{ loading: false }}
-                    >
-                      <Button>删除</Button>
-                    </Popconfirm>
-                  </div>
-                ))}
-              </div>
+              {pageType.txt === "look" ? (
+                <>
+                  {linkArr.map((v) => (
+                    <div className="lookErLink" key={v.id}>
+                      <div className="lookErLink1">{v.name}:</div>
+                      <a
+                        title={v.link}
+                        className="lookErLink2"
+                        href={v.link}
+                        target="_blank"
+                        rel="noreferrer"
+                      >
+                        {v.link}
+                      </a>
+                    </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="请输入链接标题"
+                      />
+                      &emsp;
+                      <Input
+                        value={v.link}
+                        onChange={(e) =>
+                          linkChangeFu(v.id, e.target.value, "link")
+                        }
+                        style={{ width: 800 }}
+                        maxLength={100}
+                        showCount
+                        placeholder="请输入链接"
+                      />
+                      &emsp;
+                      <Popconfirm
+                        title="删除后无法恢复,是否删除?"
+                        okText="删除"
+                        cancelText="取消"
+                        onConfirm={() => delLinkFu(v.id)}
+                        okButtonProps={{ loading: false }}
+                      >
+                        <Button>删除</Button>
+                      </Popconfirm>
+                    </div>
+                  ))}
+                </div>
+              )}
             </div>
           </div>
 
@@ -350,14 +450,15 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
             <div className="e_rowL e_rowL2">
               <span> </span>项目成果:
             </div>
-            <div className="e_rowR">
+            <div className="e_rowR e_rowRML">
               <Z3upFiles
                 max={10}
                 isLook={pageType.txt === "look"}
                 ref={filesRef}
                 fileCheck={false}
-                dirCode="aaaaaaaaa"
-                myUrl="cms/goods/upload"
+                dirCode={dirCode}
+                myUrl="cms/project/upload"
+                lookData={lookFile.filter((v) => v.type === "doc")}
               />
             </div>
           </div>

+ 26 - 7
src/pages/A1Project/A1Look/index.tsx

@@ -16,10 +16,19 @@ const A1Tab = [
 type Props = {
   pageType: { txt: string; id: number };
   closeFu: () => void;
-  tabType: boolean;
+  tabType: boolean; //是否是审批
+  lookTit: string; //顶部项目名字和编号
+  editTopFu: () => void;
 };
 
-function A1Look({ pageType, closeFu, tabType }: Props) {
+function A1Look({ pageType, closeFu, tabType, lookTit, editTopFu }: Props) {
+  // 动态改变顶部 title
+  const [myTitle, setMyTitle] = useState("");
+
+  useEffect(() => {
+    setMyTitle(lookTit);
+  }, [lookTit]);
+
   const [sonPageType, setSonPageType] = useState(pageType);
 
   const [topType, setTopType] = useState(1);
@@ -39,14 +48,26 @@ function A1Look({ pageType, closeFu, tabType }: Props) {
 
   // 从 项目介绍 点击 取消
   const tab1CloseFu = useCallback(() => {
-    setTab1Key(Date.now());
     setSonPageType({ txt: "look", id: pageType.id });
   }, [pageType.id]);
 
+  // 编辑成功
+  const editSuFu = useCallback(
+    (val: string) => {
+      // 设置key,更新数据
+      setTab1Key(Date.now());
+      // 动态修改 顶部 标题
+      setMyTitle(val);
+      // 更新最外层的表格数据(点击返回的时候要看到最新的数据)
+      editTopFu();
+    },
+    [editTopFu]
+  );
+
   return (
     <div className={styles.A1Look}>
       <div className="A1LookTitle">
-        <h3>XXXXXXX 项目</h3>
+        <h3>{myTitle}</h3>
         <Button onClick={closeFu}>返 回</Button>
       </div>
       <div className="A1LookTab">
@@ -81,9 +102,7 @@ function A1Look({ pageType, closeFu, tabType }: Props) {
             pageType={sonPageType}
             closeFu={tab1CloseFu}
             addFu={() => {}}
-            editFu={() => {
-              console.log("编辑成功");
-            }}
+            editFu={(val) => editSuFu(val)}
           />
         ) : topType === 2 ? (
           <A1Outer id={pageType.id} />

+ 48 - 0
src/pages/A1Project/data.ts

@@ -0,0 +1,48 @@
+export const scheduleCollectArr = [
+  {
+    value: "",
+    label: "全部",
+  },
+  {
+    value: 1,
+    label: "已完成",
+  },
+  {
+    value: 0,
+    label: "未完成",
+  },
+];
+
+export const scheduleAuditArr = [
+  {
+    value: "",
+    label: "全部",
+  },
+  {
+    value: 0,
+    label: "存在待审批的文件",
+  },
+  {
+    value: 1,
+    label: "存在审批通过的文件",
+  },
+  {
+    value: 2,
+    label: "存在审批驳回的文件",
+  },
+];
+
+export const projectRoleArr = [
+  {
+    value: "",
+    label: "全部",
+  },
+  {
+    value: 0,
+    label: "我创建的项目",
+  },
+  {
+    value: 1,
+    label: "我参与的项目",
+  },
+];

+ 134 - 145
src/pages/A1Project/index.tsx

@@ -7,134 +7,82 @@ import React, {
 } from "react";
 import styles from "./index.module.scss";
 import { Button, Input, Popconfirm, Select, Table, Tooltip } from "antd";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
 import { RootState } from "@/store";
 import { A1TableType } from "@/types";
 import A1Add from "./A1Add";
 import A1Down from "./A1Down";
 import A1Look from "./A1Look";
-
-const bbbbArr = [
-  {
-    value: "1111s",
-    label: "shaogen - 邵根",
-  },
-  {
-    value: "2222s",
-    label: "wuweihao - 吴伟浩",
-  },
-];
-
-const ccccArr = [
-  {
-    value: "ccc1111s",
-    label: "shaogen - 邵根",
-  },
-  {
-    value: "ccc2222s",
-    label: "wuweihao - 吴伟浩",
-  },
-];
-
-const ddddArr = [
-  {
-    value: "",
-    label: "全部",
-  },
-  {
-    value: "项目状态1",
-    label: "项目状态1",
-  },
-  {
-    value: "项目状态2",
-    label: "项目状态2",
-  },
-];
-
-const eeeeArr = [
-  {
-    value: "",
-    label: "全部",
-  },
-  {
-    value: "已完成",
-    label: "已完成",
-  },
-  {
-    value: "未完成",
-    label: "未完成",
-  },
-];
-
-const ffffArr = [
-  {
-    value: "",
-    label: "全部",
-  },
-  {
-    value: "存在待审批的文件",
-    label: "存在待审批的文件",
-  },
-  {
-    value: "存在审批通过的文件",
-    label: "存在审批通过的文件",
-  },
-  {
-    value: "存在审批驳回的文件",
-    label: "存在审批驳回的文件",
-  },
-];
-
-const ggggArr = [
-  {
-    value: "",
-    label: "全部",
-  },
-  {
-    value: "我创建的项目",
-    label: "我创建的项目",
-  },
-  {
-    value: "我参与的项目",
-    label: "我参与的项目",
-  },
-];
+import { A1_APIgetList, A2_APIdelProject } from "@/store/action/A1Project";
+import { getUserListAPI } from "@/store/action/A3User";
+import { A2_APIgetList1 } from "@/store/action/A2Dict";
+import { scheduleCollectArr, scheduleAuditArr, projectRoleArr } from "./data";
+import { MessageFu } from "@/utils/message";
 
 function A1Project() {
+  const dispatch = useDispatch();
+
+  useEffect(() => {
+    // 获取用户列表(项目管理下拉筛选使用)
+    dispatch(getUserListAPI({ pageNum: 1, pageSize: 99999 }));
+    // 获取 字典 的 职能(项目详情的项目成员用)  和 状态(这个页面用)
+    dispatch(A2_APIgetList1());
+  }, [dispatch]);
+
+  // 从仓库获取用户列表--项目经理下拉框 和 商务经理下拉框使用
+  const A3UserList = useSelector(
+    (state: RootState) => state.A3User.tableInfo.list
+  );
+
+  const pmNameArr = useMemo(() => {
+    const arr1 = A3UserList.filter((v) => v.userName !== "admin");
+    const arr2: { value: number; label: string }[] = arr1.map((v: any) => ({
+      value: v.id,
+      label: v.userName + " - " + v.realName,
+    }));
+    return arr2;
+  }, [A3UserList]);
+
+  // 从仓库 获取 项目状态的下拉框 数据
+  const statusArr = useSelector(
+    (state: RootState) => state.A2Dict.A2Tab1_1Obj.status
+  );
+
   // 顶部的试图切换
   const [topType, setTopType] = useState<"outer" | "inner">("outer");
 
   // 表单数据
   const [fromData, setFromData] = useState({
-    aaaa: "",
-    bbbb: "",
-    cccc: "",
-    dddd: "",
-    eeee: "",
-    ffff: "",
-    gggg: "",
+    searchKey: "",
+    pmName: "",
+    bmName: "",
+    statusId: "",
+    scheduleCollect: "",
+    scheduleAudit: "",
+    projectRole: "",
     pageNum: 1,
     pageSize: 10,
+    type: "inside",
   });
 
   // 封装发送请求的函数
   const A1getListFu = useCallback(() => {
-    console.log(fromData);
-  }, [fromData]);
+    dispatch(A1_APIgetList(fromData));
+  }, [dispatch, fromData]);
 
   useEffect(() => {
     A1getListFu();
   }, [A1getListFu]);
 
   // 项目编号/项目名称/建设单位 的 输入
-  const aaaaTime = useRef(-1);
-  const aaaaChange = useCallback(
+  const searchKeyTime = useRef(-1);
+  const searchKeyChange = useCallback(
     (e: React.ChangeEvent<HTMLInputElement>) => {
-      clearTimeout(aaaaTime.current);
-      aaaaTime.current = window.setTimeout(() => {
+      clearTimeout(searchKeyTime.current);
+      searchKeyTime.current = window.setTimeout(() => {
         setFromData({
           ...fromData,
-          aaaa: e.target.value,
+          searchKey: e.target.value,
           pageNum: 1,
         });
       }, 500);
@@ -143,12 +91,12 @@ function A1Project() {
   );
 
   // 项目经理 下拉 搜索 的 改变
-  const bbbbChange = useCallback(
+  const pmNameChange = useCallback(
     (value: string) => {
       const val = value ? value : "";
       setFromData({
         ...fromData,
-        bbbb: val,
+        pmName: val,
         pageNum: 1,
       });
     },
@@ -156,12 +104,12 @@ function A1Project() {
   );
 
   // 商务经理 下拉 搜索 的 改变
-  const ccccChange = useCallback(
+  const bmNameChange = useCallback(
     (value: string) => {
       const val = value ? value : "";
       setFromData({
         ...fromData,
-        cccc: val,
+        bmName: val,
         pageNum: 1,
       });
     },
@@ -174,15 +122,16 @@ function A1Project() {
     // 把2个输入框和时间选择器清空
     setInputKey(Date.now());
     setFromData({
-      aaaa: "",
-      bbbb: "",
-      cccc: "",
-      dddd: "",
-      eeee: "",
-      ffff: "",
-      gggg: "",
+      searchKey: "",
+      pmName: "",
+      bmName: "",
+      statusId: "",
+      scheduleCollect: "",
+      scheduleAudit: "",
+      projectRole: "",
       pageNum: 1,
       pageSize: 10,
+      type: "inside",
     });
   }, []);
 
@@ -209,7 +158,16 @@ function A1Project() {
   );
 
   // 点击删除
-  const delById = useCallback((id: number) => {}, []);
+  const delById = useCallback(
+    async (id: number) => {
+      const res = await A2_APIdelProject(id);
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        A1getListFu();
+      }
+    },
+    [A1getListFu]
+  );
 
   // 点击下载
   const [downId, setDownId] = useState(0);
@@ -217,43 +175,55 @@ function A1Project() {
   // 点击审批
   const lookTabType = useRef(false);
 
+  // 待审批,通过,驳回 的 格式处理
+  const pcsTxt = useCallback((s1: string, s2: string, s3: string) => {
+    const ss1 = s1 ? s1 : "0";
+    const ss2 = s2 ? `/${s2}` : "/0";
+    const ss3 = s3 ? `/${s3}` : "/0";
+    return ss1 + ss2 + ss3;
+  }, []);
+
   const columns = useMemo(() => {
     const arr: any = [
       {
         title: "项目编号",
-        dataIndex: "a",
+        dataIndex: "num",
       },
       {
         title: "项目名称",
-        dataIndex: "a",
+        dataIndex: "name",
       },
       {
         title: "建设单位",
-        dataIndex: "a",
+        render: (item: A1TableType) => (item.unit ? item.unit : "(空)"),
       },
       {
         title: "项目地点",
-        dataIndex: "a",
+        render: (item: A1TableType) =>
+          item.province ? item.province : "(空)",
       },
       {
         title: "项目周期",
-        dataIndex: "a",
+        render: (item: A1TableType) =>
+          item.dateScope ? item.dateScope : "(空)",
       },
       {
         title: "项目经理",
-        dataIndex: "a",
+        render: (item: A1TableType) =>
+          item.snapPmUser ? item.snapPmUser : "(空)",
       },
       {
         title: "商务经理",
-        dataIndex: "a",
+        render: (item: A1TableType) =>
+          item.snapBmUser ? item.snapBmUser : "(空)",
       },
       {
         title: "项目状态",
-        dataIndex: "a",
+        dataIndex: "statusName",
       },
       {
         title: "最近编辑时间",
-        dataIndex: "a",
+        dataIndex: "updateTime",
       },
     ];
 
@@ -261,7 +231,8 @@ function A1Project() {
       arr.push(
         {
           title: "收集文件类型",
-          dataIndex: "a",
+          render: (item: A1TableType) =>
+            item.pcsCollect ? item.pcsCollect : "(空)",
         },
         {
           width: 164,
@@ -273,7 +244,8 @@ function A1Project() {
               </div>
             </Tooltip>
           ),
-          dataIndex: "a",
+          render: (item: A1TableType) =>
+            pcsTxt(item.pcs0, item.pcs1, item.pcs2),
         }
       );
     }
@@ -287,7 +259,11 @@ function A1Project() {
             type="text"
             onClick={() => {
               lookTabType.current = false;
-              setPageType({ txt: "look", id: item.id });
+              setPageType({
+                txt: "look",
+                id: item.id,
+                tit: item.num + " - " + item.name,
+              });
             }}
           >
             查看
@@ -298,7 +274,11 @@ function A1Project() {
               type="text"
               onClick={() => {
                 lookTabType.current = true;
-                setPageType({ txt: "look", id: item.id });
+                setPageType({
+                  txt: "look",
+                  id: item.id,
+                  tit: item.num + " - " + item.name,
+                });
               }}
             >
               审批
@@ -324,10 +304,14 @@ function A1Project() {
     });
 
     return arr;
-  }, [delById, topType]);
+  }, [delById, pcsTxt, topType]);
 
   // 新增和查看
-  const [pageType, setPageType] = useState({ txt: "", id: 0 });
+  const [pageType, setPageType] = useState<{
+    txt: string;
+    id: number;
+    tit?: string;
+  }>({ txt: "", id: 0 });
 
   return (
     <div className={styles.A1Project}>
@@ -367,7 +351,7 @@ function A1Project() {
               style={{ width: 200 }}
               placeholder="请输入内容,最多20字"
               allowClear
-              onChange={(e) => aaaaChange(e)}
+              onChange={(e) => searchKeyChange(e)}
             />
           </div>
 
@@ -380,13 +364,13 @@ function A1Project() {
               allowClear
               placeholder="请选择或输入内容搜索"
               optionFilterProp="children"
-              onChange={bbbbChange}
+              onChange={pmNameChange}
               filterOption={(input, option) =>
                 (option?.label ?? "")
                   .toLowerCase()
                   .includes(input.toLowerCase())
               }
-              options={bbbbArr}
+              options={pmNameArr}
             />
           </div>
 
@@ -399,13 +383,13 @@ function A1Project() {
               allowClear
               placeholder="请选择或输入内容搜索"
               optionFilterProp="children"
-              onChange={ccccChange}
+              onChange={bmNameChange}
               filterOption={(input, option) =>
                 (option?.label ?? "")
                   .toLowerCase()
                   .includes(input.toLowerCase())
               }
-              options={ccccArr}
+              options={pmNameArr}
             />
           </div>
         </div>
@@ -414,11 +398,14 @@ function A1Project() {
             <span>项目状态:</span>
             <Select
               style={{ width: 164 }}
-              value={fromData.dddd}
+              value={fromData.statusId}
               onChange={(e) =>
-                setFromData({ ...fromData, dddd: e, pageNum: 1 })
+                setFromData({ ...fromData, statusId: e, pageNum: 1 })
               }
-              options={ddddArr}
+              options={[
+                { value: "", label: "全部" },
+                ...statusArr.map((v) => ({ value: v.id, label: v.name })),
+              ]}
             />
           </div>
 
@@ -429,11 +416,11 @@ function A1Project() {
                 <span>收集进度:</span>
                 <Select
                   style={{ width: 164 }}
-                  value={fromData.eeee}
+                  value={fromData.scheduleCollect}
                   onChange={(e) =>
-                    setFromData({ ...fromData, eeee: e, pageNum: 1 })
+                    setFromData({ ...fromData, scheduleCollect: e, pageNum: 1 })
                   }
-                  options={eeeeArr}
+                  options={scheduleCollectArr}
                 />
               </div>
 
@@ -441,11 +428,11 @@ function A1Project() {
                 <span>审批进度:</span>
                 <Select
                   style={{ width: 164 }}
-                  value={fromData.ffff}
+                  value={fromData.scheduleAudit}
                   onChange={(e) =>
-                    setFromData({ ...fromData, ffff: e, pageNum: 1 })
+                    setFromData({ ...fromData, scheduleAudit: e, pageNum: 1 })
                   }
-                  options={ffffArr}
+                  options={scheduleAuditArr}
                 />
               </div>
 
@@ -453,11 +440,11 @@ function A1Project() {
                 <span>项目角色:</span>
                 <Select
                   style={{ width: 164 }}
-                  value={fromData.gggg}
+                  value={fromData.projectRole}
                   onChange={(e) =>
-                    setFromData({ ...fromData, gggg: e, pageNum: 1 })
+                    setFromData({ ...fromData, projectRole: e, pageNum: 1 })
                   }
-                  options={ggggArr}
+                  options={projectRoleArr}
                 />
               </div>
             </>
@@ -506,6 +493,8 @@ function A1Project() {
           pageType={pageType}
           closeFu={() => setPageType({ txt: "", id: 0 })}
           tabType={lookTabType.current}
+          lookTit={pageType.tit!}
+          editTopFu={() => A1getListFu()}
         />
       ) : null}
 

+ 2 - 2
src/pages/A3User/UserAdd/index.tsx

@@ -187,7 +187,7 @@ function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
             rules={[{ required: true, message: "请选择部门!" }]}
           >
             <Cascader
-              style={{ width: 300 }}
+              style={{ width: 400 }}
               options={deptList}
               fieldNames={{ label: "name", value: "id" }}
               placeholder="请选择"
@@ -200,7 +200,7 @@ function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
             rules={[{ required: true, message: "请选择角色!" }]}
           >
             <Select
-              style={{ width: 300 }}
+              style={{ width: 400 }}
               placeholder="请选择"
               options={roleList}
             />

+ 7 - 4
src/pages/A3User/index.tsx

@@ -1,5 +1,6 @@
 import { RootState } from "@/store";
 import {
+  A3_APIgetRole,
   getUserListAPI,
   userPassResetAPI,
   userRemoveAPI,
@@ -21,6 +22,11 @@ import UserAdd from "./UserAdd";
 function A3User() {
   const dispatch = useDispatch();
 
+  useEffect(() => {
+    // 获取角色 列表 信息(给 下拉框 页面使用)
+    dispatch(A3_APIgetRole());
+  }, [dispatch]);
+
   const pageNumRef = useRef(1);
   const pagePageRef = useRef(10);
 
@@ -100,11 +106,8 @@ function A3User() {
   // 点击重置
   const [inputKey, setInputKey] = useState(1);
   const resetSelectFu = useCallback(() => {
-
     // 级联筛选 恢复 初始
-    setTreeDept([undefined])
-
-
+    setTreeDept([undefined]);
 
     // 把2个输入框和时间选择器清空
     setInputKey(Date.now());

+ 4 - 8
src/pages/Layout/index.tsx

@@ -23,7 +23,6 @@ import { useDispatch, useSelector } from "react-redux";
 import { A5_APIgetList } from "@/store/action/A5Section";
 import { A4_APIgetRoleAll } from "@/store/action/A4Role";
 import { A2_APIgetListFile } from "@/store/action/A2Dict";
-import { A3_APIgetRole } from "@/store/action/A3User";
 import NotFound from "@/components/NotFound";
 import tabLeftArr from "./data";
 import { RootState } from "@/store";
@@ -33,16 +32,13 @@ function Layout() {
   const dispatch = useDispatch();
 
   useEffect(() => {
-    // 进页面获取 部门 列表 信息(给 用户管理、字段管理、项目管理 页面使用)
-    dispatch(A5_APIgetList());
-
-    // 获取角色 列表 信息(给 用户管理、项目管理 页面使用)
-    dispatch(A3_APIgetRole());
-
     // 获取权限信息(整个项目的关于权限的信息)
     dispatch(A4_APIgetRoleAll());
 
-    // 获取字典的 -内控文件属性 列表(角色管理等页面使用)
+    // 进页面获取 部门 列表 信息(给 用户管理、字典管理 项目管理-内控文件下拉框 页面使用)
+    dispatch(A5_APIgetList());
+
+    // 获取字典的 -内控文件属性 列表(角色管理 项目管理-内控文件下拉框 页面使用)
     dispatch(A2_APIgetListFile());
   }, [dispatch]);
 

+ 23 - 3
src/store/action/A1Project.ts

@@ -5,14 +5,34 @@ import { AppDispatch } from "..";
  */
 export const A1_APIgetList = (data: any) => {
   return async (dispatch: AppDispatch) => {
-    const res = await http.post("cms/book/pageList", data);
+    const res = await http.post("cms/project/pageList", data);
     if (res.code === 0) {
       const obj = {
         list: res.data.records,
         total: res.data.total,
       };
-
       dispatch({ type: "A1/getList", payload: obj });
     }
   };
-};
+};
+
+/**
+ * 新增、编辑 项目
+ */
+export const A2_APIaddProject = (data: any) => {
+  return http.post("cms/project/save", data);
+};
+
+/**
+ * 通过id获取项目详情
+ */
+export const A2_APIgetInfoById = (id: number) => {
+  return http.get(`cms/project/detail/${id}`);
+};
+
+/**
+ * 通过id删除项目
+ */
+export const A2_APIdelProject = (id: number) => {
+  return http.get(`cms/project/remove/${id}`);
+};

+ 1 - 4
src/store/reducer/A1Project.ts

@@ -4,10 +4,7 @@ import { A1TableType } from "@/types";
 const initState = {
   // 列表数据
   tableInfo: {
-    list: [
-      { id: 1, a: 1, b: 2, c: 3, d: 4, e: 5 },
-      { id: 2, a: 1, b: 2, c: 3, d: 4, e: 5 },
-    ] as A1TableType[],
+    list: [] as A1TableType[],
     total: 2,
   },
 };

+ 20 - 1
src/types/api/A1Project.d.ts

@@ -1 +1,20 @@
-export type A1TableType=any
+export type A1TableType = {
+  city: string;
+  createTime: string;
+  creatorId?: any;
+  creatorName: string;
+  dateScope: string;
+  id: number;
+  name: string;
+  num: string;
+  pcs0: string;
+  pcs1: string;
+  pcs2: string;
+  pcsCollect: string;
+  province: string;
+  snapBmUser: string;
+  snapPmUser: string;
+  unit: string;
+  updateTime: string;
+  amount:string
+};

+ 1 - 0
src/types/api/layot.d.ts

@@ -14,4 +14,5 @@ export type FileImgListType = {
   id: number;
   fileName: string;
   filePath: string;
+  type:'img'|'video'|'doc'
 };

+ 6 - 2
src/utils/http.ts

@@ -10,7 +10,7 @@ export const baseURL =
   process.env.NODE_ENV === "development"
     ? "http://192.168.20.61:8054/api/"
     : "";
-  // process.env.NODE_ENV === "development" ? "https://ytxbwg.4dage.com" : "";
+// process.env.NODE_ENV === "development" ? "https://ytxbwg.4dage.com" : "";
 
 // 处理  类型“AxiosResponse<any, any>”上不存在属性“code”
 declare module "axios" {
@@ -83,7 +83,11 @@ http.interceptors.response.use(
         if (store.getState().A0Layout.closeUpFile.state)
           MessageFu.warning("取消上传!");
         else MessageFu.error("网络繁忙,请稍后重试!");
-      } else MessageFu.error("响应错误,请联系管理员!");
+      } else {
+        if (err.response && err.response.data && err.response.data.msg)
+          MessageFu.error(err.response.data.msg);
+        else MessageFu.error("响应错误,请联系管理员!");
+      }
     }, 100);
 
     return Promise.reject(err);