我想在我的lodash _.filter
if (bolMine && !bolUnassigned)
{
o => o.AssignedDriver == CurrentLoggedOnUser;
}
else if (bolMine && bolUnassigned)
{
o => (o.AssignedDriver == CurrentLoggedOnUser || o.AssignedDriver == 0);
}
else if (!bolMine && bolUnassigned)
{
o => o.AssignedDriver == CurrentLoggedOnUser;
}
if (bolExvat)
{
o => o.ExVatOrder == bolExtVat;
}
if(intCategory > 0)
{
o => o.OrderCategory == intCategory
}
如何将此转换为我的iteratee?
this.filteredOrders = _.filter(this.orders, iteratee);
答案 0 :(得分:1)
function filterOrders(o) {
if (bolMine && !bolUnassigned)
{
return o.AssignedDriver == CurrentLoggedOnUser;
}
else if (bolMine && bolUnassigned)
{
return (o.AssignedDriver == CurrentLoggedOnUser || o.AssignedDriver == 0);
}
else if (!bolMine && bolUnassigned)
{
return o.AssignedDriver == CurrentLoggedOnUser;
}
if (bolExvat)
{
return o.ExVatOrder == bolExtVat;
}
if(intCategory > 0)
{
return o.OrderCategory == intCategory
}
}
this.filteredOrders = _.filter(this.orders, filterOrders);