|
|
@ -26,7 +26,7 @@ import { ASSET_SOURCE_MAP, ASSET_STATUS_MAP, MAX_PAGE_SIZE } from 'app/constants |
|
|
|
import { AnyObject, TableOption } from 'app/shared/components/server-paginated-table' |
|
|
|
import { PositionSelectComponent } from '../position-select/position-select.component' |
|
|
|
import { ManufacturerSelectComponent } from '../manufacturer-select/manufacturer-select.component' |
|
|
|
import { tap } from 'rxjs' |
|
|
|
import { map, tap } from 'rxjs' |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-asset-select', |
|
|
@ -99,7 +99,7 @@ export class AssetSelectComponent { |
|
|
|
this.table |
|
|
|
.setConfig({ |
|
|
|
selectable: true, |
|
|
|
rowKey: 'assetId', |
|
|
|
rowKey: 'key', |
|
|
|
radio: this.radio, |
|
|
|
noneCache: true, |
|
|
|
}) |
|
|
@ -115,10 +115,12 @@ export class AssetSelectComponent { |
|
|
|
fetchData(p: {}, q: AnyObject) { |
|
|
|
const fn = this.storage ? 'getAeamBusinessStorageList' : 'getAssetStroagePage' |
|
|
|
return this.api[fn]({ ...p, ...q }).pipe( |
|
|
|
tap((res) => { |
|
|
|
map((res) => { |
|
|
|
res.body.rows.forEach((item: NzSafeAny) => { |
|
|
|
this.allGetedDataMap.set(item.assetId, item) |
|
|
|
item['key'] = item.assetId + '_' + item.warehouseId |
|
|
|
this.allGetedDataMap.set(item.key, item) |
|
|
|
}) |
|
|
|
return res |
|
|
|
}), |
|
|
|
) |
|
|
|
} |
|
|
@ -134,8 +136,8 @@ export class AssetSelectComponent { |
|
|
|
this.selectedDataList = [] |
|
|
|
} |
|
|
|
this.allGetedDataMap.forEach((i: NzSafeAny) => { |
|
|
|
if (this.table.ref.selected.has(String(i.assetId))) { |
|
|
|
if (!this.selectedDataList.some((s) => s.assetId === i.assetId)) { |
|
|
|
if (this.table.ref.selected.has(String(i.key))) { |
|
|
|
if (!this.selectedDataList.some((s) => s.key === i.key)) { |
|
|
|
this.selectedDataList.push({ ...i, count: i.count === 0 ? 0 : 1, max: i.count }) |
|
|
|
} |
|
|
|
} |
|
|
@ -148,11 +150,15 @@ export class AssetSelectComponent { |
|
|
|
} |
|
|
|
|
|
|
|
onRemove() { |
|
|
|
this.selectedDataList = this.selectedDataList.filter((i) => !this.setOfCheckedId.has(i.assetId)) |
|
|
|
this.selectedDataList = this.selectedDataList.filter((i) => !this.setOfCheckedId.has(i.key)) |
|
|
|
this.refreshCheckedStatus() |
|
|
|
this.onChange(this.selectedDataList) |
|
|
|
} |
|
|
|
|
|
|
|
onCountChange() { |
|
|
|
this.onChange(this.selectedDataList) |
|
|
|
} |
|
|
|
|
|
|
|
updateCheckedSet(id: number, checked: boolean): void { |
|
|
|
if (checked) { |
|
|
|
this.setOfCheckedId.add(id) |
|
|
@ -163,9 +169,8 @@ export class AssetSelectComponent { |
|
|
|
|
|
|
|
refreshCheckedStatus(): void { |
|
|
|
const listOfEnabledData = this.selectedDataList.filter(({ disabled }) => !disabled) |
|
|
|
this.checkedAll = listOfEnabledData.every(({ assetId }) => this.setOfCheckedId.has(assetId)) |
|
|
|
this.indeterminate = |
|
|
|
listOfEnabledData.some(({ assetId }) => this.setOfCheckedId.has(assetId)) && !this.checkedAll |
|
|
|
this.checkedAll = listOfEnabledData.every(({ key }) => this.setOfCheckedId.has(key)) |
|
|
|
this.indeterminate = listOfEnabledData.some(({ key }) => this.setOfCheckedId.has(key)) && !this.checkedAll |
|
|
|
} |
|
|
|
|
|
|
|
onItemChecked(id: number, checked: boolean): void { |
|
|
@ -176,7 +181,7 @@ export class AssetSelectComponent { |
|
|
|
onAllChecked(checked: boolean): void { |
|
|
|
this.selectedDataList |
|
|
|
.filter(({ disabled }) => !disabled) |
|
|
|
.forEach(({ assetId }) => this.updateCheckedSet(assetId, checked)) |
|
|
|
.forEach(({ key }) => this.updateCheckedSet(key, checked)) |
|
|
|
this.refreshCheckedStatus() |
|
|
|
} |
|
|
|
|
|
|
@ -195,6 +200,7 @@ export class AssetSelectComponent { |
|
|
|
// const ids = vals.map((i: NzSafeAny) => i.assetId)
|
|
|
|
this.api.getAssetStorageListByIds(vals).subscribe((res) => { |
|
|
|
this.selectedDataList = res.body.rows.map((item: NzSafeAny) => { |
|
|
|
item['key'] = item.assetId + '_' + item.warehouseId |
|
|
|
this.allGetedDataMap.set(item.assetId, item) |
|
|
|
return item |
|
|
|
}) |
|
|
|