import { Component } from '@angular/core' import { FormControl, FormGroup } from '@angular/forms' import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' import { ApiService } from 'app/services' import { SharedModule } from 'app/shared/shared.module' import { format } from 'date-fns' import { of } from 'rxjs' @Component({ selector: 'app-fixed-asset-manage', standalone: true, imports: [SharedModule], templateUrl: './fixed-asset-manage.component.html', styleUrl: './fixed-asset-manage.component.less', }) export class FixedAssetManageComponent { constructor(private api: ApiService) {} queryForm = new FormGroup({ name: new FormControl(''), type: new FormControl(''), status: new FormControl(''), date: new FormControl(''), }) table = new TableOption(this.fetchData.bind(this)) ngOnInit(): void { this.table .setConfig({ selectable: true, }) .setColumn([ { key: '办理状态', title: '办理状态', visible: true }, { key: '资产编号', title: '资产编号', visible: true }, { key: '资产状态', title: '资产状态', visible: true }, { key: '资产分类', title: '资产分类', visible: true }, { key: '资产名称', title: '资产名称', visible: true }, { key: '规格型号', title: '规格型号', visible: true }, { key: '所属公司', title: '所属公司', visible: true }, { key: '使用组织', title: '使用组织', visible: true }, { key: '存放位置', title: '存放位置', visible: true }, ]) .setRowOperate([ { title: '查看', premissions: [] }, { title: '修改' }, { title: '复制' }, { title: '密文箱' }, { title: '折旧记录' }, { title: '二维码' }, { title: '操作明细' }, { title: '删除' }, ]) } fetchData(p: {}, q: AnyObject) { if (Array.isArray(q['createTime'])) { const createTimeStart = q['createTime']?.[0] const createTimeEnd = q['createTime']?.[1] q['createTimeStart'] = createTimeStart ? format(new Date(createTimeStart), 'yyyy-MM-dd HH:mm:ss') : '' q['createTimeEnd'] = createTimeEnd ? format(new Date(createTimeEnd), 'yyyy-MM-dd HH:mm:ss') : '' } return of({ data: { total: 5, records: [ { id: 1, name: '沙滩', price: 590, type: 0, lifespan: 6, number: 20, max: 20, status: 1, createTime: '2024-05-01', }, ], }, }) return this.api.getEntityPage(p, q) } }