28 changed files with 2629 additions and 2619 deletions
@ -1,16 +0,0 @@ |
|||
# Editor configuration, see https://editorconfig.org |
|||
root = true |
|||
|
|||
[*] |
|||
charset = utf-8 |
|||
indent_style = space |
|||
indent_size = 2 |
|||
insert_final_newline = true |
|||
trim_trailing_whitespace = true |
|||
|
|||
[*.ts] |
|||
quote_type = single |
|||
|
|||
[*.md] |
|||
max_line_length = off |
|||
trim_trailing_whitespace = false |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"singleQuote": true, |
|||
"trailingComma": "all", |
|||
"useTabs": true, |
|||
"tabWidth": 4, |
|||
"semi": false, |
|||
"printWidth": 120 |
|||
} |
|||
@ -1,140 +1,128 @@ |
|||
<app-page> |
|||
<ng-template #pageExtraTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length" (click)="deleteItem()">批量删除</button> |
|||
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length" |
|||
(click)="printTag()">批量打印营养标签</button> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="showFoodForm()"> |
|||
<i nz-icon nzType="plus"></i> |
|||
新增菜品 |
|||
</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="h-full overflow-hidden bg-white rounded-lg"> |
|||
<ng-template #pageExtraTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length" (click)="deleteItem()">批量删除</button> |
|||
<button *nzSpaceItem nz-button [disabled]="!selectedIds.length" (click)="printTag()"> |
|||
批量打印营养标签 |
|||
</button> |
|||
<button *nzSpaceItem nz-button nzType="primary" (click)="showFoodForm()"> |
|||
<i nz-icon nzType="plus"></i> |
|||
新增菜品 |
|||
</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
<div class="h-full overflow-hidden bg-white rounded-lg"> |
|||
<nz-card [nzBordered]="false" nzTitle="菜品管理"> |
|||
<table-list |
|||
[props]="tableList" |
|||
[search]="searchTpl" |
|||
[action]="pageExtraTpl" |
|||
[formGroup]="queryForm" |
|||
[renderColumns]="renderColumnsTpl" |
|||
> |
|||
<ng-template #searchTpl> |
|||
<nz-form-item class="w-60"> |
|||
<nz-form-control> |
|||
<nz-select nzPlaceHolder="请选择单位" formControlName="vendors"> |
|||
<nz-option |
|||
*ngFor="let o of listOfOption" |
|||
[nzLabel]="o.text" |
|||
[nzValue]="o.value" |
|||
></nz-option> |
|||
</nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item class="w-40"> |
|||
<nz-form-control> |
|||
<nz-select nzPlaceHolder="菜品标签" formControlName="mark" nzAllowClear> |
|||
<nz-option |
|||
*ngFor="let item of globalEnum.mark" |
|||
[nzLabel]="item.key" |
|||
[nzValue]="item.key" |
|||
> |
|||
</nz-option> |
|||
</nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-card [nzBordered]="false" nzTitle="菜品管理"> |
|||
<table-list [props]="tableList" [search]="searchTpl" [action]="pageExtraTpl" [formGroup]="queryForm" |
|||
[renderColumns]="renderColumnsTpl"> |
|||
|
|||
|
|||
<ng-template #searchTpl> |
|||
<nz-form-item class="w-60"> |
|||
<nz-form-control> |
|||
<nz-select |
|||
nzPlaceHolder="请选择单位" |
|||
formControlName="vendors"> |
|||
<nz-option *ngFor="let o of listOfOption" [nzLabel]="o.text" |
|||
[nzValue]="o.value"></nz-option> |
|||
</nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item class="w-40"> |
|||
<nz-form-control> |
|||
<nz-select nzPlaceHolder="菜品标签" formControlName="mark" nzAllowClear> |
|||
<nz-option *ngFor="let item of globalEnum.mark" [nzLabel]="item.key" |
|||
[nzValue]="item.key"> |
|||
</nz-option> |
|||
</nz-select> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-form-item> |
|||
<nz-form-control> |
|||
<input nz-input placeholder="请输入菜品名称" formControlName="keyword" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</ng-template> |
|||
<ng-template #renderColumnsTpl let-data let-key="key" let-row="row"> |
|||
<ng-container [ngSwitch]="key"> |
|||
<ng-container *ngSwitchCase="'icon'"> |
|||
<div class="dish-img overflow-auto" |
|||
*ngIf="data" |
|||
[ngStyle]="{'background-image':'url(/api/icon/' + data + ')'}"> |
|||
</div> |
|||
</ng-container> |
|||
<ng-container *ngSwitchCase="'vender'"> |
|||
{{ tableOrg[data] ? tableOrg[data].name : '-'}} |
|||
</ng-container> |
|||
<ng-container *ngSwitchCase="'ingredient'"> |
|||
<div class=" flex flex-wrap"> |
|||
<ng-container *ngFor="let item of data"> |
|||
<nz-tag *ngIf="tableFoods[item.key]" class="m-1"> |
|||
{{tableFoods[item.key]['name']}}:{{item.value}} g |
|||
</nz-tag> |
|||
</ng-container> |
|||
</div> |
|||
</ng-container> |
|||
<ng-container *ngSwitchDefault> |
|||
{{data}} |
|||
</ng-container> |
|||
</ng-container> |
|||
</ng-template> |
|||
</table-list> |
|||
</nz-card> |
|||
</div> |
|||
<nz-form-item> |
|||
<nz-form-control> |
|||
<input nz-input placeholder="请输入菜品名称" formControlName="keyword" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</ng-template> |
|||
<ng-template #renderColumnsTpl let-data let-key="key" let-row="row"> |
|||
<ng-container [ngSwitch]="key"> |
|||
<ng-container *ngSwitchCase="'icon'"> |
|||
<div |
|||
class="dish-img overflow-auto" |
|||
*ngIf="data" |
|||
[ngStyle]="{ 'background-image': 'url(/api/icon/' + data + ')' }" |
|||
></div> |
|||
</ng-container> |
|||
<ng-container *ngSwitchCase="'vender'"> |
|||
{{ tableOrg[data] ? tableOrg[data].name : '-' }} |
|||
</ng-container> |
|||
<ng-container *ngSwitchCase="'label'"> |
|||
<nz-tag *ngFor="let item of data ?? []"> |
|||
{{ item }} |
|||
</nz-tag> |
|||
</ng-container> |
|||
<ng-container *ngSwitchCase="'ingredient'"> |
|||
<div class="flex flex-wrap"> |
|||
<ng-container *ngFor="let item of data"> |
|||
<nz-tag *ngIf="tableFoods[item.key]" class="m-1"> |
|||
{{ tableFoods[item.key]['name'] }}:{{ item.value }} g |
|||
</nz-tag> |
|||
</ng-container> |
|||
</div> |
|||
</ng-container> |
|||
<ng-container *ngSwitchDefault> |
|||
{{ data }} |
|||
</ng-container> |
|||
</ng-container> |
|||
</ng-template> |
|||
</table-list> |
|||
</nz-card> |
|||
</div> |
|||
</app-page> |
|||
|
|||
|
|||
<ng-template #formFooterTpl> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button (click)="cancelForm()" type="button"> |
|||
取消 |
|||
</button> |
|||
<button *nzSpaceItem nz-button nzType="primary" [nzLoading]="submitLoading" (click)="onSubmit()"> |
|||
保存 |
|||
</button> |
|||
</nz-space> |
|||
<nz-space> |
|||
<button *nzSpaceItem nz-button (click)="cancelForm()" type="button">取消</button> |
|||
<button *nzSpaceItem nz-button nzType="primary" [nzLoading]="submitLoading" (click)="onSubmit()">保存</button> |
|||
</nz-space> |
|||
</ng-template> |
|||
|
|||
|
|||
<app-print #print |
|||
[content]="printContent"> |
|||
</app-print> |
|||
|
|||
<app-print #print [content]="printContent"> </app-print> |
|||
|
|||
<ng-template #printContent> |
|||
|
|||
<div class="printContent" |
|||
*ngFor="let item of printData"> |
|||
|
|||
<table class="print-table"> |
|||
<tbody> |
|||
<tr> |
|||
<th colspan="3"> |
|||
{{item.name}} |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th colspan="3"> |
|||
营养成分表 |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th class="text-left"> |
|||
名称 |
|||
</th> |
|||
<th class="text-center"> |
|||
每100克(g) |
|||
</th> |
|||
<th class="text-center"> |
|||
营养参考值%(NVR%) |
|||
</th> |
|||
</tr> |
|||
</tbody> |
|||
<tbody> |
|||
<tr *ngFor="let th of item.component"> |
|||
<td [width]="'38.2%'">{{ th.name }}</td> |
|||
<td class="text-center">{{ th.nutrition }}</td> |
|||
<td class="text-center">{{ th.nvr }}</td> |
|||
</tr> |
|||
|
|||
</tbody> |
|||
</table> |
|||
<div> |
|||
主要原料:{{item.ingredients.join(',')}} |
|||
</div> |
|||
<div> |
|||
1毫克(mg)钠相当于2.5毫克食盐 |
|||
</div> |
|||
</div> |
|||
<div class="printContent" *ngFor="let item of printData"> |
|||
<table class="print-table"> |
|||
<tbody> |
|||
<tr> |
|||
<th colspan="3"> |
|||
{{ item.name }} |
|||
</th> |
|||
</tr> |
|||
<tr> |
|||
<th colspan="3">营养成分表</th> |
|||
</tr> |
|||
<tr> |
|||
<th class="text-left">名称</th> |
|||
<th class="text-center">每100克(g)</th> |
|||
<th class="text-center">营养参考值%(NVR%)</th> |
|||
</tr> |
|||
</tbody> |
|||
<tbody> |
|||
<tr *ngFor="let th of item.component"> |
|||
<td [width]="'38.2%'">{{ th.name }}</td> |
|||
<td class="text-center">{{ th.nutrition }}</td> |
|||
<td class="text-center">{{ th.nvr }}</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
<div>主要原料:{{ item.ingredients.join(',') }}</div> |
|||
<div>1毫克(mg)钠相当于2.5毫克食盐</div> |
|||
</div> |
|||
</ng-template> |
|||
@ -1,93 +1,97 @@ |
|||
import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core"; |
|||
import { FormControl, FormGroup } from "@angular/forms"; |
|||
import { NzDrawerRef, NzDrawerService } from "ng-zorro-antd/drawer"; |
|||
import { AnyObject, TableListOption } from "@cdk/public-api"; |
|||
import { DishFormComponent } from "@admin/app/components"; |
|||
import { ApiService } from "@cdk/services"; |
|||
import { NzModalService } from "ng-zorro-antd/modal"; |
|||
import { lastValueFrom } from "rxjs"; |
|||
import { NzMessageService } from "ng-zorro-antd/message"; |
|||
import { Router } from "@angular/router"; |
|||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' |
|||
import { FormControl, FormGroup } from '@angular/forms' |
|||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' |
|||
import { AnyObject, TableListOption } from '@cdk/public-api' |
|||
import { DishFormComponent } from '@admin/app/components' |
|||
import { ApiService } from '@cdk/services' |
|||
import { NzModalService } from 'ng-zorro-antd/modal' |
|||
import { lastValueFrom } from 'rxjs' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { Router } from '@angular/router' |
|||
import { StandardService } from '../standard.service' |
|||
|
|||
@Component({ |
|||
selector: "app-standard-list", |
|||
templateUrl: "./standard-list.component.html", |
|||
styleUrls: ["./standard-list.component.less"], |
|||
selector: 'app-standard-list', |
|||
templateUrl: './standard-list.component.html', |
|||
styleUrls: ['./standard-list.component.less'], |
|||
}) |
|||
export class StandardListComponent { |
|||
constructor( |
|||
private api: ApiService, |
|||
private modal: NzModalService, |
|||
private msg: NzMessageService, |
|||
private router: Router |
|||
private router: Router, |
|||
private standard: StandardService, |
|||
) {} |
|||
|
|||
public tableList = new TableListOption(this.fetchData.bind(this), { |
|||
frontPagination: false, |
|||
}); |
|||
}) |
|||
|
|||
public queryForm = new FormGroup({ |
|||
keyword: new FormControl(""), |
|||
}); |
|||
keyword: new FormControl(''), |
|||
}) |
|||
|
|||
ngOnInit(): void { |
|||
this.initTableList(); |
|||
this.initTableList() |
|||
} |
|||
|
|||
initTableList() { |
|||
this.tableList.scroll = { x: null }; |
|||
this.tableList.scroll = { x: null } |
|||
this.tableList = this.tableList.setColumns([ |
|||
{ key: "name", title: "营养标准名称" }, |
|||
{ key: "people", title: "人群细分" }, |
|||
{ key: "vendors", title: "适用单位" }, |
|||
{ key: "modify", title: "更新时间" }, |
|||
]); |
|||
{ key: 'name', title: '营养标准名称' }, |
|||
{ key: 'people', title: '人群细分' }, |
|||
{ key: 'vendors', title: '适用单位' }, |
|||
{ key: 'modify', title: '更新时间' }, |
|||
]) |
|||
|
|||
this.tableList = this.tableList.setOptions([ |
|||
{ |
|||
title: "标准设置", |
|||
title: '标准设置', |
|||
premissions: [], |
|||
onClick: this.toSetting.bind(this), |
|||
}, |
|||
{ |
|||
title: "编辑", |
|||
title: '编辑', |
|||
premissions: [], |
|||
onClick: this.toEdit.bind(this), |
|||
}, |
|||
{ |
|||
title: "删除", |
|||
title: '删除', |
|||
premissions: [], |
|||
onClick: this.deleteItem.bind(this), |
|||
}, |
|||
]); |
|||
]) |
|||
} |
|||
|
|||
fetchData(query: AnyObject, pager: AnyObject) { |
|||
return this.api.getStandardPage(pager, query); |
|||
return this.api.getStandardPage(pager, query) |
|||
} |
|||
|
|||
toEdit(d: AnyObject) { |
|||
this.router.navigate([`/standard/form/${d["id"]}`], { |
|||
// this.standard.settingData$.next(d)
|
|||
this.router.navigate([`/standard/form/${d['id']}`], { |
|||
state: d, |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
toSetting(d: AnyObject) { |
|||
this.router.navigate([`/standard/setting/${d["id"]}`], { |
|||
// this.standard.settingData$.next(d)
|
|||
this.router.navigate([`/standard/setting/${d['id']}`], { |
|||
state: d, |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
deleteItem(v: any) { |
|||
this.modal.confirm({ |
|||
nzTitle: "警告", |
|||
nzTitle: '警告', |
|||
nzContent: `是否要删除该营养标准?`, |
|||
nzOkDanger: true, |
|||
nzOnOk: async () => { |
|||
const res = await lastValueFrom(this.api.deleteStandard(v.id)); |
|||
this.msg.success(res.desc); |
|||
this.tableList.run(); |
|||
const res = await lastValueFrom(this.api.deleteStandard(v.id)) |
|||
this.msg.success(res.desc) |
|||
this.tableList.run() |
|||
}, |
|||
}); |
|||
}) |
|||
} |
|||
} |
|||
|
|||
@ -1,204 +1,283 @@ |
|||
import { Component } from "@angular/core"; |
|||
import { FormBuilder, FormGroup } from "@angular/forms"; |
|||
import { ActivatedRoute, Router } from "@angular/router"; |
|||
import { ApiService } from "@cdk/services"; |
|||
import { AnyObject } from "@cdk/types"; |
|||
import { FormValidators } from "@cdk/validators"; |
|||
import { NzMessageService } from "ng-zorro-antd/message"; |
|||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core' |
|||
import { FormBuilder, FormGroup } from '@angular/forms' |
|||
import { ActivatedRoute, Router } from '@angular/router' |
|||
import { ApiService } from '@cdk/services' |
|||
import { AnyObject } from '@cdk/types' |
|||
import { FormValidators } from '@cdk/validators' |
|||
import { NzMessageService } from 'ng-zorro-antd/message' |
|||
import { StandardService } from '../standard.service' |
|||
import { Observable, Subscription } from 'rxjs' |
|||
|
|||
// infer
|
|||
|
|||
export type StandardItemInterface = { |
|||
min: number; |
|||
max: number | null; |
|||
name: string; |
|||
type: string; |
|||
category: string[]; |
|||
}; |
|||
min: number |
|||
max: number | null |
|||
name: string |
|||
type: string |
|||
category: string[] |
|||
} |
|||
|
|||
export type StandardPeopleInterface = { |
|||
ul?: number; |
|||
hasUl: boolean; |
|||
max: number; |
|||
min: number; |
|||
nutrition: string; |
|||
}; |
|||
ul?: number |
|||
hasUl: boolean |
|||
max: number |
|||
min: number |
|||
nutrition: string |
|||
} |
|||
|
|||
@Component({ |
|||
selector: "app-standard-setting", |
|||
templateUrl: "./standard-setting.component.html", |
|||
styleUrls: ["./standard-setting.component.less"], |
|||
selector: 'app-standard-setting', |
|||
templateUrl: './standard-setting.component.html', |
|||
styleUrls: ['./standard-setting.component.less'], |
|||
}) |
|||
export class StandardSettingComponent { |
|||
export class StandardSettingComponent implements AfterViewInit, OnDestroy { |
|||
constructor( |
|||
private fb: FormBuilder, |
|||
private router: Router, |
|||
private route: ActivatedRoute, |
|||
private api: ApiService, |
|||
private msg: NzMessageService |
|||
private msg: NzMessageService, |
|||
private standard: StandardService, |
|||
) { |
|||
const id = this.route.snapshot.paramMap.get("id"); |
|||
if (id !== "create") { |
|||
const data = this.router.getCurrentNavigation()?.extras; |
|||
const id = this.route.snapshot.paramMap.get('id') |
|||
if (id !== 'create') { |
|||
const data = this.router.getCurrentNavigation()?.extras |
|||
if (data) { |
|||
this.state = data.state; |
|||
this.state = data.state |
|||
} else { |
|||
this.router.navigate(["/standard/list"]); |
|||
this.router.navigate(['/standard/list']) |
|||
} |
|||
} |
|||
} |
|||
|
|||
public globalEnum = this.api.globalEnum; |
|||
public globalEnum = this.api.globalEnum |
|||
|
|||
state: any; |
|||
state: any |
|||
|
|||
calcType = this.globalEnum.measurementType?.[0]?.key; |
|||
calcType = this.globalEnum.measurementType?.[0]?.key |
|||
|
|||
get calcTypeText() { |
|||
return this.globalEnum.measurementType.find((f) => f.key === this.calcType)?.value; |
|||
return this.globalEnum.measurementType.find((f) => f.key === this.calcType)?.value |
|||
} |
|||
|
|||
uploadLoading = false; |
|||
uploadLoading = false |
|||
|
|||
foodCategoryDay: StandardItemInterface[] = [] |
|||
|
|||
foodCategoryDay: StandardItemInterface[] = []; |
|||
foodCategoryWeek: StandardItemInterface[] = [] |
|||
|
|||
foodCategoryWeek: StandardItemInterface[] = []; |
|||
ingredient: { name: string; nutritions: StandardPeopleInterface[] }[] = [] |
|||
|
|||
ingredient: { name: string; nutritions: StandardPeopleInterface[] }[] = []; |
|||
intersection$ = new Subscription() |
|||
|
|||
renderIngredient = false |
|||
|
|||
expanded = new Set<number>() |
|||
|
|||
@ViewChild('intersectionTpl') intersectionTpl!: ElementRef<HTMLDivElement> |
|||
|
|||
ngOnInit(): void { |
|||
this.foodCategoryDay = this.parseFoodCategory(this.state?.foodCategoryDay); |
|||
this.foodCategoryWeek = this.parseFoodCategory(this.state?.foodCategoryWeek); |
|||
this.ingredient = this.parseIngredient(this.state?.ingredient); |
|||
this.foodCategoryDay = this.parseFoodCategory(this.state?.foodCategoryDay) |
|||
this.foodCategoryWeek = this.parseFoodCategory(this.state?.foodCategoryWeek) |
|||
|
|||
this.ingredient = this.parseIngredient(this.state) |
|||
} |
|||
|
|||
ngOnDestroy(): void { |
|||
// this.intersection$.unsubscribe()
|
|||
} |
|||
|
|||
ngAfterViewInit(): void { |
|||
// const el = this.intersectionTpl.nativeElement
|
|||
// if (el) {
|
|||
// this.intersection$.add(
|
|||
// this.observeElement(el).subscribe((isIn) => {
|
|||
// if (isIn) {
|
|||
// this.renderIngredient = true
|
|||
// this.intersection$.unsubscribe()
|
|||
// }
|
|||
// }),
|
|||
// )
|
|||
// }
|
|||
} |
|||
|
|||
observeElement = (element: HTMLElement) => { |
|||
return new Observable((observer) => { |
|||
const intersectionObserver = new IntersectionObserver((entries) => { |
|||
entries.forEach((entry) => { |
|||
observer.next(entry.isIntersecting) |
|||
}) |
|||
}) |
|||
|
|||
intersectionObserver.observe(element) |
|||
|
|||
return () => { |
|||
intersectionObserver.disconnect() |
|||
} |
|||
}) |
|||
} |
|||
|
|||
parseIngredient(data: any): { name: string; nutritions: StandardPeopleInterface[] }[] { |
|||
if (!data) { |
|||
return []; |
|||
if (!data?.ingredient) { |
|||
return [] |
|||
} |
|||
return Object.entries(data).map(([k, v]) => { |
|||
console.log('data', data) |
|||
const sorts = data.crows ?? Object.keys(data.ingredient) |
|||
return sorts.map((peopleName: string) => { |
|||
const v: any = data.ingredient[peopleName] |
|||
return { |
|||
name: k, |
|||
name: peopleName, |
|||
nutritions: !v |
|||
? [] |
|||
: Object.entries(v).map(([kn, vn]) => { |
|||
: Object.entries(v).map(([kn, vn]: [string, any]) => { |
|||
return { |
|||
ul: vn?.ul ?? void 0, |
|||
hasUl: !!vn?.ul, |
|||
max: vn?.max ?? 0, |
|||
min: vn?.min ?? 0, |
|||
nutrition: kn, |
|||
}; |
|||
} |
|||
}), |
|||
}; |
|||
}); |
|||
} |
|||
}) |
|||
} |
|||
|
|||
parseFoodCategory(data: any): StandardItemInterface[] { |
|||
if (!data) { |
|||
return []; |
|||
return [] |
|||
} |
|||
if (Array.isArray(data) && data.length > 0) { |
|||
this.calcType = data[0]?.type; |
|||
this.calcType = data[0]?.type |
|||
} |
|||
return data; |
|||
return data |
|||
} |
|||
|
|||
onSubmit() { |
|||
if (this.foodCategoryDay.some((s) => !s.name || typeof s.min !== "number" || s.category.length === 0)) { |
|||
this.msg.error("请设置正确的食物种类及数量标准(日)"); |
|||
return; |
|||
if (this.foodCategoryDay.some((s) => !s.name || typeof s.min !== 'number' || s.category.length === 0)) { |
|||
this.msg.error('请设置正确的食物种类及数量标准(日)') |
|||
return |
|||
} |
|||
if (this.foodCategoryWeek.some((s) => !s.name || typeof s.min !== "number" || s.category.length === 0)) { |
|||
this.msg.error("请设置正确的食物种类及数量标准(周)"); |
|||
return; |
|||
if (this.foodCategoryWeek.some((s) => !s.name || typeof s.min !== 'number' || s.category.length === 0)) { |
|||
this.msg.error('请设置正确的食物种类及数量标准(周)') |
|||
return |
|||
} |
|||
if (this.ingredient.some((s) => !s.name || !s.nutritions.some((sn) => sn.nutrition))) { |
|||
this.msg.error("请设置正确的营养标准人群"); |
|||
return; |
|||
this.msg.error('请设置正确的营养标准人群') |
|||
return |
|||
} |
|||
const foodCategoryDay = this.foodCategoryDay; |
|||
|
|||
const foodCategoryWeek = this.foodCategoryWeek; |
|||
const foodCategoryDay = this.foodCategoryDay |
|||
|
|||
const ingredient = this.ingredient.reduce((a, c) => { |
|||
const foodCategoryWeek = this.foodCategoryWeek |
|||
let crows: string = '' |
|||
const ingredient = this.ingredient.reduce((a, c, idx) => { |
|||
const crowsName = (idx === 0 ? '' : ',') + c.name |
|||
crows += crowsName |
|||
return { |
|||
...a, |
|||
[c.name]: c.nutritions.reduce((an, cn) => { |
|||
const ul = { ul: cn.hasUl ? cn.ul : void 0 }; |
|||
const ul = { ul: cn.hasUl ? cn.ul : void 0 } |
|||
return { |
|||
...an, |
|||
// idx,
|
|||
[cn.nutrition]: { |
|||
min: cn.min, |
|||
max: cn.max, |
|||
...ul, |
|||
}, |
|||
}; |
|||
} |
|||
}, {} as AnyObject), |
|||
}; |
|||
}, {} as AnyObject); |
|||
} |
|||
}, {} as AnyObject) |
|||
|
|||
this.api.saveStandard({ ...this.state, foodCategoryDay, foodCategoryWeek, ingredient }, true).subscribe((res) => { |
|||
this.msg.success(res.desc); |
|||
this.router.navigate(["/standard/list"]); |
|||
}); |
|||
this.api |
|||
.saveStandard({ ...this.state, foodCategoryDay, foodCategoryWeek, ingredient, crows }, true) |
|||
.subscribe((res) => { |
|||
this.msg.success(res.desc) |
|||
this.router.navigate(['/standard/list']) |
|||
}) |
|||
} |
|||
|
|||
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));
|
|||
item.push({ |
|||
category: [], |
|||
min: 0, |
|||
max: null, |
|||
name: "", |
|||
name: '', |
|||
type: this.calcType, |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
removeFoodType(type: string, idx: number) { |
|||
if (type === "day") { |
|||
this.foodCategoryDay = this.foodCategoryDay.filter((f, i) => idx !== i); |
|||
if (type === 'day') { |
|||
this.foodCategoryDay = this.foodCategoryDay.filter((f, i) => idx !== i) |
|||
} else { |
|||
this.foodCategoryWeek = this.foodCategoryWeek.filter((f, i) => idx !== i); |
|||
this.foodCategoryWeek = this.foodCategoryWeek.filter((f, i) => idx !== i) |
|||
} |
|||
} |
|||
|
|||
addPeopleGroup() { |
|||
this.ingredient.push({ |
|||
name: "", |
|||
name: '', |
|||
nutritions: [], |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
removePeopleGroup(idx: number) { |
|||
this.ingredient = this.ingredient.filter((_, i) => i !== idx); |
|||
this.ingredient = this.ingredient.filter((_, i) => i !== idx) |
|||
} |
|||
|
|||
calcTypeChange() { |
|||
console.log("this.calcType", this.calcType); |
|||
this.foodCategoryDay = this.foodCategoryDay.map((i) => ({ ...i, type: this.calcType })); |
|||
this.foodCategoryWeek = this.foodCategoryWeek.map((i) => ({ ...i, type: this.calcType })); |
|||
console.log('this.calcType', this.calcType) |
|||
this.foodCategoryDay = this.foodCategoryDay.map((i) => ({ ...i, type: this.calcType })) |
|||
this.foodCategoryWeek = this.foodCategoryWeek.map((i) => ({ ...i, type: this.calcType })) |
|||
} |
|||
|
|||
moveUp(idx: number) { |
|||
const arr = this.ingredient |
|||
if (idx > 0 && idx < arr.length) { |
|||
;[arr[idx], arr[idx - 1]] = [arr[idx - 1], arr[idx]] |
|||
} |
|||
} |
|||
|
|||
moveDown(idx: number) { |
|||
const arr = this.ingredient |
|||
if (idx >= 0 && idx < arr.length - 1) { |
|||
;[arr[idx], arr[idx + 1]] = [arr[idx + 1], arr[idx]] |
|||
} |
|||
} |
|||
|
|||
expand(idx: number) { |
|||
if (this.expanded.has(idx)) { |
|||
this.expanded.delete(idx) |
|||
} else { |
|||
this.expanded.add(idx) |
|||
} |
|||
} |
|||
|
|||
addNutrition(idx: number) { |
|||
const current = this.ingredient[idx]; |
|||
const current = this.ingredient[idx] |
|||
this.expanded.add(idx) |
|||
const withoutSelectNutritions = this.globalEnum.nutrient.find( |
|||
(f) => !current.nutritions.some((s) => s.nutrition === f.key) |
|||
); |
|||
(f) => !current.nutritions.some((s) => s.nutrition === f.key), |
|||
) |
|||
current.nutritions.push({ |
|||
nutrition: withoutSelectNutritions?.key ?? "", |
|||
nutrition: withoutSelectNutritions?.key ?? '', |
|||
min: 0, |
|||
max: 0, |
|||
hasUl: false, |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
removeNutrition(idx: number, nutrition: string) { |
|||
this.ingredient[idx].nutritions = this.ingredient[idx].nutritions.filter((f) => f.nutrition !== nutrition); |
|||
this.ingredient[idx].nutritions = this.ingredient[idx].nutritions.filter((f) => f.nutrition !== nutrition) |
|||
} |
|||
|
|||
ulChange(idx: number, nutrition: string, checked: boolean) { |
|||
this.ingredient[idx].nutritions = this.ingredient[idx].nutritions.map((i) => { |
|||
return i.nutrition === nutrition ? { ...i, ul: checked ? 1 : void 0 } : i; |
|||
}); |
|||
return i.nutrition === nutrition ? { ...i, ul: checked ? 1 : void 0 } : i |
|||
}) |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
import { Injectable } from '@angular/core' |
|||
import { BehaviorSubject } from 'rxjs' |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class StandardService { |
|||
constructor() {} |
|||
|
|||
settingData$ = new BehaviorSubject<any>(null) |
|||
} |
|||
@ -1,112 +1,96 @@ |
|||
<div class="body flex flex-col"> |
|||
<div class="head clearfix"> |
|||
<div class="logo"> |
|||
<img *ngIf="logo" [attr.src]="'/api/icon/' + logo" /> |
|||
</div> |
|||
<h1 class="title">{{orgName}}食谱营养报告</h1> |
|||
<div class="time">{{showTime}}</div> |
|||
</div> |
|||
<div class="mainbox flex flex-1"> |
|||
|
|||
<!-- <div class="boxnav mapc"> |
|||
<div class="head clearfix"> |
|||
<div class="logo"> |
|||
<img *ngIf="logo" [attr.src]="'/api/icon/' + logo" /> |
|||
</div> |
|||
<h1 class="title">{{ orgName }}食谱营养报告</h1> |
|||
<div class="time">{{ showTime }}</div> |
|||
</div> |
|||
<div class="mainbox flex flex-1"> |
|||
<!-- <div class="boxnav mapc"> |
|||
|
|||
</div> --> |
|||
<div class="flex-1 flex flex-col"> |
|||
<div class="flex-1 overflow-hidden pb-2"> |
|||
<div class="box"> |
|||
<div class="tit"> |
|||
今日带量食谱 |
|||
<ng-container *ngIf="currentMenu"> |
|||
【{{currentMenu.name}}】 |
|||
</ng-container> |
|||
</div> |
|||
<div class="boxnav overflow-hidden" #tableEl> |
|||
<table class="w-full"> |
|||
<thead> |
|||
<tr> |
|||
<th width="70px"> |
|||
|
|||
</th> |
|||
<th> |
|||
菜品名称 |
|||
</th> |
|||
<th *ngFor="let p of peoples"> |
|||
<div class="td"> |
|||
{{p}} |
|||
</div> |
|||
</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<ng-container *ngFor="let meal of globalEnum.mealType"> |
|||
<ng-container *ngIf="dishs[meal.value] as mealDish"> |
|||
<tr *ngFor="let item of mealDish;let first = first"> |
|||
|
|||
<td *ngIf="first" [attr.rowspan]="mealDish.length"> |
|||
{{meal.label}} |
|||
</td> |
|||
<th> |
|||
<div class="td"> |
|||
{{ item.name}} |
|||
</div> |
|||
</th> |
|||
<th *ngFor="let p of peoples"> |
|||
<div class="td"> |
|||
{{item.people[p]}}g |
|||
</div> |
|||
</th> |
|||
</tr> |
|||
</ng-container> |
|||
</ng-container> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="flex-1 overflow-hidden pt-2"> |
|||
<div class="box"> |
|||
<div class="tit">今日食材种类</div> |
|||
<div class="boxnav"> |
|||
<div class="p-4"> |
|||
<div nz-row [nzGutter]="[12,12]"> |
|||
<div nz-col nzSpan="6" *ngFor="let type of analysis?.types | keyvalue"> |
|||
{{type.key}} : <b>{{type.value}}</b> 种 |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="w-1/3 pl-4"> |
|||
<div class="box"> |
|||
<div class="tit flex justify-between items-center"> |
|||
<span> |
|||
今日营养分析 |
|||
</span> |
|||
<span *ngIf="peoples.length"> |
|||
<select [(ngModel)]="people" class="select" (ngModelChange)="getAnalysis()"> |
|||
<option *ngFor="let p of peoples" [value]="p"> |
|||
{{p}} |
|||
</option> |
|||
</select> |
|||
</span> |
|||
</div> |
|||
<div class="boxnav overflow-hidden" #nutritionEl> |
|||
<div class="p-4"> |
|||
<nz-spin [nzSpinning]="analysisLoading"> |
|||
<lib-nutrition-table *ngIf="analysis" |
|||
[dark]="true" |
|||
[nutritions]="analysis.ingredient"> |
|||
</lib-nutrition-table> |
|||
</nz-spin> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
|
|||
</div> |
|||
<div class="flex-1 flex flex-col"> |
|||
<div class="flex-1 overflow-hidden pb-2"> |
|||
<div class="box"> |
|||
<div class="tit"> |
|||
今日带量食谱 |
|||
<ng-container *ngIf="currentMenu"> 【{{ currentMenu.name }}】 </ng-container> |
|||
</div> |
|||
<div class="boxnav overflow-hidden" #tableEl> |
|||
<table class="w-full"> |
|||
<thead> |
|||
<tr> |
|||
<th width="70px"></th> |
|||
<th>菜品名称</th> |
|||
<th>三低标识</th> |
|||
<th *ngFor="let p of peoples"> |
|||
<div class="td"> |
|||
{{ p }} |
|||
</div> |
|||
</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<ng-container *ngFor="let meal of globalEnum.mealType"> |
|||
<ng-container *ngIf="dishs[meal.value] as mealDish"> |
|||
<tr *ngFor="let item of mealDish; let first = first"> |
|||
<td *ngIf="first" [attr.rowspan]="mealDish.length"> |
|||
{{ meal.label }} |
|||
</td> |
|||
<td> |
|||
<div class="td"> |
|||
{{ item.name }} |
|||
</div> |
|||
</td> |
|||
<td>123</td> |
|||
<td *ngFor="let p of peoples"> |
|||
<div class="td">{{ item.people[p] }}g</div> |
|||
</td> |
|||
</tr> |
|||
</ng-container> |
|||
</ng-container> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="flex-1 overflow-hidden pt-2"> |
|||
<div class="box"> |
|||
<div class="tit">今日食材种类</div> |
|||
<div class="boxnav"> |
|||
<div class="p-4"> |
|||
<div nz-row [nzGutter]="[12, 12]"> |
|||
<div nz-col nzSpan="6" *ngFor="let type of analysis?.types | keyvalue"> |
|||
{{ type.key }} : <b>{{ type.value }}</b> 种 |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="w-1/3 pl-4"> |
|||
<div class="box"> |
|||
<div class="tit flex justify-between items-center"> |
|||
<span> 今日营养分析 </span> |
|||
<span *ngIf="peoples.length"> |
|||
<select [(ngModel)]="people" class="select" (ngModelChange)="getAnalysis()"> |
|||
<option *ngFor="let p of peoples" [value]="p"> |
|||
{{ p }} |
|||
</option> |
|||
</select> |
|||
</span> |
|||
</div> |
|||
<div class="boxnav overflow-hidden" #nutritionEl> |
|||
<div class="p-4"> |
|||
<nz-spin [nzSpinning]="analysisLoading"> |
|||
<lib-nutrition-table *ngIf="analysis" [dark]="true" [nutritions]="analysis.ingredient"> |
|||
</lib-nutrition-table> |
|||
</nz-spin> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
@ -1,184 +1,186 @@ |
|||
import { AfterViewInit, Component, ElementRef, Renderer2, ViewChild } from "@angular/core"; |
|||
import { ApiService } from "@cdk/services"; |
|||
import { format } from "date-fns"; |
|||
import { Subject, Subscription, finalize, interval, takeUntil } from "rxjs"; |
|||
import { AfterViewInit, Component, ElementRef, Renderer2, ViewChild } from '@angular/core' |
|||
import { ApiService } from '@cdk/services' |
|||
import { format } from 'date-fns' |
|||
import { Subject, Subscription, finalize, interval, takeUntil } from 'rxjs' |
|||
|
|||
interface MenuDisplayItem { |
|||
name: string; |
|||
id: number; |
|||
name: string |
|||
id: number |
|||
} |
|||
|
|||
const changeTime = 1000 * 60 * 3; |
|||
const changeTime = 1000 * 60 * 3 |
|||
|
|||
@Component({ |
|||
selector: "app-data-vis", |
|||
templateUrl: "./data-vis.component.html", |
|||
styleUrls: ["./data-vis.component.less"], |
|||
selector: 'app-data-vis', |
|||
templateUrl: './data-vis.component.html', |
|||
styleUrls: ['./data-vis.component.less'], |
|||
}) |
|||
export class DataVisComponent implements AfterViewInit { |
|||
constructor(private api: ApiService, private rd2: Renderer2) {} |
|||
|
|||
@ViewChild("tableEl") tableEl!: ElementRef<HTMLElement>; |
|||
@ViewChild('tableEl') tableEl!: ElementRef<HTMLElement> |
|||
|
|||
@ViewChild("nutritionEl") nutritionEl!: ElementRef<HTMLElement>; |
|||
@ViewChild('nutritionEl') nutritionEl!: ElementRef<HTMLElement> |
|||
|
|||
destroy$ = new Subject(); |
|||
destroy$ = new Subject() |
|||
|
|||
showTime: string = ""; |
|||
showTime: string = '' |
|||
|
|||
orgName = ""; |
|||
orgName = '' |
|||
|
|||
dishs: { |
|||
[K: string]: any[]; |
|||
} = {}; |
|||
[K: string]: any[] |
|||
} = {} |
|||
|
|||
peoples: string[] = []; |
|||
peoples: string[] = [] |
|||
|
|||
globalEnum = this.api.globalEnum; |
|||
globalEnum = this.api.globalEnum |
|||
|
|||
analysisLoading = false; |
|||
analysisLoading = false |
|||
|
|||
analysis: any; |
|||
analysis: any |
|||
|
|||
scroll: Record<string, number> = {}; |
|||
scroll: Record<string, number> = {} |
|||
|
|||
people = ""; |
|||
people = '' |
|||
|
|||
menuId?: string; |
|||
menuId?: string |
|||
|
|||
logo = ""; |
|||
logo = '' |
|||
|
|||
menus: MenuDisplayItem[] = []; |
|||
menus: MenuDisplayItem[] = [] |
|||
|
|||
currentMenu: MenuDisplayItem | null = null; |
|||
currentMenu: MenuDisplayItem | null = null |
|||
|
|||
lastTime: number = 0; |
|||
lastTime: number = 0 |
|||
|
|||
ngOnInit(): void { |
|||
this.api.getOrgInfo().subscribe((res) => { |
|||
const account = this.api.account; |
|||
const account = this.api.account |
|||
|
|||
this.orgName = account?.vender?.name ?? ""; |
|||
this.logo = account?.vender?.icon ?? ""; |
|||
}); |
|||
this.orgName = account?.vender?.name ?? '' |
|||
this.logo = account?.vender?.icon ?? '' |
|||
}) |
|||
|
|||
interval(1000) |
|||
.pipe(takeUntil(this.destroy$)) |
|||
.subscribe(() => { |
|||
const now = new Date(); |
|||
this.showTime = format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
|||
const now = new Date() |
|||
this.showTime = format(new Date(), 'yyyy-MM-dd HH:mm:ss') |
|||
if (now.getTime() - this.lastTime > changeTime) { |
|||
const currentIndex = this.menus.findIndex((f) => f.id === this.currentMenu?.id); |
|||
let idx = currentIndex + 1; |
|||
const currentIndex = this.menus.findIndex((f) => f.id === this.currentMenu?.id) |
|||
let idx = currentIndex + 1 |
|||
if (idx > this.menus.length - 1) { |
|||
idx = 0; |
|||
idx = 0 |
|||
} |
|||
this.currentMenu = this.menus[idx] |
|||
if (this.currentMenu) { |
|||
this.getDataVisData(this.currentMenu.id) |
|||
this.lastTime = now.getTime() |
|||
} |
|||
this.currentMenu = this.menus[idx]; |
|||
this.getDataVisData(this.currentMenu.id); |
|||
this.lastTime = now.getTime(); |
|||
} |
|||
}); |
|||
}) |
|||
|
|||
this.api.getCurrentDayDataVisList().subscribe((r) => { |
|||
if (Array.isArray(r.body)) { |
|||
this.menus = r.body; |
|||
this.menus = r.body |
|||
} |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
ngAfterViewInit(): void {} |
|||
|
|||
ngOnDestroy(): void { |
|||
this.destroy$.next(null); |
|||
this.destroy$.complete(); |
|||
this.destroy$.next(null) |
|||
this.destroy$.complete() |
|||
} |
|||
|
|||
getDataVisData(id: number) { |
|||
this.analysis = null; |
|||
this.peoples = []; |
|||
this.people = ""; |
|||
this.dishs = {}; |
|||
this.scroll = {}; |
|||
this.analysis = null |
|||
this.peoples = [] |
|||
this.people = '' |
|||
this.dishs = {} |
|||
this.scroll = {} |
|||
|
|||
this.api.getMenuDataVis(id).subscribe((res) => { |
|||
const dishs = res.body; |
|||
const dishs = res.body |
|||
if (Array.isArray(dishs)) { |
|||
this.peoples = Object.keys(dishs?.[0]?.ingredient?.[0]?.value); |
|||
this.people = this.peoples[0]; |
|||
this.peoples = Object.keys(dishs?.[0]?.ingredient?.[0]?.value) |
|||
this.people = this.peoples[0] |
|||
if (!this.peoples) { |
|||
console.error("dishs?.[0]?.ingredient?.[0]?.value 数据错误:", dishs); |
|||
return; |
|||
console.error('dishs?.[0]?.ingredient?.[0]?.value 数据错误:', dishs) |
|||
return |
|||
} |
|||
this.menuId = dishs?.[0]?.menu; |
|||
this.getAnalysis(); |
|||
this.menuId = dishs?.[0]?.menu |
|||
this.getAnalysis() |
|||
|
|||
dishs.forEach((i: any) => { |
|||
// 把每个食材按照不同的人群将重量加起来
|
|||
this.peoples.forEach((people) => { |
|||
const foods = i.ingredient as any[]; |
|||
const foods = i.ingredient as any[] |
|||
const c = foods.reduce((a, c) => { |
|||
return a + c.value[people]; |
|||
}, 0); |
|||
return a + c.value[people] |
|||
}, 0) |
|||
if (!i.people) { |
|||
i.people = {}; |
|||
i.people = {} |
|||
} |
|||
i.people[people] = c; |
|||
}); |
|||
i.people[people] = c |
|||
}) |
|||
|
|||
if (Array.isArray(this.dishs[i.meal])) { |
|||
this.dishs[i.meal].push(i); |
|||
this.dishs[i.meal].push(i) |
|||
} else { |
|||
this.dishs[i.meal] = [i]; |
|||
this.dishs[i.meal] = [i] |
|||
} |
|||
}); |
|||
}) |
|||
setTimeout(() => { |
|||
this.autoScroll(this.tableEl.nativeElement, "1"); |
|||
}, 1000); |
|||
this.autoScroll(this.tableEl.nativeElement, '1') |
|||
}, 1000) |
|||
} |
|||
}); |
|||
}) |
|||
} |
|||
|
|||
scrollSubs$?: Subscription; |
|||
scrollSubs$?: Subscription |
|||
|
|||
autoScroll(el: HTMLElement, scroll: string) { |
|||
this.scrollSubs$?.unsubscribe(); |
|||
const child = el.children[0]; |
|||
this.scrollSubs$?.unsubscribe() |
|||
const child = el.children[0] |
|||
if (!child) { |
|||
return; |
|||
return |
|||
} |
|||
const elHeight = el.clientHeight; |
|||
const childHeight = child.clientHeight; |
|||
const elHeight = el.clientHeight |
|||
const childHeight = child.clientHeight |
|||
if (childHeight <= elHeight) { |
|||
return; |
|||
return |
|||
} |
|||
this.scrollSubs$ = interval(60) |
|||
.pipe(takeUntil(this.destroy$)) |
|||
.subscribe(() => { |
|||
this.scroll[scroll] = (this.scroll[scroll] ?? 0) + 1; |
|||
const paddingBottom = 100; |
|||
this.scroll[scroll] = (this.scroll[scroll] ?? 0) + 1 |
|||
const paddingBottom = 100 |
|||
if (this.scroll[scroll] - paddingBottom > childHeight - el.clientHeight) { |
|||
this.scroll[scroll] = 0; |
|||
this.scroll[scroll] = 0 |
|||
} |
|||
this.rd2.setStyle(child, "transform", `translateY(-${this.scroll[scroll]}px)`); |
|||
}); |
|||
this.rd2.setStyle(child, 'transform', `translateY(-${this.scroll[scroll]}px)`) |
|||
}) |
|||
} |
|||
|
|||
getAnalysis() { |
|||
if (!this.menuId) { |
|||
return; |
|||
return |
|||
} |
|||
this.api |
|||
.getAnalysis(this.menuId, void 0, this.people) |
|||
.pipe( |
|||
finalize(() => { |
|||
this.analysisLoading = false; |
|||
}) |
|||
this.analysisLoading = false |
|||
}), |
|||
) |
|||
.subscribe((res) => { |
|||
this.analysis = res.body; |
|||
this.analysis = res.body |
|||
// setTimeout(() => {
|
|||
// this.autoScroll(this.nutritionEl.nativeElement, "2");
|
|||
// }, 1000);
|
|||
}); |
|||
}) |
|||
} |
|||
} |
|||
|
|||
@ -1,158 +1,116 @@ |
|||
<app-page> |
|||
<nz-card [nzTitle]="orgInfoTpl" *ngIf="account?.vender as org"> |
|||
<ng-template #orgInfoTpl> |
|||
<span> |
|||
单位基础信息 |
|||
</span> |
|||
<small class="ml-2"> |
|||
<a (click)="updateOrg()"> |
|||
编辑 |
|||
</a> |
|||
</small> |
|||
</ng-template> |
|||
<div nz-form> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
单位名称 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{org.name}} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
单位Logo |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
<div class="w-20 h-20" *ngIf="org.icon"> |
|||
<img [src]="'/api/icon/' + org.icon" class=" w-full h-full" /> |
|||
</div> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
地址 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{org.address ?? '-'}} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
联系人 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{org.contacts ?? '-'}} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
联系电话 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{org.phone ?? '-'}} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
邮箱 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{org.email ?? '-'}} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
</nz-card> |
|||
<nz-card [nzTitle]="orgInfoTpl" *ngIf="account?.vender as org"> |
|||
<ng-template #orgInfoTpl> |
|||
<span> 单位基础信息 </span> |
|||
<small class="ml-2"> |
|||
<a (click)="updateOrg()"> 编辑 </a> |
|||
</small> |
|||
</ng-template> |
|||
<div nz-form> |
|||
<nz-form-item> |
|||
<nz-form-label> 单位名称 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ org.name }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 单位Logo </nz-form-label> |
|||
<nz-form-control> |
|||
<div class="w-20 h-20" *ngIf="org.icon"> |
|||
<img [src]="'/api/icon/' + org.icon" class="w-full h-full" /> |
|||
</div> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 地址 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ org.address ?? '-' }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 联系人 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ org.contacts ?? '-' }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 联系电话 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ org.phone ?? '-' }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 邮箱 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ org.email ?? '-' }} |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
</nz-card> |
|||
|
|||
<nz-card [nzTitle]="orgInfoTpl" *ngIf="account?.vender as org" class="mt-4"> |
|||
<ng-template #orgInfoTpl> |
|||
<span> |
|||
账号信息 |
|||
</span> |
|||
<small class="ml-2 text-slate-500"> |
|||
仅支持主账号操作 |
|||
</small> |
|||
</ng-template> |
|||
<div nz-form> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
账号 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{account?.uid}} |
|||
<a class="ml-4" (click)="updateAccount('uid',updateAccountInfoTpl)"> |
|||
修改账号 |
|||
</a> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-card [nzTitle]="orgInfoTpl" *ngIf="account?.vender as org" class="mt-4"> |
|||
<ng-template #orgInfoTpl> |
|||
<span> 账号信息 </span> |
|||
<small class="ml-2 text-slate-500"> 仅支持主账号操作 </small> |
|||
</ng-template> |
|||
<div nz-form> |
|||
<nz-form-item> |
|||
<nz-form-label> 账号 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ account?.uid }} |
|||
<a class="ml-4" (click)="updateAccount('uid', updateAccountInfoTpl)"> 修改账号 </a> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
密码 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
<a (click)="changePassword(changePasswordTpl)"> |
|||
修改密码 |
|||
</a> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> |
|||
账号到期时间 |
|||
</nz-form-label> |
|||
<nz-form-control> |
|||
{{org?.expire | date:'yyyy-MM-dd'}} |
|||
<a class="ml-4" (click)="updateAccount(org?.expire,updateAccountInfoTpl)"> |
|||
续费 |
|||
</a> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
|
|||
</div> |
|||
</nz-card> |
|||
<nz-form-item> |
|||
<nz-form-label> 密码 </nz-form-label> |
|||
<nz-form-control> |
|||
<a (click)="changePassword(changePasswordTpl)"> 修改密码 </a> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label> 账号到期时间 </nz-form-label> |
|||
<nz-form-control> |
|||
{{ org?.expire | date : 'yyyy-MM-dd' }} |
|||
<a class="ml-4" (click)="updateAccount(org?.expire, updateAccountInfoTpl)"> 续费 </a> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</div> |
|||
</nz-card> |
|||
</app-page> |
|||
|
|||
<ng-template #updateAccountInfoTpl> |
|||
<div *ngIf="account?.vender as org" class=" text-base text-blue-500"> |
|||
<span> |
|||
<div *ngIf="account?.vender as org" class="text-base text-blue-500"> |
|||
<!-- <span> |
|||
{{org.contacts ?? '-'}} |
|||
</span> |
|||
<span> |
|||
{{org.phone ?? '-'}} |
|||
</span> |
|||
</div> |
|||
</span> --> |
|||
<span> 028-85463212 </span> |
|||
</div> |
|||
</ng-template> |
|||
|
|||
<ng-template #changePasswordTpl> |
|||
<form nz-form [formGroup]="pwdForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzSpan="6" [nzRequired]="true"> |
|||
原密码 |
|||
</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errTipTpl" nzSpan="12"> |
|||
<input nz-input type="password" placeholder="请输入原密码" formControlName="oldPwd" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label nzSpan="6" [nzRequired]="true"> |
|||
新密码 |
|||
</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errTipTpl" nzSpan="12"> |
|||
<input nz-input type="password" placeholder="请输入新密码" formControlName="newPwd" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label nzSpan="6" [nzRequired]="true"> |
|||
确认密码 |
|||
</nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errTipTpl" nzSpan="12"> |
|||
<input nz-input type="password" placeholder="请再次输入新密码" formControlName="rePwd" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
<form nz-form [formGroup]="pwdForm"> |
|||
<nz-form-item> |
|||
<nz-form-label nzSpan="6" [nzRequired]="true"> 原密码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errTipTpl" nzSpan="12"> |
|||
<input nz-input type="password" placeholder="请输入原密码" formControlName="oldPwd" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label nzSpan="6" [nzRequired]="true"> 新密码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errTipTpl" nzSpan="12"> |
|||
<input nz-input type="password" placeholder="请输入新密码" formControlName="newPwd" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
<nz-form-item> |
|||
<nz-form-label nzSpan="6" [nzRequired]="true"> 确认密码 </nz-form-label> |
|||
<nz-form-control [nzErrorTip]="errTipTpl" nzSpan="12"> |
|||
<input nz-input type="password" placeholder="请再次输入新密码" formControlName="rePwd" /> |
|||
</nz-form-control> |
|||
</nz-form-item> |
|||
</form> |
|||
</ng-template> |
|||
|
|||
|
|||
<ng-template #errTipTpl let-control> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
<form-error-tips [control]="control"></form-error-tips> |
|||
</ng-template> |
|||
Loading…
Reference in new issue