地立项目架构图搜索条件增加部门分部

feature/ecologyChart
Chengliang 3 years ago
parent e8d142ed5a
commit f273ba49a8

@ -2,7 +2,7 @@
* @Author: Chengliang 1546584672@qq.com * @Author: Chengliang 1546584672@qq.com
* @Date: 2022-08-04 10:22:55 * @Date: 2022-08-04 10:22:55
* @LastEditors: Chengliang 1546584672@qq.com * @LastEditors: Chengliang 1546584672@qq.com
* @LastEditTime: 2022-12-01 11:53:26 * @LastEditTime: 2022-12-02 11:42:11
* @FilePath: /org-chart-frant/.umirc.ts * @FilePath: /org-chart-frant/.umirc.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
@ -26,7 +26,7 @@ export default defineConfig({
proxy: { proxy: {
'/api': { '/api': {
// 标识需要进行转换的请求的url // 标识需要进行转换的请求的url
target: 'http://192.168.1.67:9002', // 服务端域名 / http://localhost:8686 target: 'http://192.168.0.152:8093/api', // 服务端域名 / http://localhost:8686
changeOrigin: true, // 允许域名进行转换 changeOrigin: true, // 允许域名进行转换
pathRewrite: { '^/api': '' }, // 将请求url里的ci去掉 pathRewrite: { '^/api': '' }, // 将请求url里的ci去掉
}, },

Binary file not shown.

@ -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' }}

@ -17,7 +17,7 @@ export default function companyPage() {
let orgChart = null; let orgChart = null;
let topBarSearchRequest = null; let topBarSearchRequest = null;
const [hasRight, setHasRight] = useState('true'); const [hasRight, setHasRight] = useState('');
// //
function onNodeClick(nodeId) { function onNodeClick(nodeId) {
@ -90,7 +90,7 @@ export default function companyPage() {
moment(new Date()).format('YYYY-MM-DD'), moment(new Date()).format('YYYY-MM-DD'),
).then((data) => { ).then((data) => {
setData(data.data); setData(data.data);
//setHasRight(data?.hasRight); setHasRight('true');
}); });
}, [true]); }, [true]);

@ -24,7 +24,7 @@ export default function userPage() {
let orgChart = null; let orgChart = null;
let progressBtnRef = null; let progressBtnRef = null;
const [hasRight, setHasRight] = useState('true'); const [hasRight, setHasRight] = useState('');
// //
function onNodeClick(nodeId) { function onNodeClick(nodeId) {
@ -78,7 +78,7 @@ export default function userPage() {
return `./img/department/${index}.png`; return `./img/department/${index}.png`;
} }
// //
function getSubcompanyImage() { function getSubcompanyImage() {
let index = Math.floor(Math.random() * 3) + 1; let index = Math.floor(Math.random() * 3) + 1;
return `./img/subcompany/${index}.png`; return `./img/subcompany/${index}.png`;
@ -87,14 +87,14 @@ export default function userPage() {
// //
useEffect(() => { useEffect(() => {
document.cookie = document.cookie =
'ecology_JSessionid=aaa88PIn8LCwM_Y7mkOsy; JSESSIONID=aaa88PIn8LCwM_Y7mkOsy; loginidweaver=1; languageidweaver=7; loginuuids=1; __randcode__=e261bb82-0800-442e-889e-0720b8cf16fb'; 'ecology_JSessionid=aaaYiMnZkKEdO-iKnOqty; JSESSIONID=aaaYiMnZkKEdO-iKnOqty; __randcode__=140d36b3-5a03-4e73-9434-768e655afbb4; loginidweaver=1; languageidweaver=7; loginuuids=1';
d3.json( d3.json(
// "/user/data" // "/user/data"
'/api/bs/hrmorganization/jclorgchart/userData?fclass=0&root=0&date=' + '/api/bs/hrmorganization/jclorgchart/userData?fclass=0&root=0&date=' +
moment(new Date()).format('YYYY-MM-DD'), moment(new Date()).format('YYYY-MM-DD'),
).then((data) => { ).then((data) => {
setData(data.data); setData(data.data);
//setHasRight(data?.hasRight); setHasRight('true');
}); });
}, [true]); }, [true]);

Loading…
Cancel
Save