shaogen1995 1 tahun lalu
induk
melakukan
6a6a7bbf03

+ 6 - 4
src/components/MyPopconfirm.tsx

@@ -2,10 +2,10 @@ import React, { useMemo } from "react";
 import { Button, Popconfirm } from "antd";
 
 type Props = {
-  txtK: "删除" | "取消" | "重置密码"|'退出登录';
+  txtK: "删除" | "取消" | "重置密码" | "退出登录";
   onConfirm: () => void;
   Dom?: React.ReactNode;
-  loc?: 'bottom';
+  loc?: "bottom";
 };
 
 function MyPopconfirm({ txtK, onConfirm, Dom, loc }: Props) {
@@ -14,7 +14,7 @@ function MyPopconfirm({ txtK, onConfirm, Dom, loc }: Props) {
       删除: ["删除后无法恢复,是否删除?", "删除"],
       取消: ["放弃编辑后,信息将不会保存!", "放弃"],
       重置密码: ["密码重制后为123456,是否重置?", "重置"],
-      退出登录:['确定退出吗?','确定']
+      退出登录: ["确定退出吗?", "确定"],
     };
     return Reflect.get(obj, txtK) || ["", ""];
   }, [txtK]);
@@ -30,10 +30,12 @@ function MyPopconfirm({ txtK, onConfirm, Dom, loc }: Props) {
     >
       {Dom ? (
         Dom
-      ) : (
+      ) : txtK === "删除" ? (
         <Button size="small" type="text" danger>
           {txtK}
         </Button>
+      ) : (
+        <Button>{txtK}</Button>
       )}
     </Popconfirm>
   );

+ 19 - 14
src/components/MyTable/index.tsx

@@ -4,15 +4,16 @@ import { Table } from "antd";
 import ImageLazy from "../ImageLazy";
 
 type Props = {
-  yHeight: number;
-  list: any;
-  columnsTemp: any;
-  total?: number;
+  yHeight: number; //设置表格的高度
+  list: any; //表格数据
+  columnsTemp: any; //表格展示
+  total?: number; //总数
   pageNum?: number;
   pageSize?: number;
   pagingInfo?: any | boolean;
   onChange?: (pageNum: number, pageSize: number) => void;
   lastBtn?: any;
+  classKey?: string; //一个组件多次使用的时候要传递,分别设置style
 };
 
 function MyTable({
@@ -20,8 +21,8 @@ function MyTable({
   list,
   columnsTemp,
   total,
-  pageNum,
-  pageSize,
+  pageNum = 1,
+  pageSize = 10,
   pagingInfo = {
     showQuickJumper: true,
     position: ["bottomCenter"],
@@ -29,13 +30,15 @@ function MyTable({
   },
   onChange,
   lastBtn = [],
+  classKey = "",
 }: Props) {
   useEffect(() => {
     const dom = document.querySelector(
-      "#MyTable .ant-table-body"
+      `.MyTable${classKey} .ant-table-body`
     ) as HTMLDivElement;
+
     if (dom) dom.style.height = yHeight + "px";
-  }, [yHeight]);
+  }, [classKey, yHeight]);
 
   // 页码变化
   const paginationChange = useCallback(
@@ -49,6 +52,8 @@ function MyTable({
 
   const dataChangeFu = useCallback(
     (v: any) => {
+      const nullTxt = "(空)";
+
       /**
        * index:序号
        * txt:正常数据
@@ -59,14 +64,15 @@ function MyTable({
 
       const obj = {
         index: (_: any, __: any, index: number) =>
-          index + 1 + (pageNum! - 1) * pageSize!,
-        txt: (item: any) => item[v[2]] || "(空)",
+          index + 1 + (pageNum - 1) * pageSize,
+        txt: (item: any) => item[v[2]] || nullTxt,
         img: (item: any) => (
           <div className="tableImgAuto">
             <ImageLazy width={60} height={60} src={item.thumb} />
           </div>
         ),
-        txtChange: (item: any) => Reflect.get(v[3], item[v[2]]) || "(空)",
+        txtChange: (item: any) =>
+          Reflect.get(v[3], item[v[2]]) || v[4] || nullTxt,
         text: (item: any) =>
           item[v[2]] ? (
             item[v[2]].length >= v[3] ? (
@@ -77,7 +83,7 @@ function MyTable({
               item[v[2]]
             )
           ) : (
-            "(空)"
+            nullTxt
           ),
       };
 
@@ -97,8 +103,7 @@ function MyTable({
 
   return (
     <Table
-      id="MyTable"
-      className={styles.MyTable}
+      className={`${styles.MyTable} MyTable${classKey}`}
       scroll={{ y: yHeight }}
       dataSource={list}
       columns={[...columns, ...lastBtn]}

+ 1 - 5
src/pages/A1video/A1add/index.tsx

@@ -187,11 +187,7 @@ function A1add({ addId, closeFu, addTableFu, type }: Props) {
               提交
             </Button>
             &emsp;
-            <MyPopconfirm
-              txtK="取消"
-              onConfirm={closeFu}
-              Dom={<Button>取消</Button>}
-            />
+            <MyPopconfirm txtK="取消" onConfirm={closeFu} />
           </Form.Item>
         </Form>
       </div>

+ 0 - 2
src/pages/A3play/index.tsx

@@ -102,7 +102,6 @@ function A3play() {
                   setVal1(val1Ref.current);
                   setEdit1(false);
                 }}
-                Dom={<Button>取消</Button>}
               />
               &emsp;
               <Button type="primary" onClick={() => btnOkFu(1)}>
@@ -170,7 +169,6 @@ function A3play() {
                   setVal2(val2Ref.current);
                   setEdit2(false);
                 }}
-                Dom={<Button>取消</Button>}
               />
               &emsp;
               <Button type="primary" onClick={() => btnOkFu(2)}>

+ 1 - 5
src/pages/A4exhibit/A4add/index.tsx

@@ -192,11 +192,7 @@ function A4add({ addId, closeFu, addTableFu, editTableFu }: Props) {
               提交
             </Button>
             &emsp;
-            <MyPopconfirm
-              txtK="取消"
-              onConfirm={closeFu}
-              Dom={<Button>取消</Button>}
-            />
+            <MyPopconfirm txtK="取消" onConfirm={closeFu} />
           </Form.Item>
         </Form>
       </div>

+ 1 - 5
src/pages/A5goods/A5add/index.tsx

@@ -271,11 +271,7 @@ function A5add({ addId, closeFu, addTableFu, editTableFu }: Props) {
             </Button>
             <br />
             <br />
-            <MyPopconfirm
-              txtK="取消"
-              onConfirm={closeFu}
-              Dom={<Button>取消</Button>}
-            />
+            <MyPopconfirm txtK="取消" onConfirm={closeFu} />
           </Form.Item>
         </Form>
       </div>

+ 1 - 5
src/pages/A7user/UserAdd/index.tsx

@@ -111,11 +111,7 @@ function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
               提交
             </Button>
             &emsp;
-            <MyPopconfirm
-              txtK="取消"
-              onConfirm={closePage}
-              Dom={<Button>取消</Button>}
-            />
+            <MyPopconfirm txtK="取消" onConfirm={closePage} />
           </Form.Item>
         </Form>
       </div>

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

@@ -33,10 +33,9 @@ function Layout() {
     const arr = [...tabLeftArr];
 
     // 超级管理员才有 用户管理 和 系统日志
-    if (getTokenInfo().user.isAdmin === 1) {
-      arr[1].son[0].done = true;
-      arr[1].son[1].done = true;
-    }
+    const flag = getTokenInfo().user.isAdmin === 1;
+    arr[1].son[0].done = flag;
+    arr[1].son[1].done = flag;
     setList(arr);
   }, []);