Browse Source

食谱天数 修改

main
kely 1 year ago
parent
commit
4cabf5ac33
  1. 13
      projects/admin/src/app/components/dish-form/dish-form.component.html
  2. 44
      projects/admin/src/app/components/dish-form/dish-form.component.ts
  3. 4
      projects/admin/src/app/components/ingredient-status-list/ingredient-status-list.component.ts
  4. 7
      projects/admin/src/app/pages/dish/dish.component.html
  5. 46
      projects/admin/src/app/pages/dish/dish.component.ts
  6. 3
      projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html
  7. 24
      projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts
  8. 4
      projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html
  9. 20
      projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts
  10. 4
      projects/admin/src/app/pages/ingredients/ingredient-release/ingredient-release.component.ts
  11. 4
      projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts
  12. 2
      projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.html
  13. 18
      projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts
  14. 19
      projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.html
  15. 80
      projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.ts
  16. 5
      projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.html
  17. 3
      projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.less
  18. 10
      projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts
  19. 67
      projects/cdk/src/services/api.service.ts
  20. 2
      projects/cdk/src/shared/components/month-select/month-select.component.ts
  21. 2
      projects/cdk/src/shared/components/org-select/org-select.component.ts
  22. 4
      projects/client/src/app/components/dish-form/dish-form.component.html
  23. 6
      projects/client/src/app/components/dish-form/dish-form.component.ts
  24. 18
      projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts
  25. 4
      projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html
  26. 14
      projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

13
projects/admin/src/app/components/dish-form/dish-form.component.html

@ -11,15 +11,14 @@
nzPlaceHolder="请选择单位,多选时在多个单位均添加此菜品">
</nz-select> -->
<nz-select
[nzMode]="'multiple'"
nzShowSearch
nzServerSearch
nzPlaceHolder="请选择单位,多选时在多个单位均添加此菜品"
[nzShowArrow]="false"
[nzFilterOption]="nzFilterOption"
formControlName="vendors"
(nzOnSearch)="searchOrg($event)">
formControlName="vendors">
<nz-option *ngFor="let o of orgListOfOption" [nzLabel]="o.text" [nzValue]="o.value"></nz-option>
</nz-select>
</nz-form-control>
@ -72,7 +71,7 @@
<nz-form-label>
菜品图片
</nz-form-label>
<nz-form-control [nzErrorTip]="formControlErrorTpl">
<nz-form-control [nzErrorTip]="formControlErrorTpl" nzExtra="支持.jpg .jpeg .png 格式,小于2M">
<input type="hidden" formControlName="icon" />
<div class="mb-2" *ngIf="iconPreview">
<img [src]="iconPreview" class="h-20 w-20" />
@ -80,7 +79,7 @@
<button class="upload-btn " nz-button [nzLoading]="uploadLoading">
<i nz-icon nzType="upload"></i>
上传图片
<input type="file" (change)="onFileChange($event)" />
<input type="file" (change)="onFileChange($event)" accept=".jpg,.jpeg,.png" />
</button>
</nz-form-control>
</nz-form-item>

44
projects/admin/src/app/components/dish-form/dish-form.component.ts

@ -67,22 +67,26 @@ export class DishFormComponent {
month: this.fb.control([], []),
});
this.orgSearch$
.pipe(
debounceTime(500),
distinctUntilChanged(),
switchMap((q) => this.api.getOrgList(q))
)
.subscribe((data) => {
const listOfOption: Array<{ value: string; text: string }> = [];
data.body.forEach((item) => {
listOfOption.push({
value: item.id.toString(),
text: item.name,
});
});
this.orgListOfOption = listOfOption;
});
this.api.getOrgList().subscribe((res) => {
this.orgListOfOption = res;
});
// this.orgSearch$
// .pipe(
// debounceTime(500),
// distinctUntilChanged(),
// switchMap((q) => this.api.getOrgList(q))
// )
// .subscribe((data) => {
// const listOfOption: Array<{ value: string; text: string }> = [];
// data.forEach((item) => {
// listOfOption.push({
// value: item.id.toString(),
// text: item.name,
// });
// });
// this.orgListOfOption = listOfOption;
// });
this.foodSearch$
.pipe(
filter((f) => !!f),
@ -121,7 +125,9 @@ export class DishFormComponent {
this.foodSelected.push(f.key);
}
});
this.iconPreview = "/icon/" + this.data["icon"];
if (this.data["icon"]) {
this.iconPreview = "/icon/" + this.data["icon"];
}
this.formGroup.patchValue({
...this.data,
vendors: [this.data.vender],
@ -222,8 +228,8 @@ export class DishFormComponent {
const target = e.target as HTMLInputElement;
const file = target.files![0];
target.value = "";
if (file.size / 1024 / 1024 >= 5) {
this.msg.error("图片大小不能超过5M");
if (file.size / 1024 / 1024 >= 2) {
this.msg.error("图片大小不能超过2M");
return;
}
const fileReader = new FileReader();

4
projects/admin/src/app/components/ingredient-status-list/ingredient-status-list.component.ts

@ -128,8 +128,8 @@ export class IngredientStatusListComponent {
if (vendors.length > 0) {
this.api.getOrgList({ vendors }).subscribe((org) => {
if (Array.isArray(org.body)) {
this.tableOrg = org.body.reduce((a, c) => {
if (Array.isArray(org)) {
this.tableOrg = org.reduce((a, c) => {
return {
...a,
[c.id]: c,

7
projects/admin/src/app/pages/dish/dish.component.html

@ -21,13 +21,8 @@
<nz-form-item class="w-60">
<nz-form-control>
<nz-select
nzShowSearch
nzServerSearch
nzPlaceHolder="请选择单位"
[nzShowArrow]="false"
formControlName="vendors"
[nzFilterOption]="nzFilterOption"
(nzOnSearch)="searchOrg($event)">
formControlName="vendors">
<nz-option *ngFor="let o of listOfOption" [nzLabel]="o.text"
[nzValue]="o.value"></nz-option>
</nz-select>

46
projects/admin/src/app/pages/dish/dish.component.ts

@ -64,7 +64,7 @@ export class DishComponent {
tableFoods: { [k: string]: any } = {};
listOfOption: Array<{ value: number; text: string }> = [];
listOfOption: Array<{ value: number | string; text: string }> = [];
nzFilterOption = (): boolean => true;
@ -72,24 +72,28 @@ export class DishComponent {
ngOnInit(): void {
this.initTableList();
this.orgSearch$
.pipe(
filter((f) => !!f),
debounceTime(500),
distinctUntilChanged(),
takeUntil(this.destroy$),
switchMap((term: string) => this.api.getOrgList({ keyword: term }))
)
.subscribe((data) => {
const listOfOption: Array<{ value: number; text: string }> = [];
data.body.forEach((item) => {
listOfOption.push({
value: item.id,
text: item.name,
});
});
this.listOfOption = listOfOption;
});
this.api.getOrgList().subscribe((res) => {
this.listOfOption = res;
});
// this.orgSearch$
// .pipe(
// filter((f) => !!f),
// debounceTime(500),
// distinctUntilChanged(),
// takeUntil(this.destroy$),
// switchMap((term: string) => this.api.getOrgList({ keyword: term }))
// )
// .subscribe((data) => {
// const listOfOption: Array<{ value: number; text: string }> = [];
// data.forEach((item) => {
// listOfOption.push({
// value: item.id,
// text: item.name,
// });
// });
// this.listOfOption = listOfOption;
// });
this.tableList.getState$.pipe(takeUntil(this.destroy$)).subscribe((res) => {
this.selectedIds = res.selectedKeys as Array<string>;
@ -174,8 +178,8 @@ export class DishComponent {
if (vendors.length > 0) {
this.api.getOrgList({ vendors }).subscribe((org) => {
if (Array.isArray(org.body)) {
this.tableOrg = org.body.reduce((a, c) => {
if (Array.isArray(org)) {
this.tableOrg = org.reduce((a, c) => {
return {
...a,
[c.id]: c,

3
projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html

@ -40,7 +40,8 @@
</nz-card>
<div class="p-4">
<app-ingredient-dish #menuDish [menuBaisc]="menuItem"
<app-ingredient-dish #menuDish
[menuBaisc]="menuItem"
[menuDishFormServer]="menuDishFormServer">
</app-ingredient-dish>
</div>

24
projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts

@ -45,12 +45,13 @@ export class IngredientFormComponent implements OnInit {
getDetail() {
if (this.id && this.id !== "create") {
this.api.getMenuItem(this.id).subscribe((res) => {
const id = this.id.split(",")[0];
this.api.getMenuItem(id).subscribe((res) => {
if (res.body) {
this.menuItem = res.body;
}
});
this.api.getMenuDist(this.id).subscribe((res) => {
this.api.getMenuDist(id).subscribe((res) => {
if (Array.isArray(res.body)) {
res.body.forEach((d) => {
d.ingredient.forEach((f: any) => {
@ -91,20 +92,10 @@ export class IngredientFormComponent implements OnInit {
});
}
onStepChange(basicInfo: any) {
onStepChange(idStr: string) {
this.step = 1;
this.menuItem = {
...basicInfo,
menuIds: basicInfo.menuId,
meals: basicInfo.meals.reduce(
(a: string[], c: OptionItemInterface) => (c["checked"] ? a.concat(c.value) : a),
[] as string[]
),
crows: basicInfo.peoples.reduce(
(a: string[], c: OptionItemInterface) => (c["checked"] ? a.concat(c.value) : a),
[] as string[]
),
};
this.id = idStr;
this.getDetail();
}
createNewMenu() {
@ -153,10 +144,9 @@ export class IngredientFormComponent implements OnInit {
nzWidth: 650,
nzOnOk: () => {
const { mealDishList } = this.menuDish;
this.api
.saveMenuDist({
menuIds: this.menuItem.menuIds ?? [this.menuItem.id],
menuIds: this.id?.split(","),
dishes: this.formatData(mealDishList),
})
.subscribe((res) => {

4
projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html

@ -55,7 +55,7 @@
<nz-tag *ngFor="let item of data">{{item}}</nz-tag>
</ng-container>
<ng-container *ngSwitchCase="'day'">
{{data}}
{{data}}
</ng-container>
<ng-container *ngSwitchCase="'status'">
{{statusTextMap[data]}}
@ -69,7 +69,7 @@
</ng-container>
<ng-container *ngIf="data.length !== 12">
<nz-tag *ngFor="let item of data" class="mb-1">
{{monthText[item]}}
{{item}}
</nz-tag>
</ng-container>
</div>

20
projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

@ -71,16 +71,16 @@ export class IngredientListComponent {
}
initTableList() {
this.tableList.scroll = { x: null };
this.tableList.scroll = { x: "900px" };
this.tableList = this.tableList.setColumns([
{ key: "name", title: "食谱名称" },
{ key: "vender", title: "单位" },
{ key: "meals", title: "包含餐次" },
{ key: "month", title: "适用月份", width: "300px" },
{ key: "name", title: "食谱名称", width: "200px" },
{ key: "vender", title: "单位", width: "200px" },
{ key: "meals", title: "包含餐次", width: "180px" },
{ key: "month", title: "适用月份" },
{ key: "day", title: "周期" },
{ key: "status", title: "状态" },
{ key: "modify", title: "更新时间" },
{ key: "operate", title: "创建人" },
{ key: "status", title: "状态", width: "120px" },
{ key: "modify", title: "更新时间", width: "170px" },
{ key: "operate", title: "创建人", width: "160px" },
]);
this.tableList = this.tableList.setOptions([
@ -156,8 +156,8 @@ export class IngredientListComponent {
if (vendors.length > 0) {
this.api.getOrgList({ vendors }).subscribe((org) => {
if (Array.isArray(org.body)) {
this.tableOrg = org.body.reduce((a, c) => {
if (Array.isArray(org)) {
this.tableOrg = org.reduce((a, c) => {
return {
...a,
[c.id]: c,

4
projects/admin/src/app/pages/ingredients/ingredient-release/ingredient-release.component.ts

@ -97,8 +97,8 @@ export class IngredientReleaseComponent {
if (vendors.length > 0) {
this.api.getOrgList({ vendors }).subscribe((org) => {
if (Array.isArray(org.body)) {
this.tableOrg = org.body.reduce((a, c) => {
if (Array.isArray(org)) {
this.tableOrg = org.reduce((a, c) => {
return {
...a,
[c.id]: c,

4
projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts

@ -63,7 +63,7 @@ export class StandardFormComponent {
if (Array.isArray(this.state.vendors)) {
this.api.getOrgList({ vendors: this.state.vendors }).subscribe((data) => {
const listOfOption: Array<{ value: number; text: string }> = [];
data.body.forEach((item) => {
data.forEach((item) => {
listOfOption.push({
value: item.id,
text: item.name,
@ -83,7 +83,7 @@ export class StandardFormComponent {
)
.subscribe((data) => {
const listOfOption: Array<{ value: number; text: string }> = [];
data.body.forEach((item) => {
data.forEach((item) => {
listOfOption.push({
value: item.id,
text: item.name,

2
projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.html

@ -15,7 +15,7 @@
<span class="expanded-icon" nz-icon nzType="caret-right" nzTheme="outline"></span>
</button>
<span>
{{day}}
{{weekdayMap[day]}}
</span>
</div>
</ng-template>

18
projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts

@ -7,6 +7,7 @@ import { forkJoin } from "rxjs";
import { ApiService } from "@cdk/services";
import { NzDrawerService } from "ng-zorro-antd/drawer";
import { IngredientAnalysisComponent } from "../ingredient-analysis/ingredient-analysis.component";
import { weekdayMap } from "../ingredient-form-basic/ingredient-form-basic.component";
// export interface MenuObjectInterface {
// [Day: number]: {
@ -53,6 +54,8 @@ export class IngredientDishComponent implements OnChanges {
selectDay: OptionItemInterface[] = [];
weekdayMap = weekdayMap;
mealCurrentIndex: Record<number, number> = {};
// d = {
@ -102,15 +105,16 @@ export class IngredientDishComponent implements OnChanges {
initMenuBasic() {
if (this.menuBaisc) {
const meals = this.menuBaisc.meals as string[];
const day = this.menuBaisc.day as number;
this.days = Array.from({ length: day }, (_, i) => {
const d = i + 1;
console.log("this.menuBaisc", this.menuBaisc);
const day = this.menuBaisc.day as number[];
this.days = day.map((i) => {
const d = weekdayMap[i];
this.selectDay.push({
label: `${d}`,
label: d,
value: String(d),
});
this.mealCurrentIndex[d] = 0;
this.expanded.add(d);
this.mealCurrentIndex[i] = 0;
this.expanded.add(i);
// if (!this.menuObject) {
// this.menuObject = {};
// }
@ -120,7 +124,7 @@ export class IngredientDishComponent implements OnChanges {
// [idx]: [],
// };
// }, {} as Record<number, MealDishInterface[]>);
return i + 1;
return i;
});
}
}

19
projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.html

@ -51,16 +51,14 @@
<nz-form-label nzRequired nzSpan="6">
天数
</nz-form-label>
<nz-form-control [nzErrorTip]="formControlErrorTpl">
<nz-radio-group formControlName="day">
<label nz-radio [nzValue]="1">1天</label>
<label nz-radio [nzValue]="2">2天</label>
<label nz-radio [nzValue]="3">3天</label>
<label nz-radio [nzValue]="4">4天</label>
<label nz-radio [nzValue]="5">5天</label>
<label nz-radio [nzValue]="6">6天</label>
<label nz-radio [nzValue]="7">7天</label>
</nz-radio-group>
<nz-form-control [nzErrorTip]="formControlErrorTpl" nzSpan="12">
<nz-checkbox-group
[(ngModel)]="weekday"
[ngModelOptions]="{standalone: true}">
</nz-checkbox-group>
</nz-form-control>
</nz-form-item>
<nz-form-item class="block">
@ -68,6 +66,7 @@
餐次
</nz-form-label>
<nz-form-control [nzErrorTip]="formControlErrorTpl" nzSpan="12">
<nz-checkbox-group
class="flex flex-wrap checkbox-wrap"
[(ngModel)]="meals"

80
projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.ts

@ -3,12 +3,31 @@ import { FormArray, FormBuilder, FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { OrgDTO } from "@cdk/dtos";
import { ApiService } from "@cdk/services";
import { OptionItemInterface } from "@cdk/types";
import { AnyObject, OptionItemInterface } from "@cdk/types";
import { Utils } from "@cdk/utils";
import { FormValidators } from "@cdk/validators";
import { NzMessageService } from "ng-zorro-antd/message";
import { Subject, debounceTime, distinctUntilChanged, filter, finalize, switchMap, takeUntil } from "rxjs";
export const weekday = [
{ label: "周一", value: 1, checked: false },
{ label: "周二", value: 2, checked: false },
{ label: "周三", value: 3, checked: false },
{ label: "周四", value: 4, checked: false },
{ label: "周五", value: 5, checked: false },
{ label: "周六", value: 6 },
{ label: "周日", value: 7 },
];
export const weekdayMap: Record<number, string> = {
1: "周一",
2: "周二",
3: "周三",
4: "周四",
5: "周五",
6: "周六",
7: "周日",
};
@Component({
selector: "app-ingredient-form-basic",
templateUrl: "./ingredient-form-basic.component.html",
@ -35,6 +54,8 @@ export class IngredientFormBasicComponent implements OnChanges {
formGroup!: FormGroup;
weekday = weekday;
meals = this.api.globalEnum.mealType;
standardOfOption: Array<OptionItemInterface> = [];
@ -54,7 +75,7 @@ export class IngredientFormBasicComponent implements OnChanges {
id: this.fb.control("", []),
name: this.fb.control("", [FormValidators.required()]),
nutrient: this.fb.control("", [FormValidators.required()]),
day: this.fb.control(1, [FormValidators.required()]),
// day: this.fb.control([], [FormValidators.required()]),
vendors: this.fb.control([], this.client ? [] : [FormValidators.required()]),
month: this.fb.control([], [FormValidators.required()]),
});
@ -85,7 +106,6 @@ export class IngredientFormBasicComponent implements OnChanges {
this.onStandardChange(this.menu.nutrient);
}
}
this.standardOfOption = listOfOption;
});
@ -95,15 +115,19 @@ export class IngredientFormBasicComponent implements OnChanges {
ngOnChanges(changes: SimpleChanges): void {}
setValues() {
let weekday = [];
if (this.menu) {
console.log("this.formGroup", this.formGroup, this.menu);
this.standardSearch$.next({ id: this.menu.nutrient });
this.meals = this.meals.map((i) => (this.menu.meals.includes(i.value) ? { ...i, checked: true } : i));
weekday = this.weekday.map((i) => (this.menu.day.includes(i.value) ? { ...i, checked: true } : i));
this.formGroup.patchValue({
...this.menu,
vendors: [String(this.menu.vender)],
});
} else {
weekday = this.weekday.map((i) => ({ ...i, checked: i.value <= 5 }));
}
this.weekday = weekday;
}
ngOnDestroy(): void {
@ -134,7 +158,7 @@ export class IngredientFormBasicComponent implements OnChanges {
return;
}
this.api.getOrgList({ vendors: currentStandard["vendors"] }).subscribe((res) => {
this.currentOrgs = res.body.map((i) => ({
this.currentOrgs = res.map((i) => ({
...i,
value: String(i.id),
label: i.name,
@ -143,32 +167,38 @@ export class IngredientFormBasicComponent implements OnChanges {
}
}
checkboxToValue(data: any[]) {
return data
.reduce((a, c) => {
return c["checked"] ? a.concat(c.value) : a;
}, [] as string[])
.join(",");
}
onSubmit() {
if (Utils.validateFormGroup(this.formGroup)) {
if (!this.meals.some((s) => s["checked"])) {
this.msg.error("请选择餐次");
return;
}
if (!this.weekday.some((s) => s["checked"])) {
this.msg.error("请选择天数");
return;
}
if (!this.currentPeoples.some((s) => s["checked"])) {
this.msg.error("请选择人群显示");
return;
}
this.submitLoading = true;
this.api
.saveMenu({
...this.formGroup.value,
crows: this.currentPeoples
.reduce((a, c) => {
return c["checked"] ? a.concat(c.value) : a;
}, [] as string[])
.join(","),
crows: this.checkboxToValue(this.currentPeoples),
month: this.formGroup.value.month.join(","),
vendors: this.formGroup.value.vendors.join(","),
meals: this.meals
.reduce((a, c) => {
return c["checked"] ? a.concat(c.value) : a;
}, [] as string[])
.join(","),
meals: this.checkboxToValue(this.meals),
day: this.checkboxToValue(this.weekday),
})
.pipe(
finalize(() => {
@ -177,17 +207,15 @@ export class IngredientFormBasicComponent implements OnChanges {
)
.subscribe((res) => {
this.msg.success(res.desc);
this.router.navigate([], {
relativeTo: this.route,
queryParams: { newId: res.body },
queryParamsHandling: "merge",
});
this.onSave.emit({
...this.formGroup.value,
meals: this.meals,
menuId: res.body,
peoples: this.currentPeoples,
});
let id = this.menu?.id;
if (Array.isArray(res.body)) {
id = res.body.join(",");
this.router.navigate(["/ingredient/item/form/", id]);
}
this.onSave.emit(id);
});
}
}

5
projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.html

@ -59,7 +59,7 @@
<th *ngFor="let day of days">
<div>
<div class="table-day-row">
<div class="td"> {{day}} </div>
<div class="td"> {{weekdayMap[day]}} </div>
<div class="td"> 重量/克 </div>
</div>
<div class="table-menu-row flex ">
@ -102,7 +102,8 @@
<ul>
<ng-container *ngFor="let f of d.items;let last = last">
<li class="flex food-item">
<div class="td food-name text-left">
<div class="td food-name text-left"
[attr.title]="f['foodName']">
{{f['foodName']}}
</div>
<div

3
projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.less

@ -105,6 +105,9 @@
.food-name {
width: 180px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.td {

10
projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts

@ -6,6 +6,7 @@ import { DishInterface } from "../ingredient-dish/ingredient-dish.component";
import { forkJoin, map } from "rxjs";
import { IngredientAnalysisComponent } from "../ingredient-analysis/ingredient-analysis.component";
import { NzDrawerService } from "ng-zorro-antd/drawer";
import { weekdayMap } from "../ingredient-form-basic/ingredient-form-basic.component";
@Component({
selector: "app-ingredient-preview",
@ -42,6 +43,8 @@ export class IngredientPreviewComponent {
12: "十二月",
} as any;
weekdayMap = weekdayMap;
days: number[] = [];
ngOnInit(): void {
@ -57,7 +60,9 @@ export class IngredientPreviewComponent {
})
)
.subscribe(([dishs, basic]) => {
this.days = Array.from({ length: basic.day }, (_, i) => i + 1);
// this.days = Array.from({ length: basic.day }, (_, i) => i + 1);
this.days = basic.day;
this.getStandardName(basic.nutrient);
this.basic = basic;
@ -69,7 +74,8 @@ export class IngredientPreviewComponent {
if (storage) {
try {
const { basic, dishs } = JSON.parse(storage);
this.days = Array.from({ length: basic.day }, (_, i) => i + 1);
// this.days = Array.from({ length: basic.day }, (_, i) => i + 1);
this.days = basic.day;
this.getStandardName(basic.nutrient);
this.basic = basic;
this.dishs = dishs;

67
projects/cdk/src/services/api.service.ts

@ -1,6 +1,6 @@
import { HttpClient, HttpParams, HttpResponse } from "@angular/common/http";
import { Inject, Injectable, InjectionToken } from "@angular/core";
import { AnyObject, OptionItemInterface, PageResult, ResponseType } from "@cdk/types";
import { AnyObject, Augmented, OptionItemInterface, PageResult, ResponseType } from "@cdk/types";
import { format, addDays } from "date-fns";
import { Utils } from "@cdk/utils";
import { Observable, map, of, tap } from "rxjs";
@ -189,9 +189,25 @@ export class ApiService {
});
}
getOrgList(query: { vendors?: number[]; keyword?: string }) {
const q = Utils.objectStringify(query);
return this.http.get<ResponseType<OrgDTO[]>>(`/api/vender/select?${q}`);
orgList: (OrgDTO & { value: string; text: string })[] = [];
getOrgList(query?: { vendors?: number[]; keyword?: string }, force?: boolean) {
if (this.orgList.length && !force) {
return of(this.orgList);
}
// const q = Utils.objectStringify(query);
return this.http.get<ResponseType<OrgDTO[]>>(`/api/vender/select?keyword= `).pipe(
map((r) => {
return r.body.map((i) => ({
...i,
value: i.id.toString(),
text: i.name,
}));
}),
tap((r) => {
this.orgList = r;
})
);
}
getOrgPage(p: {}, q: {}) {
@ -340,9 +356,46 @@ export class ApiService {
);
}
getStandard(q: { id?: string; name?: string }) {
const query = Utils.objectStringify(q);
return this.http.get<ResponseType<any>>(`/api/nutrition/select?${query}`);
getO1rgList(query?: { vendors?: number[]; keyword?: string }, force?: boolean) {
if (this.orgList.length && !force) {
return of(this.orgList);
}
// const q = Utils.objectStringify(query);
return this.http.get<ResponseType<OrgDTO[]>>(`/api/vender/select?keyword= `).pipe(
map((r) => {
return r.body.map((i) => ({
...i,
value: i.id.toString(),
text: i.name,
}));
}),
tap((r) => {
this.orgList = r;
})
);
}
standardList: (AnyObject & { value: string; text: string })[] = [];
getStandard(q: { id?: string; name?: string }, force?: boolean) {
// if (this.standardList.length && !force) {
// return of(this.standardList);
// }
const query = q ? Utils.objectStringify(q) : { name: "" };
return this.http
.get<ResponseType<any>>(`/api/nutrition/select?${query}`)
.pipe
// map((r) => {
// return r.body.map((i: any) => ({
// ...i,
// value: i.id.toString(),
// text: i.name,
// }));
// }),
// tap((r) => {
// this.orgList = r;
// })
();
}
saveStandard(v: AnyObject, isEdit?: boolean) {

2
projects/cdk/src/shared/components/month-select/month-select.component.ts

@ -79,7 +79,7 @@ export class MonthSelectComponent implements ControlValueAccessor {
ontouch(v: any) {}
writeValue(v: number[]): void {
console.log("v", v);
// console.log("v", v);
this.allMonth = this.allMonth.map((i) => (v.includes(i.value) ? { ...i, checked: true } : i));
this.monthCheckEffect();
}

2
projects/cdk/src/shared/components/org-select/org-select.component.ts

@ -40,7 +40,7 @@ export class OrgSelectComponent implements OnInit, ControlValueAccessor {
)
.subscribe((data) => {
const listOfOption: Array<OptionItemInterface> = [];
data.body.forEach((item) => {
data.forEach((item) => {
listOfOption.push({
value: String(item.id),
label: item.name,

4
projects/client/src/app/components/dish-form/dish-form.component.html

@ -45,7 +45,7 @@
<nz-form-label>
菜品图片
</nz-form-label>
<nz-form-control [nzErrorTip]="formControlErrorTpl">
<nz-form-control [nzErrorTip]="formControlErrorTpl" nzExtra="支持.jpg .jpeg .png 格式,小于2M">
<input type="hidden" formControlName="icon" />
<div class="mb-2" *ngIf="iconPreview">
<img [src]="iconPreview" class="h-20 w-20" />
@ -53,7 +53,7 @@
<button class="upload-btn " nz-button [nzLoading]="uploadLoading">
<i nz-icon nzType="upload"></i>
上传图片
<input type="file" (change)="onFileChange($event)" />
<input type="file" (change)="onFileChange($event)" accept=".jpg,.jpeg,.png" />
</button>
</nz-form-control>
</nz-form-item>

6
projects/client/src/app/components/dish-form/dish-form.component.ts

@ -74,7 +74,7 @@ export class DishFormComponent {
)
.subscribe((data) => {
const listOfOption: Array<{ value: string; text: string }> = [];
data.body.forEach((item) => {
data.forEach((item) => {
listOfOption.push({
value: item.id.toString(),
text: item.name,
@ -222,8 +222,8 @@ export class DishFormComponent {
const target = e.target as HTMLInputElement;
const file = target.files![0];
target.value = "";
if (file.size / 1024 / 1024 >= 5) {
this.msg.error("图片大小不能超过5M");
if (file.size / 1024 / 1024 >= 2) {
this.msg.error("图片大小不能超过2M");
return;
}
const fileReader = new FileReader();

18
projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts

@ -90,20 +90,10 @@ export class IngredientFormComponent implements OnInit {
});
}
onStepChange(basicInfo: any) {
onStepChange(idStr: string) {
this.step = 1;
this.menuItem = {
...basicInfo,
menuIds: basicInfo.menuId,
meals: basicInfo.meals.reduce(
(a: string[], c: OptionItemInterface) => (c["checked"] ? a.concat(c.value) : a),
[] as string[]
),
crows: basicInfo.peoples.reduce(
(a: string[], c: OptionItemInterface) => (c["checked"] ? a.concat(c.value) : a),
[] as string[]
),
};
this.id = idStr;
this.getDetail();
}
createNewMenu() {
@ -155,7 +145,7 @@ export class IngredientFormComponent implements OnInit {
this.api
.saveMenuDist({
menuIds: this.menuItem.menuIds ?? [this.menuItem.id],
menuIds: this.id?.split(","),
dishes: this.formatData(mealDishList),
})
.subscribe((res) => {

4
projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html

@ -51,7 +51,7 @@
<nz-tag *ngFor="let item of data">{{item}}</nz-tag>
</ng-container>
<ng-container *ngSwitchCase="'day'">
{{data}}
{{data}}
</ng-container>
<ng-container *ngSwitchCase="'status'">
{{statusTextMap[data]}}
@ -65,7 +65,7 @@
</ng-container>
<ng-container *ngIf="data.length !== 12">
<nz-tag *ngFor="let item of data" class="mb-1">
{{monthText[item]}}
{{item}}
</nz-tag>
</ng-container>
</div>

14
projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

@ -71,16 +71,16 @@ export class IngredientListComponent {
}
initTableList() {
this.tableList.scroll = { x: null };
this.tableList.scroll = { x: "900px" };
this.tableList = this.tableList.setColumns([
{ key: "name", title: "食谱名称" },
{ key: "name", title: "食谱名称", width: "200px" },
{ key: "meals", title: "包含餐次" },
{ key: "month", title: "适用月份", width: "300px" },
{ key: "meals", title: "包含餐次", width: "180px" },
{ key: "month", title: "适用月份" },
{ key: "day", title: "周期" },
{ key: "status", title: "状态" },
{ key: "modify", title: "更新时间" },
{ key: "operate", title: "创建人" },
{ key: "status", title: "状态", width: "120px" },
{ key: "modify", title: "更新时间", width: "170px" },
{ key: "operate", title: "创建人", width: "160px" },
]);
this.tableList = this.tableList.setOptions([

Loading…
Cancel
Save