作者:万梅同芳正当时 | 来源:互联网 | 2023-09-18 11:48
如何在g网格中删除重复的assetCode或如何mocker.GetMock()
.Setup(x => x.CreateExportJob(It.IsAny()))
.ReturnsAsync(true);
不再重复。
而是PRN和PRN1不断重复...
代码如下:
list.component.ts
assetCode
这是输出:
在输出上添加新数据时,它添加了ngOnInit() {
this.rowData.push(
{
'code': 'Machine 1','assetCode': 'PRN','assetCount': 1,'date': '2019-01-18 00:00:00'
},{
'code': 'Machine 1','date': '2019-01-19 00:00:00'
},{
'code': 'Machine 2','assetCode': 'PRN 1','assetCount': 3,'date': '2019-01-20 00:00:00'
},{
'code': 'Machine 3','date': '2019-01-21 00:00:00'
},{
'code': 'Machine 4','date': '2019-01-22 00:00:00'
},{
'code': 'Machine 5','date': '2019-01-23 00:00:00'
},);
this.rowData = this.rowData.filter((item: any) => {
return format(item.date,'YYYY') === param;
});
const newData: any = [];
this.rowData.forEach((x: any) => {
const existing = newData.find((y: any) => format(y.date,'YYYY-MM') === format(x.date,'YYYY-MM')
&& y.assetCode === x.assetCode && y.code === x.code);
if (existing) {
console.log(existing);
existing.assetCount += existing.assetCount;
} else {
newData.push(x);
this.rowData = newData;
}
});
this.columnDefs.push(
{
'headerName': 'Style/Machine','field': 'code','pinned': 'left','lockPosition': true
}
);
for (let i = 0; i <12; i++) {
const record = {
'headerName': this.monthNames[i].monthName,'children': [
{
'headerName': 'Total','columnGroupShow': 'closed','field': 'total'
}
]
};
this.rowData.forEach((key: any) => {
if (this.monthNames[i].mOnthName=== format(key.date,'MMMM')) {
record.children.push(
{
'headerName': key.assetCode,'columnGroupShow': 'open','field': 'assetCount'
}
);
}
});
this.columnDefs.push(record);
}
}
输出应仅显示assetCode
和PRN
....
预先感谢...