edit
This commit is contained in:
		
							
								
								
									
										13
									
								
								src/app/routes/download/components/list/list.component.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/app/routes/download/components/list/list.component.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
<page-header-wrapper [title]="'下载中心'"></page-header-wrapper>
 | 
			
		||||
 | 
			
		||||
<nz-card nzSize="small">
 | 
			
		||||
  <!-- 搜索区 -->
 | 
			
		||||
  <sf #sf mode="search" [schema]="schema" (formSubmit)="st.load(1)" (formReset)="resetSF()"></sf>
 | 
			
		||||
  <!-- 数据列表 -->
 | 
			
		||||
  <st #st multiSort [scroll]="{ x: '1200px' }" [size]="'small'" [data]="service.$api_get_page" [columns]="columns"
 | 
			
		||||
    [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
 | 
			
		||||
    [res]="{ reName: { list: 'data.records', total: 'data.total' } }"
 | 
			
		||||
    [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
 | 
			
		||||
    [loading]="service.http.loading">
 | 
			
		||||
  </st>
 | 
			
		||||
</nz-card>
 | 
			
		||||
							
								
								
									
										136
									
								
								src/app/routes/download/components/list/list.component.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								src/app/routes/download/components/list/list.component.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,136 @@
 | 
			
		||||
import { Component, OnInit, ViewChild } from '@angular/core';
 | 
			
		||||
import { ActivatedRoute, Router } from '@angular/router';
 | 
			
		||||
import { STChange, STColumn, STComponent, STData } from '@delon/abc/st';
 | 
			
		||||
import { SFComponent, SFDateWidgetSchema, SFSchema, SFUISchema } from '@delon/form';
 | 
			
		||||
import { _HttpClient } from '@delon/theme';
 | 
			
		||||
import { NzModalService } from 'ng-zorro-antd/modal';
 | 
			
		||||
import { DownloadService } from '../../services/download.service';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-download-center-components-list',
 | 
			
		||||
  templateUrl: './list.component.html',
 | 
			
		||||
})
 | 
			
		||||
export class DownloadComponentsListComponent implements OnInit {
 | 
			
		||||
  ui: SFUISchema = {};
 | 
			
		||||
  schema: SFSchema = {};
 | 
			
		||||
  columns: STColumn[] = [];
 | 
			
		||||
  @ViewChild('st', { static: false }) st!: STComponent;
 | 
			
		||||
  @ViewChild('sf', { static: false }) sf!: SFComponent;
 | 
			
		||||
  constructor(public service: DownloadService, private modal: NzModalService, private router: Router, private ar: ActivatedRoute) {}
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * 查询参数
 | 
			
		||||
   */
 | 
			
		||||
  get reqParams() {
 | 
			
		||||
    const params = Object.assign({}, this.sf?.value || {});
 | 
			
		||||
    delete params._$expand;
 | 
			
		||||
    return { ...params };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * 重置表单
 | 
			
		||||
   */
 | 
			
		||||
  resetSF() {
 | 
			
		||||
    this.sf.reset();
 | 
			
		||||
  }
 | 
			
		||||
  /**
 | 
			
		||||
   * 程序初始化入口
 | 
			
		||||
   */
 | 
			
		||||
  ngOnInit() {
 | 
			
		||||
    this.initSF();
 | 
			
		||||
    this.initST();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * 初始化查询表单
 | 
			
		||||
   */
 | 
			
		||||
  initSF() {
 | 
			
		||||
    this.schema = {
 | 
			
		||||
      properties: {
 | 
			
		||||
        _$expand: {
 | 
			
		||||
          type: 'boolean',
 | 
			
		||||
          ui: { hidden: true },
 | 
			
		||||
        },
 | 
			
		||||
        applyStartTime: {
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          title: '创建时间',
 | 
			
		||||
          ui: {
 | 
			
		||||
            widget: 'date',
 | 
			
		||||
            format: 'yyyy-MM-dd',
 | 
			
		||||
            end: 'applyEndTime',
 | 
			
		||||
          } as SFDateWidgetSchema,
 | 
			
		||||
        },
 | 
			
		||||
        applyEndTime: {
 | 
			
		||||
          type: 'string',
 | 
			
		||||
          title: '',
 | 
			
		||||
          ui: { widget: 'date', end: 'end' } as SFDateWidgetSchema,
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    };
 | 
			
		||||
    this.ui = { '*': { spanLabelFixed: 80, grid: { span: 8, gutter: 4 } } };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * 初始化数据列表
 | 
			
		||||
   */
 | 
			
		||||
  initST() {
 | 
			
		||||
    this.columns = [
 | 
			
		||||
      { title: '文件名称', index: 'dataSourcesDetail', className: 'text-center' },
 | 
			
		||||
      { title: '文件来源', index: 'dataSources', className: 'text-center' },
 | 
			
		||||
      { title: '文件大小', index: 'dataSize', width: '120px', className: 'text-center' },
 | 
			
		||||
      {
 | 
			
		||||
        title: '生成状态',
 | 
			
		||||
        index: 'status',
 | 
			
		||||
        width: '120px',
 | 
			
		||||
        className: 'text-center',
 | 
			
		||||
        type: 'enum',
 | 
			
		||||
        enum: {
 | 
			
		||||
          0: '生成中',
 | 
			
		||||
          1: '已完成',
 | 
			
		||||
          2: '失败',
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
      { title: '下载次数', index: 'downloadCount', width: '120px', className: 'text-center' },
 | 
			
		||||
      { title: '创建时间', index: 'createTime', width: '120px', className: 'text-center' },
 | 
			
		||||
      { title: '生成时间', index: 'completeTime', width: '180px', className: 'text-center' },
 | 
			
		||||
      {
 | 
			
		||||
        title: '操作',
 | 
			
		||||
        fixed: 'right',
 | 
			
		||||
        width: '170px',
 | 
			
		||||
        className: 'text-center',
 | 
			
		||||
        buttons: [
 | 
			
		||||
          { text: '下载', click: (_record) => this.download(_record), iif: (item) => item.status === 1 },
 | 
			
		||||
          { text: '删除', click: (_record) => this.delOne(_record), iif: (item) => item.status !== 0 },
 | 
			
		||||
        ],
 | 
			
		||||
      },
 | 
			
		||||
    ];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * 删除单个实例
 | 
			
		||||
   * @param record 记录实例
 | 
			
		||||
   */
 | 
			
		||||
  delOne(record: STData) {
 | 
			
		||||
    const headers = [{ key: 'Content-Type', value: 'application/json' }];
 | 
			
		||||
    this.modal.confirm({
 | 
			
		||||
      nzTitle: '<i>删除确认</i>',
 | 
			
		||||
      nzContent: `<b>即将删除 当前行数据,请仔细核对,避免误操作!<br>是否删除?</br>`,
 | 
			
		||||
      nzOnOk: () =>
 | 
			
		||||
        this.service.request(this.service.encodeUrlHeader(this.service.$api_del_many, headers), { fileKey: record.id }).subscribe((res) => {
 | 
			
		||||
          if (res) {
 | 
			
		||||
            this.service.msgSrv.success('数据删除成功!');
 | 
			
		||||
            this.st?.reload();
 | 
			
		||||
          }
 | 
			
		||||
        }),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
  download(record: STData) {
 | 
			
		||||
    const headers = [{ key: 'Content-Type', value: 'application/json' }];
 | 
			
		||||
    this.service.downloadFile(
 | 
			
		||||
      this.service.encodeUrlHeader(this.service.$api_download_file, headers),
 | 
			
		||||
      {},
 | 
			
		||||
      { fileKey: record.fileUniqueKey },
 | 
			
		||||
      'POST',
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user