|
@@ -0,0 +1,337 @@
|
|
|
+/* #region 引入 */
|
|
|
+import {
|
|
|
+ Component,
|
|
|
+ OnInit,
|
|
|
+ Injector,
|
|
|
+ ChangeDetectorRef,
|
|
|
+ ChangeDetectionStrategy,
|
|
|
+ ElementRef,
|
|
|
+ AfterViewInit,
|
|
|
+ HostListener,
|
|
|
+ ViewChild,
|
|
|
+ ViewContainerRef,
|
|
|
+ ComponentFactoryResolver,
|
|
|
+ Inject
|
|
|
+} from '@angular/core';
|
|
|
+import { ActivatedRoute } from '@angular/router';
|
|
|
+import { DashboardHttpService, GeneralHttpService, PageDesignHttpService } from '@core';
|
|
|
+import * as icConstant from '@core';
|
|
|
+import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
|
|
|
+import { _HttpClient, ModalHelper } from '@delon/theme';
|
|
|
+import { deepCopy } from '@delon/util';
|
|
|
+import { DynamicComponentService } from 'src/app/core/utils/dynamic-component.service';
|
|
|
+import { IcLoginConfigH5Component } from 'src/app/shared/component/ic-login-config-h5/ic-login-config-h5.component';
|
|
|
+import { IcLoginConfigPcComponent } from 'src/app/shared/component/ic-login-config-pc/ic-login-config-pc.component';
|
|
|
+import { IcPagePartWrapperComponent } from 'src/app/shared/component/ic-page-part/wrapper/list.component';
|
|
|
+import { IcDashboardWdigetReflectionRegistry } from 'src/app/shared/service/dashboard.widget.reflection.service';
|
|
|
+
|
|
|
+import * as icUtils from '../../../shared/utils/ic-utils';
|
|
|
+
|
|
|
+/* #endregion */
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'ic-console-main',
|
|
|
+ templateUrl: './console.project.component.html',
|
|
|
+ styleUrls: ['./console.project.component.less'],
|
|
|
+ changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
+})
|
|
|
+export class ConsoleProjectComponent implements OnInit, AfterViewInit {
|
|
|
+ pageloading = false;
|
|
|
+ appType: 'pc' | 'h5' = 'pc';
|
|
|
+ treeData = [
|
|
|
+ {
|
|
|
+ title: '登录',
|
|
|
+ key: '10',
|
|
|
+ isLeaf: true,
|
|
|
+ url: '/passport/login'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '仪表盘',
|
|
|
+ key: '100',
|
|
|
+ isLeaf: true,
|
|
|
+ url: '/dashboarditem/31385d80e9df4335ac588c87227d9d64'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '项目管理',
|
|
|
+ key: '1001',
|
|
|
+ children: [
|
|
|
+ { title: '项目列表', key: '10010', isLeaf: true, url: '/page/s/2041bd8918ed4281afc913f7e2d3d099' },
|
|
|
+ { title: '项目里程碑', key: '10011', isLeaf: true },
|
|
|
+ { title: '项目进度填报', key: '10012', isLeaf: true }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '合同管理',
|
|
|
+ key: '1002',
|
|
|
+ children: [
|
|
|
+ { title: '经营合同', key: '10020', isLeaf: true },
|
|
|
+ { title: '采购合同', key: '10021', isLeaf: true }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ constant = icConstant;
|
|
|
+ @ViewChild('itemDom', { read: ViewContainerRef }) itemDom!: ViewContainerRef;
|
|
|
+ componentRef: any;
|
|
|
+ graph: any;
|
|
|
+ formId?: string;
|
|
|
+ constructor(
|
|
|
+ private cdr: ChangeDetectorRef,
|
|
|
+ private injector: Injector,
|
|
|
+ private cfr: ComponentFactoryResolver,
|
|
|
+ private componentService: DynamicComponentService,
|
|
|
+ private pageHttp: PageDesignHttpService,
|
|
|
+ private dashboardHttp: DashboardHttpService,
|
|
|
+ private compReflection: IcDashboardWdigetReflectionRegistry,
|
|
|
+ private el: ElementRef,
|
|
|
+ private modal: ModalHelper,
|
|
|
+ private activeRoute: ActivatedRoute,
|
|
|
+ @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService,
|
|
|
+ private http: GeneralHttpService,
|
|
|
+ public httpClient: _HttpClient
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ ngOnInit(): void {
|
|
|
+ this.formId = this.activeRoute.snapshot.params.formId;
|
|
|
+ const queryInfo = {
|
|
|
+ dataSourceCode: 'sys_app_list',
|
|
|
+ dataType: 'sql',
|
|
|
+ queryType: 'senior',
|
|
|
+ current: 1,
|
|
|
+ size: 10,
|
|
|
+ columnQueryTypes: [
|
|
|
+ {
|
|
|
+ lastTyepRelation: 'AND',
|
|
|
+ columnInnerRelation: 'AND',
|
|
|
+ columns: [
|
|
|
+ { field: 'DELETED', value: '0', fieldType: 'string', symbol: 'equal' },
|
|
|
+ { field: 'ID', value: this.formId, fieldType: 'string', symbol: 'equal' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ orders: [{ orderName: 'MODIFYDATE', orderType: 'DESC' }]
|
|
|
+ };
|
|
|
+ this.http.getGeneralCRUDListData(queryInfo).subscribe({
|
|
|
+ next: res => {
|
|
|
+ console.log('res', res);
|
|
|
+ const row = res.data.records[0];
|
|
|
+ const config = JSON.parse(row.ROPTION);
|
|
|
+ icUtils.icVisitTree(config.menus, v => {
|
|
|
+ v.key = icUtils.uuid16();
|
|
|
+ if (!icUtils.icIsNotNull(v.children)) {
|
|
|
+ v.isLeaf = true;
|
|
|
+ } else {
|
|
|
+ v.expanded = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log('config', config);
|
|
|
+ this.treeData = config.menus;
|
|
|
+ },
|
|
|
+ error: err => {
|
|
|
+ console.log('err', err);
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.cdr.markForCheck();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ngAfterViewInit(): void {
|
|
|
+ this.resetLeftHeight();
|
|
|
+ }
|
|
|
+
|
|
|
+ rowSelect(e: any): void {
|
|
|
+ console.log('rowSelect', e);
|
|
|
+ this.itemDom.clear();
|
|
|
+ let url = e.node.origin.url;
|
|
|
+ if (url) {
|
|
|
+ if (url === '/passport/login') {
|
|
|
+ // 登录
|
|
|
+ let tpl: any = IcLoginConfigH5Component;
|
|
|
+ if (this.appType === 'pc') {
|
|
|
+ tpl = IcLoginConfigPcComponent;
|
|
|
+ }
|
|
|
+ let componentFactory = this.cfr.resolveComponentFactory(tpl);
|
|
|
+ this.componentRef = this.itemDom.createComponent(componentFactory);
|
|
|
+ } else if (url.includes('/page/s')) {
|
|
|
+ // 业务页面
|
|
|
+ this.pageloading = true;
|
|
|
+ let sourceUrl = url.split('?')[0].split('/');
|
|
|
+ let pageId = sourceUrl[sourceUrl.length - 1];
|
|
|
+ this.pageHttp.getPagePartById(pageId).subscribe({
|
|
|
+ next: (res: any) => {
|
|
|
+ const data = res.data;
|
|
|
+ let compConfig = res.data.config;
|
|
|
+ if (!compConfig) {
|
|
|
+ compConfig = JSON.parse(res.data.roption);
|
|
|
+ }
|
|
|
+ data.config = compConfig;
|
|
|
+ let componentFactory = this.cfr.resolveComponentFactory(IcPagePartWrapperComponent);
|
|
|
+ this.componentRef = this.itemDom.createComponent(componentFactory);
|
|
|
+ this.componentRef.instance.config = data;
|
|
|
+ this.componentRef.instance.refreshComp();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.pageloading = false;
|
|
|
+ this.cdr.markForCheck();
|
|
|
+ }, 50);
|
|
|
+ },
|
|
|
+ error: error => console.error(error),
|
|
|
+ complete: () => {}
|
|
|
+ });
|
|
|
+ } else if (url.includes('/dashboarditem/')) {
|
|
|
+ // 门户
|
|
|
+ this.pageloading = true;
|
|
|
+ let sourceUrl = url.split('?')[0].split('/');
|
|
|
+ let pageId = sourceUrl[sourceUrl.length - 1];
|
|
|
+ this.dashboardHttp.getItemConfigById(pageId).subscribe({
|
|
|
+ next: (res: any) => {
|
|
|
+ if (res.data.roption) {
|
|
|
+ res.data.roption = JSON.parse(res.data.roption);
|
|
|
+ }
|
|
|
+ const itemConfig = res.data;
|
|
|
+ let componentFactory = this.cfr.resolveComponentFactory(this.compReflection.getType(itemConfig['instcode']));
|
|
|
+ this.componentRef = this.itemDom.createComponent(componentFactory);
|
|
|
+ this.componentRef.instance.config = itemConfig;
|
|
|
+ if (this.componentRef.instance?.icEchartsChange) {
|
|
|
+ this.componentRef.instance.icEchartsChange.subscribe({
|
|
|
+ next: (res: any) => {
|
|
|
+ if ((res?.type || '') === 'after_init') {
|
|
|
+ this.componentRef.instance.refresh();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.pageloading = false;
|
|
|
+ this.cdr.markForCheck();
|
|
|
+ }, 50);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: (error: any) => console.error(error),
|
|
|
+ complete: () => {}
|
|
|
+ });
|
|
|
+ } else if (this.componentRef.instance?.icDashboardItemChange) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.componentRef.instance.refresh();
|
|
|
+ this.pageloading = false;
|
|
|
+ this.cdr.markForCheck();
|
|
|
+ }, 200);
|
|
|
+ } else {
|
|
|
+ console.error(`搜索不到id为${pageId}的组件`);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: error => console.error(error),
|
|
|
+ complete: () => {}
|
|
|
+ });
|
|
|
+ } else if (url.includes('/page/lr/')) {
|
|
|
+ // 左右结构
|
|
|
+ }
|
|
|
+ this.cdr.markForCheck();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rowOperation(e: any, oper: string, row: any): void {
|
|
|
+ console.log('row', row);
|
|
|
+ const stylemy = deepCopy(this.constant.pageModalConfig);
|
|
|
+ switch (oper) {
|
|
|
+ case 'edit':
|
|
|
+ console.log('编辑', row);
|
|
|
+ const sourceRow = row.origin;
|
|
|
+ if (sourceRow.url.includes('/page/s')) {
|
|
|
+ this.pageloading = true;
|
|
|
+ const id = sourceRow.url.split('/').pop();
|
|
|
+ const queryInfo = {
|
|
|
+ dataSourceCode: `ic_page_part_ex_list`,
|
|
|
+ dataType: 'sql',
|
|
|
+ queryType: 'senior',
|
|
|
+ current: 1,
|
|
|
+ size: 10,
|
|
|
+ columnQueryTypes: [
|
|
|
+ {
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ field: 'DELETED',
|
|
|
+ value: '0',
|
|
|
+ fieldType: 'string',
|
|
|
+ symbol: 'equal'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'ID',
|
|
|
+ value: '104c2e4c7a2d4659bf3e1fbdccc1a08c',
|
|
|
+ fieldType: 'string',
|
|
|
+ symbol: 'equal'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ lastTyepRelation: 'AND',
|
|
|
+ columnInnerRelation: 'AND'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ this.http.getGeneralCRUDListData(queryInfo).subscribe({
|
|
|
+ next: res => {
|
|
|
+ const configs = JSON.parse(res.data.records[0].ROPTION);
|
|
|
+ this.componentService.getSysComponentByName('ic-page-part-ex-edit').then(component => {
|
|
|
+ this.modal
|
|
|
+ .create(component, { pageConfig: configs, baseFormData: configs.base }, { modalOptions: this.constant.fullModalConfig })
|
|
|
+ .subscribe((res: any) => {
|
|
|
+ if (res) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ error: err => console.error(err),
|
|
|
+ complete: () => {
|
|
|
+ this.pageloading = false;
|
|
|
+ this.cdr.markForCheck();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'delete':
|
|
|
+ console.log('删除', row);
|
|
|
+ break;
|
|
|
+ case 'addPage':
|
|
|
+ this.componentService.getSysComponentByName('ic-page-part-ex-edit').then(component => {
|
|
|
+ this.modal.create(component, {}, { modalOptions: this.constant.fullModalConfig }).subscribe((res: any) => {
|
|
|
+ if (res) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'addDashboard':
|
|
|
+ this.componentService.getPageConfigComponentByName('ic-pageconfig-dashboard').then(component => {
|
|
|
+ this.modal.create(component, {}, { modalOptions: this.constant.fullModalConfig }).subscribe((res: any) => {
|
|
|
+ if (res) {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @HostListener('window:resize', ['$event'])
|
|
|
+ resetLeftHeight(): void {
|
|
|
+ const topLeft = this.el.nativeElement.querySelector('.app-top-left');
|
|
|
+ const topRight = this.el.nativeElement.querySelector('.app-top-right');
|
|
|
+ if (topLeft && topRight) {
|
|
|
+ topLeft.style.height = `${document.body.clientHeight - topLeft.offsetTop}px`;
|
|
|
+ topRight.style.height = `${document.body.clientHeight - topRight.offsetTop - 16}px`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ logout(e: any) {
|
|
|
+ const token = (this.injector.get(DA_SERVICE_TOKEN) as ITokenService).get()?.token || '';
|
|
|
+ this.httpClient
|
|
|
+ .post(`inControlServer/sys/login/logout`, {
|
|
|
+ token: token
|
|
|
+ })
|
|
|
+ .subscribe({
|
|
|
+ next: (res: any) => {},
|
|
|
+ error: (error: any) => {
|
|
|
+ console.error(error);
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.tokenService.clear();
|
|
|
+ window.location.reload();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|