固定资产项目前端文件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.7 KiB

2 years ago
import { Component } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms'
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table'
2 years ago
import { ApiService } from 'app/services'
import { SharedModule } from 'app/shared/shared.module'
import { format } from 'date-fns'
import { lastValueFrom, of } from 'rxjs'
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NzModalService } from 'ng-zorro-antd/modal'
import { NzMessageService } from 'ng-zorro-antd/message'
import { AssetBusinessCollectionComponent, AssetBusinessStorageFormComponent } from 'app/components'
import { BUSINESS_STATUS_MAP } from 'app/constants'
2 years ago
@Component({
selector: 'app-fixed-asset-manage-distribution',
standalone: true,
imports: [SharedModule],
2 years ago
templateUrl: './fixed-asset-manage-distribution.component.html',
styleUrl: './fixed-asset-manage-distribution.component.less',
})
export class FixedAssetManageDistributionComponent {
constructor(
private api: ApiService,
private modal: NzModalService,
private msg: NzMessageService,
) {}
2 years ago
queryForm = new FormGroup({
name: new FormControl(),
businessId: new FormControl(),
status: new FormControl(),
date: new FormControl(),
2 years ago
})
BUSINESS_STATUS_MAP = BUSINESS_STATUS_MAP
2 years ago
table = new TableOption(this.fetchData.bind(this))
ngOnInit(): void {
this.table
// .setConfig({
// selectable: true,
// rowKey: 'id',
// })
2 years ago
.setColumn([
{ key: 'id', title: '主键', visible: false },
{ key: 'businessId', title: '业务编号', visible: true, width: '350px' },
{ key: 'name', title: '业务名称', visible: true },
{ key: 'status', title: '办理状态', visible: true },
{ key: '_useOrganization', title: '领用后公司/部门', visible: true },
{ key: '_useUser', title: '使用人员', visible: true },
{ key: '_position', title: '存放位置', visible: true },
2 years ago
{ key: 'positionDetail', title: '详细位置', visible: true },
{ key: 'businessGeneratedDate', title: '领用日期', visible: true },
{ key: 'notes', title: '备注', visible: true },
2 years ago
])
.setRowOperate([
{
title: '查看',
onClick: (v) => {
this.onCreate(v, true)
},
},
{ title: '修改', onClick: this.onCreate.bind(this) },
{ title: '确认', onClick: this.confirm.bind(this) },
// { title: '单据' },
{ title: '删除', onClick: this.deleteItem.bind(this) },
2 years ago
])
}
fetchData(p: {}, q: AnyObject) {
return this.api.getBusinessCollectionPage({ ...p, ...q })
}
2 years ago
onCreate(data?: NzSafeAny, preview?: boolean) {
2 years ago
let nzTitle = data ? '编辑资产领用' : '添加资产领用'
if (preview) {
nzTitle = '预览资产领用'
}
this.modal.create({
2 years ago
nzTitle,
nzContent: AssetBusinessCollectionComponent,
nzWidth: '80vw',
nzWrapClassName: 'modal-lg',
nzData: {
value: data,
preview,
},
nzOnOk: async (e) => {
const vals = e.getValues()
if (vals) {
const res = await lastValueFrom(this.api.saveBusinessCollection(vals))
this.msg.success(res.desc)
this.table.ref.reload()
return true
}
return false
},
})
}
confirm(item?: NzSafeAny) {
const ids = [item.id]
this.modal.confirm({
nzTitle: '警告',
nzContent: `是否要进行该操作?`,
nzOnOk: async () => {
const res = await lastValueFrom(this.api.confirmBusinessCollection(ids))
this.msg.success(res.desc)
this.table.ref.reload()
},
})
}
deleteItem(item?: NzSafeAny) {
const ids = [item.id]
this.modal.confirm({
nzTitle: '警告',
nzContent: `是否要删除${ids.length}个资产领用?`,
nzOnOk: async () => {
const res = await lastValueFrom(this.api.deleteBusinessCollection(ids))
this.msg.success(res.desc)
this.table.ref.reload()
2 years ago
},
})
}
}