shaogen1995 1 year ago
parent
commit
8705c355b0

+ 126 - 90
src/pages/A4store/A4Edit/index.tsx

@@ -1,4 +1,10 @@
-import React, { useCallback, useEffect, useRef, useState } from "react";
+import React, {
+  useCallback,
+  useEffect,
+  useMemo,
+  useRef,
+  useState,
+} from "react";
 import styles from "./index.module.scss";
 import {
   Button,
@@ -24,6 +30,13 @@ type Props = {
 };
 
 function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
+  // 特别针对 慈善证书 做处理 是的话为true
+  const isTopOne = useMemo(() => {
+    let flag = false;
+    if (editInfo.id === 1) flag = true;
+    return flag;
+  }, [editInfo.id]);
+
   // 表单的ref
   const FormBoxRef = useRef<FormInstance>(null);
 
@@ -32,25 +45,30 @@ function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
   // 富文本的ref
   const ZRichTextRef = useRef<any>(null);
 
-  const getInfoFu = useCallback(async (id: number) => {
-    const res = await A4_APIgetInfo(id);
-    if (res.code === 0) {
-      const data = res.data;
-
-      ZRichTextRef.current?.ritxtShowFu(data.rtf);
+  const getInfoFu = useCallback(
+    async (id: number) => {
+      const res = await A4_APIgetInfo(id);
+      if (res.code === 0) {
+        const data = res.data;
 
-      FormBoxRef.current?.setFieldsValue({
-        ...data,
-        myTime: dayjs(data.recordDate),
-      });
+        FormBoxRef.current?.setFieldsValue({
+          ...data,
+          myTime: dayjs(data.recordDate),
+        });
+        if (!isTopOne) {
+          // 设置富文本
 
-      // 设置封面图
-      ZupOneRef1.current?.setFileComFileFu({
-        fileName: "",
-        filePath: data.thumb,
-      });
-    }
-  }, []);
+          ZRichTextRef.current?.ritxtShowFu(data.rtf);
+          // 设置封面图
+          ZupOneRef1.current?.setFileComFileFu({
+            fileName: "",
+            filePath: data.thumb,
+          });
+        }
+      }
+    },
+    [isTopOne]
+  );
 
   useEffect(() => {
     if (editInfo.id > 0) {
@@ -78,21 +96,25 @@ function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
     async (values: any) => {
       setFileCheck(true);
 
-      const coverUrl1 = ZupOneRef1.current?.fileComFileResFu();
-      // 没有传 封面图
-      if (!coverUrl1.filePath) return;
-      // 发布日期
-      const recordDate = dayjs(values.myTime).format("YYYY-MM-DD");
-
-      const rtf = ZRichTextRef.current?.fatherBtnOkFu();
-
-      const obj = {
+      let obj: any = {
         ...values,
         id: editInfo.id > 0 ? editInfo.id : null,
-        recordDate,
-        thumb: coverUrl1.filePath,
-        rtf: rtf.val,
       };
+
+      if (!isTopOne) {
+        const coverUrl1 = ZupOneRef1.current?.fileComFileResFu();
+        // 没有传 封面图
+        if (!coverUrl1.filePath) return;
+        // 发布日期
+        const recordDate = dayjs(values.myTime).format("YYYY-MM-DD");
+
+        const rtf = ZRichTextRef.current?.fatherBtnOkFu();
+
+        obj.recordDate = recordDate;
+        obj.thumb = coverUrl1.filePath;
+        obj.rtf = rtf.val || "";
+      }
+
       const res = await A4_APIsave(obj);
       if (res.code === 0) {
         MessageFu.success(editInfo.id > 0 ? "编辑成功!" : "新增成功!");
@@ -100,7 +122,7 @@ function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
         closeFu();
       }
     },
-    [addTableFu, closeFu, editInfo.id, upTableFu]
+    [addTableFu, closeFu, editInfo.id, isTopOne, upTableFu]
   );
 
   return (
@@ -121,7 +143,12 @@ function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
             rules={[{ required: true, message: "请输入奖品名称!" }]}
             getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
           >
-            <Input maxLength={20} showCount placeholder="请输入内容" />
+            <Input
+              disabled={isTopOne}
+              maxLength={20}
+              showCount
+              placeholder="请输入内容"
+            />
           </Form.Item>
 
           <Form.Item
@@ -137,26 +164,30 @@ function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
             />
           </Form.Item>
 
-          <Form.Item
-            label="库存"
-            name="stock"
-            rules={[{ required: true, message: "请输入库存!" }]}
-          >
-            <InputNumber
-              min={1}
-              max={99999}
-              precision={0}
-              placeholder="请输入数字,1~99999"
-            />
-          </Form.Item>
+          {isTopOne ? null : (
+            <>
+              <Form.Item
+                label="库存"
+                name="stock"
+                rules={[{ required: true, message: "请输入库存!" }]}
+              >
+                <InputNumber
+                  min={1}
+                  max={99999}
+                  precision={0}
+                  placeholder="请输入数字,1~99999"
+                />
+              </Form.Item>
 
-          <Form.Item
-            label="登记日期"
-            name="myTime"
-            rules={[{ required: true, message: "请选择登记日期!" }]}
-          >
-            <DatePicker />
-          </Form.Item>
+              <Form.Item
+                label="登记日期"
+                name="myTime"
+                rules={[{ required: true, message: "请选择登记日期!" }]}
+              >
+                <DatePicker />
+              </Form.Item>
+            </>
+          )}
 
           <Form.Item
             label="上架状态"
@@ -172,45 +203,50 @@ function A4Edit({ editInfo, closeFu, upTableFu, addTableFu }: Props) {
               ]}
             />
           </Form.Item>
-          {/* 封面 */}
-          <div className="formRow">
-            <div className="formLeft">
-              <span>* </span>
-              封面图:
-            </div>
-            <div className="formRight">
-              <ZupOne
-                ref={ZupOneRef1}
-                isLook={false}
-                fileCheck={fileCheck}
-                size={2}
-                dirCode="storeThumb"
-                myUrl="cms/prize/upload"
-                format={["image/jpeg", "image/png"]}
-                formatTxt="png、jpg和jpeg"
-                checkTxt="请上传封面图!"
-                upTxt="最多1张"
-                myType="thumb"
-              />
-            </div>
-          </div>
-
-          {/* 富文本 */}
-          <div className="formRow">
-            <div className="formLeft">
-              <span> </span>
-              产品简介:
-            </div>
-            <div className="formRight">
-              <ZRichText
-                check={false}
-                dirCode="storeText"
-                isLook={false}
-                ref={ZRichTextRef}
-                myUrl="cms/prize/upload"
-              />
-            </div>
-          </div>
+
+          {isTopOne ? null : (
+            <>
+              {/* 封面 */}
+              <div className="formRow">
+                <div className="formLeft">
+                  <span>* </span>
+                  封面图:
+                </div>
+                <div className="formRight">
+                  <ZupOne
+                    ref={ZupOneRef1}
+                    isLook={false}
+                    fileCheck={fileCheck}
+                    size={2}
+                    dirCode="storeThumb"
+                    myUrl="cms/prize/upload"
+                    format={["image/jpeg", "image/png"]}
+                    formatTxt="png、jpg和jpeg"
+                    checkTxt="请上传封面图!"
+                    upTxt="最多1张"
+                    myType="thumb"
+                  />
+                </div>
+              </div>
+
+              {/* 富文本 */}
+              <div className="formRow">
+                <div className="formLeft">
+                  <span> </span>
+                  产品简介:
+                </div>
+                <div className="formRight">
+                  <ZRichText
+                    check={false}
+                    dirCode="storeText"
+                    isLook={false}
+                    ref={ZRichTextRef}
+                    myUrl="cms/prize/upload"
+                  />
+                </div>
+              </div>
+            </>
+          )}
 
           {/* 确定和取消按钮 */}
           <Form.Item className="A4Ebtn">

+ 2 - 2
src/pages/A4store/A4set.tsx

@@ -68,8 +68,8 @@ function A4set({ closeFu }: Props) {
               value={isEnabled}
               onChange={(e) => setIsEnabled(e)}
               options={[
-                { value: 1, label: "关闭" },
-                { value: 0, label: "开启" },
+                { value: 1, label: "开启" },
+                { value: 0, label: "关闭" },
               ]}
             />
           </div>

+ 3 - 1
src/pages/A4store/index.tsx

@@ -62,7 +62,9 @@ function A4store() {
             >
               编辑
             </Button>
-            <MyPopconfirm txtK="删除" onConfirm={() => delTableFu(item.id)} />
+            {item.id !== 1 ? (
+              <MyPopconfirm txtK="删除" onConfirm={() => delTableFu(item.id)} />
+            ) : null}
           </>
         ),
       },

+ 203 - 0
src/pages/A7_1charity/A7_1edit.tsx

@@ -0,0 +1,203 @@
+import React, { useCallback, useEffect, useRef, useState } from "react";
+import styles from "./index.module.scss";
+import {
+  Button,
+  Form,
+  FormInstance,
+  Input,
+  InputNumber,
+  Modal,
+  Select,
+} from "antd";
+import { A7_1_APIgetInfo, A7_1_APIsave } from "@/store/action/A7_1charity";
+import { MessageFu } from "@/utils/message";
+import TextArea from "antd/es/input/TextArea";
+import ZupOne from "@/components/ZupOne";
+import MyPopconfirm from "@/components/MyPopconfirm";
+import { A7_1topValueType, topArr } from ".";
+
+type Props = {
+  fId: number;
+  selList: { label: string; value: "" | number }[];
+  closeFu: () => void;
+  addTableFu: () => void;
+  upTableFu: () => void;
+  type: A7_1topValueType;
+};
+
+function A7_1edit({
+  fId,
+  closeFu,
+  addTableFu,
+  upTableFu,
+  selList,
+  type,
+}: Props) {
+  // 设置表单初始数据(区分编辑和新增)
+  const FormBoxRef = useRef<FormInstance>(null);
+
+  const getInfoFu = useCallback(async (id: number) => {
+    const res = await A7_1_APIgetInfo(id);
+    if (res.code === 0) {
+      const data = res.data;
+
+      FormBoxRef.current?.setFieldsValue(data);
+
+      // 设置封面图
+      ZupOneRef1.current?.setFileComFileFu({
+        fileName: "",
+        filePath: data.thumb,
+      });
+    }
+  }, []);
+
+  useEffect(() => {
+    if (fId > 0) getInfoFu(fId);
+  }, [fId, getInfoFu]);
+
+  // 附件的ref
+  const ZupOneRef1 = useRef<any>(null);
+
+  // 附件 是否 已经点击过确定
+  const [fileCheck, setFileCheck] = useState(false);
+
+  // 没有通过校验
+  const onFinishFailed = useCallback(() => {
+    setFileCheck(true);
+  }, []);
+  // 通过校验点击确定
+  const onFinish = useCallback(
+    async (values: any) => {
+      setFileCheck(true);
+      // 没有传 封面图 或者视频
+      const coverUrl1 = ZupOneRef1.current?.fileComFileResFu();
+
+      if (!coverUrl1.filePath) return;
+
+      const obj = {
+        ...values,
+        id: fId > 0 ? fId : null,
+        thumb: coverUrl1.filePath,
+        type,
+      };
+
+      const res = await A7_1_APIsave(obj);
+
+      if (res.code === 0) {
+        MessageFu.success(fId > 0 ? "编辑成功!" : "新增成功!");
+        fId > 0 ? addTableFu() : upTableFu();
+        closeFu();
+      }
+    },
+    [addTableFu, closeFu, fId, type, upTableFu]
+  );
+
+  return (
+    <Modal
+      wrapClassName={styles.A7_1edit}
+      open={true}
+      title={fId > 0 ? "编辑" : "新增"}
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      <div className="A7_1eMain">
+        <Form
+          scrollToFirstError={true}
+          ref={FormBoxRef}
+          name="basic"
+          labelCol={{ span: 3 }}
+          onFinish={onFinish}
+          onFinishFailed={onFinishFailed}
+          autoComplete="off"
+        >
+          {/* 所属板块 */}
+          <div className="formRow formRow2">
+            <div className="formLeft">
+              <span>* </span>
+              所属板块:
+            </div>
+            <div className="formRight">
+              {topArr.find((v) => v.value === type)!.label}
+            </div>
+          </div>
+
+          <Form.Item
+            label="标题"
+            name="name"
+            rules={[{ required: true, message: "请输入标题!" }]}
+            getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
+          >
+            <Input maxLength={10} showCount placeholder="请输入内容" />
+          </Form.Item>
+
+          {/* 封面 */}
+          <div className="formRow">
+            <div className="formLeft">
+              <span>* </span>
+              图片:
+            </div>
+            <div className="formRight">
+              <ZupOne
+                ref={ZupOneRef1}
+                isLook={false}
+                fileCheck={fileCheck}
+                size={2}
+                dirCode={"charityThumb"}
+                myUrl="cms/charity/upload"
+                format={["image/jpeg", "image/png"]}
+                formatTxt="png、jpg和jpeg"
+                checkTxt="请上传图片!"
+                upTxt="最多1张"
+                myType="thumb"
+              />
+            </div>
+          </div>
+
+          <Form.Item
+            label="主题"
+            name="topicId"
+            rules={[{ required: true, message: "请选择主题!" }]}
+          >
+            <Select
+              placeholder="请选择"
+              style={{ width: 200 }}
+              options={selList}
+            />
+          </Form.Item>
+
+          <Form.Item
+            label="排序值"
+            name="sort"
+            rules={[{ required: true, message: "请输入排序值!" }]}
+          >
+            <InputNumber
+              min={1}
+              max={999}
+              precision={0}
+              placeholder="请输入1~999,数字越小,排序越前"
+            />
+          </Form.Item>
+
+          <Form.Item label="介绍" name="description">
+            <TextArea maxLength={500} showCount placeholder="请输入内容" />
+          </Form.Item>
+
+          {/* 确定和取消按钮 */}
+          <Form.Item className="A7_1eBtn">
+            <Button type="primary" htmlType="submit">
+              提交
+            </Button>
+            <br />
+            <br />
+            <MyPopconfirm txtK="取消" onConfirm={closeFu} />
+          </Form.Item>
+        </Form>
+      </div>
+    </Modal>
+  );
+}
+
+const MemoA7_1edit = React.memo(A7_1edit);
+
+export default MemoA7_1edit;

+ 85 - 0
src/pages/A7_1charity/A7_1theme/A7_1tEdit.tsx

@@ -0,0 +1,85 @@
+import React, { useCallback, useEffect, useState } from "react";
+import styles from "./index.module.scss";
+import { Button, Input, Modal } from "antd";
+import MyPopconfirm from "@/components/MyPopconfirm";
+import { MessageFu } from "@/utils/message";
+import { A7_1_APIthemeSave } from "@/store/action/A7_1charity";
+import { A7_1topValueType, topArr } from "..";
+
+type Props = {
+  editInfo: { id: number; name: string };
+  type: A7_1topValueType | "";
+  upTableFu: () => void;
+  closeFu: () => void;
+};
+
+function A7_1tEdit({ editInfo, upTableFu, closeFu, type }: Props) {
+  const [text, setText] = useState("");
+
+  useEffect(() => {
+    if (editInfo.name) setText(editInfo.name);
+  }, [editInfo.name]);
+
+  const btnOkFu = useCallback(async () => {
+    const res = await A7_1_APIthemeSave({
+      id: editInfo.id > 0 ? editInfo.id : null,
+      name: text,
+      display: 1,
+      type,
+    });
+    if (res.code === 0) {
+      MessageFu.success(editInfo.id > 0 ? "编辑成功!" : "新增成功!");
+      upTableFu();
+      closeFu();
+    }
+  }, [closeFu, editInfo.id, text, type, upTableFu]);
+
+  return (
+    <Modal
+      wrapClassName={styles.A7_1tEdit}
+      open={true}
+      title={(editInfo.id > 0 ? "编辑" : "新增") + "主题"}
+      footer={
+        [] // 设置footer为空,去掉 取消 确定默认按钮
+      }
+    >
+      <div className="A7_1tMain">
+        <div className="A7_1tErow">
+          <div className="A7_1tErow1 A7_1tErow11">
+            <span>* </span>所属板块:
+          </div>
+          <div className="A7_1tErow2">
+            {topArr.find((v) => v.value === type)!.label}
+          </div>
+        </div>
+
+        <div className="A7_1tErow">
+          <div className="A7_1tErow1">
+            <span>* </span>主题:
+          </div>
+          <div className="A7_1tErow2">
+            <Input
+              value={text}
+              onChange={(e) => setText(e.target.value.replace(/\s+/g, ""))}
+              placeholder="请输入文字"
+              showCount
+              maxLength={20}
+            />
+          </div>
+        </div>
+
+        <div className="A7_1tEbtn">
+          <Button type="primary" onClick={btnOkFu} disabled={text.length <= 0}>
+            提交
+          </Button>
+          &emsp;
+          <MyPopconfirm txtK="取消" onConfirm={closeFu} />
+        </div>
+      </div>
+    </Modal>
+  );
+}
+
+const MemoA7_1tEdit = React.memo(A7_1tEdit);
+
+export default MemoA7_1tEdit;

+ 72 - 0
src/pages/A7_1charity/A7_1theme/index.module.scss

@@ -0,0 +1,72 @@
+.A7_1theme {
+  position: absolute;
+  top: 0;
+  left: 0;
+  z-index: 12;
+  width: 100%;
+  height: 100%;
+  background-color: #fff;
+  border-radius: 10px;
+  padding: 24px;
+
+  :global {
+    .A7_1tBack {
+      display: flex;
+      justify-content: space-between;
+      margin-bottom: 15px;
+    }
+  }
+}
+
+// 新增和编辑的弹窗
+.A7_1tEdit {
+  :global {
+    .ant-modal-close {
+      display: none;
+    }
+
+    .ant-modal {
+      width: 800px !important;
+    }
+
+    .ant-modal-body {
+      border-top: 1px solid #ccc;
+    }
+
+    .A7_1tMain {
+      padding-top: 15px;
+
+      .A7_1tErow {
+        display: flex;
+        margin-bottom: 24px;
+
+        .A7_1tErow1 {
+          position: relative;
+          top: 3px;
+          width: 90px;
+          text-align: right;
+
+          &>span {
+            color: #ff4d4f;
+          }
+        }
+
+        .A7_1tErow11 {
+          top: 0;
+        }
+
+        .A7_1tErow2 {
+          width: calc(100% - 90px);
+
+          .ant-input-number {
+            width: 100%;
+          }
+        }
+      }
+
+      .A7_1tEbtn {
+        text-align: center;
+      }
+    }
+  }
+}

+ 167 - 0
src/pages/A7_1charity/A7_1theme/index.tsx

@@ -0,0 +1,167 @@
+import React, { useCallback, useEffect, useMemo, useState } from "react";
+import styles from "./index.module.scss";
+import { Button } from "antd";
+import MyTable from "@/components/MyTable";
+
+import MyPopconfirm from "@/components/MyPopconfirm";
+import { MessageFu } from "@/utils/message";
+import {
+  A7_1_APIgetListByTheme,
+  A7_1_APIthemeDel,
+  A7_1_APIthemeSort,
+} from "@/store/action/A7_1charity";
+import A71tEdit from "./A7_1tEdit";
+import { A7_1tableCtheme } from "@/utils/tableData";
+import { A7_1topValueType, topArr } from "..";
+
+export type ListType = {
+  id: number;
+  name: string;
+};
+
+type Props = {
+  closeFu: (type: A7_1topValueType) => void;
+  type: A7_1topValueType;
+};
+
+function A7_1theme({ closeFu, type }: Props) {
+  const [typeRes, setTypeRes] = useState<A7_1topValueType | "">("");
+
+  useEffect(() => {
+    setTypeRes(type);
+  }, [type]);
+
+  const getListFu = useCallback(async () => {
+    if (typeRes) {
+      const res = await A7_1_APIgetListByTheme(typeRes);
+      if (res.code === 0) {
+        setList(res.data);
+      }
+    }
+  }, [typeRes]);
+
+  useEffect(() => {
+    getListFu();
+  }, [getListFu]);
+
+  const [list, setList] = useState<ListType[]>([]);
+
+  // 点击删除
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await A7_1_APIthemeDel(id);
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        getListFu();
+      }
+    },
+    [getListFu]
+  );
+
+  // 点击上移和下移动
+  const moveTableFu = useCallback(
+    async (id1: number, id2: number) => {
+      const res = await A7_1_APIthemeSort(id1, id2);
+      if (res.code === 0) getListFu();
+    },
+    [getListFu]
+  );
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: "操作",
+        render: (item: ListType, _: any, index: number) => (
+          <>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => moveTableFu(item.id, list[index - 1].id)}
+              disabled={index === 0}
+            >
+              上移
+            </Button>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => moveTableFu(item.id, list[index + 1].id)}
+              disabled={index === list.length - 1}
+            >
+              下移
+            </Button>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => setEditInfo({ id: item.id, name: item.name })}
+            >
+              编辑
+            </Button>
+            <MyPopconfirm txtK="删除" onConfirm={() => delTableFu(item.id)} />
+          </>
+        ),
+      },
+    ];
+  }, [delTableFu, list, moveTableFu]);
+
+  // 点击新增
+  const [editInfo, setEditInfo] = useState({ id: 0, name: "" });
+
+  return (
+    <div className={styles.A7_1theme}>
+      <div className="A7_1tBack">
+        <div>
+          {topArr.map((v) => (
+            <Button
+              key={v.label}
+              type={v.value === typeRes ? "primary" : "default"}
+              onClick={() => setTypeRes(v.value)}
+            >
+              {v.label}
+            </Button>
+          ))}
+        </div>
+        <div>
+          <Button
+            type="primary"
+            onClick={() => {
+              if (list.length >= 50) {
+                return MessageFu.warning("最多50个主题!");
+              }
+              setEditInfo({ id: -1, name: "" });
+            }}
+          >
+            新增
+          </Button>
+          &emsp;
+          <Button
+            onClick={() => {
+              if (typeRes) closeFu(typeRes);
+            }}
+          >
+            返回
+          </Button>
+        </div>
+      </div>
+      <MyTable
+        yHeight={680}
+        list={list}
+        lastBtn={tableLastBtn}
+        columnsTemp={A7_1tableCtheme}
+        pagingInfo={false}
+      />
+
+      {editInfo.id ? (
+        <A71tEdit
+          editInfo={editInfo}
+          type={typeRes}
+          upTableFu={() => getListFu()}
+          closeFu={() => setEditInfo({ id: 0, name: "" })}
+        />
+      ) : null}
+    </div>
+  );
+}
+
+const MemoA7_1theme = React.memo(A7_1theme);
+
+export default MemoA7_1theme;

+ 103 - 0
src/pages/A7_1charity/index.module.scss

@@ -0,0 +1,103 @@
+.A7_1charity{
+  border-radius: 10px;
+  background-color: #fff;
+  padding: 15px 0;
+  position: relative;
+
+  :global{
+    .A7_1top {
+      margin-bottom: 15px;
+      padding: 0 24px;
+      display: flex;
+      justify-content: space-between;
+      .A7_1topll{
+        display: flex;
+        .A7_1row{
+          margin-left: 24px;
+        }
+      }
+    }
+    .A7tableTit {
+      display: flex;
+      justify-content: center;
+
+      .A7tableTitInco {
+        cursor: pointer;
+        width: 20px;
+        height: 20px;
+        border-radius: 50%;
+      }
+    }
+  }
+}
+
+// 新增 、 编辑
+.A7_1edit {
+  :global {
+    .ant-modal-close {
+      display: none;
+    }
+
+    .ant-modal {
+      width: 1000px !important;
+    }
+
+    .ant-modal-body {
+      border-top: 1px solid #ccc;
+    }
+
+    .A7_1eMain {
+      margin-top: 15px;
+      width: 100%;
+      height: 600px;
+      overflow-y: auto;
+
+      .ant-form {
+        width: 800px;
+
+        .ant-input-number {
+          width: 260px;
+        }
+
+
+        .formRow {
+          display: flex;
+
+          .formLeft {
+            position: relative;
+            top: 3px;
+            width: 103px;
+            text-align: right;
+
+            &>span {
+              color: #ff4d4f;
+            }
+          }
+
+          .formRight {
+            width: calc(100% - 103px);
+            .A7_1radio{
+              position: relative;
+              top: 3px;
+              margin-bottom: 15px;
+            }
+          }
+        }
+        .formRow2{
+          margin-bottom: 14px;
+          .formLeft{
+            top: 0;
+          }
+        }
+
+        .A7_1eBtn {
+          position: absolute;
+          z-index: 10;
+          right: 60px;
+          top: 50%;
+          transform: translateY(-50%);
+        }
+      }
+    }
+  }
+}

+ 246 - 0
src/pages/A7_1charity/index.tsx

@@ -0,0 +1,246 @@
+import React, { useCallback, useEffect, useMemo, useState } from "react";
+import styles from "./index.module.scss";
+import { useDispatch, useSelector } from "react-redux";
+import { RootState } from "@/store";
+import { Button, Select, Tooltip } from "antd";
+import { MessageFu } from "@/utils/message";
+import {
+  A7_1_APIdel,
+  A7_1_APIgetList,
+  A7_1_APIgetListByTheme,
+} from "@/store/action/A7_1charity";
+import MyTable from "@/components/MyTable";
+import { A7_1tableC } from "@/utils/tableData";
+import { A7_1tableType } from "@/types";
+import MyPopconfirm from "@/components/MyPopconfirm";
+import { QuestionCircleOutlined } from "@ant-design/icons";
+import A71theme from "./A7_1theme";
+import A71edit from "./A7_1edit";
+
+export type A7_1topValueType = "project" | "team" | "person";
+
+export const topArr: { label: string; value: A7_1topValueType }[] = [
+  {
+    label: "慈善项目",
+    value: "project",
+  },
+  {
+    label: "慈善团体",
+    value: "team",
+  },
+  {
+    label: "慈善个人",
+    value: "person",
+  },
+];
+
+function A7_1charity() {
+  const dispatch = useDispatch();
+
+  const tableInfo = useSelector(
+    (state: RootState) => state.A7_1charity.tableInfo
+  );
+
+  type fromDataType = {
+    pageNum: number;
+    pageSize: number;
+    type: A7_1topValueType;
+    topicId: string;
+  };
+
+  const [fromData, setFromData] = useState<fromDataType>({
+    pageNum: 1,
+    pageSize: 10,
+    type: "project",
+    topicId: "",
+  });
+
+  // 获取表格列表
+  const getListFu = useCallback(() => {
+    dispatch(A7_1_APIgetList(fromData));
+  }, [dispatch, fromData]);
+
+  // 获取下拉框列表
+  const [selList, setSelList] = useState<
+    { label: string; value: "" | number }[]
+  >([]);
+  const getSelList = useCallback(async () => {
+    const res = await A7_1_APIgetListByTheme(fromData.type);
+    if (res.code === 0) {
+      setSelList(
+        res.data.map((v: any) => ({
+          label: v.name,
+          value: v.id,
+        }))
+      );
+    }
+  }, [fromData.type]);
+
+  useEffect(() => {
+    getListFu();
+  }, [getListFu]);
+
+  useEffect(() => {
+    getSelList();
+  }, [getSelList]);
+
+  // 点击重置
+  const resetSelectFu = useCallback(() => {
+    setFromData({
+      pageNum: 1,
+      pageSize: 10,
+      type: fromData.type,
+      topicId: "",
+    });
+  }, [fromData.type]);
+
+  // 采访主题
+  const [theme, setTheme] = useState(false);
+
+  // 新增和编辑
+  const [editId, setEditId] = useState(0);
+
+  // 点击删除
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await A7_1_APIdel(id);
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        getListFu();
+      }
+    },
+    [getListFu]
+  );
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: "操作",
+        render: (item: A7_1tableType) => (
+          <>
+            <Button size="small" type="text" onClick={() => setEditId(item.id)}>
+              编辑
+            </Button>
+            <MyPopconfirm txtK="删除" onConfirm={() => delTableFu(item.id)} />
+          </>
+        ),
+      },
+    ];
+  }, [delTableFu]);
+
+  return (
+    <div className={styles.A7_1charity}>
+      <div className="pageTitle">慈善堂 {theme ? " - 主题设置" : ""}</div>
+
+      {/* 顶部筛选 */}
+      <div className="A7_1top">
+        <div className="A7_1topll">
+          {topArr.map((v) => (
+            <Button
+              key={v.label}
+              type={v.value === fromData.type ? "primary" : "default"}
+              onClick={() =>
+                setFromData({
+                  ...fromData,
+                  type: v.value,
+                  pageNum: 1,
+                  topicId: "",
+                })
+              }
+            >
+              {v.label}
+            </Button>
+          ))}
+          <div className="A7_1row">
+            <span>主题:</span>
+            <Select
+              style={{ width: 220 }}
+              value={fromData.topicId}
+              onChange={(e) =>
+                setFromData({ ...fromData, topicId: e, pageNum: 1 })
+              }
+              options={[{ value: "", label: "全部" }, ...selList]}
+            />
+          </div>
+        </div>
+        <div>
+          <Button type="primary" onClick={() => setTheme(true)}>
+            主题设置
+          </Button>
+          &emsp;
+          <Button
+            type="primary"
+            onClick={() => {
+              if (tableInfo.list.length >= 500) {
+                return MessageFu.warning("最多500条数据!");
+              }
+              setEditId(-1);
+            }}
+          >
+            新增
+          </Button>
+        </div>
+      </div>
+
+      {/* 表格 */}
+      <MyTable
+        yHeight={640}
+        list={tableInfo.list}
+        columnsTemp={A7_1tableC}
+        lastBtn={tableLastBtn}
+        pageNum={fromData.pageNum}
+        pageSize={fromData.pageSize}
+        total={tableInfo.total}
+        onChange={(pageNum, pageSize) =>
+          setFromData({ ...fromData, pageNum, pageSize })
+        }
+        myTitle={{
+          name: "排序值",
+          Com: (
+            <div className="A7tableTit">
+              <span>排序值</span>&nbsp;
+              <Tooltip title="数字越小,排序越前">
+                <div className="A7tableTitInco">
+                  <QuestionCircleOutlined rev={undefined} />
+                </div>
+              </Tooltip>
+            </div>
+          ),
+        }}
+      />
+
+      {/* 采访主题 */}
+      {theme ? (
+        <A71theme
+          closeFu={(typeRes) => {
+            // if (typeRes === fromData.type) {
+            //   getListFu();
+            //   getSelList();
+            // } else {
+            //   setFromData({ ...fromData, type: typeRes, pageNum: 1 });
+            // }
+            getSelList();
+            setTheme(false);
+          }}
+          type={fromData.type}
+        />
+      ) : null}
+
+      {/* 新增和编辑 */}
+      {editId ? (
+        <A71edit
+          fId={editId}
+          selList={selList}
+          closeFu={() => setEditId(0)}
+          upTableFu={() => getListFu()}
+          addTableFu={() => resetSelectFu()}
+          type={fromData.type}
+        />
+      ) : null}
+    </div>
+  );
+}
+
+const MemoA7_1charity = React.memo(A7_1charity);
+
+export default MemoA7_1charity;

+ 6 - 0
src/pages/Layout/data.ts

@@ -43,6 +43,12 @@ const tabLeftArr: RouterType = [
         Com: React.lazy(() => import("../A6message")),
       },
       {
+        id: 1000,
+        name: "慈善堂",
+        path: "/charity",
+        Com: React.lazy(() => import("../A7_1charity")),
+      },
+      {
         id: 700,
         name: "云学校管理",
         path: "/school",

+ 1 - 0
src/pages/Layout/index.tsx

@@ -42,6 +42,7 @@ function Layout() {
     if (res.code === 0) {
       const tempList: UserListType[] = res.data || [];
       const isOkIdArr = tempList.filter((c) => c.authority).map((v) => v.id);
+
       // 是管理员
       if (userInfo.isAdmin === 1) {
         isOkIdArr.push(2100);

+ 5 - 1
src/store/action/A4store.ts

@@ -8,7 +8,11 @@ export const A4_APIgetList = (data: any) => {
     const res = await http.post("cms/prize/pageList", data);
     if (res.code === 0) {
       const obj = {
-        list: res.data.records,
+        list: res.data.records.map((v: any) => ({
+          ...v,
+          stock: v.id === 1 ? "/" : v.stock,
+          recordDate: v.id === 1 ? "/" : v.recordDate,
+        })),
         total: res.data.total,
       };
       dispatch({ type: "A4/getList", payload: obj });

+ 73 - 0
src/store/action/A7_1charity.ts

@@ -0,0 +1,73 @@
+import http from "@/utils/http";
+import { AppDispatch } from "..";
+import { A7_1topValueType } from "@/pages/A7_1charity";
+/**
+ * 获取 慈善堂 列表
+ */
+export const A7_1_APIgetList = (data: any) => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post("cms/charity/pageList", data);
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total,
+      };
+
+      dispatch({
+        type: "A7_1/getList",
+        payload: obj,
+      });
+    }
+  };
+};
+
+/**
+ * 慈善堂 - 详情
+ */
+export const A7_1_APIgetInfo = (id: number) => {
+  return http.get(`cms/charity/detail/${id}`);
+};
+
+/**
+ * 慈善堂 - 新增、编辑
+ */
+export const A7_1_APIsave = (data: any) => {
+  return http.post("cms/charity/save", data);
+};
+
+/**
+ * 慈善堂 刊物 - 删除
+ */
+export const A7_1_APIdel = (id: number) => {
+  return http.get(`cms/charity/removes/${id}`);
+};
+
+
+/**
+ * 获取主题列表
+ */
+export const A7_1_APIgetListByTheme = (type: A7_1topValueType) => {
+  return http.get(`cms/charityTopic/getList?type=${type}`);
+};
+
+/**
+ * 主题 - 删除
+ */
+export const A7_1_APIthemeDel = (id: number) => {
+  return http.get(`cms/charityTopic/remove/${id}`);
+};
+
+/**
+ * 主题 - 排序
+ */
+export const A7_1_APIthemeSort = (id1: number, id2: number) => {
+  return http.get(`cms/charityTopic/sort/${id1}/${id2}`);
+};
+
+/**
+ * 主题 - 新增、编辑
+ */
+export const A7_1_APIthemeSave = (data: any) => {
+  return http.post("cms/charityTopic/save", data);
+};
+

+ 28 - 0
src/store/reducer/A7_1charity.ts

@@ -0,0 +1,28 @@
+import { A7_1tableType } from "@/types";
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as A7_1tableType[],
+    total: 0,
+  },
+};
+
+// 定义 action 类型
+type Props = {
+  type: "A7_1/getList";
+  payload: { list: A7_1tableType[]; total: number };
+};
+
+// reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case "A7_1/getList":
+      return { ...state, tableInfo: action.payload };
+
+    default:
+      return state;
+  }
+}

+ 2 - 0
src/store/reducer/index.ts

@@ -9,6 +9,7 @@ import A3record from "./A3record";
 import A4store from "./A4store";
 import A5cash from "./A5cash";
 import A6message from "./A6message";
+import A7_1charity from "./A7_1charity";
 import A7school from "./A7school";
 import Z1user from "./Z1user";
 import Z2log from "./Z2log";
@@ -22,6 +23,7 @@ const rootReducer = combineReducers({
   A4store,
   A5cash,
   A6message,
+  A7_1charity,
   A7school,
   Z1user,
   Z2log,

+ 14 - 0
src/types/api/A7_1charity.d.ts

@@ -0,0 +1,14 @@
+export type A7_1tableType={
+	createTime: string;
+	creatorId: number;
+	creatorName: string;
+	description: string;
+	id: number;
+	name: string;
+	sort: number;
+	thumb: string;
+	topicId: number;
+	topicName: string;
+	type: string;
+	updateTime: string;
+}

+ 1 - 0
src/types/index.d.ts

@@ -5,6 +5,7 @@ export * from './api/A3record'
 export * from './api/A4store'
 export * from './api/A5cash'
 export * from './api/A6message'
+export * from './api/A7_1charity'
 export * from './api/A7school'
 export * from './api/Z1user'
 export * from './api/Z2log'

+ 11 - 1
src/utils/tableData.ts

@@ -85,9 +85,19 @@ export const A6tableC = [
   ["text", "反馈内容", "content", 50],
 ];
 
+export const A7_1tableC = [
+  ["txt", "主题", "topicName"],
+  ["txt", "标题", "name"],
+  ["text", "介绍", "description", 50],
+  ["img", "图片", "thumb"],
+  ["txt", "排序值", "sort"],
+];
+
+export const A7_1tableCtheme = [["txt", "主题", "name"]];
+
 export const A7tableC1 = [
   ["txt", "人物姓名", "name"],
-  ["text", "人物简介", "description",50],
+  ["text", "人物简介", "description", 50],
   ["img", "人物肖像", "thumb"],
   ["txt", "采访主题", "dictName"],
   ["txt", "排序值", "sort"],