Browse Source

完善人员管理

zhaojing 1 year ago
parent
commit
759dc18efc

+ 1 - 0
package.json

@@ -56,6 +56,7 @@
     "@umijs/route-utils": "^2.0.0",
     "ahooks": "^3.1.9",
     "antd": "^4.17.0",
+    "qrcodejs2": "^0.0.2",
     "classnames": "^2.3.0",
     "lodash": "^4.17.0",
     "moment": "^2.29.0",

+ 26 - 10
src/app.tsx

@@ -1,6 +1,5 @@
 import { PageLoading } from '@ant-design/pro-layout';
 import { history, useModel } from 'umi';
-import { projectObj } from '@/config/api.js';
 import UserStorage from '@/config/sagacare/sagacare_user';
 
 /** 获取用户信息比较慢的时候会展示一个 loading */
@@ -12,22 +11,39 @@ export const initialStateConfig = {
  * @see  https://umijs.org/zh-CN/plugins/plugin-initial-state
  * */
 export async function getInitialState(): Promise<{
-  // settings?: Partial<LayoutSettings>;
+  projectId: String;
   currentUser?: API.CurrentUser;
   fetchUser?: () => Promise<API.CurrentUser | undefined>;
-  //loading?: boolean;
   //fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
 }> {
-  console.log('fsdfsdsdd');
   const { location } = history;
   var token = localStorage.getItem('token');
-  if (location.pathname.indexOf('login') == -1 && !token) {
-    history.push('/login');
+  // if (location.pathname.indexOf('login') == -1 && !token) {
+  //   history.push('/login');
+  // }
+  if (location.pathname.indexOf('login') > -1 && token) {
+    history.push('/home');
+  }
+  //debugger;
+  let currentUser = {
+    appId: 'wxda2ef261ac3cca32',
+    companyId: 'ff80c708fe72446eb790b764c3a7b66b',
+    loginType: 'app',
+    manageUserType: 3,
+    name: '赵静',
+    openId: 'oDcGY5Qq3Vk-7WKTNsn-lLGNT118',
+    phone: '13810794283',
+    projectId: 'Pj1101099999',
+    userId: 'db445a9cd7be4341a14448928014605c',
+  };
+  let projectId = 'Pj1101099999';
+  if (location.pathname.indexOf('login') == -1 && token) {
+    var localUser = localStorage.getItem('user') || '';
+    currentUser = JSON.parse(localUser);
+    projectId = currentUser?.projectId;
   }
 
-  let currentUser = {};
-
-  if (projectObj.projectId == 'Pj3301100002') {
+  if (projectId == 'Pj3301100002') {
     //之江项目 验证token
     // currentUser = await fetchUser();
   } else {
@@ -43,8 +59,8 @@ export async function getInitialState(): Promise<{
   }
 
   return {
+    projectId,
     currentUser,
-    fetchUser,
   };
 }
 

+ 2 - 2
src/config/api.js

@@ -2,5 +2,5 @@ export const BASE_PATH = '/api';
 //export const projectId = 'Pj3301100002';//之江
 //export const projectId = 'Pj1101080259';//博锐
 //export const projectId = 'Pj1101140020';//吉因加
-export const projectObj = { projectId: 'Pj1101080259' };
-// export const projectObj = { projectId: 'Pj3301100002' };
+export const projectObj = { projectId: '' };
+export const user = {};

+ 0 - 10
src/layouts/index.jsx

@@ -73,14 +73,6 @@ export default (props) => {
   };
 
   useEffect(async () => {
-    // console.log('enviroment-layout', initialState);
-    // const currentUser = await initialState?.fetchUser?.();
-    // if (currentUser) {
-    //   setInitialState((s) => {
-    //     return { ...s, currentUser: currentUser };
-    //   });
-    // }
-    //debugger;
     //关闭
     document.querySelector('#root').addEventListener('click', closeNotify, true);
     const { REACT_APP_ENV } = process.env;
@@ -91,10 +83,8 @@ export default (props) => {
     var lastFloorId = sessionStorage.getItem('lastFloorId') || '';
     changeLastBuildId(lastBuildId);
     changeLastFloorId(lastFloorId);
-    //console.log('lastBuildId,lastFloorId', lastBuildId, lastFloorId);
 
     return () => {
-      console.log('layout-useEffect-off');
       document.querySelector('#root').removeEventListener('click', closeNotify, true);
     };
   }, []);

+ 5 - 3
src/pages/Login/index.jsx

@@ -43,7 +43,7 @@ export default () => {
     }
 
     wsRef.current = new WebSocket(
-      `wss://duoduoenv.sagacloud.cn/duoduo-service/duoduoenv-service/webSocket/${qrCodeId}`,
+      `wss://duoduoenv.sagacloud.cn/duoduo-service/websocket/webSocket/${qrCodeId}`,
     );
     // 获取连接状态
     console.log('ws连接状态:' + wsRef.current.readyState);
@@ -59,10 +59,12 @@ export default () => {
       if (data?.data?.indexOf('token') > -1) {
         var info = JSON.parse(data.data);
         console.log('登录成功:', info);
-        var userInfo = info.tokenUser;
+        var tokenUser = info.tokenUser;
         var token = info.token;
-        localStorage.setItem('userInfo', userInfo);
+        localStorage.setItem('user', JSON.stringify(tokenUser));
         localStorage.setItem('token', token);
+        // projectObj = { projectId: tokenUser.projectId };
+        // user = tokenUser;
         history.push('/home');
       }
       //完成通信后关闭WebSocket连接

+ 15 - 13
src/pages/Member/components/personModal/index.jsx

@@ -13,6 +13,7 @@ import {
   Tree,
   Tooltip,
   Dropdown,
+  message,
 } from 'antd';
 import Icon from '@/tenants-ui/SgIcon';
 import styles from './index.less';
@@ -48,12 +49,11 @@ const PersonModal = ({
       var paramObj = {
         criteria: {
           userId: checkUser.userId,
-          companyId: 'ff80c708fe72446eb790b764c3a7b66b',
+          companyId: initialState?.currentUser?.companyId,
         },
       };
       queryUserInfo(paramObj)
         .then((res) => {
-          debugger;
           var userControlSpaces = res?.data?.controlSpaceUserList || [];
           var controlSpaces = [];
           //处理可控工区
@@ -86,7 +86,7 @@ const PersonModal = ({
         checkedValues.forEach((item) => {
           if (item != 'special') {
             slist.push({
-              companyId: 'ff80c708fe72446eb790b764c3a7b66b',
+              companyId: initialState?.currentUser?.companyId,
               spaceId: item,
               isPermanentSpace: radioValue == item ? true : false,
               userId: checkUser.userId,
@@ -95,23 +95,25 @@ const PersonModal = ({
         });
 
         var param = {
-          companyId: 'ff80c708fe72446eb790b764c3a7b66b',
+          companyId: initialState?.currentUser?.companyId,
           controlSpaceUserList: slist,
           ...value,
         };
         checkUser.userId && (param.userId = checkUser.userId);
         saveUserInfo(param)
           .then((res) => {
-            if (res.result == 'success') {
-              onClose();
-              refreshList();
+            if (res.message) {
+              message.error(res.message);
+            } else {
+              if (res.result == 'success') {
+                onClose();
+                refreshList();
+              }
             }
           })
           .catch((err) => {});
       })
-      .catch((err) => {
-        debugger;
-      });
+      .catch((err) => {});
   };
   const editUser = () => {
     setCheckSign('edit');
@@ -189,7 +191,7 @@ const PersonModal = ({
                   layout="vertical"
                   initialValues={{
                     ...checkUser,
-                    manageUserType: checkUser.manageUserType.toString(),
+                    manageUserType: checkUser?.manageUserType?.toString(),
                   }}
                 >
                   <Row gutter={[32, 8]}>
@@ -332,7 +334,7 @@ const PersonModal = ({
           )}
           {invalidSign && (
             <div className={styles.invalidCont}>
-              <div className={styles.title}>作废13333333333的身份</div>
+              <div className={styles.title}>作废{checkUser.phone}的身份</div>
               <div className={styles.article}>
                 该账号在贵公司的认证状态将失效,重新使用该软件需重新认证
               </div>
@@ -343,7 +345,7 @@ const PersonModal = ({
                 将保留该账号下所有已预约的空间、服务订单、访客邀请记录、历史设备操作记录及碳积分
               </div>
               <div className={styles.phoneTitle}>请在下方输入框内输入账号姓名</div>
-              <div className={styles.phone}>18611738701</div>
+              <div className={styles.phone}>{checkUser.phone}</div>
               <div className={styles.name}>
                 <Input
                   autoComplete="off"

+ 7 - 90
src/pages/Member/index.tsx

@@ -14,10 +14,11 @@ import {
   queryUserList,
   queryCompanyOAById,
   queryControlSpaceCompany,
-  deleteUser,
 } from '@/services/sagacare_service/member';
 
 const Member: React.FC = () => {
+  const { initialState } = useModel('@@initialState');
+
   const [perVisible, setPerVisible] = useState(false); //人员对话框显示
   const [temporary, setTemporary] = useState(false); //是否是临时成员添加
   const [invalidSign, setInvalidSign] = useState(false); //显示作废
@@ -173,7 +174,7 @@ const Member: React.FC = () => {
       criteria: {
         param: searchStr,
         status: 1,
-        companyId: 'ff80c708fe72446eb790b764c3a7b66b',
+        companyId: initialState?.currentUser?.companyId,
       },
       page: page.pageNum,
       size: page.pageSize,
@@ -199,96 +200,12 @@ const Member: React.FC = () => {
         setLoading(false);
       });
   }, [searchStr, page, sorter, refreshNum]);
-  useEffect(() => {
-    // const spaceMap3 = {
-    //   '北京中海金融街|2层': [
-    //     {
-    //       id: '22',
-    //       companyId: 'ff80c708fe72446eb790b764c3a7b66b',
-    //       spaceId: 'Sp110102000292ab218dd67011e88bee87db7e0ad2b711',
-    //       spaceName: 'D-303',
-    //       floorId: 'Fl1101020002bf10b9cad5c811e88bee1113190f5c6a11',
-    //       floorName: '2层',
-    //       buildingId: 'Bd110102000223fbec0accfb11e8a471b5d1be3b6dfe',
-    //       buildingName: '北京中海金融街',
-    //       isPermanentSpace: true,
-    //       createTime: 1692761562000,
-    //       updateTime: 1692760902000,
-    //     },
-    //     {
-    //       id: '33',
-    //       companyId: 'ff80c708fe72446eb790b764c3a7b66b',
-    //       spaceId: 'Sp110102000292ab218dd67011e88bee87db7e0ad2b722',
-    //       spaceName: 'D-304',
-    //       floorId: 'Fl1101020002bf10b9cad5c811e88bee1113190f5c6a22',
-    //       floorName: '2层',
-    //       buildingId: 'Bd110102000223fbec0accfb11e8a471b5d1be3b6dfe',
-    //       buildingName: '北京中海金融街',
-    //       isPermanentSpace: true,
-    //       createTime: 1692761562000,
-    //       updateTime: 1692760902000,
-    //     },
-    //     {
-    //       id: '55',
-    //       companyId: 'ff80c708fe72446eb790b764c3a7b66b',
-    //       spaceId: 'Sp110102000292ab218dd67011e88bee87db7e0ad2b733',
-    //       spaceName: 'D-306',
-    //       floorId: 'Fl1101020002bf10b9cad5c811e88bee1113190f5c6a',
-    //       floorName: '2层',
-    //       buildingId: 'Bd110102000223fbec0accfb11e8a471b5d1be3b6dfe',
-    //       buildingName: '北京中海金融街',
-    //       isPermanentSpace: true,
-    //       createTime: 1692761562000,
-    //       updateTime: 1692760902000,
-    //     },
-    //   ],
-    //   '北京中海金融街|3层': [
-    //     {
-    //       id: '22',
-    //       companyId: 'ff80c708fe72446eb790b764c3a7b66b',
-    //       spaceId: 'Sp110102000292ab218dd67011e88bee87db7e0ad2b744',
-    //       spaceName: 'C-303',
-    //       floorId: 'Fl1101020002bf10b9cad5c811e88bee1113190f5c6a',
-    //       floorName: '3层',
-    //       buildingId: 'Bd110102000223fbec0accfb11e8a471b5d1be3b6dfe',
-    //       buildingName: '北京中海金融街',
-    //       isPermanentSpace: true,
-    //       createTime: 1692761562000,
-    //       updateTime: 1692760902000,
-    //     },
-    //     {
-    //       id: '33',
-    //       companyId: 'ff80c708fe72446eb790b764c3a7b66b',
-    //       spaceId: 'Sp110102000292ab218dd67011e88bee87db7e0ad2b755',
-    //       spaceName: 'C-304',
-    //       floorId: 'Fl1101020002bf10b9cad5c811e88bee1113190f5c6a',
-    //       floorName: '3层',
-    //       buildingId: 'Bd110102000223fbec0accfb11e8a471b5d1be3b6dfe',
-    //       buildingName: '北京中海金融街',
-    //       isPermanentSpace: true,
-    //       createTime: 1692761562000,
-    //       updateTime: 1692760902000,
-    //     },
-    //     {
-    //       id: '55',
-    //       companyId: 'ff80c708fe72446eb790b764c3a7b66b',
-    //       spaceId: 'Sp110102000292ab218dd67011e88bee87db7e0ad2b766',
-    //       spaceName: 'C-306',
-    //       floorId: 'Fl1101020002bf10b9cad5c811e88bee1113190f5c6a',
-    //       floorName: '3层',
-    //       buildingId: 'Bd110102000223fbec0accfb11e8a471b5d1be3b6dfe',
-    //       buildingName: '北京中海金融街',
-    //       isPermanentSpace: true,
-    //       createTime: 1692761562000,
-    //       updateTime: 1692760902000,
-    //     },
-    //   ],
-    // };
 
+  useEffect(() => {
     //查询受控列表
     var paramObj = {
       criteria: {
-        companyId: 'ff80c708fe72446eb790b764c3a7b66b',
+        companyId: initialState?.currentUser?.companyId,
       },
     };
     queryControlSpaceCompany(paramObj)
@@ -297,7 +214,7 @@ const Member: React.FC = () => {
         setSpaceMap(data);
       })
       .catch((err) => {});
-    queryCompanyOAById({ companyId: 'ff80c708fe72446eb790b764c3a7b66b' })
+    queryCompanyOAById({ companyId: initialState?.currentUser?.companyId })
       .then((res) => {
         var isSyncOa = res?.isSyncOa;
         setIsSyncOa(isSyncOa == 1 ? true : false);
@@ -348,7 +265,7 @@ const Member: React.FC = () => {
         title={<FormattedMessage id="menu.member" />}
         action={
           <div className={styles.headerRight}>
-            <Search setSearchStr={setSearchStr} />
+            <Search changeSearchStr={setSearchStr} />
             {isSyncOa ? (
               <>
                 <div className={styles.allIn}>已开启OA同步</div>

+ 53 - 50
src/pages/Member/invalid/index.jsx

@@ -8,38 +8,54 @@ import Search from '@/sagacare_components/Search';
 import Table from '@/sagacare_components/Table';
 import Empty from '../components/Empty';
 import { EllipsisOutlined } from '@ant-design/icons';
+import { queryUserList } from '@/services/sagacare_service/member';
 
 export default (props) => {
-  const [list, setList] = useState([
-    {
-      name: 'zhangsan',
-      type: '临时成员',
-      phone: '13387842343',
-      duties: '经理', //职务
-      passablereseArea: '区域1区域2', //可通行区域
-      residentArea: '上格云1', //常驻工区
-      controlledArea: '区域3333', //可控空间
-      activateTime: '2023/07/16', //激活时间
-      state: '正常', //状态
-    },
-    {
-      name: 'zhangsan',
-      type: '临时成员',
-      phone: '1334245343',
-      duties: '经理', //职务
-      passablereseArea: '区域1区域2', //可通行区域
-      residentArea: '上格云1', //常驻工区
-      controlledArea: '区域3333', //可控空间
-      activateTime: '2023/07/16', //激活时间
-      state: '正常', //状态
-    },
-  ]);
+  const { initialState } = useModel('@@initialState');
+  const [userList, setUserList] = useState([]);
   const [total, setTotal] = useState(10);
   const [loading, setLoading] = useState(false);
   const [page, setPage] = useState({
     pageNum: 1,
     pageSize: 10,
   });
+  const [sorter, setSorter] = useState({
+    updateDate: 'DESC', //'ASC' : 'DESC'
+  });
+  const [searchStr, setSearchStr] = useState();
+
+  useEffect(() => {
+    var paramObj = {
+      criteria: {
+        param: searchStr,
+        status: 5,
+        companyId: initialState?.currentUser?.companyId,
+      },
+      page: page.pageNum,
+      size: page.pageSize,
+      orders: [
+        {
+          column: 'updateDate',
+          asc: sorter.updateDate == 'DESC' ? true : false,
+        },
+      ],
+    };
+    setLoading(true);
+
+    queryUserList(paramObj)
+      .then((res) => {
+        debugger;
+        setLoading(false);
+        var uarr = res.content || [];
+        var count = res.count || 0;
+        setUserList(uarr);
+        setTotal(count);
+      })
+      .catch((err) => {
+        setLoading(false);
+      });
+  }, [page, sorter]);
+
   const getColumns = () => {
     return [
       {
@@ -65,23 +81,12 @@ export default (props) => {
         title: '职务',
         dataIndex: 'duties',
       },
+
       {
-        title: '可通行区域',
-        dataIndex: 'passablereseArea',
-      },
-      {
-        title: '常驻工区',
-        dataIndex: 'residentArea',
-      },
-      {
-        title: '可控空间',
-        dataIndex: 'controlledArea',
-      },
-      {
-        title: '更新时间',
-        dataIndex: 'activateTime',
+        title: '作废时间',
+        dataIndex: 'updateDate',
         sorter: true,
-        sortered: 'DESC',
+        sortered: sorter.updateDate,
       },
       {
         title: '状态',
@@ -100,33 +105,31 @@ export default (props) => {
 
   return (
     <div className={styles.memberwrap}>
-      <PageHeader title={<FormattedMessage id="menu.member.invalid" />} action={<Search />} />
+      <PageHeader
+        title={<FormattedMessage id="menu.member.invalid" />}
+        action={<Search changeSearchStr={setSearchStr} />}
+      />
       <div className={styles.bottomTable}>
         <Table
           columns={getColumns()}
           rowKey="phone"
-          dataSource={list}
+          dataSource={userList}
           loading={loading}
           page={page}
           total={total}
-          pagination={!!list.length}
-          onFilterChange={(key, options) => {
-            debugger;
-            // if (key == 'spaceName' || key == 'tenantName') {
-            //   setShowFilterIds(options);
-            // }
-          }}
+          pagination={!!userList.length}
+          onFilterChange={(key, options) => {}}
           onRowClick={(record) => {}}
           onSortChange={(col, direction) => {
             debugger;
-            // setSorter({ [col['sortIndex']]: direction });
+            setSorter({ [col['dataIndex']]: direction });
           }}
           onPageChange={(p) => {
             debugger;
             setPage(p);
           }}
         />
-        {!list.length && !loading && <Empty />}
+        {!userList.length && !loading && <Empty />}
       </div>
     </div>
   );

+ 3 - 2
src/sagacare_components/Search/index.tsx

@@ -16,8 +16,9 @@ const { Option } = Select;
 type SearchInputProps = {
   // callbackSearch: (s: any) => void;
   //mapList: API.MapInfo[];
+  changeSearchStr: any;
 };
-const SearchInput: React.FC<SearchInputProps> = ({ setSearchStr }) => {
+const SearchInput: React.FC<SearchInputProps> = ({ changeSearchStr }) => {
   const [matchData, setMatchData] = useState<mapResType[]>([]);
   const [value, setValue] = useState<any>();
   const [loading, setLoading] = useState<boolean>(false);
@@ -47,7 +48,7 @@ const SearchInput: React.FC<SearchInputProps> = ({ setSearchStr }) => {
     }
     function fake2() {
       debugger;
-      setSearchStr(value);
+      changeSearchStr(value);
     }
     //防抖
     ref.current = setTimeout(fake2, 600);