shaogen1995 10 hónapja
szülő
commit
69544aa6f0

+ 1 - 1
src/pages/A4iosUser/A4ip/index.tsx

@@ -95,7 +95,7 @@ function A4ip({ closeFu }: Props) {
             >
               新增
             </Button>
-            &emsp; <Button onClick={closeFu}>返回</Button>
+            &emsp; <Button onClick={closeFu}>关闭</Button>
           </div>
         </div>
 

+ 4 - 0
src/pages/A7notice/index.module.scss

@@ -0,0 +1,4 @@
+.A7notice {
+  :global {
+  }
+}

+ 13 - 0
src/pages/A7notice/index.tsx

@@ -0,0 +1,13 @@
+import React from 'react'
+import styles from './index.module.scss'
+function A7notice() {
+  return (
+    <div className={styles.A7notice}>
+      <h1>A7notice</h1>
+    </div>
+  )
+}
+
+const MemoA7notice = React.memo(A7notice)
+
+export default MemoA7notice

+ 0 - 5
src/pages/A7video/index.module.scss

@@ -1,5 +0,0 @@
-.A7video{
-  :global{
-
-  }
-}

+ 0 - 14
src/pages/A7video/index.tsx

@@ -1,14 +0,0 @@
-import React from "react";
-import styles from "./index.module.scss";
- function A7video() {
-
-  return (
-    <div className={styles.A7video}>
-      <h1>A7video</h1>
-    </div>
-  )
-}
-
-const MemoA7video = React.memo(A7video);
-
-export default MemoA7video;

+ 0 - 5
src/pages/A8notice/index.module.scss

@@ -1,5 +0,0 @@
-.A8notice{
-  :global{
-
-  }
-}

+ 0 - 14
src/pages/A8notice/index.tsx

@@ -1,14 +0,0 @@
-import React from "react";
-import styles from "./index.module.scss";
- function A8notice() {
-
-  return (
-    <div className={styles.A8notice}>
-      <h1>A8notice</h1>
-    </div>
-  )
-}
-
-const MemoA8notice = React.memo(A8notice);
-
-export default MemoA8notice;

+ 38 - 44
src/pages/Layout/data.ts

@@ -1,80 +1,74 @@
-import { RouterType } from "@/types";
-import React from "react";
+import { RouterType } from '@/types'
+import React from 'react'
 
 const tabLeftArr: RouterType = [
   {
     id: 1,
-    name: "内容发布",
+    name: '内容发布',
     son: [
       {
         id: 200,
-        name: "图书管理",
-        path: "/",
-        Com: React.lazy(() => import("../A1manage")),
+        name: '图书管理',
+        path: '/',
+        Com: React.lazy(() => import('../A1manage'))
       },
       {
         id: 300,
-        name: "图书分类",
-        path: "/classify",
-        Com: React.lazy(() => import("../A2classify")),
+        name: '图书分类',
+        path: '/classify',
+        Com: React.lazy(() => import('../A2classify'))
       },
       {
         id: 400,
-        name: "图书推荐",
-        path: "/recommend",
-        Com: React.lazy(() => import("../A3recommend")),
+        name: '图书推荐',
+        path: '/recommend',
+        Com: React.lazy(() => import('../A3recommend'))
       },
       {
         id: 500,
-        name: "平台用户",
-        path: "/iosUser",
-        Com: React.lazy(() => import("../A4iosUser")),
-      },
-      {
-        id: 900,
-        name: "图书审核",
-        path: "/bookAudit",
-        Com: React.lazy(() => import("../A5bookAudit")),
+        name: '平台用户',
+        path: '/iosUser',
+        Com: React.lazy(() => import('../A4iosUser'))
       },
       {
         id: 600,
-        name: "评论审核",
-        path: "/remarkAudit",
-        Com: React.lazy(() => import("../A6remarkAudit")),
+        name: '图书审核',
+        path: '/bookAudit',
+        Com: React.lazy(() => import('../A5bookAudit'))
       },
       {
         id: 700,
-        name: "视频管理",
-        path: "/video",
-        Com: React.lazy(() => import("../A7video")),
+        name: '评论审核',
+        path: '/remarkAudit',
+        Com: React.lazy(() => import('../A6remarkAudit'))
       },
       {
         id: 800,
-        name: "公告管理",
-        path: "/notice",
-        Com: React.lazy(() => import("../A8notice")),
-      },
-    ],
+        name: '公告管理',
+        path: '/notice',
+        Com: React.lazy(() => import('../A7notice'))
+      }
+    ]
   },
 
   {
     id: 4,
-    name: "系统设置",
+    name: '系统设置',
     son: [
       {
         id: 2100,
-        name: "后台用户",
-        path: "/user",
-        Com: React.lazy(() => import("../Z1user")),
+        name: '后台用户',
+        path: '/user',
+        Com: React.lazy(() => import('../Z1user'))
       },
       {
         id: 2200,
-        name: "系统日志",
-        path: "/log",
-        Com: React.lazy(() => import("../Z2log")),
-      },
-    ],
-  },
-];
+        name: '系统日志',
+        path: '/log',
+        Com: React.lazy(() => import('../Z2log'))
+      }
+    ]
+  }
+]
 
-export default tabLeftArr;
+export default tabLeftArr

+ 63 - 54
src/pages/Z1user/UserAdd/index.tsx

@@ -1,39 +1,39 @@
-import { getUserInfoByIdAPI, userSaveAPI } from "@/store/action/Z1user";
-import { SaveUserType } from "@/types";
-import { MessageFu } from "@/utils/message";
-import { Button, Form, FormInstance, Input, Modal } from "antd";
-import React, { useCallback, useEffect, useRef } from "react";
-import styles from "./index.module.scss";
-import MyPopconfirm from "@/components/MyPopconfirm";
+import { getUserInfoByIdAPI, userSaveAPI } from '@/store/action/Z1user'
+import { SaveUserType } from '@/types'
+import { MessageFu } from '@/utils/message'
+import { Button, Form, FormInstance, Input, Modal } from 'antd'
+import React, { useCallback, useEffect, useRef } from 'react'
+import styles from './index.module.scss'
+import MyPopconfirm from '@/components/MyPopconfirm'
 
 type Props = {
-  id: any;
-  closePage: () => void;
-  upTableList: () => void;
-  addTableList: () => void;
-};
+  id: any
+  closePage: () => void
+  upTableList: () => void
+  addTableList: () => void
+}
 
 function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
   // 设置表单初始数据(区分编辑和新增)
-  const FormBoxRef = useRef<FormInstance>(null);
+  const FormBoxRef = useRef<FormInstance>(null)
 
   const getInfoInAPIFu = useCallback(async (id: number) => {
-    const res = await getUserInfoByIdAPI(id);
-    FormBoxRef.current?.setFieldsValue(res.data);
+    const res = await getUserInfoByIdAPI(id)
+    FormBoxRef.current?.setFieldsValue(res.data)
     // console.log("是编辑,在这里发请求拿数据", res);
-  }, []);
+  }, [])
 
   // 没有通过校验
   const onFinishFailed = useCallback(() => {
     // return MessageFu.warning("有表单不符号规则!");
-  }, []);
+  }, [])
 
   useEffect(() => {
-    if (id) getInfoInAPIFu(id);
+    if (id) getInfoInAPIFu(id)
     else {
-      FormBoxRef.current?.setFieldsValue({});
+      FormBoxRef.current?.setFieldsValue({})
     }
-  }, [getInfoInAPIFu, id]);
+  }, [getInfoInAPIFu, id])
 
   // 通过校验点击确定
   const onFinish = useCallback(
@@ -42,86 +42,95 @@ function UserAdd({ id, closePage, upTableList, addTableList }: Props) {
         ...values,
         id: id ? id : null,
         // 角色id写死 2=》普通用户
-        roleId: 2,
-      };
+        roleId: 2
+      }
 
-      const res: any = await userSaveAPI(obj);
+      const res: any = await userSaveAPI(obj)
 
       if (res.code === 0) {
-        MessageFu.success(id ? "编辑成功!" : "新增成功!");
-        if (id) upTableList();
-        else addTableList();
+        MessageFu.success(id ? '编辑成功!' : '新增成功!')
+        if (id) upTableList()
+        else addTableList()
 
-        closePage();
+        closePage()
       }
       // console.log("通过校验,点击确定");
     },
     [addTableList, closePage, id, upTableList]
-  );
+  )
 
   return (
     <Modal
       wrapClassName={styles.userAdd}
       destroyOnClose
       open={true}
-      title={id ? "编辑用户" : "新增用户"}
+      title={id ? '编辑用户' : '新增用户'}
       footer={
         [] // 设置footer为空,去掉 取消 确定默认按钮
       }
     >
-      <div className="userAddMain">
+      <div className='userAddMain'>
         <Form
           scrollToFirstError={true}
           ref={FormBoxRef}
-          name="basic"
+          name='basic'
           labelCol={{ span: 5 }}
           onFinish={onFinish}
           onFinishFailed={onFinishFailed}
-          autoComplete="off"
+          autoComplete='off'
         >
           <Form.Item
-            label="账号名"
-            name="userName"
+            label='账号名'
+            name='userName'
             rules={[
-              { required: true, message: "请输入账号名!" },
-              { min: 6, message: "最少6个字!" },
+              { required: true, message: '请输入账号名!' },
+              { min: 6, message: '最少6个字!' }
             ]}
-            getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
+            getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
+          >
+            <Input disabled={id} maxLength={15} showCount placeholder='请输入内容' />
+          </Form.Item>
+
+          <Form.Item
+            label='真实姓名'
+            name='realName'
+            rules={[{ required: true, message: '请输入真实姓名!' }]}
+            getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
           >
-            <Input
-              disabled={id}
-              maxLength={15}
-              showCount
-              placeholder="请输入内容"
-            />
+            <Input maxLength={10} showCount placeholder='请输入内容' />
           </Form.Item>
 
           <Form.Item
-            label="真实姓名"
-            name="realName"
-            // rules={[{ required: true, message: "请输入真实姓名!" }]}
-            getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
+            label='手机号'
+            name='phone'
+            rules={[
+              {
+                pattern: /^1[3-9][0-9]{9}$/,
+                message: '请输入正确格式的手机号!'
+              }
+            ]}
+            getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
           >
-            <Input maxLength={8} showCount placeholder="请输入内容" />
+            <Input maxLength={11} showCount placeholder='请输入11位手机号' />
           </Form.Item>
 
-          {id ? null : <div className="passTit">* 默认密码 123456</div>}
+          {id ? null : <div className='passTit'>* 默认密码 123456</div>}
 
           {/* 确定和取消按钮 */}
           <br />
           <Form.Item wrapperCol={{ offset: 9, span: 16 }}>
-            <Button type="primary" htmlType="submit">
+            <Button type='primary' htmlType='submit'>
               提交
             </Button>
             &emsp;
-            <MyPopconfirm txtK="取消" onConfirm={closePage} />
+            <MyPopconfirm txtK='取消' onConfirm={closePage} />
           </Form.Item>
         </Form>
       </div>
     </Modal>
-  );
+  )
 }
 
-const MemoUserAdd = React.memo(UserAdd);
+const MemoUserAdd = React.memo(UserAdd)
 
-export default MemoUserAdd;
+export default MemoUserAdd

+ 1 - 0
src/utils/tableData.ts

@@ -76,6 +76,7 @@ export const Z1tableC = [
   ['txt', '用户名', 'userName'],
   ['txtChange', '角色', 'isAdmin', { 1: '管理员', 0: '普通成员' }],
   ['txt', '真实姓名', 'realName'],
+  ['txt', '手机号', 'phone'],
   ['txt', '创建日期', 'createTime']
 ]