|
|
@ -20,7 +20,7 @@ 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 { FormValidators, 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' |
|
|
@ -44,6 +44,8 @@ export class StocktakingDetailComponent { |
|
|
|
private route: ActivatedRoute, |
|
|
|
) {} |
|
|
|
|
|
|
|
@ViewChild('startTpl') startTpl!: TemplateRef<{}> |
|
|
|
|
|
|
|
originData: NzSafeAny[] = [] |
|
|
|
|
|
|
|
loading = false |
|
|
@ -56,6 +58,12 @@ export class StocktakingDetailComponent { |
|
|
|
|
|
|
|
table = new TableOption(this.fetchData.bind(this)) |
|
|
|
|
|
|
|
uploadImgLoading = false |
|
|
|
|
|
|
|
uploadLoading = false |
|
|
|
|
|
|
|
iconPreview = '' |
|
|
|
|
|
|
|
queryForm = new FormGroup({ |
|
|
|
name: new FormControl(), |
|
|
|
model: new FormControl(), |
|
|
@ -67,10 +75,48 @@ export class StocktakingDetailComponent { |
|
|
|
manufacturersVendorId: new FormControl(), |
|
|
|
}) |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
this.api.getBasicSupplierVendorPage({ pageSize: MAX_PAGE_SIZE, pageNum: 1 }).subscribe((res) => { |
|
|
|
this.originData = res.body.rows |
|
|
|
onImgChange(e: Event) { |
|
|
|
const target = e.target as HTMLInputElement |
|
|
|
const file = target.files![0] |
|
|
|
target.value = '' |
|
|
|
if (file.size / 1024 / 1024 >= 2) { |
|
|
|
this.msg.error('图片大小不能超过2M') |
|
|
|
return |
|
|
|
} |
|
|
|
const fileReader = new FileReader() |
|
|
|
fileReader.onload = () => { |
|
|
|
const base64 = fileReader.result as string |
|
|
|
this.iconPreview = base64 |
|
|
|
} |
|
|
|
fileReader.readAsDataURL(file) |
|
|
|
const formdata = new FormData() |
|
|
|
formdata.append('file', file) |
|
|
|
this.api.upload(formdata).subscribe((res) => { |
|
|
|
this.startForm.get('img')?.setValue(res.body.fileName) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
onFileChange(e: Event) { |
|
|
|
const target = e.target as HTMLInputElement |
|
|
|
const file = target.files![0] |
|
|
|
target.value = '' |
|
|
|
|
|
|
|
const formdata = new FormData() |
|
|
|
formdata.append('file', file) |
|
|
|
this.api.upload(formdata).subscribe((res) => { |
|
|
|
this.startForm.get('attachment')?.setValue(res.body.fileName) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
this.api |
|
|
|
.getBasicSupplierVendorPage({ |
|
|
|
pageSize: MAX_PAGE_SIZE, |
|
|
|
pageNum: 1, |
|
|
|
}) |
|
|
|
.subscribe((res) => { |
|
|
|
this.originData = res.body.rows |
|
|
|
}) |
|
|
|
this.table |
|
|
|
.setConfig({ |
|
|
|
selectable: true, |
|
|
@ -86,10 +132,22 @@ export class StocktakingDetailComponent { |
|
|
|
// { key: '_useOrganization', title: '使用组织', visible: true },
|
|
|
|
// { key: '_position', title: '存放位置', visible: true },
|
|
|
|
]) |
|
|
|
.setRowOperate([ |
|
|
|
{ |
|
|
|
title: '开始盘点', |
|
|
|
onClick: this.onStart.bind(this), |
|
|
|
}, |
|
|
|
]) |
|
|
|
} |
|
|
|
|
|
|
|
fetchData(p: {}, q: AnyObject) { |
|
|
|
return this.api.getStocktakingJobDetailPage({ ...p, ...q }).pipe() |
|
|
|
return this.api |
|
|
|
.getStocktakingJobDetailPage({ |
|
|
|
...p, |
|
|
|
...q, |
|
|
|
stocktakingJobId: Number(this.route.snapshot.paramMap.get('id')), |
|
|
|
}) |
|
|
|
.pipe() |
|
|
|
} |
|
|
|
|
|
|
|
add(data?: NzSafeAny) { |
|
|
@ -122,6 +180,40 @@ export class StocktakingDetailComponent { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
startForm = new FormGroup({ |
|
|
|
status: new FormControl(null, [FormValidators.required('请选择盘点状态')]), |
|
|
|
img: new FormControl(null, []), |
|
|
|
attachment: new FormControl(null, []), |
|
|
|
notes: new FormControl(null, []), |
|
|
|
}) |
|
|
|
|
|
|
|
onStart(data: NzSafeAny) { |
|
|
|
this.modal.create({ |
|
|
|
nzTitle: '开始盘点', |
|
|
|
nzContent: this.startTpl, |
|
|
|
nzOnOk: async () => { |
|
|
|
if (FormValidators.validateFormGroup(this.startForm)) { |
|
|
|
const res = await lastValueFrom( |
|
|
|
this.api.startStocktakingJob({ |
|
|
|
...this.startForm.value, |
|
|
|
stocktakingJobId: Number(this.route.snapshot.paramMap.get('id')), |
|
|
|
assetId: data._asset.assetId, |
|
|
|
id: data.id, |
|
|
|
}), |
|
|
|
) |
|
|
|
this.msg.success(res.desc) |
|
|
|
this.table.ref.reload() |
|
|
|
this.startForm.reset() |
|
|
|
return true |
|
|
|
} |
|
|
|
return false |
|
|
|
}, |
|
|
|
nzOnCancel: () => { |
|
|
|
this.startForm.reset() |
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
deleteItem() { |
|
|
|
this.modal.confirm({ |
|
|
|
nzTitle: '警告', |
|
|
|