|
@@ -1,27 +1,37 @@
|
|
|
import BasicTable from '@/components/Table'
|
|
import BasicTable from '@/components/Table'
|
|
|
-import consts from '@/consts'
|
|
|
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
|
-import React, { useEffect, useState } from 'react'
|
|
|
|
|
|
|
+import React, { useEffect, useMemo, useState } from 'react'
|
|
|
import { connect } from 'umi'
|
|
import { connect } from 'umi'
|
|
|
import Organization from './components/Organization'
|
|
import Organization from './components/Organization'
|
|
|
|
|
|
|
|
-const AddressBook = props => {
|
|
|
|
|
|
|
+export type AddressBookProps = {
|
|
|
|
|
+ allStaffList: any[]
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const AddressBook: React.FC<AddressBookProps> = props => {
|
|
|
const { dispatch, allStaffList = [] } = props
|
|
const { dispatch, allStaffList = [] } = props
|
|
|
const [state, setState] = useState({
|
|
const [state, setState] = useState({
|
|
|
- params: { id: '0' }
|
|
|
|
|
|
|
+ departmentId: '0'
|
|
|
})
|
|
})
|
|
|
const initData = () => {
|
|
const initData = () => {
|
|
|
dispatch({
|
|
dispatch({
|
|
|
type: 'staff/fetchStaffList'
|
|
type: 'staff/fetchStaffList'
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ const dataSource = useMemo(() => {
|
|
|
|
|
+ if (state.departmentId === '0') {
|
|
|
|
|
+ return allStaffList
|
|
|
|
|
+ }
|
|
|
|
|
+ return allStaffList.filter(item => item.departmentId === state.departmentId)
|
|
|
|
|
+ }, [state.departmentId, allStaffList])
|
|
|
|
|
+
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (!allStaffList.length) {
|
|
if (!allStaffList.length) {
|
|
|
initData()
|
|
initData()
|
|
|
}
|
|
}
|
|
|
}, [])
|
|
}, [])
|
|
|
- const onSelect = id => {
|
|
|
|
|
- setState({ ...state, params: { id } })
|
|
|
|
|
|
|
+ const onSelect = departmentId => {
|
|
|
|
|
+ setState({ ...state, departmentId })
|
|
|
}
|
|
}
|
|
|
const columns = [
|
|
const columns = [
|
|
|
{
|
|
{
|
|
@@ -79,26 +89,16 @@ const AddressBook = props => {
|
|
|
<Organization onSelect={onSelect} />
|
|
<Organization onSelect={onSelect} />
|
|
|
<div style={{ width: 'calc(100% - 12rem)' }}>
|
|
<div style={{ width: 'calc(100% - 12rem)' }}>
|
|
|
<div className="ml-6 shadow-hex-3e2c5a">
|
|
<div className="ml-6 shadow-hex-3e2c5a">
|
|
|
- {state.params.id && (
|
|
|
|
|
|
|
+ {allStaffList.length ? (
|
|
|
<BasicTable
|
|
<BasicTable
|
|
|
mainMenuType="hr"
|
|
mainMenuType="hr"
|
|
|
columnStateType="ADDRESSBOOK"
|
|
columnStateType="ADDRESSBOOK"
|
|
|
- params={{ departmentId: state.params.id }}
|
|
|
|
|
- rowKey={record => record.id}
|
|
|
|
|
|
|
+ rowKey={'id'}
|
|
|
columns={columns}
|
|
columns={columns}
|
|
|
- dataSource={allStaffList}
|
|
|
|
|
- // request={async params => {
|
|
|
|
|
- // const { code = -1, data: { list = [], total = 0 } = { list: [], total: 0 } } =
|
|
|
|
|
- // await queryStaff({ ...params })
|
|
|
|
|
- // return {
|
|
|
|
|
- // data: list,
|
|
|
|
|
- // success: code === consts.RET_CODE.SUCCESS,
|
|
|
|
|
- // total
|
|
|
|
|
- // }
|
|
|
|
|
- // }}
|
|
|
|
|
|
|
+ dataSource={dataSource}
|
|
|
search={false}
|
|
search={false}
|
|
|
/>
|
|
/>
|
|
|
- )}
|
|
|
|
|
|
|
+ ) : null}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|