Browse Source

复制标准 & 食谱列表页样式

main
kkerwin 2 years ago
parent
commit
203f3949bb
  1. 1
      projects/admin/src/app/components/dish-form/dish-form.component.ts
  2. 1
      projects/admin/src/app/pages/dish/dish.component.ts
  3. 4
      projects/admin/src/app/pages/food/food.component.ts
  4. 25
      projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html
  5. 6
      projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts
  6. 32
      projects/admin/src/app/pages/standard/standard-form/standard-form.component.html
  7. 15
      projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts
  8. 18
      projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts
  9. 4
      projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts
  10. 46
      projects/cdk/src/app-page/app-page.component.ts
  11. 4
      projects/cdk/src/ingredient/ingredient-dish/ingredient-dish.component.ts
  12. 16
      projects/cdk/src/ingredient/ingredient-form-basic/ingredient-form-basic.component.ts
  13. 22
      projects/cdk/src/table-list/td-overflow.directive.ts
  14. 198
      projects/client/src/app/components/dish-form/dish-form.component.ts
  15. 4
      projects/client/src/app/pages/data-vis/data-vis.component.ts
  16. 19
      projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html
  17. 8
      projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

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

@ -139,7 +139,6 @@ export class DishFormComponent {
public getValues() { public getValues() {
let values = null let values = null
console.log('this.formGroup.getRawValue()', this.formGroup.getRawValue(), this.foodItemSelected)
if (Utils.validateFormGroup(this.formGroup)) { if (Utils.validateFormGroup(this.formGroup)) {
const value = this.formGroup.getRawValue() const value = this.formGroup.getRawValue()
// const { _nutrition, key, name, type } = this.formGroup.getRawValue(); // const { _nutrition, key, name, type } = this.formGroup.getRawValue();

1
projects/admin/src/app/pages/dish/dish.component.ts

@ -198,7 +198,6 @@ export class DishComponent {
[c.key]: c, [c.key]: c,
} }
}, {} as AnyObject) }, {} as AnyObject)
console.log('this.tableFoods', this.tableFoods)
} }
}) })
} }

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

@ -148,9 +148,7 @@ export class FoodComponent implements OnInit, OnDestroy {
} }
downloadTemplate() { downloadTemplate() {
this.api.getFoodExcelTemplate().subscribe((res) => { this.api.getFoodExcelTemplate().subscribe((res) => {})
console.log('res', res)
})
} }
showImportForm(nzContent: TemplateRef<{}>) { showImportForm(nzContent: TemplateRef<{}>) {

25
projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html

@ -52,8 +52,15 @@
<ng-container *ngSwitchCase="'modify'"> <ng-container *ngSwitchCase="'modify'">
{{ data | date : 'yyyy-MM-dd HH:mm:ss' }} {{ data | date : 'yyyy-MM-dd HH:mm:ss' }}
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'name'">
<span title="{{ data }}">
{{ data }}
</span>
</ng-container>
<ng-container *ngSwitchCase="'vender'"> <ng-container *ngSwitchCase="'vender'">
{{ tableOrg[data] ? tableOrg[data].name : '-' }} <span title="{{ tableOrg[data] ? tableOrg[data].name : '-' }}">
{{ tableOrg[data] ? tableOrg[data].name : '-' }}
</span>
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'meals'"> <ng-container *ngSwitchCase="'meals'">
<nz-tag *ngFor="let item of data">{{ item }}</nz-tag> <nz-tag *ngFor="let item of data">{{ item }}</nz-tag>
@ -63,16 +70,12 @@
{{ statusTextMap[data] }} {{ statusTextMap[data] }}
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'month'"> <ng-container *ngSwitchCase="'month'">
<div class="flex flex-wrap"> <a nz-popover [nzPopoverContent]="nzPopoverContent"> {{ data.length }}个月 </a>
<ng-container *ngIf="data.length === 12"> <ng-template #nzPopoverContent>
<nz-tag> 全年 </nz-tag> <div class="flex flex-wrap w-48">
</ng-container> <nz-tag *ngFor="let item of data" class="mb-1"> {{ item }}月 </nz-tag>
<ng-container *ngIf="data.length !== 12"> </div>
<nz-tag *ngFor="let item of data" class="mb-1"> </ng-template>
{{ item }}
</nz-tag>
</ng-container>
</div>
</ng-container> </ng-container>
<ng-container *ngSwitchDefault> <ng-container *ngSwitchDefault>
{{ data }} {{ data }}

6
projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

@ -88,9 +88,9 @@ export class IngredientListComponent {
{ key: 'name', title: '食谱名称', width: '200px' }, { key: 'name', title: '食谱名称', width: '200px' },
{ key: 'vender', title: '单位', width: '200px' }, { key: 'vender', title: '单位', width: '200px' },
{ key: 'meals', title: '包含餐次', width: '180px' }, { key: 'meals', title: '包含餐次', width: '180px' },
{ key: 'month', title: '适用月份' }, { key: 'month', title: '适用月份', width: '100px' },
{ key: 'day', title: '周期' }, { key: 'day', title: '周期', width: '100px' },
{ key: 'status', title: '状态', width: '120px' }, { key: 'status', title: '状态', width: '80px' },
{ key: 'modify', title: '更新时间', width: '170px' }, { key: 'modify', title: '更新时间', width: '170px' },
{ key: 'operate', title: '创建人', width: '160px' }, { key: 'operate', title: '创建人', width: '160px' },
]) ])

32
projects/admin/src/app/pages/standard/standard-form/standard-form.component.html

@ -28,21 +28,23 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let item of api.globalEnum.nutrient"> <ng-container *ngFor="let item of api.globalEnum.nutrient">
<td> <tr *ngIf="item.key === 'energy'">
{{ item.value }} <td>
</td> {{ item.value }}
<td> </td>
<nz-input-group nzAddOnBefore="±" nzAddOnAfter="%"> <td>
<input <nz-input-group nzAddOnBefore="±" nzAddOnAfter="%">
nz-input <input
min="0" nz-input
[(ngModel)]="overflows[item.key]" min="0"
[ngModelOptions]="{ standalone: true }" [(ngModel)]="overflows[item.key]"
/> [ngModelOptions]="{ standalone: true }"
</nz-input-group> />
</td> </nz-input-group>
</tr> </td>
</tr>
</ng-container>
</tbody> </tbody>
</nz-table> </nz-table>
</nz-form-control> </nz-form-control>

15
projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts

@ -60,7 +60,7 @@ export class StandardFormComponent {
overflows: Record<string, number> = {} overflows: Record<string, number> = {}
ngOnInit(): void { ngOnInit(): void {
console.log('this.api.globalEnum.nutrient', this.api.globalEnum.nutrient) // console.log('this.api.globalEnum.nutrient', this.api.globalEnum.nutrient)
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
id: this.fb.control('', []), id: this.fb.control('', []),
name: this.fb.control('', [FormValidators.required()]), name: this.fb.control('', [FormValidators.required()]),
@ -119,15 +119,20 @@ export class StandardFormComponent {
onSubmit(gotoSetting?: boolean) { onSubmit(gotoSetting?: boolean) {
if (Utils.validateFormGroup(this.formGroup)) { if (Utils.validateFormGroup(this.formGroup)) {
const vendors = this.listOfOption.filter((f) => f.checked).map((i) => i.id)
if (vendors.length === 0) {
this.msg.error('请选择适用单位')
return
}
this.submitLoading = true this.submitLoading = true
this.api this.api
.saveStandard({ .saveStandard({
foodCategoryDay: this.state?.foodCategoryDay, foodCategoryDay: this.state?.foodCategoryDay ?? [],
foodCategoryWeek: this.state?.foodCategoryWeek, foodCategoryWeek: this.state?.foodCategoryWeek ?? [],
ingredient: this.state?.ingredient, ingredient: this.state?.ingredient ?? {},
overflows: this.overflows, overflows: this.overflows,
...this.formGroup.value, ...this.formGroup.value,
vendors: this.listOfOption.filter((f) => f.checked).map((i) => i.id), vendors,
}) })
.pipe( .pipe(
finalize(() => { finalize(() => {

18
projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts

@ -91,14 +91,26 @@ export class StandardListComponent {
if (Utils.validateFormGroup(this.copyForm)) { if (Utils.validateFormGroup(this.copyForm)) {
const val = this.copyForm.value const val = this.copyForm.value
const name = val.name! const name = val.name!
const res = await lastValueFrom(
const add = await lastValueFrom(
this.api.saveStandard({ this.api.saveStandard({
...v, vendors: v['vendors'],
overflow: v['overflow'],
overflows: v['overflows'],
name, name,
id: null, id: null,
}), }),
) )
this.msg.success(res.desc) const update = await lastValueFrom(
this.api.saveStandard({
foodCategoryDay: v['foodCategoryDay'] ?? [],
foodCategoryWeek: v['foodCategoryWeek'] ?? [],
ingredient: v['ingredient'] ?? {},
name,
id: add.body['id'],
}),
)
this.msg.success(update.desc)
this.tableList.run() this.tableList.run()
return true return true
} }

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

@ -123,7 +123,8 @@ export class StandardSettingComponent implements AfterViewInit, OnDestroy {
return [] return []
} }
this.expand(0) this.expand(0)
const sorts = data.crows ?? Object.keys(data.ingredient) const sorts = data.crows?.length > 0 ? data.crows : Object.keys(data.ingredient)
return sorts.map((peopleName: string) => { return sorts.map((peopleName: string) => {
const v: any = data.ingredient[peopleName] const v: any = data.ingredient[peopleName]
return { return {
@ -231,7 +232,6 @@ export class StandardSettingComponent implements AfterViewInit, OnDestroy {
} }
calcTypeChange() { calcTypeChange() {
console.log('this.calcType', this.calcType)
this.foodCategoryDay = this.foodCategoryDay.map((i) => ({ ...i, type: this.calcType })) this.foodCategoryDay = this.foodCategoryDay.map((i) => ({ ...i, type: this.calcType }))
this.foodCategoryWeek = this.foodCategoryWeek.map((i) => ({ ...i, type: this.calcType })) this.foodCategoryWeek = this.foodCategoryWeek.map((i) => ({ ...i, type: this.calcType }))
} }

46
projects/cdk/src/app-page/app-page.component.ts

@ -1,19 +1,19 @@
import { CommonModule } from "@angular/common"; import { CommonModule } from '@angular/common'
import { Component, Input, OnDestroy, TemplateRef } from "@angular/core"; import { Component, Input, OnDestroy, TemplateRef } from '@angular/core'
import { ActivatedRoute, NavigationEnd, Router, Scroll } from "@angular/router"; import { ActivatedRoute, NavigationEnd, Router, Scroll } from '@angular/router'
import { Subject, filter, startWith, take, takeUntil } from "rxjs"; import { Subject, filter, startWith, take, takeUntil } from 'rxjs'
import { NzOutletModule } from "ng-zorro-antd/core/outlet"; import { NzOutletModule } from 'ng-zorro-antd/core/outlet'
interface BreadcrumbInterface { interface BreadcrumbInterface {
label: string; label: string
href?: string; href?: string
} }
@Component({ @Component({
standalone: true, standalone: true,
selector: "app-page", selector: 'app-page',
templateUrl: "./app-page.component.html", templateUrl: './app-page.component.html',
styleUrls: ["./app-page.component.less"], styleUrls: ['./app-page.component.less'],
imports: [CommonModule, NzOutletModule], imports: [CommonModule, NzOutletModule],
}) })
export class AppPageComponent implements OnDestroy { export class AppPageComponent implements OnDestroy {
@ -28,35 +28,35 @@ export class AppPageComponent implements OnDestroy {
// }); // });
} }
@Input() pageTitle?: TemplateRef<{}> | string; @Input() pageTitle?: TemplateRef<{}> | string
@Input() full: boolean = false; @Input() full: boolean = false
@Input() scroll: boolean = true; @Input() scroll: boolean = true
@Input() pageExtra?: TemplateRef<{}> | string; @Input() pageExtra?: TemplateRef<{}> | string
unSubscribe$ = new Subject<void>(); unSubscribe$ = new Subject<void>()
breadcrumb: BreadcrumbInterface[] = []; breadcrumb: BreadcrumbInterface[] = []
ngOnDestroy(): void { ngOnDestroy(): void {
this.unSubscribe$.next(); this.unSubscribe$.next()
this.unSubscribe$.complete(); this.unSubscribe$.complete()
} }
genBreadcrumb() { genBreadcrumb() {
let route: ActivatedRoute | null = this.route; let route: ActivatedRoute | null = this.route
this.breadcrumb = []; this.breadcrumb = []
while (route) { while (route) {
if (route.routeConfig?.title) { if (route.routeConfig?.title) {
this.breadcrumb.unshift({ this.breadcrumb.unshift({
label: route.routeConfig!.title as string, label: route.routeConfig!.title as string,
href: route.routeConfig.path, href: route.routeConfig.path,
}); })
} }
route = route?.parent ?? null; route = route?.parent ?? null
} }
console.log("this.route", this.breadcrumb); // console.log("this.route", this.breadcrumb);
} }
} }

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

@ -105,7 +105,7 @@ export class IngredientDishComponent implements OnChanges {
initMenuBasic() { initMenuBasic() {
if (this.menuBaisc) { if (this.menuBaisc) {
const meals = this.menuBaisc.meals as string[] const meals = this.menuBaisc.meals as string[]
console.log('this.menuBaisc', this.menuBaisc) // console.log('this.menuBaisc', this.menuBaisc)
const day = this.menuBaisc.day as number[] const day = this.menuBaisc.day as number[]
this.days = day.map((i, idx) => { this.days = day.map((i, idx) => {
const d = weekdayMap[i] const d = weekdayMap[i]
@ -146,7 +146,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, this.selectDay) // console.log('dayDishs', day, this.mealDishList, thisDayDishs, this.selectDay)
this.modal.create({ this.modal.create({
nzTitle: '请选择应用到的日期', nzTitle: '请选择应用到的日期',
nzContent, nzContent,

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

@ -118,13 +118,15 @@ export class IngredientFormBasicComponent implements OnChanges {
} }
}) })
this.api.getOrgList().subscribe((res) => { if (!this.client) {
this.allOrgs = res.map((i) => ({ this.api.getOrgList().subscribe((res) => {
...i, this.allOrgs = res.map((i) => ({
value: String(i.id), ...i,
label: i.name, value: String(i.id),
})) label: i.name,
}) }))
})
}
} }
ngOnChanges(changes: SimpleChanges): void {} ngOnChanges(changes: SimpleChanges): void {}

22
projects/cdk/src/table-list/td-overflow.directive.ts

@ -1,30 +1,30 @@
import { AfterContentInit, AfterViewInit, ChangeDetectorRef, Directive, ElementRef, Input } from "@angular/core"; import { AfterContentInit, AfterViewInit, ChangeDetectorRef, Directive, ElementRef, Input } from '@angular/core'
import { NzPopoverDirective } from "ng-zorro-antd/popover"; import { NzPopoverDirective } from 'ng-zorro-antd/popover'
@Directive({ @Directive({
selector: "[jwTdOverflow]", selector: '[jwTdOverflow]',
}) })
export class TdOverflowDirective implements AfterViewInit { export class TdOverflowDirective implements AfterViewInit {
@Input("jwTdOverflow") content!: string; @Input('jwTdOverflow') content!: string
constructor( constructor(
private elementRef: ElementRef, private elementRef: ElementRef,
private popoverDirective: NzPopoverDirective, private popoverDirective: NzPopoverDirective,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
) {} ) {}
ngOnInit() {} ngOnInit() {}
ngAfterViewInit(): void { ngAfterViewInit(): void {
const element = this.elementRef.nativeElement as HTMLElement; const element = this.elementRef.nativeElement as HTMLElement
console.log("element", element.offsetWidth, element.scrollWidth); // console.log("element", element.offsetWidth, element.scrollWidth);
// 如果元素的实际宽度大于可见宽度,就使用 nz-popover 指令来显示完整的内容 // 如果元素的实际宽度大于可见宽度,就使用 nz-popover 指令来显示完整的内容
if (element.offsetWidth < element.scrollWidth) { if (element.offsetWidth < element.scrollWidth) {
this.popoverDirective.content = this.content; this.popoverDirective.content = this.content
} else { } else {
this.popoverDirective.trigger = null; this.popoverDirective.trigger = null
this.popoverDirective.content = "da"; this.popoverDirective.content = 'da'
element.textContent = this.content; element.textContent = this.content
} }
} }
} }

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

@ -1,203 +1,203 @@
import { Component, Input, OnInit } from "@angular/core"; import { Component, Input, OnInit } from '@angular/core'
import { FormArray, FormBuilder, FormGroup } from "@angular/forms"; import { FormArray, FormBuilder, FormGroup } from '@angular/forms'
import { ApiService } from "@cdk/services"; import { ApiService } from '@cdk/services'
import { Utils } from "@cdk/utils"; import { Utils } from '@cdk/utils'
import { FormValidators } from "@cdk/validators"; import { FormValidators } from '@cdk/validators'
import { NzMessageService } from "ng-zorro-antd/message"; import { NzMessageService } from 'ng-zorro-antd/message'
import { Subject, debounceTime, distinctUntilChanged, filter, finalize, switchMap, throttleTime } from "rxjs"; import { Subject, debounceTime, distinctUntilChanged, filter, finalize, switchMap, throttleTime } from 'rxjs'
@Component({ @Component({
selector: "app-dish-form", selector: 'app-dish-form',
templateUrl: "./dish-form.component.html", templateUrl: './dish-form.component.html',
styleUrls: ["./dish-form.component.less"], styleUrls: ['./dish-form.component.less'],
}) })
export class DishFormComponent { export class DishFormComponent {
constructor(private fb: FormBuilder, private msg: NzMessageService, private api: ApiService) {} constructor(private fb: FormBuilder, private msg: NzMessageService, private api: ApiService) {}
@Input() data: any; @Input() data: any
@Input() orgs: any[] = []; @Input() orgs: any[] = []
@Input() foods: any[] = []; @Input() foods: any[] = []
private orgSearch$ = new Subject<Record<string, string>>(); private orgSearch$ = new Subject<Record<string, string>>()
private foodSearch$ = new Subject<Record<string, string>>(); private foodSearch$ = new Subject<Record<string, string>>()
formGroup!: FormGroup; formGroup!: FormGroup
selectedValue = null; selectedValue = null
orgListOfOption: Array<{ value: string; text: string }> = []; orgListOfOption: Array<{ value: string; text: string }> = []
foodListOfOption: Array<{ value: string; text: string }> = []; foodListOfOption: Array<{ value: string; text: string }> = []
searchedFood: Array<{ value: string; text: string }> = []; searchedFood: Array<{ value: string; text: string }> = []
foodSelected: string[] = []; foodSelected: string[] = []
foodItemSelected: any[] = []; foodItemSelected: any[] = []
nzFilterOption = (): boolean => true; nzFilterOption = (): boolean => true
globalEnum = this.api.globalEnum; globalEnum = this.api.globalEnum
uploadLoading = false; uploadLoading = false
addFoodVisible = false; addFoodVisible = false
iconPreview = ""; iconPreview = ''
get food(): FormArray { get food(): FormArray {
return this.formGroup.get("ingredient") as FormArray; return this.formGroup.get('ingredient') as FormArray
} }
get icon() { get icon() {
return this.formGroup.get("icon")?.value; return this.formGroup.get('icon')?.value
} }
ngOnInit(): void { ngOnInit(): void {
this.formGroup = this.fb.group({ this.formGroup = this.fb.group({
id: this.fb.control("", []), id: this.fb.control('', []),
name: this.fb.control("", [FormValidators.required()]), name: this.fb.control('', [FormValidators.required()]),
icon: this.fb.control("", []), icon: this.fb.control('', []),
mark: this.fb.control("", [FormValidators.required()]), mark: this.fb.control('', [FormValidators.required()]),
poly: this.fb.control("", [FormValidators.required()]), poly: this.fb.control('', [FormValidators.required()]),
month: this.fb.control([], []), month: this.fb.control([], []),
}); })
this.orgSearch$ this.orgSearch$
.pipe( .pipe(
debounceTime(500), debounceTime(500),
distinctUntilChanged(), distinctUntilChanged(),
switchMap((q) => this.api.getOrgList(q)) switchMap((q) => this.api.getOrgList(q)),
) )
.subscribe((data) => { .subscribe((data) => {
const listOfOption: Array<{ value: string; text: string }> = []; const listOfOption: Array<{ value: string; text: string }> = []
data.forEach((item) => { data.forEach((item) => {
listOfOption.push({ listOfOption.push({
value: item.id.toString(), value: item.id.toString(),
text: item.name, text: item.name,
}); })
}); })
this.orgListOfOption = listOfOption; this.orgListOfOption = listOfOption
}); })
this.foodSearch$ this.foodSearch$
.pipe( .pipe(
filter((f) => !!f), filter((f) => !!f),
debounceTime(500), debounceTime(500),
distinctUntilChanged(), distinctUntilChanged(),
switchMap((q) => this.api.getFoodList(q)) switchMap((q) => this.api.getFoodList(q)),
) )
.subscribe((data) => { .subscribe((data) => {
const listOfOption: Array<{ value: string; text: string }> = []; const listOfOption: Array<{ value: string; text: string }> = []
data.body.forEach((item) => { data.body.forEach((item) => {
listOfOption.push({ listOfOption.push({
value: item.key, value: item.key,
text: item.name, text: item.name,
}); })
}); })
this.searchedFood = this.searchedFood.concat(listOfOption); this.searchedFood = this.searchedFood.concat(listOfOption)
this.foodListOfOption = listOfOption; this.foodListOfOption = listOfOption
}); })
this.setValues(); this.setValues()
} }
setValues() { setValues() {
this.orgListOfOption = this.orgs.map((i) => ({ text: i.name, value: i.id })); this.orgListOfOption = this.orgs.map((i) => ({ text: i.name, value: i.id }))
if (this.data) { if (this.data) {
// this.allMonth = this.allMonth.map((i) => // this.allMonth = this.allMonth.map((i) =>
// (this.data.month ?? []).includes(i.value) ? { ...i, checked: true } : i // (this.data.month ?? []).includes(i.value) ? { ...i, checked: true } : i
// ); // );
this.foods.forEach((f) => { this.foods.forEach((f) => {
const item = { text: f.name, value: f.key }; const item = { text: f.name, value: f.key }
this.foodListOfOption.push(item); this.foodListOfOption.push(item)
this.searchedFood.push(item); this.searchedFood.push(item)
const num = this.data.ingredient.find((i: any) => i.key === f.key); const num = this.data.ingredient.find((i: any) => i.key === f.key)
if (num) { if (num) {
this.foodItemSelected.push({ num: num.value, ...item, isMain: num.isMain }); this.foodItemSelected.push({ num: num.value, ...item, isMain: num.isMain })
this.foodSelected.push(f.key); this.foodSelected.push(f.key)
} }
}); })
this.formGroup.patchValue({ this.formGroup.patchValue({
...this.data, ...this.data,
mark: this.data.marks, mark: this.data.marks,
}); })
if (this.data["icon"]) { if (this.data['icon']) {
this.iconPreview = "/api/icon/" + this.data["icon"]; this.iconPreview = '/api/icon/' + this.data['icon']
} }
} }
} }
public getValues() { public getValues() {
let values = null; let values = null
console.log("this.formGroup.getRawValue()", this.formGroup.getRawValue(), this.foodItemSelected); // console.log("this.formGroup.getRawValue()", this.formGroup.getRawValue(), this.foodItemSelected);
if (Utils.validateFormGroup(this.formGroup)) { if (Utils.validateFormGroup(this.formGroup)) {
const value = this.formGroup.getRawValue(); const value = this.formGroup.getRawValue()
// const { _nutrition, key, name, type } = this.formGroup.getRawValue(); // const { _nutrition, key, name, type } = this.formGroup.getRawValue();
let ingredient: any[] = []; let ingredient: any[] = []
for (const f of this.foodItemSelected) { for (const f of this.foodItemSelected) {
let num = Number(f.num); let num = Number(f.num)
if (!num) { if (!num) {
this.msg.error(`请输入${f.value}-${f.text}的重量`); this.msg.error(`请输入${f.value}-${f.text}的重量`)
return; return
} }
ingredient.push({ ingredient.push({
isMain: f.isMain, isMain: f.isMain,
key: f.value, key: f.value,
value: num, value: num,
}); })
} }
const month = value.month.join(","); const month = value.month.join(',')
values = { values = {
...value, ...value,
month, month,
ingredient, ingredient,
}; }
} }
return values; return values
} }
onMainChange(e: boolean, key: string) { onMainChange(e: boolean, key: string) {
this.foodItemSelected.forEach((i) => { this.foodItemSelected.forEach((i) => {
if (e) { if (e) {
i.isMain = false; i.isMain = false
if (i.value === key) { if (i.value === key) {
i.isMain = true; i.isMain = true
} }
} else { } else {
if (i.value === key) { if (i.value === key) {
i.isMain = false; i.isMain = false
} }
} }
}); })
} }
searchOrg(value: string): void { searchOrg(value: string): void {
if (value) { if (value) {
this.orgSearch$.next({ keyword: value }); this.orgSearch$.next({ keyword: value })
} }
} }
searchFood(value: string): void { searchFood(value: string): void {
if (value) { if (value) {
this.foodSearch$.next({ keyword: value }); this.foodSearch$.next({ keyword: value })
} }
} }
onFoodSelected(v: string[]) { onFoodSelected(v: string[]) {
this.foodItemSelected = []; this.foodItemSelected = []
this.searchedFood.forEach((item) => { this.searchedFood.forEach((item) => {
if (this.foodItemSelected.some((s) => s.value === item.value)) { if (this.foodItemSelected.some((s) => s.value === item.value)) {
return; return
} }
if (v.includes(item.value)) { if (v.includes(item.value)) {
this.foodItemSelected.push(item); this.foodItemSelected.push(item)
} }
}); })
// this.foodItemSelected = this.searchedFood.filter((f) => { // this.foodItemSelected = this.searchedFood.filter((f) => {
// return v.includes(f.value) // return v.includes(f.value)
@ -207,36 +207,36 @@ export class DishFormComponent {
addFood() { addFood() {
this.food.push( this.food.push(
this.fb.group({ this.fb.group({
name: this.fb.control("", [FormValidators.required()]), name: this.fb.control('', [FormValidators.required()]),
tag: this.fb.control(0, [FormValidators.required()]), tag: this.fb.control(0, [FormValidators.required()]),
weight: this.fb.control(0, [FormValidators.required()]), weight: this.fb.control(0, [FormValidators.required()]),
}) }),
); )
} }
removeFood(idx: number) { removeFood(idx: number) {
this.food.removeAt(idx); this.food.removeAt(idx)
} }
onFileChange(e: Event) { onFileChange(e: Event) {
const target = e.target as HTMLInputElement; const target = e.target as HTMLInputElement
const file = target.files![0]; const file = target.files![0]
target.value = ""; target.value = ''
if (file.size / 1024 / 1024 >= 2) { if (file.size / 1024 / 1024 >= 2) {
this.msg.error("图片大小不能超过2M"); this.msg.error('图片大小不能超过2M')
return; return
} }
const fileReader = new FileReader(); const fileReader = new FileReader()
fileReader.onload = () => { fileReader.onload = () => {
const base64 = fileReader.result as string; const base64 = fileReader.result as string
this.iconPreview = base64; this.iconPreview = base64
// this.formGroup.get("icon")?.setValue(base64); // this.formGroup.get("icon")?.setValue(base64);
}; }
fileReader.readAsDataURL(file); fileReader.readAsDataURL(file)
const formdata = new FormData(); const formdata = new FormData()
formdata.append("file", file); formdata.append('file', file)
this.api.upload(formdata).subscribe((res) => { this.api.upload(formdata).subscribe((res) => {
this.formGroup.get("icon")?.setValue(res.body); this.formGroup.get('icon')?.setValue(res.body)
}); })
} }
} }

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

@ -199,7 +199,7 @@ export class DataVisComponent implements AfterViewInit {
this.rd2.setStyle(child, 'transform', `translateY(0px)`) this.rd2.setStyle(child, 'transform', `translateY(0px)`)
const elHeight = el.clientHeight const elHeight = el.clientHeight
const childHeight = child.clientHeight const childHeight = child.clientHeight
console.log(childHeight, elHeight) // console.log(childHeight, elHeight)
if (childHeight <= elHeight) { if (childHeight <= elHeight) {
return return
} }
@ -226,7 +226,7 @@ export class DataVisComponent implements AfterViewInit {
return return
} }
this.api this.api
.getAnalysis(this.menuId, void 0, this.people) .getAnalysis(this.menuId, this.day, this.people)
.pipe( .pipe(
finalize(() => { finalize(() => {
this.analysisLoading = false this.analysisLoading = false

19
projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html

@ -50,6 +50,9 @@
<ng-container *ngSwitchCase="'vender'"> <ng-container *ngSwitchCase="'vender'">
{{ tableOrg[data] ? tableOrg[data].name : '-' }} {{ tableOrg[data] ? tableOrg[data].name : '-' }}
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'name'">
<span title="{{ data }}">{{ data }}</span>
</ng-container>
<ng-container *ngSwitchCase="'meals'"> <ng-container *ngSwitchCase="'meals'">
<nz-tag *ngFor="let item of data">{{ item }}</nz-tag> <nz-tag *ngFor="let item of data">{{ item }}</nz-tag>
@ -59,16 +62,12 @@
{{ statusTextMap[data] }} {{ statusTextMap[data] }}
</ng-container> </ng-container>
<ng-container *ngSwitchCase="'month'"> <ng-container *ngSwitchCase="'month'">
<div class="flex flex-wrap"> <a nz-popover [nzPopoverContent]="nzPopoverContent"> {{ data.length }}个月 </a>
<ng-container *ngIf="data.length === 12"> <ng-template #nzPopoverContent>
<nz-tag> 全年 </nz-tag> <div class="flex flex-wrap w-48">
</ng-container> <nz-tag *ngFor="let item of data" class="mb-1"> {{ item }}月 </nz-tag>
<ng-container *ngIf="data.length !== 12"> </div>
<nz-tag *ngFor="let item of data" class="mb-1"> </ng-template>
{{ item }}
</nz-tag>
</ng-container>
</div>
</ng-container> </ng-container>
<ng-container *ngSwitchDefault> <ng-container *ngSwitchDefault>
{{ data }} {{ data }}

8
projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

@ -82,9 +82,9 @@ export class IngredientListComponent {
{ key: 'name', title: '食谱名称', width: '200px' }, { key: 'name', title: '食谱名称', width: '200px' },
{ key: 'meals', title: '包含餐次', width: '180px' }, { key: 'meals', title: '包含餐次', width: '180px' },
{ key: 'month', title: '适用月份' }, { key: 'month', title: '适用月份', width: '100px' },
{ key: 'day', title: '周期' }, { key: 'day', title: '周期', width: '100px' },
{ key: 'status', title: '状态', width: '120px' }, { key: 'status', title: '状态', width: '80px' },
{ key: 'modify', title: '更新时间', width: '170px' }, { key: 'modify', title: '更新时间', width: '170px' },
{ key: 'operate', title: '创建人', width: '160px' }, { key: 'operate', title: '创建人', width: '160px' },
]) ])
@ -231,7 +231,7 @@ export class IngredientListComponent {
this.msg.error('请选择发布日期') this.msg.error('请选择发布日期')
return false return false
} }
console.log(id, day) // console.log(id, day)
const res = await lastValueFrom(this.api.release(id, this.startTime, day)) const res = await lastValueFrom(this.api.release(id, this.startTime, day))
this.msg.success(res.desc) this.msg.success(res.desc)
this.tableList.run() this.tableList.run()

Loading…
Cancel
Save