From 4cabf5ac33c773541967f2f77d69dd409e95f8db Mon Sep 17 00:00:00 2001 From: kely Date: Thu, 23 Nov 2023 17:55:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=9F=E8=B0=B1=E5=A4=A9=E6=95=B0=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dish-form/dish-form.component.html | 13 ++- .../dish-form/dish-form.component.ts | 44 +++++----- .../ingredient-status-list.component.ts | 4 +- .../src/app/pages/dish/dish.component.html | 7 +- .../src/app/pages/dish/dish.component.ts | 46 ++++++----- .../ingredient-form.component.html | 3 +- .../ingredient-form.component.ts | 24 ++---- .../ingredient-list.component.html | 4 +- .../ingredient-list.component.ts | 20 ++--- .../ingredient-release.component.ts | 4 +- .../standard-form/standard-form.component.ts | 4 +- .../ingredient-dish.component.html | 2 +- .../ingredient-dish.component.ts | 18 +++-- .../ingredient-form-basic.component.html | 19 +++-- .../ingredient-form-basic.component.ts | 80 +++++++++++++------ .../ingredient-preview.component.html | 5 +- .../ingredient-preview.component.less | 3 + .../ingredient-preview.component.ts | 10 ++- projects/cdk/src/services/api.service.ts | 67 ++++++++++++++-- .../month-select/month-select.component.ts | 2 +- .../org-select/org-select.component.ts | 2 +- .../dish-form/dish-form.component.html | 4 +- .../dish-form/dish-form.component.ts | 6 +- .../ingredient-form.component.ts | 18 +---- .../ingredient-list.component.html | 4 +- .../ingredient-list.component.ts | 14 ++-- 26 files changed, 253 insertions(+), 174 deletions(-) diff --git a/projects/admin/src/app/components/dish-form/dish-form.component.html b/projects/admin/src/app/components/dish-form/dish-form.component.html index 06cd1ac..2bf8580 100644 --- a/projects/admin/src/app/components/dish-form/dish-form.component.html +++ b/projects/admin/src/app/components/dish-form/dish-form.component.html @@ -11,15 +11,14 @@ nzPlaceHolder="请选择单位,多选时在多个单位均添加此菜品"> --> + + + formControlName="vendors"> @@ -72,7 +71,7 @@ 菜品图片 - +
@@ -80,7 +79,7 @@ diff --git a/projects/admin/src/app/components/dish-form/dish-form.component.ts b/projects/admin/src/app/components/dish-form/dish-form.component.ts index 7979f5a..1e3df70 100644 --- a/projects/admin/src/app/components/dish-form/dish-form.component.ts +++ b/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(); diff --git a/projects/admin/src/app/components/ingredient-status-list/ingredient-status-list.component.ts b/projects/admin/src/app/components/ingredient-status-list/ingredient-status-list.component.ts index 2943ca3..76fefde 100644 --- a/projects/admin/src/app/components/ingredient-status-list/ingredient-status-list.component.ts +++ b/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, diff --git a/projects/admin/src/app/pages/dish/dish.component.html b/projects/admin/src/app/pages/dish/dish.component.html index 85f6bcf..411fd98 100644 --- a/projects/admin/src/app/pages/dish/dish.component.html +++ b/projects/admin/src/app/pages/dish/dish.component.html @@ -21,13 +21,8 @@ + formControlName="vendors"> diff --git a/projects/admin/src/app/pages/dish/dish.component.ts b/projects/admin/src/app/pages/dish/dish.component.ts index f38cfb7..60edb17 100644 --- a/projects/admin/src/app/pages/dish/dish.component.ts +++ b/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; @@ -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, diff --git a/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html b/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html index acece79..f99ef7a 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html +++ b/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.html @@ -40,7 +40,8 @@
-
diff --git a/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts b/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts index e064f19..80086d3 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts +++ b/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) => { diff --git a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html index afc3d68..7025e73 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html +++ b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html @@ -55,7 +55,7 @@ {{item}} - {{data}} 天 + 周{{data}} {{statusTextMap[data]}} @@ -69,7 +69,7 @@ - {{monthText[item]}} + {{item}}
diff --git a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts index 0c723b8..34e25c4 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts +++ b/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, diff --git a/projects/admin/src/app/pages/ingredients/ingredient-release/ingredient-release.component.ts b/projects/admin/src/app/pages/ingredients/ingredient-release/ingredient-release.component.ts index f0b311a..3e6b95a 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-release/ingredient-release.component.ts +++ b/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, diff --git a/projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts b/projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts index b401274..8d25fb7 100644 --- a/projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts +++ b/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, diff --git a/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.html b/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.html index 86869c8..4c60bc0 100644 --- a/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.html +++ b/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.html @@ -15,7 +15,7 @@ - 第 {{day}} 天 + {{weekdayMap[day]}} diff --git a/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts b/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts index fd0cdb5..4de393f 100644 --- a/projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts +++ b/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 = {}; // 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); - return i + 1; + return i; }); } } diff --git a/projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.html b/projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.html index fce9d96..6d739b5 100644 --- a/projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.html +++ b/projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.html @@ -51,16 +51,14 @@ 天数 - - - - - - - - - - + + + + + @@ -68,6 +66,7 @@ 餐次 + = { + 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 = []; @@ -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); }); } } diff --git a/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.html b/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.html index f85784b..d7be298 100644 --- a/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.html +++ b/projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.html @@ -59,7 +59,7 @@
-
第{{day}}天
+
{{weekdayMap[day]}}
重量/克
@@ -102,7 +102,8 @@
  • -
    +
    {{f['foodName']}}
    { - 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; diff --git a/projects/cdk/src/services/api.service.ts b/projects/cdk/src/services/api.service.ts index 4cf3a83..a5b6bd3 100644 --- a/projects/cdk/src/services/api.service.ts +++ b/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>(`/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>(`/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>(`/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>(`/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>(`/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) { diff --git a/projects/cdk/src/shared/components/month-select/month-select.component.ts b/projects/cdk/src/shared/components/month-select/month-select.component.ts index cd3c0d1..9879204 100644 --- a/projects/cdk/src/shared/components/month-select/month-select.component.ts +++ b/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(); } diff --git a/projects/cdk/src/shared/components/org-select/org-select.component.ts b/projects/cdk/src/shared/components/org-select/org-select.component.ts index 9ccde8c..f01ef3c 100644 --- a/projects/cdk/src/shared/components/org-select/org-select.component.ts +++ b/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 = []; - data.body.forEach((item) => { + data.forEach((item) => { listOfOption.push({ value: String(item.id), label: item.name, diff --git a/projects/client/src/app/components/dish-form/dish-form.component.html b/projects/client/src/app/components/dish-form/dish-form.component.html index ce1d18d..1ecf046 100644 --- a/projects/client/src/app/components/dish-form/dish-form.component.html +++ b/projects/client/src/app/components/dish-form/dish-form.component.html @@ -45,7 +45,7 @@ 菜品图片 - +
    @@ -53,7 +53,7 @@ diff --git a/projects/client/src/app/components/dish-form/dish-form.component.ts b/projects/client/src/app/components/dish-form/dish-form.component.ts index bb73154..b704841 100644 --- a/projects/client/src/app/components/dish-form/dish-form.component.ts +++ b/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(); diff --git a/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts b/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts index 1763d5c..21a3985 100644 --- a/projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts +++ b/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) => { diff --git a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html b/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html index 670dd00..98451f4 100644 --- a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html +++ b/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html @@ -51,7 +51,7 @@ {{item}} - {{data}} 天 + 周{{data}} {{statusTextMap[data]}} @@ -65,7 +65,7 @@ - {{monthText[item]}} + {{item}}
    diff --git a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts b/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts index 762f731..4660dad 100644 --- a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts +++ b/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([