Browse Source

Merge branch 'dev' of ssh://10.10.100.21/source/uas-office-integration into dev

RaoMeng 5 years ago
parent
commit
24299e8ad7

+ 12 - 11
uas-office-web/uas-mobile/src/components/private/profile/ProfileCard.jsx

@@ -4,13 +4,14 @@
  */
 
 import React, { Component } from 'react'
+import { connect } from 'react-redux'
 import { isObjEmpty } from '../../../utils/common/common.util'
 import './ProfileCard.less'
 import { Icon, List } from 'antd-mobile'
 
 const Item = List.Item
 
-export default class ProfileCard extends Component {
+class ProfileCard extends Component {
 
   constructor () {
     super()
@@ -27,14 +28,8 @@ export default class ProfileCard extends Component {
   }
 
   render () {
-    let mineInfo = {
-      companyName: '深圳市英唐智能控制股份有限公司',
-      userName: '胡俊森',
-      userPost: '管理员',
-      imgUrl: '',
-      companyId: '',
-    }
-    let { companyName, userName, userPost, imgUrl } = mineInfo
+
+    let { companyName, imgUrl, userName, departName, jobName } = this.props.userState
 
     return (
       <div className="mine-info" style={{ padding: '15px 10px 0px 15px' }}>
@@ -42,7 +37,7 @@ export default class ProfileCard extends Component {
           <div className="profile-info">
             <div className="company">{companyName}</div>
             <div className="name func-font-family">{userName}</div>
-            <div className="post">{userPost}</div>
+            <div className="post">{departName + ' > ' + jobName}</div>
           </div>
           {
             imgUrl
@@ -51,9 +46,15 @@ export default class ProfileCard extends Component {
           }
         </div>
         <div className="profile-set">
-          <Item disabled={true} arrow="horizontal">设置</Item>
+          {/* <Item disabled={true} arrow="horizontal">设置</Item> */}
         </div>
       </div>
     )
   }
 }
+
+let mapStateToProps = (state) => ({
+  userState: state.userState,
+})
+
+export default connect(mapStateToProps)(ProfileCard)

+ 2 - 2
uas-office-web/uas-mobile/src/components/private/profile/ProfileList.jsx

@@ -26,10 +26,10 @@ export default class ProfileList extends Component {
   }
 
   render () {
-
+    let { accountName } = this.props
     return (
       <div className="mine-setting">
-        <Item arrow="horizontal">切换账套</Item>
+        <Item arrow="horizontal" extra={accountName}>切换账套</Item>
         <Item arrow="horizontal">清除缓存</Item>
         <Item arrow="horizontal">用户反馈</Item>
         <Item arrow="horizontal">联系我们</Item>

+ 4 - 0
uas-office-web/uas-mobile/src/configs/antd.config.less

@@ -32,6 +32,10 @@
   color: @com-text-color-normal !important;
 }
 
+.am-list-extra {
+  font-size: 14px !important;
+}
+
 .am-list-item .am-list-line .am-list-brief {
   font-size: 12px !important;
   margin-top: 2px !important;

+ 2 - 0
uas-office-web/uas-mobile/src/configs/api.config.js

@@ -16,6 +16,8 @@ export const API = {
   COMMON_LOGIN: _baseURL + '/common/login.action',
   //应用红点数
   APPCOMMON_COUNT: _baseURL + '/mobile/appcommon/count/',
+  //获取个人信息
+  COMMON_GETUSERINFO: _baseURL + '/mobile/appcommon/getEmployee.action',
 
   /*******************************应用*************************************/
   //应用菜单列表

+ 3 - 0
uas-office-web/uas-mobile/src/pages/private/homePage/HomePage.jsx

@@ -14,6 +14,7 @@ import MineRoot from './MineRoot'
 import { clearListState } from '../../../redux/actions/listState'
 import { GlobalEvent } from '../../../utils/common/eventbus/eventbus'
 import { EVENT_DOC_FUNC_COUNT } from '../../../utils/common/eventbus/events.types'
+import { requestUserInfo } from '../../../utils/private/user.util'
 
 /**
  * Created by RaoMeng on 2020/11/9
@@ -36,6 +37,8 @@ class HomePage extends Component {
 
     //刷新应用红点
     GlobalEvent.on(EVENT_DOC_FUNC_COUNT, onDocFuncCountRefresh, this)
+
+    requestUserInfo()
   }
 
   componentWillUnmount () {

+ 3 - 1
uas-office-web/uas-mobile/src/pages/private/homePage/MineRoot.jsx

@@ -25,10 +25,11 @@ class MineRoot extends Component {
   }
 
   render () {
+    let { accountName } = this.props.userState
     return (
       <div style={{ padding: '0px 5px', width: '100%' }}>
         <ProfileCard/>
-        <ProfileList/>
+        <ProfileList accountName={accountName}/>
       </div>
     )
   }
@@ -36,6 +37,7 @@ class MineRoot extends Component {
 
 let mapStateToProps = (state) => ({
   mineState: state.mineState,
+  userState: state.userState,
 })
 
 export default connect(mapStateToProps)(MineRoot)

+ 31 - 0
uas-office-web/uas-mobile/src/redux/actions/userState.js

@@ -0,0 +1,31 @@
+/**
+ * Created by Hujs on 2020/12/11
+ * Desc: 个人信息
+ */
+import store from '../store/store'
+import {
+  SAVE_USER_STATE,
+  CLEAR_USER_STATE,
+} from '../constants/actionTypes'
+
+/**
+ * Created by Hujs on 2020/12/11
+ * Desc: 储存个人信息
+ */
+export const saveUserInfo = (data) => {
+  return store.dispatch({
+    type: SAVE_USER_STATE,
+    ...data,
+  })
+}
+
+/**
+ * 清除个人信息数据
+ * @returns {Function}
+ */
+export const clearUserInfo = () => {
+  return store.dispatch({
+    type: CLEAR_USER_STATE,
+  })
+}
+

+ 3 - 0
uas-office-web/uas-mobile/src/redux/constants/actionTypes.js

@@ -7,6 +7,9 @@
 export const CLEAR_HOME_STATE = 'CLEAR_HOME_STATE'
 export const FRESH_HOME_STATE = 'FRESH_HOME_STATE'
 
+export const SAVE_USER_STATE = 'SAVE_USER_STATE'
+export const CLEAR_USER_STATE = 'CLEAR_USER_STATE'
+
 /**********************************首页********************************************/
 export const CLEAR_MAIN_STATE = 'CLEAR_MAIN_STATE'
 export const FRESH_MAIN_STATE = 'FRESH_MAIN_STATE'

+ 2 - 0
uas-office-web/uas-mobile/src/redux/reducers/index.js

@@ -5,6 +5,7 @@ import redReportState from './redReportState'
 import redDocState from './redDocState'
 import redMineState from './redMineState'
 import redListState from './redListState'
+import redUserState from './redUserState'
 
 /**
  * Created by RaoMeng on 2020/11/9
@@ -17,4 +18,5 @@ export const appReducer = combineReducers({
   docState: redDocState,
   mineState: redMineState,
   listState: redListState,
+  userState: redUserState,
 })

+ 37 - 0
uas-office-web/uas-mobile/src/redux/reducers/redUserState.js

@@ -0,0 +1,37 @@
+import { SAVE_USER_STATE, CLEAR_USER_STATE } from '../constants/actionTypes'
+
+const initUserState = {
+  accountCode: '',
+  accountId: '',
+  accountName: '',
+  companyName: '',
+  departName: '',
+  imgUrl: '',
+  jobName: '',
+  type: '',
+  userName: '',
+  userPost: '',
+}
+
+const redUserState = (state = initUserState, action) => {
+  if (action === undefined) {
+    return state
+  }
+
+  switch (action.type) {
+    case SAVE_USER_STATE:
+      //获取个人信息
+      return {
+        ...state,
+        ...action,
+      }
+    case CLEAR_USER_STATE:
+      //清空个人信息
+      return initUserState
+    default:
+      return state
+  }
+
+}
+
+export default redUserState

+ 24 - 0
uas-office-web/uas-mobile/src/utils/private/user.util.js

@@ -0,0 +1,24 @@
+import { Toast } from 'antd-mobile'
+import { fetchPostObj, fetchGet } from '../common/fetchRequest'
+import { API } from '../../configs/api.config'
+import { message } from 'antd'
+import { saveUserInfo, clearUserInfo } from '../../redux/actions/userState'
+
+/**
+ * 获取个人信息
+ */
+export function requestUserInfo () {
+  Toast.loading('数据请求中', 0)
+  return fetchGet(API.COMMON_GETUSERINFO).then(response => {
+    Toast.hide()
+    saveUserInfo(response.data)
+  }).catch(error => {
+    Toast.hide()
+    clearUserInfo()
+    if (typeof error === 'string') {
+      message.error(error)
+    } else {
+      message.error('获取个人信息失败')
+    }
+  })
+}