@ -5,14 +5,17 @@ import * as d3 from 'd3';
import { TopBar } from '../components/topBar' ;
import { TopBar } from '../components/topBar' ;
import ToolBar from '../components/toolBar' ;
import ToolBar from '../components/toolBar' ;
import TimeLine from '../components/timeline' ;
import TimeLine from '../components/timeline' ;
import DrawerComponents from '../components/drawer' ;
import jsPDF from 'jspdf' ;
import jsPDF from 'jspdf' ;
import moment from 'moment' ;
import moment from 'moment' ;
import qs from 'qs' ;
import qs from 'qs' ;
import { message } from 'antd' ;
import { message , Spin } from 'antd' ;
let active = 'top' ;
let active = 'top' ;
export default function companyPage ( ) {
export default function companyPage ( ) {
let topbar = null ;
let topbar = null ;
let timeLine = null ;
let drawerCom = null ;
const [ data , setData ] = useState ( null ) ;
const [ data , setData ] = useState ( null ) ;
const [ sliderProgress , setSliderProgress ] = useState ( 50 ) ;
const [ sliderProgress , setSliderProgress ] = useState ( 50 ) ;
let addNodeChildFunc = null ;
let addNodeChildFunc = null ;
@ -21,10 +24,13 @@ export default function companyPage() {
let topBarSearchRequest = null ;
let topBarSearchRequest = null ;
const [ hasRight , setHasRight ] = useState ( '' ) ;
const [ hasRight , setHasRight ] = useState ( '' ) ;
const [ id , setId ] = useState ( 0 ) ;
const [ id , setId ] = useState ( 0 ) ;
const [ spinning , setSpinning ] = useState ( false ) ;
/ / 点 击 节 点
/ / 点 击 节 点
function onNodeClick ( nodeId ) {
function onNodeClick ( node ) {
/ / a l e r t ( ' c l i c k e d ' + n o d e I d ) ;
if ( node . ftype == '2' ) {
drawerCom . showDrawer ( node . id ) ;
}
}
}
/ / 扩 展 按 钮 点 击
/ / 扩 展 按 钮 点 击
@ -74,8 +80,7 @@ export default function companyPage() {
/ / 获 取 分 部 图 片
/ / 获 取 分 部 图 片
function getSubcompanyImage ( ) {
function getSubcompanyImage ( ) {
let index = Math . floor ( Math . random ( ) * 3 ) + 1 ;
return ` ./img/back/level1.png ` ;
return ` ./img/subcompany/2.png ` ;
}
}
/ / 获 取 数 据
/ / 获 取 数 据
@ -113,7 +118,7 @@ export default function companyPage() {
if ( d . data . ftype == 0 ) {
if ( d . data . ftype == 0 ) {
return 100 ;
return 100 ;
} else if ( d . data . ftype == 1 ) {
} else if ( d . data . ftype == 1 ) {
return 80 ;
return 106 ;
} else if ( d . data . ftype == 2 ) {
} else if ( d . data . ftype == 2 ) {
return 106 ;
return 106 ;
}
}
@ -121,16 +126,8 @@ export default function companyPage() {
} ;
} ;
const nodeContentRender = ( d , i , arr , state ) => {
const nodeContentRender = ( d , i , arr , state ) => {
/ / 集 团 地 址
let companyUrl =
'/spa/organization/static/index.html#/main/organization/group' ;
/ / 分 部 地 址
let subcompanyUrl = ` /spa/organization/static/index.html#/main/organization/companyExtend/ ${ d . data . fobjid } ` ;
/ / 部 门 地 址
let departmentUrl = ` /spa/organization/static/index.html#/main/organization/departmentExtend/ ${ d . data . fobjid } ` ;
if ( d . data . ftype == 0 ) {
if ( d . data . ftype == 0 ) {
return ` <div onclick="if(${ d . data . fisvitual } ==1) return;window.open(' ${ companyUrl } ', '_blank')" style="text-align:center">
return ` <div style="text-align:center">
< div style = "display: inline-block; vertical-align: top;" >
< div style = "display: inline-block; vertical-align: top;" >
< img src = "./img/company.png" / >
< img src = "./img/company.png" / >
< / div >
< / div >
@ -147,23 +144,19 @@ export default function companyPage() {
< / div >
< / div >
< / div > ` ;
< / div > ` ;
} else if ( d . data . ftype == 1 ) {
} else if ( d . data . ftype == 1 ) {
return ` <div onclick="if( ${ d . data . fisvitual } ==1) return;window.open(' ${ subcompanyUrl } ', '_blank')">
return ` <div style='position:absolute;height:100%'>
< div style = " width : 144px ; border : 1px solid # 66BAF5 ; margin : 10px auto 0px ; border - radius : 10px ; text - align : center ;
< img style = 'width:144px;height:106px' src = "${getSubcompanyImage()}" / >
font - size : 14 px ;
font - family : Microsoft YaHei - Regular , Microsoft YaHei ;
font - weight : 400 ;
color : # 333333 ;
height : 56 px ;
padding : 15 px 10 px ;
" >
$ { d . data . fname }
< / div >
< / div >
< / div > ` ;
< div style = " width : 144px ; height : 80px ; top : 35px ; position : relative ; font - weight : 400 ; font - size : 14px ;
font - family : Microsoft YaHei - Regular , Microsoft YaHei ; color : # 333333 ; text - align : center ; " >
< div title = $ {
d . data . fname
} style = " width : 110 px ; margin : 0 auto ; overflow : hidden ; white - space : nowrap ; text - overflow : ellipsis ; - o - text - overflow : ellipsis ;
line - height : 18 px ; word - break : break - all ; " > $ { d . data . fname } < / div >
< / div > ` ;
} else if ( d . data . ftype == 2 ) {
} else if ( d . data . ftype == 2 ) {
return `
return `
< div style = "width: 100%; height: 100%; background-size: 100% 100%;" onclick = " if ( $ {
< div style = "width: 100%; height: 100%; background-size: 100% 100%;" >
d . data . fisvitual
} == 1 ) return ; window . open ( '${departmentUrl}' ) " >
< div style = 'position:absolute;height:100%' >
< div style = 'position:absolute;height:100%' >
< img style = 'width:144px;height:106px' src = "${getDepartmentImage()}" / >
< img style = 'width:144px;height:106px' src = "${getDepartmentImage()}" / >
< / div >
< / div >
@ -278,6 +271,7 @@ export default function companyPage() {
* @ param { * } requestData
* @ param { * } requestData
* /
* /
const handleSearch = ( requestData , cache = true ) => {
const handleSearch = ( requestData , cache = true ) => {
setSpinning ( true ) ;
if ( cache ) {
if ( cache ) {
requestData = { ... requestData , id : id } ;
requestData = { ... requestData , id : id } ;
}
}
@ -296,9 +290,21 @@ export default function companyPage() {
setData ( data ? . data ) ;
setData ( data ? . data ) ;
}
}
}
}
setSpinning ( false ) ;
} ) ;
} ) ;
} ;
} ;
/ * *
* 切换维度
* @ param { * } requestData
* /
const handleChange = ( requestData ) => {
timeLine . searchTimeLines (
` /api/bs/hrmorganization/orgchart/timeLines?fclass= ${ requestData . fclass } ` ,
) ;
handleSearch ( requestData ) ;
} ;
useEffect ( ( ) => {
useEffect ( ( ) => {
if ( active == 'left' ) {
if ( active == 'left' ) {
orgChart &&
orgChart &&
@ -338,6 +344,9 @@ export default function companyPage() {
onSearch = { ( requestData ) => {
onSearch = { ( requestData ) => {
handleSearch ( requestData ) ;
handleSearch ( requestData ) ;
} }
} }
changeFclass = { ( requestData ) => {
handleChange ( requestData ) ;
} }
type = "company"
type = "company"
url = "/api/bs/hrmorganization/orgchart/getCondition?fclass=0&type=company"
url = "/api/bs/hrmorganization/orgchart/getCondition?fclass=0&type=company"
/ >
/ >
@ -351,22 +360,27 @@ export default function companyPage() {
onZoomBehavior = { ( value ) => handleZoomBehavior ( value ) }
onZoomBehavior = { ( value ) => handleZoomBehavior ( value ) }
/ >
/ >
< TimeLine
< TimeLine
ref = { ( r ) => ( timeLine = r ) }
onClick = { ( timeline ) => {
onClick = { ( timeline ) => {
timeLineSearch ( timeline ) ;
timeLineSearch ( timeline ) ;
} }
} }
url = { '/api/bs/hrmorganization/orgchart/timelines?id=' + id }
url = { '/api/bs/hrmorganization/orgchart/timeLines?fclass=0' }
/ >
< OrgChartComponent
setChart = { ( chart ) => ( orgChart = chart ) }
setClick = { ( click ) => ( addNodeChildFunc = click ) }
onNodeClick = { onNodeClick }
data = { data }
onButtonClick = { onButtonClick }
buttonContent = { buttonContentRender }
nodeWidth = { nodeWidthRender }
nodeHeight = { nodeHeightRender }
nodeContent = { nodeContentRender }
/ >
/ >
< Spin size = "large" spinning = { spinning } >
< OrgChartComponent
setChart = { ( chart ) => ( orgChart = chart ) }
setClick = { ( click ) => ( addNodeChildFunc = click ) }
onNodeClick = { onNodeClick }
data = { data }
onButtonClick = { onButtonClick }
buttonContent = { buttonContentRender }
nodeWidth = { nodeWidthRender }
nodeHeight = { nodeHeightRender }
nodeContent = { nodeContentRender }
/ >
< / Spin >
< DrawerComponents ref = { ( r ) => ( drawerCom = r ) } / >
< / div >
< / div >
)
)
) ;
) ;