import { MsgHelper } from 'rh-base/core'; import { Component, OnInit, ViewChild } from '@angular/core'; import { RhReportManagementService } from '../report-management.service'; import { CodeClassModel, DataResultT, RhDynamicTableFieldDto, RhSelectableDto, RhTableButtonInfoDto, RhTableQueryOptionDto, RhSafeAny } from 'rh-base/model'; import { DynamicFormComponent } from 'rh-base/shared'; import { EChartsOption, ECharts } from 'echarts'; @Component({ selector: 'rh-plan-in-process-statistics', templateUrl: './plan-in-process-statistics.component.html', styleUrls: ['./plan-in-process-statistics.component.less'] }) export class RhPlanInProcessStatisticsComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; // queryDto: ProductCompleteStatisticsReportQueryDto; today = new Date(Date.now()); // 默认汇报起止时间 startTime!: Date; endTime!: Date; selectedIndex = 0; dataLoading = false; dataResult!: DataResultT; isShowEditModal = false; defaultFieldDataset: RhDynamicTableFieldDto[] = []; editButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('edit', '编辑', 'default', 'edit', false, null, (data) => this.openEditTab(data as RhBaseDto)) ]; titleButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('new', '新建', 'primary', 'file', false, null, () => this.openEditTab(), true) ]; dataChart!: ECharts; dataOption!: EChartsOption; axisLabel: RhSafeAny = { // textStyle: { // color: '#8c8c8c', // fontStyle: 'normal', // fontFamily: '微软雅黑', // fontSize: 16 // } color: '#8c8c8c', fontStyle: 'normal', fontFamily: '微软雅黑', fontSize: 16 }; constructor(private operator: RhReportManagementService) { // } ngOnInit() { this.initDataOption(); } setDatas(dataset: DataResultT) { this.dataResult = dataset; this.dataOption = this.handleBarDatas(this.dataResult.Attach); //this.dataChart?.setOption(opt); if (!this.dataResult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataResult?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDatset(item: CodeClassModel) { const tempDatas: RhDynamicTableFieldDto[] = []; item.CodeProperties.forEach((ele) => { const temp = RhDynamicTableFieldDto.create(); temp.name = ele.PropertyName; temp.displayName = ele.Descirption; tempDatas.push(temp); }); this.defaultFieldDataset = [...tempDatas]; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } //调用子组件中的接口 private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { this.queryFormCmt.submitDefaultForm(null, option); } } // 图表区域 onChartInit(event: RhSafeAny) { this.dataChart = event; } initDataOption() { this.dataOption = { title: { text: '计划在制统计', left: 'center' }, legend: { right: '20%' }, xAxis: { type: 'category' }, yAxis: { type: 'value' } }; } handleBarDatas(dataSource: RhSelectableDto[]): EChartsOption { const xAxisDatas = dataSource.map((ele) => ele['OrganizationStructureName']).splice(0, 10); const SeriesDatas = [ dataSource.map((ele) => ele['CreatedCount']).splice(0, 10), dataSource.map((ele) => ele['IssuedCount']).splice(0, 10), dataSource.map((ele) => ele['InProductionCount']).splice(0, 10) ]; const opt: EChartsOption = { title: { text: '计划在制统计', left: 'center' }, legend: { // 图例 right: '10%', top: '5%', itemGap: 16, itemWidth: 18, itemHeight: 10, data: [{ name: '制单数' }, { name: '下达数' }, { name: '生产数' }], textStyle: { color: '#8c8c8c', fontStyle: 'normal', fontFamily: '微软雅黑', fontSize: 16 } }, tooltip: { // 提示框组件 trigger: 'axis', // 坐标轴触发 formatter: '{b}
{a0}: {c0}
{a1}: {c1}
{a2}: {c2}', axisPointer: { type: 'shadow', label: { backgroundColor: '#6a7985' } }, textStyle: { color: '#000', fontStyle: 'normal', fontFamily: '微软雅黑', fontSize: 16 } }, xAxis: [ { type: 'category', data: xAxisDatas, //nameGap: 1, // 坐标轴刻度标签的相关设置。 // axisLabel: this.axisLabel, axisTick: { //坐标轴刻度相关设置。 show: false }, axisLine: { //坐标轴轴线相关设置 lineStyle: { color: '#000', opacity: 0.2 } }, splitLine: { //坐标轴在 grid 区域中的分隔线。 show: false } } ], yAxis: [ { type: 'value', // splitNumber: 5, minInterval: 1, // 刻度显示为整数 axisLabel: this.axisLabel, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: true, lineStyle: { color: ['#000'], opacity: 0.1 } } } ], series: [ { name: '制单数', type: 'bar', data: SeriesDatas[0], barWidth: 20, barGap: '1' }, { name: '下达数', type: 'bar', data: SeriesDatas[1], barWidth: 20, barGap: '1' }, { name: '生产数', type: 'bar', data: SeriesDatas[2], barWidth: 20, barGap: '1' } ] }; return opt; } }