shaogen1995 2 gadi atpakaļ
vecāks
revīzija
762f33ff51

+ 2 - 46
README.md

@@ -1,46 +1,2 @@
-# Getting Started with Create React App
-
-This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
-
-## Available Scripts
-
-In the project directory, you can run:
-
-### `npm start`
-
-Runs the app in the development mode.\
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
-
-The page will reload if you make edits.\
-You will also see any lint errors in the console.
-
-### `npm test`
-
-Launches the test runner in the interactive watch mode.\
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
-
-### `npm run build`
-
-Builds the app for production to the `build` folder.\
-It correctly bundles React in production mode and optimizes the build for the best performance.
-
-The build is minified and the filenames include the hashes.\
-Your app is ready to be deployed!
-
-See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
-
-### `npm run eject`
-
-**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
-
-If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
-
-Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
-
-You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
-
-## Learn More
-
-You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
-
-To learn React, check out the [React documentation](https://reactjs.org/).
+改动了部分源码。
+接手项目请联系:邵根-18702025090

+ 1 - 1
src/assets/styles/base.css

@@ -153,7 +153,7 @@ textarea {
 }
 #root #A2Table3 .ant-table-cell-with-append {
   display: flex;
-  justify-content: start;
+  justify-content: flex-start;
 }
 [hidden] {
   display: none !important;

+ 1 - 1
src/assets/styles/base.less

@@ -207,7 +207,7 @@ textarea {
 
     .ant-table-cell-with-append {
       display: flex;
-      justify-content: start;
+      justify-content: flex-start;
     }
   }
 

+ 8 - 1
src/pages/A1Project/A1Add/index.tsx

@@ -162,11 +162,18 @@ function A1Add({ pageType, closeFu, addFu, editFu }: Props) {
       // 项目成果
       const filesRes = filesRef.current.filesIdRes();
 
+      const fileIds =
+        imgsRes + videosRes
+          ? `,${videosRes}`
+          : "" + filesRes
+          ? `,${filesRes}`
+          : "";
+
       const obj = {
         ...value,
         id: pageType.txt === "add" ? null : pageType.id,
         dateScope,
-        fileIds: imgsRes + "," + videosRes + "," + filesRes,
+        fileIds,
         linkJson: JSON.stringify(linkArr),
         province,
         dirCode,

+ 31 - 8
src/pages/A1Project/A1Inner/A1IupFile/index.module.scss

@@ -6,7 +6,7 @@
     }
 
     .ant-modal {
-      width: 800px !important;
+      width: 1000px !important;
     }
 
     .A1OMain {
@@ -36,10 +36,10 @@
       }
 
       .ant-upload-list-item-name {
-        width: calc(100% - 538px) !important;
+        width: calc(100% - 632px) !important;
         transition: none !important;
         flex: none !important;
-        margin-right: 506px;
+        margin-right: 598px;
       }
 
       .ant-upload-list-item-container {
@@ -76,7 +76,7 @@
             cursor: default;
             position: absolute;
             z-index: 15;
-            right: 470px;
+            right: 854px;
             top: -1px;
             font-size: 12px;
             height: 30px;
@@ -85,10 +85,9 @@
 
           // 下拉框
           .A1IUselect {
-            max-lines: 0;
             cursor: default;
             position: absolute;
-            left: -460px;
+            left: -552px;
             top: 0px;
             z-index: 10;
 
@@ -96,9 +95,9 @@
               font-size: 12px;
               position: absolute;
               top: 25px;
-              left: -126px;
+              left: -235px;
               z-index: -1;
-              width: 650px;
+              width: 850px;
 
               .A1IUselectTit1 {
                 color: #ff4d4f;
@@ -109,6 +108,7 @@
                 display: flex;
 
                 &>div {
+                  color: #999;
                   flex: 1;
                   cursor: pointer;
                   overflow: hidden;
@@ -123,6 +123,29 @@
             }
           }
 
+          // 重命名
+          .A1IUselectName {
+            position: absolute;
+            z-index: 10;
+            left: -339px;
+            top: 0px;
+            display: flex;
+            width: 335px;
+            font-size: 12px;
+
+            .A1IUselectName1 {
+              cursor: default;
+              width: 60px;
+            }
+
+            .A1IUselectName2 {
+              width: calc(100% - 60px);
+              overflow: hidden;
+              text-overflow: ellipsis;
+              white-space: nowrap;
+            }
+          }
+
         }
 
 

+ 159 - 71
src/pages/A1Project/A1Inner/A1IupFile/index.tsx

@@ -19,56 +19,121 @@ import history from "@/utils/history";
 import React from "react";
 import { getTokenFu } from "@/utils/storage";
 import { MessageFu } from "@/utils/message";
-import { A1_APIOupFileIds, A1_APIremoveSure } from "@/store/action/A1Project";
+import {
+  A1_APIIupBtnOk,
+  A1_APIIupIsList,
+  A1_APIremoveSure,
+} from "@/store/action/A1Project";
 import { authFilesLookFu, urlChangeFu } from "@/utils/authFilesLook";
 import { useSelector } from "react-redux";
 import { RootState } from "@/store";
+import { domShowFu } from "@/utils/domShow";
 
 const { Dragger } = Upload;
 
-type SelectType = {
-  id: string;
-  value: number | undefined;
-  txt: string;
-  tit: string;
-  fileName: string;
-};
+// type SelectType = {
+//   id: number;
+//   value: number | undefined;
+//   txt: string;
+//   tit: string;
+//   fileName: string;
+//   resName:string
+// };
 
 type props = {
   myUrl: string;
   upFileFu: () => void;
   closeFu: () => void;
+  myTitle: string;
+  projectId: number;
 };
 
-function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
-  // 从仓库获取 内控文件 属性
-  const typeData = useSelector((state: RootState) => state.A2Dict.A2Tab2Arr);
+function A1IupFile({ myUrl, closeFu, upFileFu, myTitle, projectId }: props) {
+  // 获取回显列表,重命名的时候使用
+  const [isFileList, setIsFileList] = useState<string[]>([]);
 
-  const [typeSelect, setTypeSelect] = useState([] as SelectType[]);
+  const getIsFileListFu = useCallback(async () => {
+    const res = await A1_APIIupIsList(projectId);
+    if (res.code === 0) {
+      setIsFileList(res.data.map((v: any) => v.fileName));
+    }
+  }, [projectId]);
 
   useEffect(() => {
-    console.log("pppppppp", typeSelect);
-  }, [typeSelect]);
+    getIsFileListFu();
+  }, [getIsFileListFu]);
+
+  const [modal, contextHolder] = Modal.useModal();
+
+  const [fileList, setFileList] = useState<UploadFile[]>([]);
+
+  const timeRef = useRef(-1);
+
+  // 从仓库获取 内控文件 属性
+  const typeData = useSelector((state: RootState) => state.A2Dict.A2Tab2Arr);
 
   // 下拉框改变
   const selectChangeFu = useCallback(
-    (val: number, id: string) => {
+    (val: number, uid: string, id: number) => {
       const info = typeData.find((v) => v.id === val)!;
 
       const tit = info.suffix ? info.suffix : "all";
 
-      setTypeSelect(
-        typeSelect.map((v) => ({
+      const idName = info.name;
+
+      // 如果已经有相同的重命名
+      let resName = myTitle + "_" + idName;
+
+      const isArr = fileList.find((v) => v.mySelect.resName === resName);
+
+      const nameArr = fileList.filter((v) =>
+        v.mySelect.resName.includes(resName)
+      );
+
+      if (isFileList.length) {
+
+        console.log(isFileList);
+        
+
+        const isArr2 = isFileList.find((v) => v === resName);
+        const nameArr2 = isFileList.filter((v) => v.includes(resName));
+
+        if (nameArr.length > 0 && nameArr2.length > 0 && isArr && isArr2) {
+          resName = `${myTitle}_${idName}(${
+            nameArr.length + nameArr2.length + 1
+          })`;
+        }
+      } else {
+        if (nameArr.length > 0 && isArr) {
+          resName = `${myTitle}_${idName}(${nameArr.length + 1})`;
+        }
+      }
+
+      setFileList(
+        fileList.map((v) => ({
           ...v,
-          value: v.id === id ? val : v.value,
-          txt: v.id === id ? info.description : v.txt,
-          tit: v.id === id ? tit : v.tit,
+          mySelect:
+            v.uid === uid
+              ? {
+                  ...v.mySelect,
+                  value: v.mySelect.id === id ? val : v.mySelect.value,
+                  txt: v.mySelect.id === id ? info.description : v.mySelect.txt,
+                  tit: v.mySelect.id === id ? tit : v.mySelect.tit,
+                  resName,
+                }
+              : v.mySelect,
         }))
       );
     },
-    [typeData, typeSelect]
+    [fileList, isFileList, myTitle, typeData]
   );
 
+  // 重命名的文件后缀
+  const houzuiFu = useCallback((name: string) => {
+    const arr = name.split(".") || [""];
+    return "." + arr[arr.length - 1];
+  }, []);
+
   // 校验指定格式
   const typeGeShiFlag = useCallback((val: string, name: string) => {
     if (val === "all") return false;
@@ -85,11 +150,14 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
     }
   }, []);
 
-  // 确定按钮的格式校验
-  const disBtnOkRes = useMemo(() => {
+  // 确定按钮的格式校验(指定文件类型,没有对应上)
+  const disBtnOkRes1 = useMemo(() => {
     let flag = false;
-    typeSelect.forEach((v) => {
-      if (v.tit !== "all") {
+
+    const resArr = fileList.map((v) => v.mySelect || {});
+
+    resArr.forEach((v) => {
+      if (v.tit && v.tit !== "all") {
         const arr = v.tit.split(","); //['pdf','gif']
 
         const arr2 = v.fileName.split(".");
@@ -100,13 +168,20 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
       }
     });
     return flag;
-  }, [typeSelect]);
+  }, [fileList]);
 
-  const [modal, contextHolder] = Modal.useModal();
+  //  确定按钮的格式校验(有下拉框没有选择)
+  const disBtnOkRes2 = useMemo(() => {
+    let flag = false;
 
-  const [fileList, setFileList] = useState<UploadFile[]>([]);
+    fileList.forEach((v) => {
+      if (v.mySelect) {
+        if (!v.mySelect.value) flag = true;
+      } else flag = true;
+    });
 
-  const timeRef = useRef(-1);
+    return flag;
+  }, [fileList]);
 
   const FileProps: UploadProps = {
     name: "file",
@@ -154,18 +229,22 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
       }
       if (status === "done") {
         // console.log("-----", info);
-
-        setTypeSelect([
-          ...typeSelect,
-          {
-            id: info.file.response.data.id,
-            value: undefined,
-            txt: "",
-            tit: "",
-            fileName: info.file.name,
-          },
-        ]);
-
+        setFileList(
+          info.fileList.map((v) => ({
+            ...v,
+            mySelect:
+              info.file.uid === v.uid
+                ? {
+                    id: info.file.response.data.id,
+                    value: undefined,
+                    txt: "",
+                    tit: "",
+                    resName: "",
+                    fileName: info.file.name,
+                  }
+                : v.mySelect,
+          }))
+        );
         // message.success(`${info.file.fileName} 上传成功.`);
       } else if (status === "error") {
         message.error(`${info.file.fileName} 上传失败.`);
@@ -196,9 +275,12 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
               const res = await A1_APIremoveSure([id + ""]);
 
               if (res.code === 0) {
-                setTypeSelect(typeSelect.filter((v) => v.id !== id));
+                domShowFu("#AsyncSpinLoding", true);
                 resolve(true);
-                MessageFu.success("删除成功!");
+                setTimeout(() => {
+                  domShowFu("#AsyncSpinLoding", false);
+                  MessageFu.success("删除成功!");
+                }, 2000);
               }
             } else {
               resolve(true);
@@ -221,20 +303,24 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
 
     // 拿到 id集合
 
-    const ids: number[] = [];
+    const arr: any = [];
 
     fileList.forEach((v) => {
-      ids.push(v.response.data.id);
+      arr.push({
+        attributeId: v.mySelect.value,
+        fileName: v.mySelect.resName + houzuiFu(v.mySelect.fileName),
+        id: v.mySelect.id,
+      });
     });
 
-    const res = await A1_APIOupFileIds(ids.join(","));
+    const res = await A1_APIIupBtnOk(projectId, arr);
 
     if (res.code === 0) {
       MessageFu.success("保存成功!");
       upFileFu();
       closeFu();
     }
-  }, [closeFu, fileList, upFileFu]);
+  }, [closeFu, fileList, houzuiFu, projectId, upFileFu]);
 
   return (
     <Modal
@@ -298,8 +384,8 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
                     <Select
                       style={{ width: 200 }}
                       placeholder="请选择"
-                      value={typeSelect[i] ? typeSelect[i].value : undefined}
-                      onChange={(e) => selectChangeFu(e, typeSelect[i].id)}
+                      value={v.mySelect.value || undefined}
+                      onChange={(e) => selectChangeFu(e, v.uid, v.mySelect.id)}
                       options={typeData.map((v) => ({
                         value: v.id,
                         label: v.name,
@@ -308,45 +394,51 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
 
                     {/* 没选择的时候的提示 */}
                     <div className="A1IUselectTit">
-                      {typeSelect[i] && typeSelect[i].value ? (
+                      {v.mySelect && v.mySelect.value ? (
                         <div className="A1IUselectTit2">
-                          <div title={typeSelect[i].txt}>
-                            {typeSelect[i].txt}
-                          </div>
+                          <div title={v.mySelect.txt}>{v.mySelect.txt}</div>
 
                           {typeGeShiFlag(
-                            typeSelect[i].tit,
-                            typeSelect[i].fileName
+                            v.mySelect.tit,
+                            v.mySelect.fileName
                           ) ? (
                             <div
                               className="A1IUselectTit2Tit"
-                              title={`该文件类型只支持 ${typeSelect[i].tit}`}
+                              title={`该文件类型只支持 ${v.mySelect.tit}`}
                             >
-                              &emsp;该文件类型只支持 {typeSelect[i].tit} 格式
+                              &emsp;该文件类型只支持 {v.mySelect.tit} 格式
                             </div>
                           ) : null}
-
-                          {/* {typeSelect[i].tit !== "all" &&
-                          typeSelect[i].fileName.includes(typeSelect[i].tit) ? (
-                            
-                          ) : (
-                            ""
-                          )} */}
                         </div>
                       ) : (
                         <div className="A1IUselectTit1">请选择文件类型</div>
                       )}
                     </div>
                   </div>
+
+                  {/* 重命名 */}
+                  {v.mySelect.resName ? (
+                    <div className="A1IUselectName">
+                      <div className="A1IUselectName1">重命名为:</div>
+                      <div
+                        className="A1IUselectName2"
+                        title={
+                          v.mySelect.resName + houzuiFu(v.mySelect.fileName)
+                        }
+                      >
+                        {v.mySelect.resName + houzuiFu(v.mySelect.fileName)}
+                      </div>
+                    </div>
+                  ) : null}
                 </>
               ) : (
                 ""
               )}
 
               {/* 3.前面的序号 */}
-              {/* <div className="mySortQ" hidden={fileList.length <= 1}>
+              <div className="mySortQ" hidden={fileList.length <= 1}>
                 {i + 1}.
-              </div> */}
+              </div>
             </div>
           ))}
         </div>
@@ -366,11 +458,7 @@ function A1IupFile({ myUrl, closeFu, upFileFu }: props) {
         <Button
           type="primary"
           onClick={btnOkFu}
-          disabled={
-            fileList.length <= 0 ||
-            typeSelect.some((v) => !v.value) ||
-            disBtnOkRes
-          }
+          disabled={fileList.length <= 0 || disBtnOkRes1 || disBtnOkRes2}
         >
           确定
         </Button>

+ 4 - 1
src/pages/A1Project/A1Inner/index.tsx

@@ -28,9 +28,10 @@ type FromType = {
 
 type Props = {
   projectId: number;
+  myTitle:string
 };
 
-function A1Inner({ projectId }: Props) {
+function A1Inner({ projectId,myTitle }: Props) {
   // 表单数据
   const [fromData, setFromData] = useState<FromType>({
     searchKey: "",
@@ -370,6 +371,8 @@ function A1Inner({ projectId }: Props) {
           myUrl={`${baseURL}cms/inside/upload/${projectId}`}
           upFileFu={() => getListFu()}
           closeFu={() => setUpFileOpen(false)}
+          myTitle={myTitle}
+          projectId={projectId}
         />
       ) : null}
     </div>

+ 6 - 6
src/pages/A1Project/A1Look/index.tsx

@@ -20,10 +20,9 @@ type Props = {
   closeFu: () => void;
   tabType: boolean; //是否是审批
   lookTit: string; //顶部项目名字和编号
-  editTopFu: () => void;
 };
 
-function A1Look({ pageType, closeFu, tabType, lookTit, editTopFu }: Props) {
+function A1Look({ pageType, closeFu, tabType, lookTit }: Props) {
   // 动态改变顶部 title
   const [myTitle, setMyTitle] = useState("");
 
@@ -61,10 +60,8 @@ function A1Look({ pageType, closeFu, tabType, lookTit, editTopFu }: Props) {
       setTab1Key(Date.now());
       // 动态修改 顶部 标题
       setMyTitle(val);
-      // 更新最外层的表格数据(点击返回的时候要看到最新的数据)
-      editTopFu();
     },
-    [editTopFu]
+    []
   );
 
   return (
@@ -110,7 +107,10 @@ function A1Look({ pageType, closeFu, tabType, lookTit, editTopFu }: Props) {
         ) : topType === 2 ? (
           <A1Outer projectId={pageType.id} projectName={myTitle} />
         ) : topType === 3 ? (
-          <A1Inner projectId={pageType.id}/>
+          <A1Inner
+            projectId={pageType.id}
+            myTitle={myTitle.split(" - ") ? myTitle.split(" - ")[0] : ""}
+          />
         ) : topType === 4 ? (
           <A1User projectId={pageType.id} />
         ) : null}

+ 5 - 2
src/pages/A1Project/index.tsx

@@ -499,10 +499,13 @@ function A1Project() {
       ) : pageType.txt === "look" ? (
         <A1Look
           pageType={pageType}
-          closeFu={() => setPageType({ txt: "", id: 0 })}
+          closeFu={() => {
+            setPageType({ txt: "", id: 0 });
+            // 从查看页面返回的时候更新列表数据
+            A1getListFu();
+          }}
           tabType={lookTabType.current}
           lookTit={pageType.tit!}
-          editTopFu={() => A1getListFu()}
         />
       ) : null}
 

+ 17 - 4
src/store/action/A1Project.ts

@@ -180,10 +180,23 @@ export const A1_APIIsaveLack = (
   return http.post(`cms/inside/lack/save/${projectId}`, data);
 };
 
-
 /**
  * 内控文件---------审批
  */
-export const A1_APIIaudit = (data:any) => {
-  return http.post('cms/inside/audit',data);
-};
+export const A1_APIIaudit = (data: any) => {
+  return http.post("cms/inside/audit", data);
+};
+
+/**
+ * 内控文件---------上传点击确定
+ */
+export const A1_APIIupBtnOk = (projectId: number, data: any) => {
+  return http.post(`cms/inside/update/${projectId}`, data);
+};
+
+/**
+ * 内控文件---------回显已上传的文件
+ */
+export const A1_APIIupIsList = (projectId: number) => {
+  return http.get(`cms/inside/download/echoList/${projectId}`);
+};