import { JobDto } from './../../syc-models'; import { RhSycService } from './../../syc.service'; import { Component, OnInit, ViewChild } from '@angular/core'; import { MsgHelper } from 'rh-base/core'; import { DynamicFormComponent } from 'rh-base/shared'; import { DataResultT, RhBaseDto, RhSafeAny, RhTableQueryOptionDto } from 'rh-base/model'; import { NzTabComponent } from 'ng-zorro-antd/tabs'; type type = 'replace' | 'delete' | 'return'; enum typeEnum { replace = 'replace', delete = 'delete', return = 'return' } type status = 'deleted' | 'failed' | 'succeeded' | 'processing' | 'schedule'; enum statusEum { deleted = 'deleted', failed = 'failed', succeeded = 'succeeded', processing = 'processing', schedule = 'schedule' } @Component({ selector: 'rh-my-information', templateUrl: './my-information.component.html', styleUrls: ['./my-information.component.css'] }) export class MyInformationComponent implements OnInit { /** tab头部 右上角的数量以及颜色 */ tabStatus = { deleted: 0, //删除 failed: 0, //失败 succeeded: 0, //完成 Processing: 0, //正在运行 Scheduled: 0 //计划 }; collapseQueryDto: RhSafeAny = { StateName: '' }; /** Enqueued表数据 */ // EnqueuedDataResult: RhSafeAny; // 表头按钮 // titleButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('redo', '运行', 'primary', 'redo', false, null, (data) => this.replaceBtnFun(), true, false, 'blue'), // new RhTableButtonInfoDto('del', '删除', 'primary', 'delete', false, null, (data) => this.removeBtnFun(), true, false, 'blue') // ]; /** 计划表数据 */ DataResult: RhSafeAny; defaultQueryDto: RhSafeAny; @ViewChild('queryForm', { static: false }) queryForm!: DynamicFormComponent; SelectData: RhSafeAny[] = []; selectedIndex = 0; isShowDetail = false; detailData!: RhBaseDto | RhSafeAny; dataLoading = false; detailsStatus!: status; selectedTopIndex = 0; //-------------------------------正在重试的任务---------------------------------- @ViewChild('entryQueryForm', { static: false }) entryQueryFormCmt!: DynamicFormComponent; entryQueryDto!: JobDto; entryDataResult!: DataResultT; returnTabIndex = 0; constructor(private sycService: RhSycService) {} ngOnInit(): void { this.getJobCountData(); } getData(option?: RhTableQueryOptionDto) { // this.getJobCountData(); // this.getProcessingJob(); // this.getScheduledJob(); setTimeout(() => { this.defaultQueryDto = { ...this.defaultQueryDto, ...this.collapseQueryDto }; this.queryForm.submitDefaultForm(null, option); this.getJobCountData(); }); } /** * 获取界面数据 */ getJobCountData() { this.sycService.GetJobCountData().subscribe((result) => { if (result.Success) { this.tabStatus = { ...this.tabStatus, ...result.Attach }; } else { MsgHelper.ShowInfoMessage('查询失败' + result.Message); // this.tabStatus = { // deleted: 0, //删除 // failed: 0, //失败 // succeeded: 0, //完成 // processing: 0, //正在运行 // schedule: 0 //计划 // }; } }); } /** * 刷新表格 * @param data * @param status */ refreshDatas(option: RhTableQueryOptionDto) { this.defaultQueryDto = { ...this.defaultQueryDto, ...this.collapseQueryDto }; setTimeout(() => { this.getData(option); }, 10); } /** * 打开详情 * @param data */ openDetailsBtnFun(data: RhSafeAny, index: number) { this.returnTabIndex = index; this.isShowDetail = false; setTimeout(() => { this.detailData = data.data; this.isShowDetail = true; this.selectedIndex = 2; // console.log(status, data); }, 20); } /** * 数据查询到赋值 * @param data * @param status */ resultDataChange(data: RhSafeAny) { this.DataResult = data; } /** * 作业下tab切换 * @param event */ tabChange(event: { index: number; tab: NzTabComponent }) { this.dataLoading = true; if (event.index === 0) { this.getData(); } } /** * 单选选中事件 * @param event */ selectedDatasChange(event: RhSafeAny) { this.SelectData = event; } /** * * @param status */ dataLoadingChange(status: boolean) { this.dataLoading = status; } //关闭tab closeEntryTab() { this.selectedIndex = this.returnTabIndex; this.isShowDetail = false; } /** * 详情关闭 * @param event */ detailsClose(event: { type: type }) { switch (event.type) { case typeEnum.replace: this.isShowDetail = false; this.selectedIndex = 1; // this.processingQueryFormCmt.submitDefaultForm(null); // this.getProcessingJob(); break; case typeEnum.delete: this.isShowDetail = false; this.selectedIndex = 4; // this.getData(); break; case typeEnum.return: this.selectedIndex = this.returnTabIndex; break; } this.getData(); } replaceBtnFun() { MsgHelper.ShowDeleteConfirm(`是否启动所选任务?`, () => {}); } removeBtnFun() { MsgHelper.ShowDeleteConfirm(`是否删除所选任务?`, () => {}); } initDefaultQueryDto(dto: RhSafeAny) { this.collapseQueryDto = dto; this.defaultQueryDto = { ...this.defaultQueryDto, ...this.collapseQueryDto }; } getValueChange() { this.defaultQueryDto = { ...this.defaultQueryDto, ...this.collapseQueryDto }; setTimeout(() => { this.getData(); }); } //-------------------------------正在重试的任务---------------------------------- // 调用查询 getDatasRetry(option?: RhTableQueryOptionDto) { // console.log(this.queryFormCmt); setTimeout(() => { this.entryQueryFormCmt.submitDefaultForm(null, option); }); } // getDatas() { // this.sycSerivce.GetRetryJob().subscribe((result) => { // if (result.Success) { // this.entryDataResult = result; // } else { // this.entryDataResult = []; // } // }); // } /** * 数据查询到赋值 * @param data * @param status */ resultEntryDataChange(data: DataResultT) { this.entryDataResult = data; if (!data.Success) { MsgHelper.ShowInfoMessage(`查询无数据:${data.Message}`); } } /** * 刷新表格 * @param data * @param status */ refreshEntryDatas(option: RhTableQueryOptionDto) { setTimeout(() => { // this.entryQueryFormCmt.submitDefaultForm(null); this.entryQueryFormCmt.submitDefaultForm(null, option); }, 10); } }