shaogen1995 2 éve
szülő
commit
0eda3cfac2

+ 2 - 2
src/pages/A2Dict/A2Tab1/A2Table3.tsx

@@ -1,5 +1,5 @@
 import React, { useCallback, useMemo } from "react";
-import { Button, Popconfirm, Table } from "antd";
+import { Button, Empty, Popconfirm, Table } from "antd";
 import { useSelector } from "react-redux";
 import { RootState } from "@/store";
 import { A2_APIdel, A2_APIsort } from "@/store/action/A2Dict";
@@ -191,7 +191,7 @@ function A2Table3({ editFu, upTaleFu, myType }: Props) {
           pagination={false}
           expandable={{ defaultExpandAllRows: true }}
         />
-      ) : null}
+      ) : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
     </div>
   );
 }

+ 55 - 44
src/pages/A2Dict/A2Tab2/A2Tab2Add/index.module.scss

@@ -6,68 +6,79 @@
 
     .ant-modal {
       width: 800px !important;
+      top: 50px !important;
+
     }
 
     .A2Tab2AddMain {
       margin-top: 10px;
       border-top: 1px solid #999999;
       padding-top: 25px;
-      max-height: 650px;
-      overflow-y: auto;
-
-      .A2Tab2AddRow {
-        margin-bottom: 20px;
-        position: relative;
-        display: flex;
-        padding: 0 24px 0 0px;
-        text-align: right;
-
-        .rowSpan {
-          display: inline-block;
-          width: 80px;
-          line-height: 32px;
-
-          &>span {
-            position: relative;
-            top: 2px;
-            color: #ff4d4f;
+
+      max-height: 610px;
+
+
+      .A2Tab2AddMainC {
+        min-height: 200px;
+        max-height: 540px;
+        overflow-y: auto;
+
+        .A2Tab2AddRow {
+          margin-bottom: 20px;
+          position: relative;
+          display: flex;
+          padding: 0 24px 0 0px;
+          text-align: right;
+
+          .rowSpan {
+            display: inline-block;
+            width: 80px;
+            line-height: 32px;
+
+            &>span {
+              position: relative;
+              top: 2px;
+              color: #ff4d4f;
+            }
           }
-        }
 
-        .bs {
-          &::before {
-            content: '*';
-            position: absolute;
-            top: 2px;
-            left: 1px;
-            z-index: 10;
-            color: #ff4d4f;
+          .bs {
+            &::before {
+              content: '*';
+              position: absolute;
+              top: 2px;
+              left: 1px;
+              z-index: 10;
+              color: #ff4d4f;
+            }
           }
-        }
 
-        .inputBox {
-          width: calc(100% - 90px);
+          .inputBox {
+            width: calc(100% - 90px);
 
-          // 针对树表格
-          .ant-table-row-expand-icon {
-            display: none !important;
-          }
+            // 针对树表格
+            .ant-table-row-expand-icon {
+              display: none !important;
+            }
 
-        }
+          }
 
-        .A2Tab2AddRowRigth {
-          padding-top: 4px;
-          width: calc(100% - 90px);
-          text-align: left;
+          .A2Tab2AddRowRigth {
+            padding-top: 4px;
+            width: calc(100% - 90px);
+            text-align: left;
 
-          .A2T2row3 {
-            padding-top: 10px;
-            padding-left: 96px;
+            .A2T2row3 {
+              padding-top: 10px;
+              padding-left: 96px;
+            }
           }
-        }
 
+        }
       }
 
+
+
       .A2Tab2AddMBtn {
         margin-top: 30px;
         text-align: center;

+ 142 - 93
src/pages/A2Dict/A2Tab2/A2Tab2Add/index.tsx

@@ -7,12 +7,21 @@ import { MessageFu } from "@/utils/message";
 import A2Tab2AddTable from "./A2Tab2AddTable";
 import { RootState } from "@/store";
 import { useSelector } from "react-redux";
+import { A2_APIFileAdd } from "@/store/action/A2Dict";
 
 const row3ArrData = [
   { id: 1, name: "所有格式" },
   { id: 2, name: "指定格式" },
 ];
 
+const arrTemp = [
+  {
+    id: 1,
+    done: true,
+    label: "pdf",
+  },
+];
+
 type Props = {
   info: A2Tab2Type;
   closeFu: () => void;
@@ -29,18 +38,7 @@ function A2Tab2Add({ info, closeFu, addFu }: Props) {
   // 支持格式
   const [row3, setRow3] = useState<"所有格式" | "指定格式">("所有格式");
 
-  const [row3Arr, setRow3Arr] = useState([
-    {
-      id: 1,
-      done: true,
-      label: "pdf",
-    },
-    {
-      id: 2,
-      done: true,
-      label: "gif",
-    },
-  ]);
+  const [row3Arr, setRow3Arr] = useState(arrTemp);
 
   const row3OnChangeFu = useCallback(
     (val: boolean, id: number) => {
@@ -76,26 +74,68 @@ function A2Tab2Add({ info, closeFu, addFu }: Props) {
     if (info.id !== -1) {
       setName(info.name);
       setDescription(info.description);
+      if (info.formatType === "0") setRow3("所有格式");
+      else {
+        setRow3("指定格式");
+        const arr = info.suffix.split(",");
+        arr.forEach((v1) => {
+          arrTemp.forEach((v2) => {
+            if (v1 === v2.label) v2.done = true;
+          });
+        });
+        setRow3Arr(arrTemp);
+      }
+
+      setRow4Id(info.deptId + "");
+
+      setRow5Id(info.stageId + "");
     }
   }, [info]);
 
   // 点击提交
-  const btnOkFu = useCallback(() => {
+  const btnOkFu = useCallback(async () => {
     if (!name) return MessageFu.warning("文件名称不能为空!");
 
-    if (row3 === "指定格式") {
-      console.log(
-        "-------",
-        row3Arr.filter((v) => v.done)
-      );
+    let obj = {};
+
+    if (info.name === "未分类") {
+      obj = {
+        id: info.id,
+        name,
+        description,
+      };
+    } else {
+      const row3Txt = row3Arr
+        .filter((v) => v.done)
+        .map((v) => v.label)
+        .join(",");
+
+      const id3 = row4Ref.current.A2Tab2AddTableResFu();
+      const id4 = row5Ref.current.A2Tab2AddTableResFu();
+
+      if (!id3) return MessageFu.warning("请选择责任部门!");
+      if (!id4) return MessageFu.warning("请选择所属阶段!");
+
+      obj = {
+        id: info.id === -1 ? null : info.id,
+        name,
+        description,
+        deptId: id3 + "",
+        stageId: id4 + "",
+        suffix: row3 === "指定格式" ? row3Txt : null,
+        formatType: row3 === "所有格式" ? "0" : "1",
+        type: "内控文件",
+      };
     }
 
-    const id3 = row4Ref.current.A2Tab2AddTableResFu();
-    const id4 = row5Ref.current.A2Tab2AddTableResFu();
+    const res = await A2_APIFileAdd(obj);
 
-    if (!id3) return MessageFu.warning("请选择责任部门!");
-    if (!id4) return MessageFu.warning("请选择所属阶段!");
-  }, [name, row3, row3Arr]);
+    if (res.code === 0) {
+      MessageFu.success(info.id === -1 ? "新增成功!" : "编辑成功!");
+      addFu();
+      closeFu();
+    }
+  }, [addFu, closeFu, description, info.id, info.name, name, row3, row3Arr]);
 
   return (
     <Modal
@@ -108,82 +148,91 @@ function A2Tab2Add({ info, closeFu, addFu }: Props) {
       }
     >
       <div className="A2Tab2AddMain">
-        <div className="A2Tab2AddRow">
-          <span className="bs rowSpan">文件名称:</span>
-          <div className="inputBox">
-            <Input
-              disabled={info.name === "未分类"}
-              maxLength={10}
-              value={name}
-              onChange={(e) => setName(e.target.value.replace(/\s+/g, ""))}
-              showCount
-              placeholder="请输入内容,不能重复"
-            />
-          </div>
-        </div>
-
-        <div className="A2Tab2AddRow">
-          <span className="rowSpan">文件说明:</span>
-          <div className="inputBox">
-            <TextArea
-              rows={4}
-              placeholder="请输入内容"
-              maxLength={100}
-              showCount
-              value={description}
-              onChange={(e) =>
-                setDescription(e.target.value.replace(/\s+/g, ""))
-              }
-            />
+        <div className="A2Tab2AddMainC">
+          <div className="A2Tab2AddRow">
+            <span className="bs rowSpan">文件名称:</span>
+            <div className="inputBox">
+              <Input
+                disabled={info.name === "未分类"}
+                maxLength={10}
+                value={name}
+                onChange={(e) => setName(e.target.value.replace(/\s+/g, ""))}
+                showCount
+                placeholder="请输入内容,不能重复"
+              />
+            </div>
           </div>
-        </div>
 
-        <div className="A2Tab2AddRow">
-          <span className="bs rowSpan">支持格式:</span>
-          <div className="A2Tab2AddRowRigth">
-            <Radio.Group onChange={(e) => setRow3(e.target.value)} value={row3}>
-              {row3ArrData.map((v) => (
-                <Radio value={v.name} key={v.id}>
-                  {v.name}
-                </Radio>
-              ))}
-            </Radio.Group>
-            <div className="A2T2row3" hidden={row3 === "所有格式"}>
-              {row3Arr.map((v) => (
-                <Checkbox
-                  key={v.id}
-                  onChange={(e) => row3OnChangeFu(e.target.checked, v.id)}
-                  checked={v.done}
-                >
-                  {v.label}
-                </Checkbox>
-              ))}
+          <div className="A2Tab2AddRow">
+            <span className="rowSpan">文件说明:</span>
+            <div className="inputBox">
+              <TextArea
+                rows={4}
+                placeholder="请输入内容"
+                maxLength={100}
+                showCount
+                value={description}
+                onChange={(e) =>
+                  setDescription(e.target.value.replace(/\s+/g, ""))
+                }
+              />
             </div>
           </div>
-        </div>
 
-        <div className="A2Tab2AddRow">
-          <span className="bs rowSpan">责任部门:</span>
-          <div className="inputBox">
-            <A2Tab2AddTable
-              data={arr1}
-              type="部门"
-              valAc={row4Id}
-              ref={row4Ref}
-            />
-          </div>
-        </div>
+          {info.name === "未分类" ? null : (
+            <>
+              <div className="A2Tab2AddRow">
+                <span className="bs rowSpan">支持格式:</span>
+                <div className="A2Tab2AddRowRigth">
+                  <Radio.Group
+                    onChange={(e) => setRow3(e.target.value)}
+                    value={row3}
+                  >
+                    {row3ArrData.map((v) => (
+                      <Radio value={v.name} key={v.id}>
+                        {v.name}
+                      </Radio>
+                    ))}
+                  </Radio.Group>
+                  <div className="A2T2row3" hidden={row3 === "所有格式"}>
+                    {row3Arr.map((v) => (
+                      <Checkbox
+                        key={v.id}
+                        onChange={(e) => row3OnChangeFu(e.target.checked, v.id)}
+                        checked={v.done}
+                      >
+                        {v.label}
+                      </Checkbox>
+                    ))}
+                  </div>
+                </div>
+              </div>
 
-        <div className="A2Tab2AddRow">
-          <span className="bs rowSpan">所属阶段:</span>
-          <div className="inputBox">
-            <A2Tab2AddTable
-              data={arr2}
-              type="阶段"
-              valAc={row5Id}
-              ref={row5Ref}
-            />
-          </div>
+              <div className="A2Tab2AddRow">
+                <span className="bs rowSpan">责任部门:</span>
+                <div className="inputBox">
+                  <A2Tab2AddTable
+                    data={arr1}
+                    type="部门"
+                    valAc={row4Id}
+                    ref={row4Ref}
+                  />
+                </div>
+              </div>
+
+              <div className="A2Tab2AddRow">
+                <span className="bs rowSpan">所属阶段:</span>
+                <div className="inputBox">
+                  <A2Tab2AddTable
+                    data={arr2}
+                    type="阶段"
+                    valAc={row5Id}
+                    ref={row5Ref}
+                  />
+                </div>
+              </div>
+            </>
+          )}
         </div>
 
         <div className="A2Tab2AddMBtn">

+ 5 - 1
src/pages/A2Dict/A2Tab2/index.tsx

@@ -55,7 +55,11 @@ function A2Tab2() {
       },
       {
         title: "责任部门",
-        dataIndex: "dept",
+        render: (item: A2Tab2Type) => (item.deptName ? item.deptName : "(空)"),
+      },
+      {
+        title: "所属阶段",
+        render: (item: A2Tab2Type) => (item.stageName ? item.stageName : "(空)"),
       },
       {
         title: "操作",

+ 7 - 0
src/store/action/A2Dict.ts

@@ -98,3 +98,10 @@ export const A2_APIgetListFile = () => {
 export const A2_APIdelFile = (id: number) => {
   return http.get(`cms/attribute/remove/${id}`);
 };
+
+/**
+ * 新增/修改
+ */
+export const A2_APIFileAdd = (data: any) => {
+  return http.post("cms/attribute/save", data);
+};

+ 4 - 2
src/types/api/A2Dict.d.ts

@@ -21,12 +21,14 @@ export type A2Tab2Type = {
   createTime: string;
   creatorId?: any;
   creatorName: string;
-  dept: string;
+  deptId:string;
+  deptName: string;
   description: string;
   formatType: string;
   id: number;
   name: string;
-  stage: string;
+  stageId: string;
+  stageName: string;
   suffix: string;
   type: string;
   updateTime: string;

+ 1 - 1
src/utils/http.ts

@@ -8,7 +8,7 @@ import { domShowFu } from "./domShow";
 export const baseURL =
   // 线下的图片地址需要加上/api/
   process.env.NODE_ENV === "development"
-    ? "http://192.168.20.21:8054/api/"
+    ? "http://192.168.20.61:8054/api/"
     : "";
   // process.env.NODE_ENV === "development" ? "https://ytxbwg.4dage.com" : "";