固定资产项目前端文件
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.

139 lines
3.8 KiB

12 months ago
import { STOCKTAKING_JOB_STATUS_MAP } from './../../../../constants/index'
import {
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnInit,
Output,
TemplateRef,
ViewChild,
forwardRef,
} from '@angular/core'
import { ControlValueAccessor, FormControl, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NzModalService } from 'ng-zorro-antd/modal'
import { ApiService } from 'app/services'
import { NzMessageService } from 'ng-zorro-antd/message'
import { SharedModule } from 'app/shared/shared.module'
import { Utils } from 'app/utils'
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree'
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select'
import { ASSET_SOURCE_MAP, ASSET_STATUS_MAP, MAX_PAGE_SIZE } from 'app/constants'
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table'
import { AssetSelectComponent, StocktakingDetailFormComponent } from 'app/components'
import { lastValueFrom } from 'rxjs'
import { ActivatedRoute } from '@angular/router'
@Component({
selector: 'app-stocktaking-detail',
standalone: true,
imports: [SharedModule],
templateUrl: './stocktaking-detail.component.html',
styleUrl: './stocktaking-detail.component.less',
})
export class StocktakingDetailComponent {
constructor(
private api: ApiService,
private modal: NzModalService,
private msg: NzMessageService,
private route: ActivatedRoute,
) {}
originData: NzSafeAny[] = []
loading = false
ASSET_SOURCE_MAP = ASSET_SOURCE_MAP
ASSET_STATUS_MAP = ASSET_STATUS_MAP()
STOCKTAKING_JOB_STATUS_MAP = STOCKTAKING_JOB_STATUS_MAP
table = new TableOption(this.fetchData.bind(this))
queryForm = new FormGroup({
name: new FormControl(),
model: new FormControl(),
status: new FormControl(),
assetCode: new FormControl(),
serialNumber: new FormControl(),
sourceId: new FormControl(),
positionId: new FormControl(),
manufacturersVendorId: new FormControl(),
})
ngOnInit(): void {
this.api.getBasicSupplierVendorPage({ pageSize: MAX_PAGE_SIZE, pageNum: 1 }).subscribe((res) => {
this.originData = res.body.rows
})
this.table
.setConfig({
selectable: true,
})
.setColumn([
{ key: 'id', title: '主键', visible: true },
{ key: 'code', title: '资产编号', visible: true },
{ key: 'name', title: '资产名称', visible: true },
11 months ago
// { key: 'category', title: '资产分类', visible: true },
12 months ago
{ key: 'status', title: '盘点状态', visible: true },
{ key: 'createTime', title: '操作时间', visible: true },
// { key: '_ownCompany', title: '所属公司', visible: true },
// { key: '_useOrganization', title: '使用组织', visible: true },
// { key: '_position', title: '存放位置', visible: true },
])
}
fetchData(p: {}, q: AnyObject) {
return this.api.getStocktakingJobDetailPage({ ...p, ...q }).pipe()
}
add(data?: NzSafeAny) {
let nzTitle = data ? '编辑资产盘点' : '添加资产盘点'
this.modal.create({
nzTitle,
nzContent: StocktakingDetailFormComponent,
nzWidth: '80vw',
nzWrapClassName: 'modal-lg',
nzData: {
value: data,
},
nzOnOk: async (e) => {
const vals = e.getValues()
if (vals) {
const res = await lastValueFrom(
this.api.saveStocktakingJobDetail({
...vals,
stocktakingJobId: Number(this.route.snapshot.paramMap.get('id')),
}),
)
this.msg.success(res.desc)
this.table.ref.reload()
return true
}
return false
},
})
}
deleteItem() {
this.modal.confirm({
nzTitle: '警告',
nzContent: '是否要删除该盘点?',
nzOnOk: async () => {
const res = await lastValueFrom(
this.api.deleteStocktakingDetail(Array.from(this.table.ref.selected).map((i) => Number(i))),
)
this.msg.success(res.desc)
this.table.ref.reload()
},
})
}
}