Browse Source

修复 人群 与 食品数量 对应不上的问题

main
kely 5 hours ago
parent
commit
812222d541
  1. 24
      projects/cdk/src/ingredient/ingredient-meals/ingredient-meals.component.html
  2. 10
      projects/cdk/src/ingredient/ingredient.module.ts

24
projects/cdk/src/ingredient/ingredient-meals/ingredient-meals.component.html

@ -27,9 +27,7 @@
<tr>
<th nzWidth="200px" nzLeft>菜品</th>
<th nzWidth="200px" nzLeft>食材</th>
<th *ngFor="let p of peopleGroups">
{{ p }}
</th>
<th *ngFor="let p of peopleGroups">{{ p }}</th>
</tr>
</thead>
<tbody>
@ -81,15 +79,17 @@
</nz-dropdown-menu>
</div>
</td>
<td *ngFor="let g of food['groupValues']">
<nz-input-group nzAddOnAfter="g" class="w-28">
<input
nz-input
type="number"
[(ngModel)]="g.value"
(ngModelChange)="onValueChange()"
/>
</nz-input-group>
<td *ngFor="let people of peopleGroups">
<ng-container *ngIf="food['groupValues'] | findByPeople: people as g">
<nz-input-group nzAddOnAfter="g" class="w-28">
<input
nz-input
type="number"
[(ngModel)]="g.value"
(ngModelChange)="onValueChange()"
/>
</nz-input-group>
</ng-container>
</td>
</tr>
</ng-container>

10
projects/cdk/src/ingredient/ingredient.module.ts

@ -1,4 +1,4 @@
import { NgModule } from '@angular/core'
import { NgModule, Pipe } from '@angular/core'
import { SharedModule } from '@cdk/shared/shared.module'
import { AddDishToIngredientComponent } from './add-dish-to-ingredient/add-dish-to-ingredient.component'
import { IngredientMealsComponent } from './ingredient-meals/ingredient-meals.component'
@ -10,6 +10,13 @@ import { IngredientAnalysisComponent } from './ingredient-analysis/ingredient-an
import { NutritionTableComponent } from './nutrition-table/nutrition-table.component'
import { SelectFoodComponent } from './select-food/select-food.component'
@Pipe({ name: 'findByPeople', pure: true })
export class FindByPeoplePipe {
transform(values: any[], people: any) {
return values?.find((v) => v.peopleName === people)
}
}
@NgModule({
declarations: [
AddDishToIngredientComponent,
@ -21,6 +28,7 @@ import { SelectFoodComponent } from './select-food/select-food.component'
IngredientAnalysisComponent,
NutritionTableComponent,
SelectFoodComponent,
FindByPeoplePipe,
],
imports: [SharedModule],
exports: [

Loading…
Cancel
Save