lanjianrong 4 anni fa
parent
commit
3e6f6db144
1 ha cambiato i file con 12 aggiunte e 4 eliminazioni
  1. 12 4
      src/pages/Workbench/Dashboard/index.jsx

+ 12 - 4
src/pages/Workbench/Dashboard/index.jsx

@@ -3,7 +3,7 @@ import ProTable from '@ant-design/pro-table'
 import { Row, Col, Select, Card, Skeleton, TreeSelect } from 'antd'
 import { AddressBook, City, Finance, Comment } from '@icon-park/react'
 import consts from '@/consts'
-import { connect } from 'umi'
+import { connect, useModel } from 'umi'
 import { useModal } from '@/components/Modal'
 import { queryDashboard } from '@/services/dashboard'
 import { queryStaff } from '@/services/staff'
@@ -20,6 +20,7 @@ import styles from './index.less'
 import { isDevMode } from '@/utils/env'
 
 const Dashboard = ({ dispatch, departments = [] }) => {
+  const { initialState: { currentUser } = { currentUser: {} } } = useModel('@@initialState')
   const timer = useRef(null)
   const [defaultPermAuthCache, defaultStaffIds] = getPermAuthCache(PermDataTypeEunm.WORKBENCH)
 
@@ -81,7 +82,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
   }
 
   // dataPermission-all 拉取部门下员工列表
-  const queryStaffList = async departmentId => {
+  const queryStaffList = async (departmentId, canSetState = true) => {
     const { code = -1, data: { list = [] } = { list: [] } } = await queryStaff({
       departmentId,
       current: 1,
@@ -89,8 +90,9 @@ const Dashboard = ({ dispatch, departments = [] }) => {
     })
     if (code === consts.RET_CODE.SUCCESS) {
       // list存起来
-      setState({ ...state, staffList: list })
+      canSetState && setState({ ...state, staffList: list })
     }
+    return list
   }
   const handleStaffClick = id => {
     const sId = `s_${id}`
@@ -119,9 +121,14 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       }
     } = await queryDashboard(payload)
     if (code === consts.RET_CODE.SUCCESS) {
+      let staffList
+      if (state.params.dataPermission === 'department' && currentUser) {
+        staffList = await queryStaffList(currentUser.departmentId)
+      }
       if (state.immediate) {
         setState({
           ...state,
+          staffList,
           loading: false,
           immediate: false,
           reminderData,
@@ -141,6 +148,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
         setState({
           ...state,
           loading: false,
+          staffList,
           reminderData,
           leaderboard,
           productLeaderBoard,
@@ -324,7 +332,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
           </span>
         ) : null}
         <div>
-          {state.params.dataPermission === 'all' &&
+          {['all', 'department'].includes(state.params.dataPermission) &&
             state.staffList.map(item => (
               <div className="inline-block" key={item.id} onClick={() => handleStaffClick(item.id)}>
                 {state.selectId === item.id ? (