diff --git a/angular.json b/angular.json index 76ab956..57327a0 100644 --- a/angular.json +++ b/angular.json @@ -43,13 +43,13 @@ "budgets": [ { "type": "initial", - "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumWarning": "21mb", + "maximumError": "21mb" }, { "type": "anyComponentStyle", - "maximumWarning": "2kb", - "maximumError": "4kb" + "maximumWarning": "21mb", + "maximumError": "21mb" } ], "outputHashing": "all" @@ -164,13 +164,13 @@ "budgets": [ { "type": "initial", - "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumWarning": "21mb", + "maximumError": "21mb" }, { "type": "anyComponentStyle", - "maximumWarning": "2kb", - "maximumError": "4kb" + "maximumWarning": "21mb", + "maximumError": "21mb" } ], "outputHashing": "all" diff --git a/projects/admin/src/app/app-routing.module.ts b/projects/admin/src/app/app-routing.module.ts index 47a3f6e..f20ff9d 100644 --- a/projects/admin/src/app/app-routing.module.ts +++ b/projects/admin/src/app/app-routing.module.ts @@ -26,7 +26,7 @@ const routes: Routes = [ component: AppLayoutComponent, canActivate: [authGuard], children: [ - { path: "", pathMatch: "full", redirectTo: "home" }, + { path: "", pathMatch: "full", redirectTo: "food" }, { path: "home", component: HomeComponent }, { path: "food", component: FoodComponent, title: "食材管理" }, { path: "dish", component: DishComponent, title: "菜品管理" }, 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 579fec4..15394e8 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 @@ -49,26 +49,7 @@ 适用月份 -
- -
- -
- -
- +
@@ -146,11 +127,7 @@ {{f.value}}-{{f.text}}: --> - +
+
+ + + 是否主料 +
+ - {{data}} - 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 dbfd742..9e660b6 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 @@ -17,14 +17,29 @@ export class IngredientListComponent { private drawerRef?: NzDrawerRef; - tempImg = "https://cdn.pixabay.com/photo/2023/08/08/18/01/butterfly-8177925_1280.jpg"; - - public tableList = new TableListOption(this.fetchData.bind(this)); + public tableList = new TableListOption(this.fetchData.bind(this), { + frontPagination: false, + }); public queryForm = new FormGroup({ name: new FormControl(""), }); + monthText = { + 1: "一月", + 2: "二月", + 3: "三月", + 4: "四月", + 5: "五月", + 6: "六月", + 7: "七月", + 8: "八月", + 9: "九月", + 10: "十月", + 11: "十一月", + 12: "十二月", + } as any; + ngOnInit(): void { this.initTableList(); } @@ -33,14 +48,13 @@ export class IngredientListComponent { this.tableList.scroll = { x: null }; this.tableList = this.tableList.setColumns([ { key: "name", title: "食谱名称" }, - { key: "name", title: "单位" }, - { key: "name", title: "包含餐次" }, - { key: "name", title: "单位" }, - { key: "name", title: "适用月份" }, - { key: "name", title: "周期" }, - { key: "name", title: "状态" }, - { key: "name", title: "更新时间" }, - { key: "name", title: "创建人" }, + { key: "vender", title: "单位" }, + { key: "meals", title: "包含餐次" }, + { key: "month", title: "适用月份", width: "300px" }, + { key: "day", title: "周期" }, + { key: "status", title: "状态" }, + { key: "modify", title: "更新时间" }, + { key: "operate", title: "创建人" }, ]); this.tableList = this.tableList.setOptions([ @@ -78,7 +92,7 @@ export class IngredientListComponent { } fetchData(query: AnyObject, pager: AnyObject) { - return this.api.page(pager, query); + return this.api.getMenuPage(pager, query); } showFoodForm(food?: any) { 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 779c2a5..4c47043 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 @@ -125,7 +125,7 @@ export class StandardFormComponent { ) .subscribe((res) => { this.msg.success(res.desc); - const redirectTo = gotoSetting ? ["/", "standard", "setting", res.body] : ["/standard/list"]; + const redirectTo = gotoSetting ? ["/", "standard", "setting", res.body.id] : ["/standard/list"]; this.router.navigate(redirectTo); }); } diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts index b96fdd9..95286db 100644 --- a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts +++ b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts @@ -139,12 +139,10 @@ export class StandardSettingComponent { }; }, {} as AnyObject); - this.api - .saveStandard({ id: this.state.id, foodCategoryDay, foodCategoryWeek, ingredient }, true) - .subscribe((res) => { - this.msg.success(res.desc); - this.router.navigate(["/standard/list"]); - }); + this.api.saveStandard({ ...this.state, foodCategoryDay, foodCategoryWeek, ingredient }, true).subscribe((res) => { + this.msg.success(res.desc); + this.router.navigate(["/standard/list"]); + }); } addFoodType(type: string) { diff --git a/projects/cdk/src/dtos/enum.dto.ts b/projects/cdk/src/dtos/enum.dto.ts index 4e26c97..b32346c 100644 --- a/projects/cdk/src/dtos/enum.dto.ts +++ b/projects/cdk/src/dtos/enum.dto.ts @@ -1,14 +1,19 @@ +import { OptionItemInterface } from "@cdk/types"; + export type GlobalEnum = { category: CategoryDTO[]; mark: MarkDTO[]; nutrient: NutrientDTO[]; venderType: CategoryDTO[]; + mealType: OptionItemInterface[]; + menuStatus: OptionItemInterface[]; }; export type CategoryDTO = { key: string; value: string; }; + export type MarkDTO = { key: string; value: string; diff --git a/projects/cdk/src/services/api.service.ts b/projects/cdk/src/services/api.service.ts index 8d9c086..044ac9f 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, PageResult, ResponseType } from "@cdk/types"; +import { AnyObject, OptionItemInterface, PageResult, ResponseType } from "@cdk/types"; import { Utils } from "@cdk/utils"; import { Observable, map, of, tap } from "rxjs"; import { @@ -12,6 +12,7 @@ import { ClientAccountDTO, AdminAccountDTO, OrgConfigDTO, + CategoryDTO, } from "@cdk/public-api"; export const PROJECT_NAME = new InjectionToken("projectName"); @@ -58,13 +59,20 @@ export class ApiService { } } + private _formatEnum(v: CategoryDTO[]): OptionItemInterface[] { + return v.map((i) => ({ label: i.key, value: i.value })); + } + getAllEnum(force?: boolean): Observable { if (this.globalEnum && !force) { return of(this.globalEnum); } - return this.http.get>("/api/basic/enum").pipe( + return this.http.get>("/api/enum").pipe( map((res) => { - return res.body; + return { + ...res.body, + mealType: this._formatEnum(res.body.mealType), + }; }), tap((r) => { this.globalEnum = r; @@ -103,7 +111,7 @@ export class ApiService { updatePassword(v: {}) { const body = Utils.objectToFormData(v); - return this.http.post("/api/basic/user", body); + return this.http.post("/api/password", body); } getRoleList() { @@ -151,7 +159,7 @@ export class ApiService { }); } - getOrgList(query: {}) { + getOrgList(query: { vendors?: number[]; keyword?: string }) { const q = Utils.objectStringify(query); return this.http.get>(`/api/vender/select?${q}`); } @@ -302,6 +310,11 @@ export class ApiService { ); } + getStandard(q: { id?: string; name?: string }) { + const query = Utils.objectStringify(q); + return this.http.get>(`/api/nutrition/select?${query}`); + } + saveStandard(v: AnyObject, isEdit?: boolean) { const body = Utils.objectToFormData({ ...v, vendors: v["vendors"]?.join(",") }); const method = v["id"] ? "post" : "put"; @@ -318,18 +331,18 @@ export class ApiService { return this.http.get>(`/api/dish?${params}`).pipe( map((r) => { if (Array.isArray(r.body.content)) { - r.body.content = r.body.content.map((o) => { - return { - ...o, - foodArr: Object.entries(o.ingredient).map(([k, v]) => { - return { - key: k, - value: v, - label: k, - }; - }), - }; - }); + // r.body.content = r.body.content.map((o) => { + // return { + // ...o, + // foodArr: Object.entries(o.ingredient).map(([k, v]) => { + // return { + // key: k, + // value: v, + // label: k, + // }; + // }), + // }; + // }); } return r; }) @@ -346,4 +359,20 @@ export class ApiService { const params = Utils.objectToFormData({ ids: ids.join(",") }); return this.http.delete(`/api/dish`, { body: params }); } + + getMenuPage(p: {}, q: {}) { + const params = Utils.objectStringify({ ...p, ...q }); + return this.http.get>(`/api/menu?${params}`); + } + + getMenuItem() { + const params = Utils.objectStringify({ menuId: 1 }); + return this.http.get(`/api/menu/dish?${params}`); + } + + saveMenu(v: AnyObject) { + const body = Utils.objectToFormData(v); + const method = v["id"] ? "post" : "put"; + return this.http[method]("/api/menu", body); + } } diff --git a/projects/cdk/src/shared/components/index.ts b/projects/cdk/src/shared/components/index.ts index 31254ed..ae37f41 100644 --- a/projects/cdk/src/shared/components/index.ts +++ b/projects/cdk/src/shared/components/index.ts @@ -1 +1,2 @@ export * from "./search-and-select/search-and-select.component"; +export * from "./month-select/month-select.component"; diff --git a/projects/cdk/src/shared/components/month-select/month-select.component.html b/projects/cdk/src/shared/components/month-select/month-select.component.html new file mode 100644 index 0000000..baaa346 --- /dev/null +++ b/projects/cdk/src/shared/components/month-select/month-select.component.html @@ -0,0 +1,15 @@ +
+ +
+ +
+ +
\ No newline at end of file diff --git a/projects/cdk/src/shared/components/month-select/month-select.component.less b/projects/cdk/src/shared/components/month-select/month-select.component.less new file mode 100644 index 0000000..4ae17d1 --- /dev/null +++ b/projects/cdk/src/shared/components/month-select/month-select.component.less @@ -0,0 +1,17 @@ +.month-wrap { + ::ng-deep { + .ant-checkbox-wrapper { + margin: 6px 0; + flex-basis: calc(100% / 6); + } + } +} + +.block-label { + ::ng-deep { + label { + display: inline-flex; + width: 100%; + } + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..e123c3f --- /dev/null +++ b/projects/cdk/src/shared/components/month-select/month-select.component.ts @@ -0,0 +1,93 @@ +import { Component } from "@angular/core"; +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms"; + +@Component({ + selector: "app-month-select", + templateUrl: "./month-select.component.html", + styleUrls: ["./month-select.component.less"], + providers: [ + { + provide: NG_VALUE_ACCESSOR, + multi: true, + useExisting: MonthSelectComponent, + }, + ], +}) +export class MonthSelectComponent implements ControlValueAccessor { + allMonthChecked = false; + + indeterminate = false; + + allMonth = [ + { value: 1, label: "一月", checked: false }, + { value: 2, label: "二月", checked: false }, + { value: 3, label: "三月", checked: false }, + { value: 4, label: "四月", checked: false }, + { value: 5, label: "五月", checked: false }, + { value: 6, label: "六月", checked: false }, + { value: 7, label: "七月", checked: false }, + { value: 8, label: "八月", checked: false }, + { value: 9, label: "九月", checked: false }, + { value: 10, label: "十月", checked: false }, + { value: 11, label: "十一月", checked: false }, + { value: 12, label: "十二月", checked: false }, + ]; + + updateAllMonthChecked() { + this.indeterminate = false; + if (this.allMonthChecked) { + this.allMonth = this.allMonth.map((item) => ({ + ...item, + checked: true, + })); + } else { + this.allMonth = this.allMonth.map((item) => ({ + ...item, + checked: false, + })); + } + this.formatVal(); + } + + monthChecked(checked: boolean, value: number) { + this.allMonth = this.allMonth.map((i) => (i.value === value ? { ...i, checked } : i)); + this.monthCheckEffect(); + this.formatVal(); + } + + monthCheckEffect() { + if (this.allMonth.every((item) => !item.checked)) { + this.allMonthChecked = false; + this.indeterminate = false; + } else if (this.allMonth.every((item) => item.checked)) { + this.allMonthChecked = true; + this.indeterminate = false; + } else { + this.indeterminate = true; + } + } + + formatVal() { + const vals = this.allMonth.reduce((a, c) => { + return c.checked ? a.concat(c.value) : a; + }, [] as number[]); + this.onChange(vals); + } + + onChange(v: number[]) {} + + ontouch(v: any) {} + + writeValue(v: number[]): void { + this.allMonth = this.allMonth.map((i) => (v.includes(i.value) ? { ...i, checked: true } : i)); + this.monthCheckEffect(); + } + + registerOnChange(fn: any): void { + this.onChange = fn; + } + + registerOnTouched(fn: any): void { + this.ontouch = fn; + } +} diff --git a/projects/cdk/src/shared/shared.module.ts b/projects/cdk/src/shared/shared.module.ts index 666a971..576b7e2 100644 --- a/projects/cdk/src/shared/shared.module.ts +++ b/projects/cdk/src/shared/shared.module.ts @@ -20,7 +20,7 @@ import { // import { environment } from "@manage/environments/environment"; import { NgxPermissionsModule } from "ngx-permissions"; import { AppPageComponent } from "@cdk/app-page/app-page.component"; -import { SearchAndSelectComponent } from "./components"; +import { SearchAndSelectComponent, MonthSelectComponent } from "./components"; const ngModules = [CommonModule, HttpClientModule, FormsModule, RouterModule, ReactiveFormsModule]; const components: any = []; @@ -36,7 +36,7 @@ const cdks = [ ] as any; @NgModule({ - declarations: [...components, ...directives, SearchAndSelectComponent], + declarations: [...components, ...directives, SearchAndSelectComponent, MonthSelectComponent], imports: [...ngZorroModules, ...ngModules, ...cdks, AppPageComponent], exports: [ ...ngZorroModules, @@ -46,6 +46,7 @@ const cdks = [ ...cdks, AppPageComponent, SearchAndSelectComponent, + MonthSelectComponent, ], }) export class SharedModule {} diff --git a/projects/client/src/app/pages/system/org-info/org-info.component.ts b/projects/client/src/app/pages/system/org-info/org-info.component.ts index f329a2d..8db6e51 100644 --- a/projects/client/src/app/pages/system/org-info/org-info.component.ts +++ b/projects/client/src/app/pages/system/org-info/org-info.component.ts @@ -9,6 +9,7 @@ import { NzMessageService } from "ng-zorro-antd/message"; import { OrgFormComponent } from "../../../components"; import { lastValueFrom } from "rxjs"; import { MD5 } from "crypto-js"; +import { Router } from "@angular/router"; @Component({ selector: "app-org-info", @@ -16,7 +17,12 @@ import { MD5 } from "crypto-js"; styleUrls: ["./org-info.component.less"], }) export class OrgInfoComponent implements OnInit { - constructor(private api: ApiService, private modal: NzModalService, private msg: NzMessageService) {} + constructor( + private api: ApiService, + private modal: NzModalService, + private msg: NzMessageService, + private router: Router + ) {} account: any = this.api.account; @@ -73,11 +79,16 @@ export class OrgInfoComponent implements OnInit { } const res = await lastValueFrom( this.api.updatePassword({ + oldPassword: MD5(value.oldPwd!).toString().slice(-16), password: MD5(value.newPwd!).toString().slice(-16), // name: }) ); this.msg.success(res.desc); + this.api.logout().subscribe(() => { + this.msg.success("请重新登录"); + this.router.navigate(["/login"]); + }); return true; } return false;