Browse Source

修改

main
kely 2 years ago
parent
commit
af01bce942
  1. 1
      package.json
  2. 21
      pnpm-lock.yaml
  3. 2
      projects/admin/src/app/components/dish-form/dish-form.component.ts
  4. 2
      projects/admin/src/app/pages/dish/dish.component.html
  5. 2
      projects/admin/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts
  6. 2
      projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts
  7. 61
      projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html
  8. 46
      projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts
  9. 1
      projects/cdk/src/dtos/enum.dto.ts
  10. 2
      projects/cdk/src/ingredient/confirm-ingredient/confirm-ingredient.component.html
  11. 156
      projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.html
  12. 78
      projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.ts
  13. 6
      projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts
  14. 2
      projects/cdk/src/ingredient/ingredient-preview/ingredient-preview.component.ts
  15. 11
      projects/cdk/src/services/api.service.ts
  16. 2
      projects/client/src/app/components/dish-form/dish-form.component.ts
  17. 2
      projects/client/src/app/components/org-form/org-form.component.ts
  18. 2
      projects/client/src/app/pages/dashboard/dashboard.component.html
  19. 2
      projects/client/src/app/pages/data-vis/data-vis.component.html
  20. 2
      projects/client/src/app/pages/dish/dish.component.html
  21. 2
      projects/client/src/app/pages/ingredients/ingredient-form/ingredient-form.component.ts
  22. 2
      projects/client/src/app/pages/system/org-info/org-info.component.html

1
package.json

@ -24,6 +24,7 @@
"@ant-design/icons-angular": "^16.0.0", "@ant-design/icons-angular": "^16.0.0",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"echarts": "^5.4.3",
"immer": "^10.0.2", "immer": "^10.0.2",
"ng-zorro-antd": "16.1.0", "ng-zorro-antd": "16.1.0",
"ngx-permissions": "^16.0.1", "ngx-permissions": "^16.0.1",

21
pnpm-lock.yaml

@ -41,6 +41,9 @@ dependencies:
date-fns: date-fns:
specifier: ^2.30.0 specifier: ^2.30.0
version: 2.30.0 version: 2.30.0
echarts:
specifier: ^5.4.3
version: 5.4.3
immer: immer:
specifier: ^10.0.2 specifier: ^10.0.2
version: 10.0.2 version: 10.0.2
@ -3432,6 +3435,7 @@ packages:
/debug@3.2.7: /debug@3.2.7:
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
requiresBuild: true
peerDependencies: peerDependencies:
supports-color: '*' supports-color: '*'
peerDependenciesMeta: peerDependenciesMeta:
@ -3580,6 +3584,13 @@ packages:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
dev: true dev: true
/echarts@5.4.3:
resolution: {integrity: sha512-mYKxLxhzy6zyTi/FaEbJMOZU1ULGEQHaeIeuMR5L+JnJTpz+YR03mnnpBhbR4+UYJAgiXgpyTVLffPAjOTLkZA==}
dependencies:
tslib: 2.3.0
zrender: 5.4.4
dev: false
/ee-first@1.1.1: /ee-first@1.1.1:
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
dev: true dev: true
@ -5766,6 +5777,7 @@ packages:
/pify@4.0.1: /pify@4.0.1:
resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==}
engines: {node: '>=6'} engines: {node: '>=6'}
requiresBuild: true
dev: true dev: true
optional: true optional: true
@ -5980,6 +5992,7 @@ packages:
/prr@1.0.1: /prr@1.0.1:
resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==}
requiresBuild: true
dev: true dev: true
optional: true optional: true
@ -6300,6 +6313,7 @@ packages:
/sax@1.2.4: /sax@1.2.4:
resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==}
requiresBuild: true
dev: true dev: true
optional: true optional: true
@ -6336,6 +6350,7 @@ packages:
/semver@5.7.2: /semver@5.7.2:
resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==}
hasBin: true hasBin: true
requiresBuild: true
dev: true dev: true
optional: true optional: true
@ -7433,3 +7448,9 @@ packages:
resolution: {integrity: sha512-7m3hNNyswsdoDobCkYNAy5WiUulkMd3+fWaGT9ij6iq3Zr/IwJo4RMCYPSDjT+r7tnPErmY9sZpKhWQ8S5k6XQ==} resolution: {integrity: sha512-7m3hNNyswsdoDobCkYNAy5WiUulkMd3+fWaGT9ij6iq3Zr/IwJo4RMCYPSDjT+r7tnPErmY9sZpKhWQ8S5k6XQ==}
dependencies: dependencies:
tslib: 2.3.0 tslib: 2.3.0
/zrender@5.4.4:
resolution: {integrity: sha512-0VxCNJ7AGOMCWeHVyTrGzUgrK4asT4ml9PEkeGirAkKNYXYzoPJCLvmyfdoOXcjTHPs10OZVMfD1Rwg16AZyYw==}
dependencies:
tslib: 2.3.0
dev: false

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

@ -126,7 +126,7 @@ export class DishFormComponent {
} }
}); });
if (this.data["icon"]) { if (this.data["icon"]) {
this.iconPreview = "/icon/" + this.data["icon"]; this.iconPreview = "/api/icon/" + this.data["icon"];
} }
this.formGroup.patchValue({ this.formGroup.patchValue({
...this.data, ...this.data,

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

@ -49,7 +49,7 @@
<ng-container *ngSwitchCase="'icon'"> <ng-container *ngSwitchCase="'icon'">
<div class="dish-img overflow-auto" <div class="dish-img overflow-auto"
*ngIf="data" *ngIf="data"
[ngStyle]="{'background-image':'url(/icon/' + data + ')'}"> [ngStyle]="{'background-image':'url(/api/icon/' + data + ')'}">
</div> </div>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'vender'"> <ng-container *ngSwitchCase="'vender'">

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

@ -110,7 +110,7 @@ export class IngredientFormComponent implements OnInit {
analysis() { analysis() {
this.drawer.create({ this.drawer.create({
nzWidth: 620, nzWidth: 20,
nzWrapClassName: "analysis-drawer", nzWrapClassName: "analysis-drawer",
nzContent: IngredientAnalysisComponent, nzContent: IngredientAnalysisComponent,
nzContentParams: { nzContentParams: {

2
projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts

@ -63,7 +63,7 @@ export class OrganizationFormComponent {
}); });
this.formGroup.patchValue(this.state); this.formGroup.patchValue(this.state);
if (this.state["icon"]) { if (this.state["icon"]) {
this.iconPreview = "/icon/" + this.state["icon"]; this.iconPreview = "/api/icon/" + this.state["icon"];
} }
} }

61
projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html

@ -1,4 +1,4 @@
<app-page> <!-- <app-page>
<div nz-form nzLayout="vertical"> <div nz-form nzLayout="vertical">
<nz-card nzTitle="食物种类及数量标准设置"> <nz-card nzTitle="食物种类及数量标准设置">
@ -195,9 +195,9 @@
</nz-space> </nz-space>
</div> </div>
</div> </div>
</app-page> </app-page> -->
<!-- <app-page> <app-page>
<div nz-form nzLayout="vertical"> <div nz-form nzLayout="vertical">
<ng-template #calcTypeTpl> <ng-template #calcTypeTpl>
@ -207,8 +207,10 @@
</div> </div>
<div *nzSpaceItem> <div *nzSpaceItem>
<nz-radio-group [(ngModel)]="calcType"> <nz-radio-group [(ngModel)]="calcType">
<label nz-radio [nzValue]="''"></label> <label nz-radio [nzValue]="item.key"
<label nz-radio [nzValue]="'g'">[formGroup]="form"</label> *ngFor="let item of globalEnum.measurementType">
{{item.value}}
</label>
</nz-radio-group> </nz-radio-group>
</div> </div>
</nz-space> </nz-space>
@ -229,13 +231,12 @@
<div nz-row [nzGutter]="[48,12]"> <div nz-row [nzGutter]="[48,12]">
<div nz-col nzSpan="24" *ngFor="let d of foodCategoryDay"> <div nz-col nzSpan="24" *ngFor="let d of foodCategoryDay">
<div class="flex items-center"> <div class="flex items-center">
<div class="w-60"> <div class="w-50">
<input nz-input [(ngModel)]="d.name" placeholder="请输入自定义规则名称" />
<input nz-input placeholder="请输入自定义规则名称" />
</div> </div>
<div class="flex-1"> <div class="flex-1 pl-2">
<nz-select nzPlaceHolder="请选择包含食物种类(多选时数量合并计算)" nzMode="multiple" <nz-select nzPlaceHolder="请选择包含食物种类(多选时数量合并计算)" nzMode="multiple"
class="w-full" [(ngModel)]="d.type"> class="w-full" [(ngModel)]="d.category">
<nz-option *ngFor="let cate of globalEnum.category" <nz-option *ngFor="let cate of globalEnum.category"
[nzLabel]="cate.key" [nzLabel]="cate.key"
[nzValue]="cate.value"> [nzValue]="cate.value">
@ -245,16 +246,20 @@
<div class="flex-1 mx-3"> <div class="flex-1 mx-3">
<div class="flex"> <div class="flex">
<div class="flex-1"> <div class="flex-1">
<input type="number" min="0" nz-input [(ngModel)]="d.value" /> <input type="number" min="0" nz-input [(ngModel)]="d.min" />
</div> </div>
<div> <div class="flex items-center justify-center px-2">
~ ~
</div> </div>
<div class="flex-1"> <div class="flex-1">
<input type="number" min="0" nz-input [(ngModel)]="d.value" /> <input type="number" placeholder="不填即不限" min="0" nz-input
[(ngModel)]="d.max" />
</div> </div>
</div> </div>
</div> </div>
<div class="flex items-center justify-center">
{{calcTypeText}}
</div>
<div> <div>
<button nz-button nzType="link" (click)="removeFoodType('day',d.type)"> <button nz-button nzType="link" (click)="removeFoodType('day',d.type)">
<i nz-icon nzType="delete"></i> <i nz-icon nzType="delete"></i>
@ -279,10 +284,14 @@
<div *ngIf="foodCategoryWeek.length > 0"> <div *ngIf="foodCategoryWeek.length > 0">
<div class=""> <div class="">
<div nz-row [nzGutter]="[48,12]"> <div nz-row [nzGutter]="[48,12]">
<div nz-col nzSpan="12" *ngFor="let w of foodCategoryWeek"> <div nz-col nzSpan="24" *ngFor="let w of foodCategoryWeek">
<div class="flex items-center"> <div class="flex items-center">
<div class="w-60"> <div class="w-50">
<nz-select nzPlaceHolder="请选择" class="w-full" [(ngModel)]="w.type"> <input nz-input [(ngModel)]="w.name" placeholder="请输入自定义规则名称" />
</div>
<div class="flex-1 pl-2">
<nz-select nzPlaceHolder="请选择包含食物种类(多选时数量合并计算)" nzMode="multiple"
class="w-full" [(ngModel)]="w.category">
<nz-option *ngFor="let cate of globalEnum.category" <nz-option *ngFor="let cate of globalEnum.category"
[nzLabel]="cate.key" [nzLabel]="cate.key"
[nzValue]="cate.value"> [nzValue]="cate.value">
@ -290,9 +299,21 @@
</nz-select> </nz-select>
</div> </div>
<div class="flex-1 mx-3"> <div class="flex-1 mx-3">
<nz-input-group nzAddOnBefore="大于等于" nzAddOnAfter="种"> <div class="flex">
<input type="number" nz-input [(ngModel)]="w.value" /> <div class="flex-1">
</nz-input-group> <input type="number" min="0" nz-input [(ngModel)]="w.min" />
</div>
<div class="flex items-center justify-center px-2">
~
</div>
<div class="flex-1">
<input type="number" placeholder="不填即不限" min="0" nz-input
[(ngModel)]="w.max" />
</div>
</div>
</div>
<div class="flex items-center justify-center">
{{calcTypeText}}
</div> </div>
<div> <div>
<button nz-button nzType="link" (click)="removeFoodType('week',w.type)"> <button nz-button nzType="link" (click)="removeFoodType('week',w.type)">
@ -421,4 +442,4 @@
</nz-space> </nz-space>
</div> </div>
</div> </div>
</app-page> --> </app-page>

46
projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts

@ -7,8 +7,11 @@ import { FormValidators } from "@cdk/validators";
import { NzMessageService } from "ng-zorro-antd/message"; import { NzMessageService } from "ng-zorro-antd/message";
export type StandardItemInterface = { export type StandardItemInterface = {
min: number;
max: number | null;
name: string;
type: string; type: string;
value: number; category: string[];
}; };
export type StandardPeopleInterface = { export type StandardPeopleInterface = {
@ -47,7 +50,11 @@ export class StandardSettingComponent {
state: any; state: any;
calcType = "种"; calcType = this.globalEnum.measurementType?.[0]?.key;
get calcTypeText() {
return this.globalEnum.measurementType.find((f) => f.key === this.calcType)?.value;
}
uploadLoading = false; uploadLoading = false;
@ -89,20 +96,15 @@ export class StandardSettingComponent {
if (!data) { if (!data) {
return []; return [];
} }
return Object.entries(data).map(([k, v]) => { return data;
return {
type: k,
value: v as number,
};
});
} }
onSubmit() { onSubmit() {
if (this.foodCategoryDay.some((s) => !s.type || !s.value)) { if (this.foodCategoryDay.some((s) => !s.name || typeof s.min !== "number" || s.category.length === 0)) {
this.msg.error("请设置正确的食物种类及数量标准(日)"); this.msg.error("请设置正确的食物种类及数量标准(日)");
return; return;
} }
if (this.foodCategoryWeek.some((s) => !s.type || !s.value)) { if (this.foodCategoryWeek.some((s) => !s.name || typeof s.min !== "number" || s.category.length === 0)) {
this.msg.error("请设置正确的食物种类及数量标准(周)"); this.msg.error("请设置正确的食物种类及数量标准(周)");
return; return;
} }
@ -110,19 +112,9 @@ export class StandardSettingComponent {
this.msg.error("请设置正确的营养标准人群"); this.msg.error("请设置正确的营养标准人群");
return; return;
} }
const foodCategoryDay = this.foodCategoryDay.reduce((a, c) => { const foodCategoryDay = this.foodCategoryDay;
return {
...a,
[c.type]: c.value,
};
}, {} as AnyObject);
const foodCategoryWeek = this.foodCategoryWeek.reduce((a, c) => { const foodCategoryWeek = this.foodCategoryWeek;
return {
...a,
[c.type]: c.value,
};
}, {} as AnyObject);
const ingredient = this.ingredient.reduce((a, c) => { const ingredient = this.ingredient.reduce((a, c) => {
return { return {
@ -149,8 +141,14 @@ export class StandardSettingComponent {
addFoodType(type: string) { addFoodType(type: string) {
const item = type === "day" ? this.foodCategoryDay : this.foodCategoryWeek; const item = type === "day" ? this.foodCategoryDay : this.foodCategoryWeek;
const withoutSelectType = this.globalEnum.category.find((f) => !item.some((s) => s.type === f.key)); // const withoutSelectType = this.globalEnum.category.find((f) => !item.some((s) => s.type === f.key));
item.push({ type: withoutSelectType?.key ?? "", value: 1 }); item.push({
category: [],
min: 0,
max: null,
name: "",
type: this.calcType,
});
} }
removeFoodType(type: string, foodType: string) { removeFoodType(type: string, foodType: string) {

1
projects/cdk/src/dtos/enum.dto.ts

@ -7,6 +7,7 @@ export type GlobalEnum = {
venderType: CategoryDTO[]; venderType: CategoryDTO[];
mealType: OptionItemInterface[]; mealType: OptionItemInterface[];
menuStatus: OptionItemInterface[]; menuStatus: OptionItemInterface[];
measurementType: CategoryDTO[];
poly: { key: string; name: string }[]; poly: { key: string; name: string }[];
}; };

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

@ -4,7 +4,7 @@
天数 天数
</nz-form-label> </nz-form-label>
<nz-form-control nzSpan="12"> <nz-form-control nzSpan="12">
<nz-tag nzColor="cyan">{{data.day}}天</nz-tag> <nz-tag nzColor="cyan" *ngFor="let item of data.day">周{{item}}</nz-tag>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>

156
projects/cdk/src/ingredient/ingredient-analysis/ingredient-analysis.component.html

@ -1,9 +1,7 @@
<nz-tabset> <nz-tabset (nzSelectedIndexChange)="nzSelectedIndexChange($event)">
<nz-tab nzTitle="营养分析"> <nz-tab nzTitle="营养分析">
<div nz-row [nzGutter]="12"> <div nz-row [nzGutter]="12">
<div nz-col nzSpan="8" *ngIf="menu.days.length"> <div nz-col nzSpan="8" *ngIf="menu.days.length">
<nz-select class="w-full" [(ngModel)]="currentDay" (ngModelChange)="getAnalysis()"> <nz-select class="w-full" [(ngModel)]="currentDay" (ngModelChange)="getAnalysis()">
<nz-option *ngFor="let item of menu.days" [nzLabel]="weekdayMap[item]" [nzValue]="item"> <nz-option *ngFor="let item of menu.days" [nzLabel]="weekdayMap[item]" [nzValue]="item">
@ -95,6 +93,15 @@
</div> </div>
</nz-tab> </nz-tab>
<nz-tab nzTitle="食材种类"> <nz-tab nzTitle="食材种类">
<div nz-row [nzGutter]="12">
<div nz-col nzSpan="16">
<nz-select class="w-full" [(ngModel)]="currentPeople" (ngModelChange)="getAnalysis()">
<nz-option *ngFor="let item of menu.crows" [nzLabel]="item" nzValue="{{item}}">
</nz-option>
</nz-select>
</div>
</div>
<ng-container *ngIf="rules"> <ng-container *ngIf="rules">
<h4 class="my-4"> <h4 class="my-4">
周规则 周规则
@ -129,7 +136,24 @@
{{w.supplied}} {{w.supplied}}
</td> </td>
<td> <td>
{{w.lack}} <ng-container>
<ng-container *ngIf="w.lack === 0 else elseTpl">
<div class=" text-green-500">
<span nz-icon nzType="smile" nzTheme="outline"></span>
</div>
</ng-container>
<ng-template #elseTpl>
<ng-container *ngIf="w.lack < 0 else defaultTpl">
<div class=" text-red-500">
超量
</div>
</ng-container>
<ng-template #defaultTpl>
<ng-container>{{w.lack}}</ng-container>
</ng-template>
</ng-template>
</ng-container>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -139,11 +163,13 @@
日规则 日规则
</h4> </h4>
<div> <div>
<div *ngFor="let day of rules.dayRule" class="mb-3"> <div *ngFor="let day of rules.dayRule|keyvalue" class="mb-3">
<nz-table nzTemplateMode nzSize="small" nzBordered> <nz-table nzTemplateMode nzSize="small" nzBordered>
<thead> <thead>
<tr> <tr>
<th [attr.colspan]="2"> <th></th>
<th>
种类名称 种类名称
</th> </th>
<th> <th>
@ -158,9 +184,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let d of day;let first = first"> <tr *ngFor="let d of $any(day.value);let first = first">
<td *ngIf="first" [attr.rowspan]="day.length"> <td *ngIf="first" [attr.rowSpan]="$any(day.value).length">
第{{d.day}}天 周{{d.day}}
</td> </td>
<td> <td>
{{d.name}} {{d.name}}
@ -172,13 +198,123 @@
{{d.supplied}} {{d.supplied}}
</td> </td>
<td> <td>
{{d.lack}} <ng-container>
<ng-container *ngIf="d.lack === 0 else elseTpl">
<div class=" text-green-500">
<span nz-icon nzType="smile" nzTheme="outline"></span>
</div>
</ng-container>
<ng-template #elseTpl>
<ng-container *ngIf="d.lack < 0 else defaultTpl">
<div class=" text-red-500">
超量
</div>
</ng-container>
<ng-template #defaultTpl>
<ng-container>{{d.lack}}</ng-container>
</ng-template>
</ng-template>
</ng-container>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
</div>
</div>
</ng-container>
</nz-tab>
<nz-tab nzTitle="盐油糖趋势">
<div nz-row [nzGutter]="12">
<div nz-col nzSpan="16">
<nz-select class="w-full" [(ngModel)]="currentPeople" (ngModelChange)="getAnalysis()">
<nz-option *ngFor="let item of menu.crows" [nzLabel]="item" nzValue="{{item}}">
</nz-option>
</nz-select>
</div>
</div>
<div class="mt-4">
<p>
人均盐、糖、油摄入量趋势变化
</p>
<div #sugerTpl class=" h-80">
</div>
</div>
</nz-tab>
<nz-tab nzTitle="烹饪方式">
<div nz-row [nzGutter]="12">
<div nz-col nzSpan="16">
<nz-select class="w-full" [(ngModel)]="currentPeople" (ngModelChange)="getAnalysis()">
<nz-option *ngFor="let item of menu.crows" [nzLabel]="item" nzValue="{{item}}">
</nz-option>
</nz-select>
</div> </div>
</div> </div>
<div class="mt-2">
<h4 class="my-4">
总计
</h4>
<div>
<nz-table nzTemplateMode nzSize="small" nzBordered>
<thead>
<tr>
<th>
烹饪方式
</th>
<th>
菜品数量
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let w of poly.total">
<td>
{{w.name}}
</td>
<td>
{{w.value}}
</td>
</tr>
</tbody>
</nz-table>
<h4 class="my-4">
每日统计
</h4>
<div *ngFor="let p of poly.days|keyvalue" class="mb-2">
<nz-table nzTemplateMode nzSize="small" nzBordered>
<thead>
<tr>
<th></th>
<th>
烹饪方式
</th>
<th>
菜品数量
</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let w of $any(p.value);let first = first">
<tr>
<td [attr.rowSpan]="$any(p.value).length" *ngIf="first">
{{weekdayMap[$any(p.key)]}}
</td>
<td>
{{w.name}}
</td>
<td>
{{w.value}}
</td>
</tr>
</ng-container> </ng-container>
</tbody>
</nz-table>
</div>
</div>
</div>
</nz-tab> </nz-tab>
</nz-tabset> </nz-tabset>

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

@ -1,8 +1,15 @@
import { Component, Input, OnInit } from "@angular/core"; import { Component, ElementRef, Input, OnInit, ViewChild } from "@angular/core";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { ApiService } from "@cdk/services"; import { ApiService } from "@cdk/services";
import { finalize } from "rxjs"; import { finalize } from "rxjs";
import { weekdayMap } from "../ingredient-form-basic/ingredient-form-basic.component"; import { weekdayMap } from "../ingredient-form-basic/ingredient-form-basic.component";
import { EChartsType, init } from "echarts";
const sugerMap = new Map([
["salt", "盐"],
["sugar", "糖"],
["oil", "油"],
]);
@Component({ @Component({
selector: "lib-ingredient-analysis", selector: "lib-ingredient-analysis",
@ -16,6 +23,10 @@ export class IngredientAnalysisComponent implements OnInit {
@Input() current: any; @Input() current: any;
@ViewChild("sugerTpl", { static: true }) sugerEl!: ElementRef<HTMLElement>;
sugerRef?: EChartsType;
currentDay: number = 1; currentDay: number = 1;
currentPeople!: string; currentPeople!: string;
@ -28,17 +39,22 @@ export class IngredientAnalysisComponent implements OnInit {
energy: any; energy: any;
poly = {
total: [] as any[],
days: {} as any,
};
suger: any;
analysisLoading = false; analysisLoading = false;
weekdayMap = weekdayMap; weekdayMap = weekdayMap;
ngOnInit(): void { ngOnInit(): void {
console.log("this.current", this.menu);
this.currentDay = this.current?.day ?? this.menu.day[0]; this.currentDay = this.current?.day ?? this.menu.day[0];
this.currentPeople = this.menu.crows[0]; this.currentPeople = this.menu.crows[0];
this.id = this.route.snapshot.queryParamMap.get("newId") ?? this.menu.id; this.id = this.route.snapshot.queryParamMap.get("newId") ?? this.menu.id;
this.getAnalysis(); this.getAnalysis();
this.getRule();
} }
getAnalysis() { getAnalysis() {
@ -56,6 +72,9 @@ export class IngredientAnalysisComponent implements OnInit {
}); });
this.getEnergy(); this.getEnergy();
this.getRule();
this.getSugar();
this.getPoly();
} }
getEnergy() { getEnergy() {
@ -69,4 +88,57 @@ export class IngredientAnalysisComponent implements OnInit {
this.rules = res.body; this.rules = res.body;
}); });
} }
getSugar() {
this.api.getAnalysisSugar(this.id, this.currentPeople).subscribe((res) => {
this.suger = res.body;
});
}
getPoly() {
this.api.getAnalysisPoly(this.id, this.currentPeople).subscribe((res) => {
const poly = {
total: [] as any[],
days: {} as any,
};
Object.entries(res.body).forEach(([k, v]) => {
if (k === "0") {
poly.total = Object.entries(v as any).map((o) => ({ name: o[0], value: o[1] }));
} else if (k !== "crow") {
poly.days[k] = Object.entries(v as any).map((o) => ({ name: o[0], value: o[1] }));
}
});
this.poly = poly;
});
}
nzSelectedIndexChange(d: any) {
if (d === 2) {
const xAxis: string[] = Object.keys(this.suger["oil"]).map((i: any) => weekdayMap[i]);
const series: any[] = [];
Object.entries(this.suger).forEach(([k, v]) => {
if (k !== "crow") {
series.push({
type: "line",
name: sugerMap.get(k),
data: Object.values(v as any),
});
}
});
const option = {
legend: {},
tooltip: { trigger: "axis" },
xAxis: { type: "category", data: xAxis },
yAxis: {},
series,
};
if (!this.sugerRef) {
this.sugerRef = init(this.sugerEl.nativeElement);
}
this.sugerRef.setOption(option);
}
}
} }

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

@ -111,7 +111,7 @@ export class IngredientDishComponent implements OnChanges {
const d = weekdayMap[i]; const d = weekdayMap[i];
this.selectDay.push({ this.selectDay.push({
label: d, label: d,
value: String(d), value: String(i),
}); });
this.mealCurrentIndex[i] = 0; this.mealCurrentIndex[i] = 0;
this.expanded.add(i); this.expanded.add(i);
@ -144,7 +144,7 @@ export class IngredientDishComponent implements OnChanges {
reuse(day: number, nzContent: TemplateRef<{}>) { reuse(day: number, nzContent: TemplateRef<{}>) {
const thisDayDishs = this.mealDishList.filter((f) => f.day === day); const thisDayDishs = this.mealDishList.filter((f) => f.day === day);
console.log("dayDishs", day, this.mealDishList, thisDayDishs); console.log("dayDishs", day, this.mealDishList, thisDayDishs, this.selectDay);
this.modal.create({ this.modal.create({
nzTitle: "请选择应用到的日期", nzTitle: "请选择应用到的日期",
nzContent, nzContent,
@ -166,7 +166,7 @@ export class IngredientDishComponent implements OnChanges {
analysis(day: number) { analysis(day: number) {
console.log("this.days", this.days); console.log("this.days", this.days);
this.drawer.create({ this.drawer.create({
nzWidth: 620, nzWidth: 720,
nzWrapClassName: "analysis-drawer", nzWrapClassName: "analysis-drawer",
nzContent: IngredientAnalysisComponent, nzContent: IngredientAnalysisComponent,
nzContentParams: { nzContentParams: {

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

@ -140,7 +140,7 @@ export class IngredientPreviewComponent {
analysis(day: number) { analysis(day: number) {
this.drawer.create({ this.drawer.create({
nzWidth: 620, nzWidth: 720,
nzWrapClassName: "analysis-drawer", nzWrapClassName: "analysis-drawer",
nzContent: IngredientAnalysisComponent, nzContent: IngredientAnalysisComponent,
nzContentParams: { nzContentParams: {

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

@ -556,6 +556,17 @@ export class ApiService {
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}`);
} }
getAnalysisSugar(id: string, crow?: string) {
const params = Utils.objectStringify({ id, crow });
return this.http.get<ResponseType>(`/api/menu/analysis/sugar?${params}`);
}
getAnalysisPoly(id: string, crow?: string) {
const params = Utils.objectStringify({ id, crow });
return this.http.get<ResponseType>(`/api/menu/analysis/poly?${params}`);
}
getAnalysisRule(id: string, 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}`);

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

@ -125,7 +125,7 @@ export class DishFormComponent {
mark: this.data.marks, mark: this.data.marks,
}); });
if (this.data["icon"]) { if (this.data["icon"]) {
this.iconPreview = "/icon/" + this.data["icon"]; this.iconPreview = "/api/icon/" + this.data["icon"];
} }
} }
} }

2
projects/client/src/app/components/org-form/org-form.component.ts

@ -48,7 +48,7 @@ export class OrgFormComponent {
}); });
this.formGroup.patchValue(this.state); this.formGroup.patchValue(this.state);
if (this.state["icon"]) { if (this.state["icon"]) {
this.iconPreview = "/icon/" + this.state["icon"]; this.iconPreview = "/api/icon/" + this.state["icon"];
} }
} }

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

@ -91,7 +91,7 @@
</p> </p>
<ul class="ul"> <ul class="ul">
<li> <li>
点击右上角[食预览]完成查看食谱全貌 点击右上角[食预览]完成查看食谱全貌
</li> </li>
<li> <li>
确认食谱应用分析结果 确认食谱应用分析结果

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

@ -1,7 +1,7 @@
<div class="body flex flex-col"> <div class="body flex flex-col">
<div class="head clearfix"> <div class="head clearfix">
<div class="logo"> <div class="logo">
<img *ngIf="logo" [attr.src]="'/icon/' + logo" /> <img *ngIf="logo" [attr.src]="'/api/icon/' + logo" />
</div> </div>
<h1 class="title">{{orgName}}食谱营养报告</h1> <h1 class="title">{{orgName}}食谱营养报告</h1>
<div class="time">{{showTime}}</div> <div class="time">{{showTime}}</div>

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

@ -60,7 +60,7 @@
<ng-container *ngSwitchCase="'icon'"> <ng-container *ngSwitchCase="'icon'">
<div class="dish-img overflow-auto" <div class="dish-img overflow-auto"
*ngIf="data" *ngIf="data"
[ngStyle]="{'background-image':'url(/icon/' + data + ')'}"> [ngStyle]="{'background-image':'url(/api/icon/' + data + ')'}">
</div> </div>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'vender'"> <ng-container *ngSwitchCase="'vender'">

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

@ -108,7 +108,7 @@ export class IngredientFormComponent implements OnInit {
analysis() { analysis() {
this.drawer.create({ this.drawer.create({
nzWidth: 620, nzWidth: 720,
nzWrapClassName: "analysis-drawer", nzWrapClassName: "analysis-drawer",
nzContent: IngredientAnalysisComponent, nzContent: IngredientAnalysisComponent,
nzContentParams: { nzContentParams: {

2
projects/client/src/app/pages/system/org-info/org-info.component.html

@ -25,7 +25,7 @@
</nz-form-label> </nz-form-label>
<nz-form-control> <nz-form-control>
<div class="w-20 h-20" *ngIf="org.icon"> <div class="w-20 h-20" *ngIf="org.icon">
<img [src]="'/icon/' + org.icon" class=" w-full h-full" /> <img [src]="'/api/icon/' + org.icon" class=" w-full h-full" />
</div> </div>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>

Loading…
Cancel
Save