This commit is contained in:
Lingzi
2022-03-29 18:41:51 +08:00
parent ca0cc0f24c
commit 6bbbc68ff7
25 changed files with 742 additions and 591 deletions

View File

@ -1,45 +1,161 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { STColumn, STComponent } from '@delon/abc/st';
import { SFSchema } from '@delon/form';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { SFComponent, SFDateWidgetSchema, SFSchema, SFUISchema } from '@delon/form';
import { DatePipe, _HttpClient } from '@delon/theme';
import { differenceInCalendarDays } from 'date-fns';
import { DataService } from '../../../services/data.service';
@Component({
selector: 'app-datatable-owner',
templateUrl: './owner.component.html',
styleUrls: ['./owner.component.less'],
providers: [DatePipe]
})
export class DatatableOwnerComponent implements OnInit {
url = `/user`;
searchSchema: SFSchema = {
properties: {
no: {
type: 'string',
title: '编号'
}
}
};
@ViewChild('st') private readonly st!: STComponent;
@ViewChild('st', { static: false }) st!: STComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
_$expand = false;
type = 1;
mode = 'year';
date: any = null;
defineDate = [];
time: any = ['2022-01-01 00:00:00']
dateFormat = 'yyyy-MM-dd';
today = new Date();
ui: SFUISchema = {};
schema: SFSchema = {};
columns: STColumn[] = [
{ title: '编号', index: 'no' },
{ title: '调用次数', type: 'number', index: 'callNo' },
{ title: '头像', type: 'img', width: '50px', index: 'avatar' },
{ title: '时间', type: 'date', index: 'updatedAt' },
{
title: '',
buttons: [
// { text: '查看', click: (item: any) => `/form/${item.id}` },
// { text: '编辑', type: 'static', component: FormEditComponent, click: 'reload' },
]
}
{ title: '货主名称', index: 'networkTransporterName', className: 'text-center' },
{ title: '注册时间', index: 'zsl', className: 'text-center' },
{ title: '客户类型', index: 'yingsje', className: 'text-center' },
{ title: '业务员', index: 'cys', className: 'text-center' },
{ title: '合伙人', index: 'yingfyf', className: 'text-center' },
{ title: '客户状态', index: 'yl', className: 'text-center' },
{ title: '订单数', index: 'djd', className: 'text-center' },
{ title: '订单金额', index: 'ysz', className: 'text-center' },
{ title: '应收订单数', index: 'yswc', className: 'text-center' },
{ title: '应收金额', index: 'yisje', className: 'text-center' },
{ title: '待开票订单数', index: 'yifyf', className: 'text-center' },
{ title: '待开票金额', index: 'yifyf', className: 'text-center' },
{ title: '已收金额', render: 'yifyf', className: 'text-center' },
{ title: '附加费金额', index: 'yifyf', className: 'text-center' },
{ title: '已收附加费', index: 'yifyf', className: 'text-center' },
{ title: '附加费率', index: 'yifyf', className: 'text-center' },
{ title: '已开票金额', index: 'yifyf', className: 'text-center' }
];
constructor(private http: _HttpClient, private modal: ModalHelper) { }
ngOnInit(): void { }
add(): void {
// this.modal
// .createStatic(FormEditComponent, { i: { id: 0 } })
// .subscribe(() => this.st.reload());
/**
* 查询参数
*/
get reqParams() {
if(this.mode === 'year') {
this.type = 1
} else if(this.mode === 'month') {
this.type = 2
} else if(this.mode === 'date') {
this.type = 3
} else {
this.type = 4
}
let params: any = {
time: this.time,
type: this.type
};
delete params._$expand;
return { ...params };
}
constructor(public service: DataService, private datePipe: DatePipe) { }
ngOnInit(): void {
this.initSF();
}
/**
* 初始化查询表单
*/
initSF() {
this.schema = {
properties: {
_$expand: { type: 'boolean', ui: { hidden: true } },
billCode: {
type: 'string',
title: '货主名称',
ui: {
placeholder: '请输入',
}
},
resourceCode: {
type: 'string',
title: '客户类型',
ui: {
placeholder: '请选择',
}
},
loadingPlace: {
type: 'string',
title: '客户状态',
ui: {
placeholder: '请选择',
}
},
createTime: {
title: '注册时间',
type: 'string',
ui: {
widget: 'sl-from-to', type: 'date', format: 'yyyy-MM-dd', visibleIf: {
_$expand: (value: boolean) => value,
},
} as SFDateWidgetSchema,
}
},
type: 'object'
};
this.ui = { '*': { spanLabelFixed: 110, grid: { span: 8, gutter: 4 } } };
}
changeData(){
if(this.mode === 'year') {
this.dateFormat = 'yyyy'
} else if(this.mode === 'month') {
this.dateFormat = 'yyyy-MM'
} else {
this.dateFormat = 'yyyy-MM-dd'
}
}
onChange(result: any) {
if(this.mode === 'year') {
this.time = [this.datePipe.transform(this.date, 'yyyy') + '-01-01 00:00:00']
} else if(this.mode === 'month') {
this.time = [this.datePipe.transform(this.date, 'yyyy-MM') + '-01 00:00:00']
} else if(this.mode === 'date') {
this.time = [this.datePipe.transform(this.date, 'yyyy-MM-dd') + ' 00:00:00']
} else{
this.time = [this.datePipe.transform(this.defineDate[0], 'yyyy-MM-dd') + '00:00:00', this.datePipe.transform(this.defineDate[1], 'yyyy-MM-dd') + ' 00:00:00']
}
this.st.reload({ ...this.reqParams });
}
disabledDate = (current: Date): boolean =>
// Can not select days before today and today
differenceInCalendarDays(current, this.today) > 0;
export() {
// this.service.downloadFile(this.service.$api_exportUploadBill, this.sf.value, {});
}
search() {
this.st?.load(1)
}
/**
* 伸缩查询条件
*/
expandToggle() {
this._$expand = !this._$expand;
this.sf?.setValue('/_$expand', this._$expand);
}
/**
* 重置表单
*/
resetSF() {
this.sf.reset();
this._$expand = false;
}
}