仅供测试,请勿发布
This commit is contained in:
parent
746535dfee
commit
b5c71a7cde
@ -335,7 +335,7 @@ class HomeContent extends React.Component {
|
|||||||
title: {
|
title: {
|
||||||
text: '当月工作培训统计数量',
|
text: '当月工作培训统计数量',
|
||||||
x: 'center',
|
x: 'center',
|
||||||
y: 'center',
|
y: '25%',
|
||||||
textStyle: { fontSize: 16, color: '#999' },
|
textStyle: { fontSize: 16, color: '#999' },
|
||||||
},
|
},
|
||||||
graphic: {
|
graphic: {
|
||||||
@ -343,7 +343,7 @@ class HomeContent extends React.Component {
|
|||||||
left: 'center',
|
left: 'center',
|
||||||
top: 'middle',
|
top: 'middle',
|
||||||
style: {
|
style: {
|
||||||
text: '暂无培训数据',
|
text: '暂无数据',
|
||||||
fill: '#999',
|
fill: '#999',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class TrainingContent extends React.Component {
|
|||||||
title: {
|
title: {
|
||||||
text: '本年度各公司培训分析',
|
text: '本年度各公司培训分析',
|
||||||
x: 'center',
|
x: 'center',
|
||||||
y: 'center',
|
y: '25%',
|
||||||
textStyle: { fontSize: 16, color: '#999' },
|
textStyle: { fontSize: 16, color: '#999' },
|
||||||
},
|
},
|
||||||
graphic: {
|
graphic: {
|
||||||
@ -68,7 +68,7 @@ class TrainingContent extends React.Component {
|
|||||||
left: 'center',
|
left: 'center',
|
||||||
top: 'middle',
|
top: 'middle',
|
||||||
style: {
|
style: {
|
||||||
text: '暂无培训数据',
|
text: '暂无数据',
|
||||||
fill: '#999',
|
fill: '#999',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
},
|
},
|
||||||
@ -190,6 +190,14 @@ class TrainingContent extends React.Component {
|
|||||||
</Option>
|
</Option>
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
getCompanyOptions = () => {
|
||||||
|
const { companyData } = this.props;
|
||||||
|
return companyData.map((company, index) => (
|
||||||
|
<Option key={index + 1} value={company.ID}>
|
||||||
|
{company.NAME}
|
||||||
|
</Option>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
// 图表2: 各部门培训完成率(横向柱状图)
|
// 图表2: 各部门培训完成率(横向柱状图)
|
||||||
renderChart2 = async () => {
|
renderChart2 = async () => {
|
||||||
@ -219,7 +227,7 @@ class TrainingContent extends React.Component {
|
|||||||
title: {
|
title: {
|
||||||
text: '本年度各公司培训分析',
|
text: '本年度各公司培训分析',
|
||||||
x: 'center',
|
x: 'center',
|
||||||
y: 'center',
|
y: '25%',
|
||||||
textStyle: { fontSize: 16, color: '#999' },
|
textStyle: { fontSize: 16, color: '#999' },
|
||||||
},
|
},
|
||||||
graphic: {
|
graphic: {
|
||||||
@ -227,7 +235,7 @@ class TrainingContent extends React.Component {
|
|||||||
left: 'center',
|
left: 'center',
|
||||||
top: 'middle',
|
top: 'middle',
|
||||||
style: {
|
style: {
|
||||||
text: '暂无培训数据',
|
text: '暂无数据',
|
||||||
fill: '#999',
|
fill: '#999',
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
},
|
},
|
||||||
@ -357,60 +365,131 @@ class TrainingContent extends React.Component {
|
|||||||
|
|
||||||
this.echartsInstances.chart3 = echarts.init(chartDom);
|
this.echartsInstances.chart3 = echarts.init(chartDom);
|
||||||
|
|
||||||
// 培训类型分布数据
|
// 使用 props 传入的 trainingSubData 数据(来自 getHomeSESubYear 接口)
|
||||||
const trainingTypes = [
|
const { trainingSubBSType } = this.props;
|
||||||
{ name: '安全法规培训', value: 35 },
|
const listNAME = trainingSubBSType?.listNAME || [];
|
||||||
{ name: '操作规程培训', value: 28 },
|
const monthRecordCount = trainingSubBSType?.MonthRecordCount || []; // 培训场次
|
||||||
{ name: '应急演练培训', value: 20 },
|
const monthPersonCount = trainingSubBSType?.MonthPersonCount || []; // 培训人次
|
||||||
{ name: '职业健康培训', value: 12 },
|
|
||||||
{ name: '其他培训', value: 5 },
|
// 如果没有数据,显示暂无数据提示
|
||||||
];
|
if (listNAME.length === 0) {
|
||||||
|
this.echartsInstances.chart3.setOption({
|
||||||
|
title: {
|
||||||
|
text: '当月公司的培训类型情况',
|
||||||
|
x: 'center',
|
||||||
|
y: '25%',
|
||||||
|
textStyle: { fontSize: 16, color: '#999' },
|
||||||
|
},
|
||||||
|
graphic: {
|
||||||
|
type: 'text',
|
||||||
|
left: 'center',
|
||||||
|
top: 'middle',
|
||||||
|
style: {
|
||||||
|
text: '暂无数据',
|
||||||
|
fill: '#999',
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const option = {
|
const option = {
|
||||||
title: {
|
title: {
|
||||||
text: '培训类型分布',
|
text: '当月公司的培训类型情况',
|
||||||
x: 'center',
|
x: 'center',
|
||||||
y: '5%',
|
y: '5%',
|
||||||
textStyle: { fontSize: 16, color: '#000', fontWeight: 'bold' },
|
textStyle: { fontSize: 16, color: '#000', fontWeight: 'bold' },
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'item',
|
trigger: 'axis',
|
||||||
|
axisPointer: { type: 'shadow' },
|
||||||
formatter: function (params) {
|
formatter: function (params) {
|
||||||
return `${params.name}: ${params.value}场 (${params.percent}%)`;
|
let result = `${params[0].axisValue}<br/>`;
|
||||||
|
params.forEach((param) => {
|
||||||
|
result += `${param.marker}${param.seriesName}: ${param.value}<br/>`;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
orient: 'vertical',
|
data: ['培训人次', '培训场次'],
|
||||||
right: '5%',
|
right: '3%', // 靠右
|
||||||
top: 'middle',
|
top: '5%', // 垂直居中
|
||||||
itemGap: 12,
|
itemGap: 16,
|
||||||
itemWidth: 14,
|
itemWidth: 18,
|
||||||
itemHeight: 10,
|
itemHeight: 12,
|
||||||
textStyle: { color: '#333', fontSize: 11 },
|
textStyle: { color: '#000', fontSize: 14 },
|
||||||
formatter: function (name) {
|
},
|
||||||
const item = trainingTypes.find((t) => t.name === name);
|
grid: {
|
||||||
return `${name} ${item?.value || 0}场`;
|
left: '5%',
|
||||||
|
right: '5%', // 为右侧垂直图例留出空间
|
||||||
|
top: '18%',
|
||||||
|
bottom: '8%',
|
||||||
|
containLabel: true,
|
||||||
|
},
|
||||||
|
xAxis: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
data: listNAME,
|
||||||
|
axisLine: { show: false },
|
||||||
|
axisTick: { show: false },
|
||||||
|
axisLabel: {
|
||||||
|
textStyle: { color: '#000' },
|
||||||
|
rotate: listNAME.length > 4 ? 15 : 0,
|
||||||
|
interval: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
color: ['#4285F4', '#66bb6a', '#ffa94d', '#ab47bc', '#ef5350'],
|
],
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
show: true,
|
||||||
|
axisLine: { show: false },
|
||||||
|
axisTick: { show: false },
|
||||||
|
axisLabel: {
|
||||||
|
show: true,
|
||||||
|
textStyle: { color: '#000' },
|
||||||
|
},
|
||||||
|
splitLine: { show: false },
|
||||||
|
name: '',
|
||||||
|
nameTextStyle: { show: false },
|
||||||
|
},
|
||||||
|
],
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: '培训场次',
|
name: '培训人次',
|
||||||
type: 'pie',
|
type: 'bar',
|
||||||
radius: ['45%', '70%'],
|
data: monthPersonCount,
|
||||||
center: ['40%', '55%'],
|
itemStyle: {
|
||||||
avoidLabelOverlap: false,
|
normal: {
|
||||||
|
color: '#4285F4', // 蓝色
|
||||||
|
},
|
||||||
|
},
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
position: 'outside',
|
position: 'top',
|
||||||
formatter: '{b}: {d}%',
|
textStyle: { color: '#4285F4', fontSize: 12 },
|
||||||
textStyle: { fontSize: 11, color: '#333' },
|
formatter: (params) => `${params.value}`,
|
||||||
},
|
},
|
||||||
emphasis: {
|
barWidth: '35%',
|
||||||
label: { show: true, fontSize: 14, fontWeight: 'bold' },
|
|
||||||
},
|
},
|
||||||
labelLine: { length: 8, length2: 8, smooth: true },
|
{
|
||||||
data: trainingTypes,
|
name: '培训场次',
|
||||||
|
type: 'bar',
|
||||||
|
data: monthRecordCount,
|
||||||
|
itemStyle: {
|
||||||
|
normal: {
|
||||||
|
color: '#ffe066', // 黄色
|
||||||
|
},
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: true,
|
||||||
|
position: 'top',
|
||||||
|
textStyle: { color: '#d4a000', fontSize: 12 },
|
||||||
|
formatter: (params) => `${params.value}`,
|
||||||
|
},
|
||||||
|
barWidth: '35%',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@ -565,13 +644,19 @@ class TrainingContent extends React.Component {
|
|||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
// 当 trainingSubData 或 trainingSubDataMonth 变化时重新渲染图表
|
// 当 trainingSubData 或 trainingSubDataMonth 变化时重新渲染图表
|
||||||
if (
|
if (
|
||||||
prevProps.trainingSubData !== this.props.trainingSubData ||
|
|
||||||
prevProps.trainingSubDataMonth !== this.props.trainingSubDataMonth ||
|
prevProps.trainingSubDataMonth !== this.props.trainingSubDataMonth ||
|
||||||
prevProps.selectedMonth !== this.props.selectedMonth
|
prevProps.selectedMonth !== this.props.selectedMonth
|
||||||
) {
|
) {
|
||||||
// this.renderChart1();
|
// this.renderChart1();
|
||||||
this.renderChart2();
|
this.renderChart2();
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
prevProps.trainingSubBSType !== this.props.trainingSubBSType ||
|
||||||
|
prevProps.selectedCompany !== this.props.selectedCompany
|
||||||
|
) {
|
||||||
|
// this.renderChart1();
|
||||||
|
this.renderChart3();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -580,7 +665,7 @@ class TrainingContent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { selectedMonth = 1, onMonthChange } = this.props;
|
const { selectedMonth = 1, onMonthChange, onCompanyChange, selectedCompany } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className={styles.trainingContentWrapper}>
|
<div className={styles.trainingContentWrapper}>
|
||||||
<div className={styles.trainingGrid}>
|
<div className={styles.trainingGrid}>
|
||||||
@ -608,6 +693,18 @@ class TrainingContent extends React.Component {
|
|||||||
{/* 第二行 - 图表3和图表4 */}
|
{/* 第二行 - 图表3和图表4 */}
|
||||||
<div className={styles.trainingRow}>
|
<div className={styles.trainingRow}>
|
||||||
<div className={styles.trainingCard}>
|
<div className={styles.trainingCard}>
|
||||||
|
{/* 添加月份选择器 */}
|
||||||
|
<div className={styles.monthSelectorWrapper}>
|
||||||
|
<span className={styles.monthSelectorLabel}>选择公司:</span>
|
||||||
|
<Select
|
||||||
|
value={selectedCompany}
|
||||||
|
onChange={onCompanyChange}
|
||||||
|
style={{ width: 120 }}
|
||||||
|
className={styles.monthSelect}
|
||||||
|
>
|
||||||
|
{this.getCompanyOptions()}
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
<div id="trainingChart3" className={styles.trainingChartContainer}></div>
|
<div id="trainingChart3" className={styles.trainingChartContainer}></div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.trainingCard}>
|
<div className={styles.trainingCard}>
|
||||||
|
|||||||
@ -61,8 +61,10 @@ class FullScreen extends React.Component {
|
|||||||
},
|
},
|
||||||
trainingSubIDCard: {},
|
trainingSubIDCard: {},
|
||||||
trainingSubBSType: {},
|
trainingSubBSType: {},
|
||||||
|
companyData: [],
|
||||||
// 新增:当前选择的月份
|
// 新增:当前选择的月份
|
||||||
selectedMonth: new Date().getMonth() + 1, // 默认当前月份,1-12
|
selectedMonth: new Date().getMonth() + 1, // 默认当前月份,1-12
|
||||||
|
selectedCompany: '',
|
||||||
};
|
};
|
||||||
this.isUnmounted = false;
|
this.isUnmounted = false;
|
||||||
}
|
}
|
||||||
@ -132,6 +134,7 @@ class FullScreen extends React.Component {
|
|||||||
this.getHomeSESubYearMonthData();
|
this.getHomeSESubYearMonthData();
|
||||||
this.getHomeSESubIDCardData();
|
this.getHomeSESubIDCardData();
|
||||||
this.getBSTypeMonthData();
|
this.getBSTypeMonthData();
|
||||||
|
this.getCompanyData();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -238,6 +241,13 @@ class FullScreen extends React.Component {
|
|||||||
this.getHomeSESubYearMonthData();
|
this.getHomeSESubYearMonthData();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
handleCompanyChange = (company) => {
|
||||||
|
console.log(company, '11111');
|
||||||
|
this.setState({ selectedCompany: company }, () => {
|
||||||
|
// 重新获取月份数据
|
||||||
|
this.getBSTypeMonthData();
|
||||||
|
});
|
||||||
|
};
|
||||||
// 获取安全培训页面数据
|
// 获取安全培训页面数据
|
||||||
getHomeSESubYearMonthData = () => {
|
getHomeSESubYearMonthData = () => {
|
||||||
const orgId = storage('lacal').getItem('webOrgId')?.val;
|
const orgId = storage('lacal').getItem('webOrgId')?.val;
|
||||||
@ -280,6 +290,7 @@ class FullScreen extends React.Component {
|
|||||||
const currentDateStr = `${year}-${month}-${day}`; // 例如:2024-06-15
|
const currentDateStr = `${year}-${month}-${day}`; // 例如:2024-06-15
|
||||||
|
|
||||||
json.Parameter1 = currentDateStr; // 设置为当前日期
|
json.Parameter1 = currentDateStr; // 设置为当前日期
|
||||||
|
json.Parameter2 = this.state.selectedCompany.toString(); // 月份
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
type: 'app/getDataByPost',
|
type: 'app/getDataByPost',
|
||||||
payload: json,
|
payload: json,
|
||||||
@ -303,6 +314,7 @@ class FullScreen extends React.Component {
|
|||||||
const currentDateStr = `${year}-${month}-${day}`; // 例如:2024-06-15
|
const currentDateStr = `${year}-${month}-${day}`; // 例如:2024-06-15
|
||||||
|
|
||||||
json.Parameter1 = currentDateStr; // 设置为当前日期
|
json.Parameter1 = currentDateStr; // 设置为当前日期
|
||||||
|
json.Parameter2 = this.state.selectedCompany;
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
type: 'app/getDataByPost',
|
type: 'app/getDataByPost',
|
||||||
payload: json,
|
payload: json,
|
||||||
@ -316,18 +328,47 @@ class FullScreen extends React.Component {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
getCompanyData = () => {
|
||||||
|
const orgId = storage('lacal').getItem('webOrgId')?.val;
|
||||||
|
const json = initFilter(orgId);
|
||||||
|
this.props.dispatch({
|
||||||
|
type: 'app/getDataByPost',
|
||||||
|
payload: json,
|
||||||
|
url: 'FM/Organization/OrderPaged',
|
||||||
|
onComplete: (ret) => {
|
||||||
|
if (ret && !this.isUnmounted) {
|
||||||
|
this.setState({
|
||||||
|
companyData: ret,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
renderOtherTabContent = () => {
|
renderOtherTabContent = () => {
|
||||||
const { activeTab, trainingData, trainingSubData, trainingSubDataMonth, selectedMonth } = this.state;
|
const {
|
||||||
|
activeTab,
|
||||||
|
trainingData,
|
||||||
|
trainingSubData,
|
||||||
|
trainingSubDataMonth,
|
||||||
|
selectedMonth,
|
||||||
|
selectedCompany,
|
||||||
|
trainingSubBSType,
|
||||||
|
companyData,
|
||||||
|
} = this.state;
|
||||||
// 如果是安全培训,显示专门的培训页面
|
// 如果是安全培训,显示专门的培训页面
|
||||||
if (activeTab === '安全培训') {
|
if (activeTab === '安全培训') {
|
||||||
return (
|
return (
|
||||||
<TrainingContent
|
<TrainingContent
|
||||||
trainingData={trainingData}
|
trainingData={trainingData}
|
||||||
trainingSubData={trainingSubData}
|
trainingSubData={trainingSubData}
|
||||||
|
trainingSubBSType={trainingSubBSType}
|
||||||
|
companyData={companyData}
|
||||||
trainingSubDataMonth={trainingSubDataMonth}
|
trainingSubDataMonth={trainingSubDataMonth}
|
||||||
selectedMonth={selectedMonth}
|
selectedMonth={selectedMonth}
|
||||||
|
selectedCompany={selectedCompany}
|
||||||
onMonthChange={this.handleMonthChange}
|
onMonthChange={this.handleMonthChange}
|
||||||
|
onCompanyChange={this.handleCompanyChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user