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