|
|
@ -9,6 +9,7 @@ import {
|
|
|
|
Col,
|
|
|
|
Col,
|
|
|
|
Dropdown,
|
|
|
|
Dropdown,
|
|
|
|
Menu,
|
|
|
|
Menu,
|
|
|
|
|
|
|
|
TreeSelect,
|
|
|
|
} from 'antd';
|
|
|
|
} from 'antd';
|
|
|
|
const { Option } = Select;
|
|
|
|
const { Option } = Select;
|
|
|
|
import moment from 'moment';
|
|
|
|
import moment from 'moment';
|
|
|
@ -21,20 +22,24 @@ export class TopBar extends React.Component {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
this.state = {
|
|
|
|
fclasslist: [],
|
|
|
|
fclasslist: [],
|
|
|
|
companylist: [],
|
|
|
|
companylist: [], //下拉框跟节点
|
|
|
|
deptartmentList: [],
|
|
|
|
companyData: [],
|
|
|
|
|
|
|
|
departmentData: [],
|
|
|
|
|
|
|
|
companyTreeData: [],
|
|
|
|
|
|
|
|
deptartmentTreeData: [],
|
|
|
|
requestData: {
|
|
|
|
requestData: {
|
|
|
|
date: moment(new Date()).format('YYYY-MM-DD'),
|
|
|
|
date: moment(new Date()).format('YYYY-MM-DD'),
|
|
|
|
fclass: '0',
|
|
|
|
fclass: '0',
|
|
|
|
root: '0',
|
|
|
|
root: '0',
|
|
|
|
level: '3',
|
|
|
|
level: '3',
|
|
|
|
fisvitual: '0',
|
|
|
|
fisvitual: '0',
|
|
|
|
|
|
|
|
company: undefined,
|
|
|
|
|
|
|
|
department: undefined,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleFormChange(payload) {
|
|
|
|
handleFormChange(payload) {
|
|
|
|
debugger;
|
|
|
|
|
|
|
|
let requestData = { ...this.state.requestData, ...payload };
|
|
|
|
let requestData = { ...this.state.requestData, ...payload };
|
|
|
|
this.setState({ requestData });
|
|
|
|
this.setState({ requestData });
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -52,6 +57,119 @@ export class TopBar extends React.Component {
|
|
|
|
this.props.onExport('png');
|
|
|
|
this.props.onExport('png');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 分部
|
|
|
|
|
|
|
|
* @param {*} parentId
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
getCompanyTreeNode = (parentId) => {
|
|
|
|
|
|
|
|
let api =
|
|
|
|
|
|
|
|
'/api/bs/hrmorganization/jclorgchart/getCompanyTree?company=' + parentId;
|
|
|
|
|
|
|
|
fetch(api)
|
|
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
|
|
|
.then((data) => {
|
|
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
|
|
|
|
|
let arr = [...this.state.companyTreeData, ...data.data];
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
companyTreeData: arr,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 部门
|
|
|
|
|
|
|
|
* @param {} parentId
|
|
|
|
|
|
|
|
* @returns
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
getDepartmentTreeNode = (parentId) => {
|
|
|
|
|
|
|
|
let api =
|
|
|
|
|
|
|
|
'/api/bs/hrmorganization/jclorgchart/getDepartmentTree?department=' +
|
|
|
|
|
|
|
|
parentId;
|
|
|
|
|
|
|
|
fetch(api)
|
|
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
|
|
|
.then((data) => {
|
|
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
|
|
|
|
|
let arr = [...this.state.deptartmentTreeData, ...data.data];
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
deptartmentTreeData: arr,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onCompanyLoadData = (treeNode) =>
|
|
|
|
|
|
|
|
new Promise((resolve) => {
|
|
|
|
|
|
|
|
const { id } = treeNode.props;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
this.getCompanyTreeNode(id);
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
|
|
}, 300);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onDepartmentLoadData = (treeNode) =>
|
|
|
|
|
|
|
|
new Promise((resolve) => {
|
|
|
|
|
|
|
|
const { id } = treeNode.props;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
this.getDepartmentTreeNode(id);
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
|
|
}, 300);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onCompanyChange = (value, label, extra) => {
|
|
|
|
|
|
|
|
let company = value.length > 0 ? this.paramsUtil(value) : undefined;
|
|
|
|
|
|
|
|
let requestData = {
|
|
|
|
|
|
|
|
...this.state.requestData,
|
|
|
|
|
|
|
|
company: company,
|
|
|
|
|
|
|
|
department: undefined,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
companyData: value,
|
|
|
|
|
|
|
|
requestData,
|
|
|
|
|
|
|
|
departmentData: [],
|
|
|
|
|
|
|
|
deptartmentTreeData: [],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.getDepartmentTreeList(company);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onDepartmentChange = (value) => {
|
|
|
|
|
|
|
|
let department = value.length > 0 ? this.paramsUtil(value) : undefined;
|
|
|
|
|
|
|
|
let requestData = { ...this.state.requestData, department: department };
|
|
|
|
|
|
|
|
this.setState({ departmentData: value, requestData });
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getCompanyTreeList = () => {
|
|
|
|
|
|
|
|
let api = '/api/bs/hrmorganization/jclorgchart/getCompanyTree';
|
|
|
|
|
|
|
|
fetch(api)
|
|
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
|
|
|
.then((data) => {
|
|
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
companyTreeData: data.data,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getDepartmentTreeList = (company) => {
|
|
|
|
|
|
|
|
let api = `/api/bs/hrmorganization/jclorgchart/getDepartmentTree?company=${company}`;
|
|
|
|
|
|
|
|
fetch(api)
|
|
|
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
|
|
|
.then((data) => {
|
|
|
|
|
|
|
|
if (data.code == 200) {
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
deptartmentTreeData: data.data,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
paramsUtil = (param) => {
|
|
|
|
|
|
|
|
let arr = param.map(function (obj, index) {
|
|
|
|
|
|
|
|
return obj.value;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return arr.join(',');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
componentDidMount() {
|
|
|
|
fetch(this.props.url)
|
|
|
|
fetch(this.props.url)
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((res) => res.json())
|
|
|
@ -61,6 +179,7 @@ export class TopBar extends React.Component {
|
|
|
|
companylist: data.companylist,
|
|
|
|
companylist: data.companylist,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.getCompanyTreeList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
menu = (
|
|
|
|
menu = (
|
|
|
@ -80,10 +199,12 @@ export class TopBar extends React.Component {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const { companyTreeData, deptartmentTreeData } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className={style.topbarWrapper}>
|
|
|
|
<div className={style.topbarWrapper}>
|
|
|
|
<Row>
|
|
|
|
<Row>
|
|
|
|
<Col span={5}>
|
|
|
|
<Col span={6}>
|
|
|
|
数据日期:
|
|
|
|
数据日期:
|
|
|
|
<DatePicker
|
|
|
|
<DatePicker
|
|
|
|
placeholder="请选择日期"
|
|
|
|
placeholder="请选择日期"
|
|
|
@ -105,7 +226,7 @@ export class TopBar extends React.Component {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
|
|
<Col span={4}>
|
|
|
|
<Col span={6}>
|
|
|
|
维度:
|
|
|
|
维度:
|
|
|
|
<Select
|
|
|
|
<Select
|
|
|
|
defaultValue="0"
|
|
|
|
defaultValue="0"
|
|
|
@ -119,25 +240,44 @@ export class TopBar extends React.Component {
|
|
|
|
</Select>
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
|
|
<Col span={4}>
|
|
|
|
<Col span={6}>
|
|
|
|
根节点:
|
|
|
|
分部:
|
|
|
|
<Select
|
|
|
|
<TreeSelect
|
|
|
|
showSearch
|
|
|
|
showSearch
|
|
|
|
filterOption={(input, option) =>
|
|
|
|
allowClear
|
|
|
|
(option?.children).includes(input)
|
|
|
|
treeDataSimpleMode
|
|
|
|
}
|
|
|
|
treeCheckable
|
|
|
|
defaultValue="0"
|
|
|
|
treeCheckStrictly
|
|
|
|
style={{ width: 120 }}
|
|
|
|
style={{ width: '80%' }}
|
|
|
|
value={this.state.requestData.root}
|
|
|
|
value={this.state.companyData}
|
|
|
|
onChange={(value) => this.handleFormChange({ root: value })}
|
|
|
|
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
|
|
|
>
|
|
|
|
placeholder="请选择分部节点"
|
|
|
|
{this.state.companylist.map((item) => (
|
|
|
|
onChange={this.onCompanyChange}
|
|
|
|
<Option value={item.id}>{item.fname}</Option>
|
|
|
|
loadData={this.onCompanyLoadData}
|
|
|
|
))}
|
|
|
|
treeData={companyTreeData}
|
|
|
|
</Select>
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
|
|
<Col span={5}>
|
|
|
|
<Col span={6}>
|
|
|
|
|
|
|
|
部门:
|
|
|
|
|
|
|
|
<TreeSelect
|
|
|
|
|
|
|
|
showSearch
|
|
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
|
|
treeDataSimpleMode
|
|
|
|
|
|
|
|
treeCheckable
|
|
|
|
|
|
|
|
treeCheckStrictly
|
|
|
|
|
|
|
|
style={{ width: '80%' }}
|
|
|
|
|
|
|
|
value={this.state.departmentData}
|
|
|
|
|
|
|
|
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
|
|
|
|
|
|
|
placeholder="请选择部门节点"
|
|
|
|
|
|
|
|
onChange={this.onDepartmentChange}
|
|
|
|
|
|
|
|
loadData={this.onDepartmentLoadData}
|
|
|
|
|
|
|
|
treeData={deptartmentTreeData}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
<Row style={{ marginTop: '15px' }}>
|
|
|
|
|
|
|
|
<Col span={6}>
|
|
|
|
显示层级:
|
|
|
|
显示层级:
|
|
|
|
<Select
|
|
|
|
<Select
|
|
|
|
defaultValue="3"
|
|
|
|
defaultValue="3"
|
|
|
@ -151,7 +291,7 @@ export class TopBar extends React.Component {
|
|
|
|
</Select>
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
|
|
<Col span={3}>
|
|
|
|
<Col span={6}>
|
|
|
|
<Checkbox
|
|
|
|
<Checkbox
|
|
|
|
style={{ marginTop: '5px' }}
|
|
|
|
style={{ marginTop: '5px' }}
|
|
|
|
onChange={(e) =>
|
|
|
|
onChange={(e) =>
|
|
|
@ -163,7 +303,7 @@ export class TopBar extends React.Component {
|
|
|
|
显示虚拟组织
|
|
|
|
显示虚拟组织
|
|
|
|
</Checkbox>
|
|
|
|
</Checkbox>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
<Col span={3}>
|
|
|
|
<Col span={6}>
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
type="primary"
|
|
|
|
style={{ marginRight: '10px' }}
|
|
|
|
style={{ marginRight: '10px' }}
|
|
|
|