|
@@ -31,8 +31,8 @@ function Department(props) {
|
|
|
const columns = [
|
|
|
{
|
|
|
title: '部门名称',
|
|
|
- // render: record => <a onClick={() => showUserModal(record)}>{record.dep_name}</a>,
|
|
|
- render: record => <a onClick={() => setCurrent(record)}>{record.dep_name}</a>,
|
|
|
+ render: record => <a onClick={() => showUserModal(record)}>{record.dep_name}</a>,
|
|
|
+ // render: record => <a onClick={() => setCurrent(record)}>{record.dep_name}</a>,
|
|
|
width: '32%',
|
|
|
},
|
|
|
{
|
|
@@ -72,11 +72,11 @@ function Department(props) {
|
|
|
title: '总计',
|
|
|
dataIndex: 'total_cnt',
|
|
|
},
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- width: 80,
|
|
|
- render: item => <a onClick={() => showDepCompare(item)}>详情</a>,
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // title: '操作',
|
|
|
+ // width: 80,
|
|
|
+ // render: item => <a onClick={() => showDepCompare(item)}>详情</a>,
|
|
|
+ // },
|
|
|
// {
|
|
|
// title: '付费工时数',
|
|
|
// dataIndex: 'pay_workload_cnt',
|
|
@@ -124,15 +124,20 @@ function Department(props) {
|
|
|
);
|
|
|
};
|
|
|
const onExpand = (expanded, record) => {
|
|
|
- if (expanded && !record.isLoad) {
|
|
|
- dispatch({
|
|
|
- type: 'report/queryDepReport',
|
|
|
- payload: {
|
|
|
- filter: filterRef.current,
|
|
|
- record: record,
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
+ return new Promise(resolve => {
|
|
|
+ if (expanded && !record.isLoad) {
|
|
|
+ dispatch({
|
|
|
+ type: 'report/queryDepReport',
|
|
|
+ payload: {
|
|
|
+ filter: filterRef.current,
|
|
|
+ record: record,
|
|
|
+ },
|
|
|
+ callback: resolve,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
// const showUserModal = item => {
|
|
|
const showDepCompare = item => {
|
|
@@ -144,17 +149,8 @@ function Department(props) {
|
|
|
});
|
|
|
setVisible(true);
|
|
|
};
|
|
|
- const renderChart = item => {
|
|
|
- let data = [
|
|
|
- { value: item.type_project_cnt, name: '执行项目人日' },
|
|
|
- { value: item.type_sale_cnt, name: '售前支持' },
|
|
|
- { value: item.type_market_cnt, name: '市场品牌' },
|
|
|
- { value: item.type_normal_cnt, name: '日常' },
|
|
|
- { value: item.type_standardize_cnt, name: '标准化' },
|
|
|
- { value: item.type_rd_cnt, name: '研发' },
|
|
|
- ];
|
|
|
- // 过滤为0的值
|
|
|
- data = data.filter(item => item.value);
|
|
|
+ const renderChart = () => {
|
|
|
+ current;
|
|
|
chartRef.current.setOption({
|
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
@@ -163,7 +159,7 @@ function Department(props) {
|
|
|
{
|
|
|
type: 'pie',
|
|
|
radius: '70%',
|
|
|
- data: data,
|
|
|
+ data: current,
|
|
|
emphasis: {
|
|
|
itemStyle: {
|
|
|
shadowBlur: 10,
|
|
@@ -176,6 +172,20 @@ function Department(props) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ const handleChangeCurrent = item => {
|
|
|
+ let data = [
|
|
|
+ { value: item.type_project_cnt, name: '执行项目人日' },
|
|
|
+ { value: item.type_sale_cnt, name: '售前支持' },
|
|
|
+ { value: item.type_market_cnt, name: '市场品牌' },
|
|
|
+ { value: item.type_normal_cnt, name: '日常' },
|
|
|
+ { value: item.type_standardize_cnt, name: '标准化' },
|
|
|
+ { value: item.type_rd_cnt, name: '研发' },
|
|
|
+ ];
|
|
|
+ // 过滤为0的值
|
|
|
+ data = data.filter(item => item.value);
|
|
|
+ setCurrent(data);
|
|
|
+ };
|
|
|
+
|
|
|
const renderDepSelect = () => {
|
|
|
return (
|
|
|
<TreeSelect
|
|
@@ -184,10 +194,18 @@ function Department(props) {
|
|
|
placeholder="请选择部门"
|
|
|
style={{ width: '80%' }}
|
|
|
multiple={false}
|
|
|
- treeData={depUserTree}
|
|
|
+ treeData={dep.list}
|
|
|
+ fieldNames={{
|
|
|
+ label: 'dep_name',
|
|
|
+ value: 'dep_id',
|
|
|
+ }}
|
|
|
filterTreeNode={(input, option) => {
|
|
|
return option.props.title === input;
|
|
|
}}
|
|
|
+ onSelect={(_, node) => {
|
|
|
+ handleChangeCurrent(node);
|
|
|
+ }}
|
|
|
+ loadData={node => onExpand(true, node)}
|
|
|
/>
|
|
|
);
|
|
|
};
|
|
@@ -205,7 +223,7 @@ function Department(props) {
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (current) {
|
|
|
- renderChart(current);
|
|
|
+ renderChart();
|
|
|
}
|
|
|
}, [current]);
|
|
|
|
|
@@ -229,11 +247,15 @@ function Department(props) {
|
|
|
/>
|
|
|
<Affix offsetTop={20}>
|
|
|
<Card
|
|
|
- extra={<CloseOutlined onClick={() => setCurrent(null)} />}
|
|
|
+ // extra={<CloseOutlined onClick={() => setCurrent(null)} />}
|
|
|
title={renderDepSelect()}
|
|
|
style={{ display: 'block', marginLeft: 20 }}
|
|
|
>
|
|
|
- <div id="chart" style={{ width: 400, height: 340 }}></div>
|
|
|
+ {!current?.length && <Empty style={{ width: 400 }} />}
|
|
|
+ <div
|
|
|
+ id="chart"
|
|
|
+ style={{ width: 400, height: 340, display: current?.length > 0 ? 'block' : 'none' }}
|
|
|
+ ></div>
|
|
|
</Card>
|
|
|
</Affix>
|
|
|
</div>
|