Browse Source

优化& bug

main
kely 1 year ago
parent
commit
4ed56368c1
  1. 4
      projects/admin/src/app/components/app-layout/app-layout.component.html
  2. 3
      projects/admin/src/app/components/app-layout/app-layout.component.ts
  3. 2
      projects/admin/src/app/pages/food/food.component.ts
  4. 2
      projects/admin/src/app/pages/login/login.component.html
  5. 3
      projects/admin/src/app/pages/login/login.component.ts
  6. BIN
      projects/admin/src/assets/images/jl-logo.png
  7. BIN
      projects/admin/src/favicon.ico
  8. 2
      projects/admin/src/index.html
  9. 1
      projects/cdk/src/app-settings/index.ts
  10. 10
      projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.ts
  11. 8
      projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts
  12. 14
      projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.ts
  13. 16
      projects/cdk/src/services/api.service.ts
  14. 4
      projects/client/src/app/components/app-layout/app-layout.component.html
  15. 3
      projects/client/src/app/components/app-layout/app-layout.component.ts
  16. 2
      projects/client/src/app/pages/data-vis/data-vis.component.ts
  17. 2
      projects/client/src/app/pages/food/food.component.html
  18. 2
      projects/client/src/app/pages/login/login.component.html
  19. 3
      projects/client/src/app/pages/login/login.component.ts
  20. BIN
      projects/client/src/assets/images/jl-logo.png
  21. BIN
      projects/client/src/favicon.ico
  22. 2
      projects/client/src/index.html

4
projects/admin/src/app/components/app-layout/app-layout.component.html

@ -28,9 +28,9 @@
<nz-layout class="app-layout-main"> <nz-layout class="app-layout-main">
<nz-sider nzWidth="220px" nzTheme="dark" class="sider-menu"> <nz-sider nzWidth="220px" nzTheme="dark" class="sider-menu">
<div class="logo flex items-center py-4"> <div class="logo flex items-center py-4">
<img class="block h-[40px] mr-2" src="../assets/images/jl-logo.png" /> <img class="block h-[40px] " src="../assets/images/jl-logo.png" />
<span class="text-base text-white font-bold"> <span class="text-base text-white font-bold">
智慧配餐管理后台 {{appName}}后台
</span> </span>
</div> </div>
<ul nz-menu nzMode="inline" nzTheme="dark"> <ul nz-menu nzMode="inline" nzTheme="dark">

3
projects/admin/src/app/components/app-layout/app-layout.component.ts

@ -5,6 +5,7 @@ import { NzMessageService } from "ng-zorro-antd/message";
import { NzModalService } from "ng-zorro-antd/modal"; import { NzModalService } from "ng-zorro-antd/modal";
import { Subject, filter, lastValueFrom, takeUntil } from "rxjs"; import { Subject, filter, lastValueFrom, takeUntil } from "rxjs";
import { appName } from "@cdk/app-settings";
@Component({ @Component({
selector: "app-layout", selector: "app-layout",
@ -31,6 +32,8 @@ export class AppLayoutComponent implements OnInit {
fullPage = false; fullPage = false;
appName = appName;
account = this.api.adminAccount; account = this.api.adminAccount;
ngOnInit(): void {} ngOnInit(): void {}

2
projects/admin/src/app/pages/food/food.component.ts

@ -179,12 +179,10 @@ export class FoodComponent implements OnInit, OnDestroy {
onFileChange(e: FileList | Event) { onFileChange(e: FileList | Event) {
let files: FileList; let files: FileList;
console.log(e instanceof FileList, e);
if (e instanceof FileList) { if (e instanceof FileList) {
files = e; files = e;
} else { } else {
const target = e.target as HTMLInputElement; const target = e.target as HTMLInputElement;
console.log(e instanceof FileList, target.files);
files = target.files!; files = target.files!;
} }
if (files?.length > 0) { if (files?.length > 0) {

2
projects/admin/src/app/pages/login/login.component.html

@ -10,7 +10,7 @@
<div class="img"></div> <div class="img"></div>
<div class="form py-5 px-10 flex-1"> <div class="form py-5 px-10 flex-1">
<div class="text-left "> <div class="text-left ">
<h2 class="mt-4 text-3xl font-bold">智慧配餐管理后台</h2> <h2 class="mt-4 text-3xl font-bold">{{appName}}后台</h2>
<h3 class="mt-10 text-xl">登录</h3> <h3 class="mt-10 text-xl">登录</h3>
<form nz-form [formGroup]="loginForm" class="mt-10"> <form nz-form [formGroup]="loginForm" class="mt-10">

3
projects/admin/src/app/pages/login/login.component.ts

@ -8,6 +8,7 @@ import { FormValidators } from "projects/cdk/src/public-api";
import { Utils } from "projects/cdk/src/utils"; import { Utils } from "projects/cdk/src/utils";
import { ApiService } from "@cdk/services"; import { ApiService } from "@cdk/services";
import { appName } from "@cdk/app-settings";
@Component({ @Component({
selector: "app-login", selector: "app-login",
@ -24,6 +25,8 @@ export class LoginComponent {
public loading: boolean = false; public loading: boolean = false;
appName = appName;
ngOnInit(): void {} ngOnInit(): void {}
async onLogin() { async onLogin() {

BIN
projects/admin/src/assets/images/jl-logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 350 KiB

BIN
projects/admin/src/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 64 KiB

2
projects/admin/src/index.html

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>智慧配餐管理后台</title> <title>营养配餐系统后台</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">

1
projects/cdk/src/app-settings/index.ts

@ -0,0 +1 @@
export const appName = "营养配餐系统";

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

@ -9,7 +9,7 @@ import { finalize } from "rxjs";
styleUrls: ["./ingredient-analysis.component.less"], styleUrls: ["./ingredient-analysis.component.less"],
}) })
export class IngredientAnalysisComponent implements OnInit { export class IngredientAnalysisComponent implements OnInit {
constructor(private api: ApiService) {} constructor(private api: ApiService, private route: ActivatedRoute) {}
@Input() menu: any; @Input() menu: any;
@ -32,14 +32,16 @@ export class IngredientAnalysisComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.currentDay = this.current.day; this.currentDay = this.current.day;
this.currentPeople = this.menu.crows[0]; this.currentPeople = this.menu.crows[0];
this.id = this.route.snapshot.queryParamMap.get("newId") ?? this.menu.id;
this.getAnalysis(); this.getAnalysis();
this.getRule(); this.getRule();
} }
getAnalysis() { getAnalysis() {
this.analysisLoading = true; this.analysisLoading = true;
this.api this.api
.getAnalysis(this.menu.id, this.currentDay, this.currentPeople) .getAnalysis(this.id, this.currentDay, this.currentPeople)
.pipe( .pipe(
finalize(() => { finalize(() => {
this.analysisLoading = false; this.analysisLoading = false;
@ -53,13 +55,13 @@ export class IngredientAnalysisComponent implements OnInit {
} }
getEnergy() { getEnergy() {
this.api.getAnalysisEnergy(this.menu.id, this.currentDay, this.currentPeople).subscribe((res) => { this.api.getAnalysisEnergy(this.id, this.currentDay, this.currentPeople).subscribe((res) => {
this.energy = res.body; this.energy = res.body;
}); });
} }
getRule() { getRule() {
this.api.getAnalysisRule(this.menu.id, this.currentDay, this.currentPeople).subscribe((res) => { this.api.getAnalysisRule(this.id, this.currentDay, this.currentPeople).subscribe((res) => {
this.rules = res.body; this.rules = res.body;
}); });
} }

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

@ -104,11 +104,13 @@ export class IngredientDishComponent implements OnChanges {
const meals = this.menuBaisc.meals as string[]; const meals = this.menuBaisc.meals as string[];
const day = this.menuBaisc.day as number; const day = this.menuBaisc.day as number;
this.days = Array.from({ length: day }, (_, i) => { this.days = Array.from({ length: day }, (_, i) => {
const d = i + 1;
this.selectDay.push({ this.selectDay.push({
label: `${i + 1}`, label: `${d}`,
value: String(i + 1), value: String(d),
}); });
this.mealCurrentIndex[i] = 0; this.mealCurrentIndex[d] = 0;
this.expanded.add(d);
// if (!this.menuObject) { // if (!this.menuObject) {
// this.menuObject = {}; // this.menuObject = {};
// } // }

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

@ -1,5 +1,6 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from "@angular/core"; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from "@angular/core";
import { FormArray, FormBuilder, FormGroup } from "@angular/forms"; import { FormArray, FormBuilder, FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { OrgDTO } from "@cdk/dtos"; import { OrgDTO } from "@cdk/dtos";
import { ApiService } from "@cdk/services"; import { ApiService } from "@cdk/services";
import { OptionItemInterface } from "@cdk/types"; import { OptionItemInterface } from "@cdk/types";
@ -14,7 +15,13 @@ import { Subject, debounceTime, distinctUntilChanged, filter, finalize, switchMa
styleUrls: ["./ingredient-form-basic.component.less"], styleUrls: ["./ingredient-form-basic.component.less"],
}) })
export class IngredientFormBasicComponent implements OnChanges { export class IngredientFormBasicComponent implements OnChanges {
constructor(private fb: FormBuilder, private msg: NzMessageService, private api: ApiService) {} constructor(
private fb: FormBuilder,
private msg: NzMessageService,
private api: ApiService,
private router: Router,
private route: ActivatedRoute
) {}
@Input() menu: any | null; @Input() menu: any | null;
@ -170,6 +177,11 @@ export class IngredientFormBasicComponent implements OnChanges {
) )
.subscribe((res) => { .subscribe((res) => {
this.msg.success(res.desc); this.msg.success(res.desc);
this.router.navigate([], {
relativeTo: this.route,
queryParams: { newId: res.body },
queryParamsHandling: "merge",
});
this.onSave.emit({ this.onSave.emit({
...this.formGroup.value, ...this.formGroup.value,
meals: this.meals, meals: this.meals,

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

@ -301,11 +301,11 @@ export class ApiService {
observe: "response", observe: "response",
responseType: "blob" as "json", responseType: "blob" as "json",
}) })
.pipe( .pipe
tap((res) => { // tap((res) => {
this.downLoadFile(res); // this.downLoadFile(res);
}) // })
); ();
} }
markFood(mark: string, key: string) { markFood(mark: string, key: string) {
@ -511,16 +511,16 @@ export class ApiService {
); );
} }
getAnalysis(id: number, day?: number, crow?: string) { getAnalysis(id: string, day?: number, crow?: string) {
const params = Utils.objectStringify({ id, day, crow }); const params = Utils.objectStringify({ id, day, crow });
return this.http.get<ResponseType>(`/api/menu/analysis?${params}`); return this.http.get<ResponseType>(`/api/menu/analysis?${params}`);
} }
getAnalysisEnergy(id: number, day?: number, crow?: string) { getAnalysisEnergy(id: string, day?: number, crow?: string) {
const params = Utils.objectStringify({ id, day, crow }); const params = Utils.objectStringify({ id, day, crow });
return this.http.get<ResponseType>(`/api/menu/analysis/energy?${params}`); return this.http.get<ResponseType>(`/api/menu/analysis/energy?${params}`);
} }
getAnalysisRule(id: number, day?: number, crow?: string) { getAnalysisRule(id: string, day?: number, crow?: string) {
const params = Utils.objectStringify({ id, day, crow }); const params = Utils.objectStringify({ id, day, crow });
return this.http.get<ResponseType>(`/api/menu/analysis/types?${params}`); return this.http.get<ResponseType>(`/api/menu/analysis/types?${params}`);
} }

4
projects/client/src/app/components/app-layout/app-layout.component.html

@ -7,9 +7,9 @@
<nz-header class="app-header"> <nz-header class="app-header">
<div class="flex items-center justify-between h-full"> <div class="flex items-center justify-between h-full">
<div class="logo flex items-center h-full"> <div class="logo flex items-center h-full">
<img class="block h-[40px] mr-2" src="../assets/images/jl-logo.png" /> <img class="block h-[40px] mr-1" src="../assets/images/jl-logo.png" />
<span class="text-lg text-white font-bold"> <span class="text-lg text-white font-bold">
智慧配餐系统 {{appName}}
</span> </span>
</div> </div>
<div class="profile"> <div class="profile">

3
projects/client/src/app/components/app-layout/app-layout.component.ts

@ -5,6 +5,7 @@ import { NzMessageService } from "ng-zorro-antd/message";
import { NzModalService } from "ng-zorro-antd/modal"; import { NzModalService } from "ng-zorro-antd/modal";
import { Subject, filter, lastValueFrom, takeUntil } from "rxjs"; import { Subject, filter, lastValueFrom, takeUntil } from "rxjs";
import { ApiService } from "@cdk/services"; import { ApiService } from "@cdk/services";
import { appName } from "@cdk/app-settings";
@Component({ @Component({
selector: "app-layout", selector: "app-layout",
@ -32,6 +33,8 @@ export class AppLayoutComponent implements OnInit {
fullPage = false; fullPage = false;
account = this.api.account; account = this.api.account;
appName = appName;
unSubscribe$ = new Subject<void>(); unSubscribe$ = new Subject<void>();
currentUrl: string = ""; currentUrl: string = "";

2
projects/client/src/app/pages/data-vis/data-vis.component.ts

@ -37,7 +37,7 @@ export class DataVisComponent implements AfterViewInit {
people = ""; people = "";
menuId!: number; menuId!: string;
logo = ""; logo = "";

2
projects/client/src/app/pages/food/food.component.html

@ -1,7 +1,7 @@
<app-page [scroll]="false"> <app-page [scroll]="false">
<div nz-row class="h-full overflow-hidden bg-white rounded-lg"> <div nz-row class="h-full overflow-hidden bg-white rounded-lg">
<div nz-col nzFlex="220px" class="food-type"> <div nz-col nzFlex="220px" class="food-type h-full">
<nz-card class="h-full" [nzBordered]="false" nzTitle="食材类型" <nz-card class="h-full" [nzBordered]="false" nzTitle="食材类型"
[nzBodyStyle]="{padding:'1px 0 0 0', height:'100%',overflow:'auto'}"> [nzBodyStyle]="{padding:'1px 0 0 0', height:'100%',overflow:'auto'}">
<ul nz-menu nzMode="inline"> <ul nz-menu nzMode="inline">

2
projects/client/src/app/pages/login/login.component.html

@ -12,7 +12,7 @@
</div> </div>
<div class="form py-5 px-10 flex-1"> <div class="form py-5 px-10 flex-1">
<div class="form-inner"> <div class="form-inner">
<h2 class="mt-4 text-3xl font-bold">智慧配餐管理</h2> <h2 class="mt-4 text-3xl font-bold">{{appName}}</h2>
<h3 class="mt-10 text-xl">登录</h3> <h3 class="mt-10 text-xl">登录</h3>
<form nz-form [formGroup]="loginForm" class="mt-10"> <form nz-form [formGroup]="loginForm" class="mt-10">

3
projects/client/src/app/pages/login/login.component.ts

@ -7,6 +7,7 @@ import { Utils } from "projects/cdk/src/utils";
import { finalize, lastValueFrom } from "rxjs"; import { finalize, lastValueFrom } from "rxjs";
import { MD5 } from "crypto-js"; import { MD5 } from "crypto-js";
import { ApiService } from "@cdk/services"; import { ApiService } from "@cdk/services";
import { appName } from "@cdk/app-settings";
@Component({ @Component({
selector: "app-login", selector: "app-login",
@ -23,6 +24,8 @@ export class LoginComponent {
public loading: boolean = false; public loading: boolean = false;
appName = appName;
ngOnInit(): void {} ngOnInit(): void {}
async onLogin() { async onLogin() {

BIN
projects/client/src/assets/images/jl-logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 350 KiB

BIN
projects/client/src/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 64 KiB

2
projects/client/src/index.html

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>智慧配餐系统</title> <title>营养配餐系统</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">

Loading…
Cancel
Save