Browse Source

云学校-口述史

shaogen1995 1 year ago
parent
commit
d20b432171

+ 8 - 7
src/components/MyTable/index.tsx

@@ -14,7 +14,10 @@ type Props = {
   onChange?: (pageNum: number, pageSize: number) => void;
   lastBtn?: any;
   classKey?: string; //一个组件多次使用的时候要传递,分别设置style
+  // 表格简单的合并
   merge?: { type: string; num: number; loc: "rowSpan" | "colSpan" };
+  // 定制化表头
+  myTitle?: { name: string; Com: React.ReactNode };
 };
 
 function MyTable({
@@ -33,6 +36,7 @@ function MyTable({
   lastBtn = [],
   classKey = "",
   merge,
+  myTitle,
 }: Props) {
   useEffect(() => {
     const dom = document.querySelector(
@@ -94,24 +98,21 @@ function MyTable({
     [pageNum, pageSize]
   );
 
-
-
   const columns = useMemo(() => {
     const arr: any = columnsTemp.map((v: any) => ({
-      title: v[1],
+      title: myTitle && v.includes(myTitle.name) ? myTitle.Com : v[1],
       render: dataChangeFu(v),
       onCell:
         merge && v.includes(merge.type)
-          ?
-          // {rowSpan:3} 
-          (item: any, index: number) => ({
+          ? // {rowSpan:3}
+            (item: any, index: number) => ({
               rowSpan: index === 0 ? merge.num : 0,
             })
           : "",
     }));
 
     return arr;
-  }, [columnsTemp, dataChangeFu, merge]);
+  }, [columnsTemp, dataChangeFu, merge, myTitle]);
 
   return (
     <Table

+ 2 - 6
src/pages/A4store/A3Edit/index.tsx

@@ -27,8 +27,6 @@ function A3Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
   // 表单的ref
   const FormBoxRef = useRef<FormInstance>(null);
 
-  // 文件的code码
-  const [dirCode, setDirCode] = useState("");
 
   // 封面图的ref
   const ZupOneRef1 = useRef<any>(null);
@@ -42,7 +40,6 @@ function A3Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
 
       ZRichTextRef.current?.ritxtShowFu(data.rtf);
 
-      setDirCode(data.dirCode);
 
       FormBoxRef.current?.setFieldsValue({
         ...data,
@@ -62,7 +59,6 @@ function A3Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
       // 编辑
       getInfoFu(editInfo.id);
     } else {
-      setDirCode(Date.now() + "");
       // 新增
       FormBoxRef.current?.setFieldsValue({
         myTime: dayjs(Date.now()),
@@ -190,7 +186,7 @@ function A3Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
                 isLook={false}
                 fileCheck={fileCheck}
                 size={2}
-                dirCode={dirCode}
+                dirCode='storeThumb'
                 myUrl="cms/prize/upload"
                 format={["image/jpeg", "image/png"]}
                 formatTxt="png、jpg和jpeg"
@@ -210,7 +206,7 @@ function A3Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
             <div className="formRight">
               <ZRichText
                 check={false}
-                dirCode={dirCode}
+                dirCode='storeText'
                 isLook={false}
                 ref={ZRichTextRef}
                 myUrl="cms/prize/upload"

+ 49 - 14
src/pages/A7school/A7tab1M.tsx

@@ -9,11 +9,16 @@ import {
   Modal,
   Select,
 } from "antd";
-import { A7_APIgetInfo, A7_APIgetListByTheme } from "@/store/action/A7school";
+import {
+  A7_APIgetInfo,
+  A7_APIgetListByTheme,
+  A7_APIsave,
+} from "@/store/action/A7school";
 import { ListType } from "./A7theme";
 import MyPopconfirm from "@/components/MyPopconfirm";
 import TextArea from "antd/es/input/TextArea";
 import ZupOne from "@/components/ZupOne";
+import { MessageFu } from "@/utils/message";
 
 type Props = {
   fId: number;
@@ -29,8 +34,20 @@ function A7tab1M({ fId, closeFu, addTableFu, upTableFu }: Props) {
   const getInfoFu = useCallback(async (id: number) => {
     const res = await A7_APIgetInfo(id);
     if (res.code === 0) {
-      console.log(123, res);
-      // setDirCode()
+      const data = res.data;
+
+      FormBoxRef.current?.setFieldsValue(data);
+
+      // 设置封面图
+      ZupOneRef1.current?.setFileComFileFu({
+        fileName: "",
+        filePath: data.thumb,
+      });
+      // 设置视频
+      ZupOneRef2.current?.setFileComFileFu({
+        fileName: data.fileName,
+        filePath: data.filePath,
+      });
     }
   }, []);
 
@@ -44,9 +61,6 @@ function A7tab1M({ fId, closeFu, addTableFu, upTableFu }: Props) {
   useEffect(() => {
     getSelList();
     if (fId > 0) getInfoFu(fId);
-    else {
-      // FormBoxRef.current?.setFieldsValue({});
-    }
   }, [fId, getInfoFu, getSelList]);
 
   // 附件的ref
@@ -56,17 +70,38 @@ function A7tab1M({ fId, closeFu, addTableFu, upTableFu }: Props) {
   // 附件 是否 已经点击过确定
   const [fileCheck, setFileCheck] = useState(false);
 
-  // 文件的code码
-  const [dirCode, setDirCode] = useState("");
-
   // 没有通过校验
   const onFinishFailed = useCallback(() => {
     setFileCheck(true);
   }, []);
   // 通过校验点击确定
-  const onFinish = useCallback(async (values: any) => {
-    setFileCheck(true);
-  }, []);
+  const onFinish = useCallback(
+    async (values: any) => {
+      setFileCheck(true);
+      // 没有传 封面图 或者视频
+      const coverUrl1 = ZupOneRef1.current?.fileComFileResFu();
+      const coverUrl2 = ZupOneRef2.current?.fileComFileResFu();
+
+      if (!coverUrl1.filePath || !coverUrl2.filePath) return;
+
+      const obj = {
+        ...values,
+        id: fId > 0 ? fId : null,
+        fileName: coverUrl2.fileName,
+        filePath: coverUrl2.filePath,
+        thumb: coverUrl1.filePath,
+      };
+
+      const res = await A7_APIsave(obj);
+
+      if (res.code === 0) {
+        MessageFu.success(fId > 0 ? "编辑成功!" : "新增成功!");
+        fId > 0 ? addTableFu() : upTableFu();
+        closeFu();
+      }
+    },
+    [addTableFu, closeFu, fId, upTableFu]
+  );
 
   return (
     <Modal
@@ -144,7 +179,7 @@ function A7tab1M({ fId, closeFu, addTableFu, upTableFu }: Props) {
                 isLook={false}
                 fileCheck={fileCheck}
                 size={2}
-                dirCode={dirCode}
+                dirCode="schoolThumb"
                 myUrl="cms/person/upload"
                 format={["image/jpeg", "image/png"]}
                 formatTxt="png、jpg和jpeg"
@@ -167,7 +202,7 @@ function A7tab1M({ fId, closeFu, addTableFu, upTableFu }: Props) {
                 isLook={false}
                 fileCheck={fileCheck}
                 size={500}
-                dirCode={dirCode}
+                dirCode="schoolVideo"
                 myUrl="cms/person/upload"
                 format={["video/mp4"]}
                 formatTxt="mp4"

+ 28 - 4
src/pages/A7school/A7table.tsx

@@ -1,13 +1,15 @@
 import MyPopconfirm from "@/components/MyPopconfirm";
 import MyTable from "@/components/MyTable";
 import { RootState } from "@/store";
-import { A7_APIgetList } from "@/store/action/A7school";
+import { A7_APIdel, A7_APIgetList } from "@/store/action/A7school";
 import { A7tableType } from "@/types";
 import { A7tableC1, A7tableC2 } from "@/utils/tableData";
-import { Button } from "antd";
-import React, { useCallback, useEffect, useMemo, useState } from "react";
+import { Button, Tooltip } from "antd";
+import { useCallback, useEffect, useMemo, useState } from "react";
 import { useDispatch, useSelector } from "react-redux";
 import { forwardRef, useImperativeHandle } from "react";
+import { QuestionCircleOutlined } from "@ant-design/icons";
+import { MessageFu } from "@/utils/message";
 
 type Props = {
   type: "口述史" | "刊物";
@@ -36,7 +38,16 @@ function A7tab1({ type, editTableFu }: Props, ref: any) {
   );
 
   // 点击删除
-  const delTableFu = useCallback(async (id: number) => {}, []);
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await A7_APIdel(id, type);
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        getListFu();
+      }
+    },
+    [getListFu, type]
+  );
 
   // 新增完成之后 重新获取数据
   const resetSelectFu = useCallback(() => {
@@ -84,6 +95,19 @@ function A7tab1({ type, editTableFu }: Props, ref: any) {
       onChange={(pageNum, pageSize) =>
         setFromData({ ...fromData, pageNum, pageSize })
       }
+      myTitle={{
+        name: "排序值",
+        Com: (
+          <div className="A7tableTit">
+            <span>排序值</span>&emsp;
+            <Tooltip title="数字越小,排序越前">
+              <div className="A7tableTitInco">
+                <QuestionCircleOutlined />
+              </div>
+            </Tooltip>
+          </div>
+        ),
+      }}
     />
   );
 }

+ 15 - 1
src/pages/A7school/index.module.scss

@@ -16,11 +16,25 @@
       overflow: hidden;
       margin-top: 15px;
       height: calc(100% - 32px);
+
+
+      .A7tableTit {
+        display: flex;
+        justify-content: center;
+
+        .A7tableTitInco {
+          cursor: pointer;
+          width: 20px;
+          height: 20px;
+          border-radius: 50%;
+        }
+      }
     }
   }
 }
 
 
+// 新增 、 编辑
 .A7tab1M {
   :global {
     .ant-modal-close {
@@ -38,7 +52,7 @@
     .A7mMaiin {
       margin-top: 15px;
       width: 100%;
-      height: 100%;
+      height: 570px;
       overflow-y: auto;
 
       .ant-form {

+ 2 - 2
src/pages/A7school/index.tsx

@@ -89,8 +89,8 @@ function A7school() {
         <A7tab1M
           fId={openSon}
           closeFu={() => setOpenSon(0)}
-          addTableFu={() => tableRef2.current.resetSelectFu()}
-          upTableFu={() => tableRef2.current.getListFu()}
+          addTableFu={() => tableRef1.current.resetSelectFu()}
+          upTableFu={() => tableRef1.current.getListFu()}
         />
       ) : null}
     </div>

+ 2 - 2
src/pages/Layout/index.module.scss

@@ -9,7 +9,7 @@
       position: relative;
       width: 220px;
       height: 100%;
-      background-color:  #589498;
+      background-color: #589498;
 
 
       .layoutLeftTop {
@@ -39,7 +39,7 @@
             font-size: 16px;
             height: 50px;
             line-height: 50px;
-            margin-top: 20px;
+            margin-top: 10px;
 
             &:hover {
               background-color: var(--themeColor2);

+ 16 - 0
src/store/action/A7school.ts

@@ -58,3 +58,19 @@ export const A7_APIthemeSave = (data: any) => {
 export const A7_APIgetInfo = (id: number) => {
   return http.get(`cms/person/detail/${id}`);
 };
+
+/**
+ * 口述史 - 新增、编辑
+ */
+export const A7_APIsave = (data: any) => {
+  return http.post("cms/person/save", data);
+};
+
+/**
+ * 口述史 刊物 - 删除
+ */
+export const A7_APIdel = (id: number, type: "口述史" | "刊物") => {
+  return http.get(
+    `cms/${type === "口述史" ? "person" : "periodical"}/removes/${id}`
+  );
+};

+ 15 - 1
src/types/api/A7school.d.ts

@@ -1 +1,15 @@
-export type A7tableType =any
+export type A7tableType ={
+	createTime: string;
+	creatorId: number;
+	creatorName: string;
+	description: string;
+	dictId: number;
+	dictName: string;
+	fileName: string;
+	filePath: string;
+	id: number;
+	name: string;
+	sort: number;
+	thumb: string;
+	updateTime: string;
+}

+ 5 - 4
src/utils/tableData.ts

@@ -77,10 +77,11 @@ export const A6tableC = [
 ];
 
 export const A7tableC1 = [
-  ["txt", "时间", "createTime"],
-  ["txt", "称呼", "name"],
-  ["txt", "联系方式", "phone"],
-  ["text", "反馈内容", "content", 50],
+  ["txt", "人物姓名", "name"],
+  ["text", "人物简介", "description",50],
+  ["img", "人物肖像", "thumb"],
+  ["txt", "采访主题", "dictName"],
+  ["txt", "排序值", "sort"],
 ];
 export const A7tableC2 = [
   ["txt", "时间2", "createTime"],