This commit is contained in:
Taric Xin
2022-01-13 17:13:24 +08:00
parent 46379ffe4f
commit fe3d6b6f92
14 changed files with 288 additions and 27 deletions

View 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>

View 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',
);
}
}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { DownloadComponentsListComponent } from './components/list/list.component';
const routes: Routes = [
{ path: '', redirectTo: 'list', pathMatch: 'full' },
{ path: 'list', component: DownloadComponentsListComponent, data: { reuse: true } },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class DownloadRoutingModule {}

View File

@ -0,0 +1,12 @@
import { NgModule, Type } from '@angular/core';
import { SharedModule } from '@shared';
import { DownloadComponentsListComponent } from './components/list/list.component';
import { DownloadRoutingModule } from './download-routing.module';
const COMPONENTS: Type<void>[] = [DownloadComponentsListComponent];
@NgModule({
imports: [SharedModule, DownloadRoutingModule],
declarations: COMPONENTS,
})
export class DownloadModule {}

View File

@ -0,0 +1,18 @@
import { Injectable, Injector } from '@angular/core';
import { BaseService } from '@shared';
@Injectable({
providedIn: 'root',
})
export class DownloadService extends BaseService {
// 删除多个实例接口地址
$api_del_many = '/scm/cms/cms/deleteRecordInfo/file';
// 获取实例分页数据接口地址
$api_get_page = '/api/mdc/pbc/asynExportInfo/getAsynExportInfoListPage';
// 下载文件
$api_download_file = '/api/mdc/pbc/download/file';
constructor(public injector: Injector) {
super(injector);
}
}