From c01f8b36f50a0ea4007721730eaa1d221e9b11df Mon Sep 17 00:00:00 2001 From: kely Date: Mon, 11 Dec 2023 14:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E9=A3=9F=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/app/pages/dish/dish.component.html | 2 +- .../src/app/pages/dish/dish.component.ts | 2 +- .../ingredient-list.component.html | 198 ++++++++--------- .../ingredient-list.component.ts | 44 ++-- .../standard-setting.component.ts | 2 +- projects/cdk/src/services/api.service.ts | 5 + .../org-select/org-select.component.html | 13 +- .../org-select/org-select.component.ts | 55 ++--- .../app-layout/app-layout.component.html | 52 +---- .../src/app/pages/dish/dish.component.html | 2 +- .../src/app/pages/dish/dish.component.ts | 2 +- .../ingredient-list.component.ts | 199 ++++++++++-------- 12 files changed, 284 insertions(+), 292 deletions(-) diff --git a/projects/admin/src/app/pages/dish/dish.component.html b/projects/admin/src/app/pages/dish/dish.component.html index 7b13a28..7cde65e 100644 --- a/projects/admin/src/app/pages/dish/dish.component.html +++ b/projects/admin/src/app/pages/dish/dish.component.html @@ -64,7 +64,7 @@ {{ tableOrg[data] ? tableOrg[data].name : '-' }} - + {{ item }} diff --git a/projects/admin/src/app/pages/dish/dish.component.ts b/projects/admin/src/app/pages/dish/dish.component.ts index 07995aa..ba0667e 100644 --- a/projects/admin/src/app/pages/dish/dish.component.ts +++ b/projects/admin/src/app/pages/dish/dish.component.ts @@ -115,7 +115,7 @@ export class DishComponent { { key: 'icon', title: '菜品图片', width: '66px' }, { key: 'name', title: '菜品名称' }, { key: 'marks', title: '菜品标签' }, - { key: 'label', title: '三低菜品标识' }, + { key: 'label', title: '三低标识' }, { key: 'poly', title: '烹饪方式' }, { key: 'ingredient', title: '食材及含量', width: '30%' }, { key: 'vender', title: '单位' }, diff --git a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html index eaf14c2..32dd623 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html +++ b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html @@ -1,33 +1,38 @@ - - - - - 创建食谱 - - - -
- - - - - - - - - - - - - - - - - - - - - - - - {{data | date:'yyyy-MM-dd HH:mm:ss'}} - - - {{ tableOrg[data] ? tableOrg[data].name : '-'}} - - - {{item}} - - - 周{{data}} - - - {{statusTextMap[data]}} - - -
- - - 全年 - - - - - {{item}} - - -
-
- - {{data}} - -
-
-
-
-
+ + + + + + + + + + {{ data | date : 'yyyy-MM-dd HH:mm:ss' }} + + + {{ tableOrg[data] ? tableOrg[data].name : '-' }} + + + {{ item }} + + 周{{ data }} + + {{ statusTextMap[data] }} + + +
+ + 全年 + + + + {{ item }} + + +
+
+ + {{ data }} + +
+
+ + +
- -
- - -
- 1、请在发布前确认配餐内容是否正确,发布即视为已完成食谱审核; -
-
- 2、已发布的食谱无法修改,如需调整,需取消发布后进行编辑 -
-
-
- - - 发布日期 - - - - - -
-
\ No newline at end of file +
+ + +
1、请在发布前确认配餐内容是否正确,发布即视为已完成食谱审核;
+
2、已发布的食谱无法修改,如需调整,需取消发布后进行编辑
+
+
+ + 发布日期 + + + + +
+ + +
+ + 单位 + + + + +
+
diff --git a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts index 19bf189..293b346 100644 --- a/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts +++ b/projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core' import { FormControl, FormGroup } from '@angular/forms' import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer' -import { AnyObject, OrgDTO, TableListOption } from '@cdk/public-api' +import { AnyObject, OrgDTO, TableListOption, Utils } from '@cdk/public-api' import { ApiService } from '@cdk/services' import { NzModalService } from 'ng-zorro-antd/modal' import { lastValueFrom, tap } from 'rxjs' @@ -29,6 +29,8 @@ export class IngredientListComponent { @ViewChild('releaseStartTimeTpl') releaseStartTimeTpl!: TemplateRef<{}> + @ViewChild('copyTpl') copyTpl!: TemplateRef<{}> + private drawerRef?: NzDrawerRef public tableList = new TableListOption(this.fetchData.bind(this), { @@ -41,6 +43,10 @@ export class IngredientListComponent { status: new FormControl(''), }) + public copyForm = new FormGroup({ + vendors: new FormControl([]), + }) + startTime: Date | null = null tableOrg: { [k: number]: OrgDTO } = {} @@ -92,7 +98,6 @@ export class IngredientListComponent { { title: '导出', premissions: [], - onClick: this.export.bind(this), }, // { @@ -124,11 +129,11 @@ export class IngredientListComponent { // return [2].includes(v.status); // }, // }, - // { - // title: '复制', - // premissions: [], - // onClick: this.copy.bind(this), - // }, + { + title: '复制', + premissions: [], + onClick: this.copy.bind(this), + }, { title: '编辑', premissions: [], @@ -192,20 +197,19 @@ export class IngredientListComponent { } copy(v: AnyObject) { - this.modal.confirm({ - nzTitle: '警告', - nzContent: '是否要复制该食谱?', + this.modal.create({ + nzTitle: '复制食谱', + nzContent: this.copyTpl, nzOnOk: async () => { - const res = await lastValueFrom( - this.api.saveMenu({ - name: v['name'] + '【复制】', - nutrient: v['nutrient'], - vendors: v['vendors'], - month: v, - }), - ) - this.msg.success(res.desc) - this.tableList.run() + if (Utils.validateFormGroup(this.copyForm)) { + const copyName = v['name'] + '【复制】' + const vendors = this.copyForm.value.vendors?.join(',') + const res = await lastValueFrom(this.api.copyMenu(v['id'], copyName, vendors)) + this.msg.success(res.desc) + this.tableList.run() + return true + } + return false }, }) } diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts index 2947f5e..23587fd 100644 --- a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts +++ b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts @@ -122,7 +122,7 @@ export class StandardSettingComponent implements AfterViewInit, OnDestroy { if (!data?.ingredient) { return [] } - console.log('data', data) + this.expand(0) const sorts = data.crows ?? Object.keys(data.ingredient) return sorts.map((peopleName: string) => { const v: any = data.ingredient[peopleName] diff --git a/projects/cdk/src/services/api.service.ts b/projects/cdk/src/services/api.service.ts index 54fe21c..950e80f 100644 --- a/projects/cdk/src/services/api.service.ts +++ b/projects/cdk/src/services/api.service.ts @@ -558,6 +558,11 @@ export class ApiService { return this.http.get(`/api/menu/analysis?${params}`) } + copyMenu(id: string, name: string, vendors: string = '') { + const params = Utils.objectToHttpParams({ id, name, vendors }) + return this.http.put(` /api/menu/copy`, params) + } + getAnalysisEnergy(id: string, day?: number, crow?: string) { const params = Utils.objectStringify({ id, day, crow }) return this.http.get(`/api/menu/analysis/energy?${params}`) diff --git a/projects/cdk/src/shared/components/org-select/org-select.component.html b/projects/cdk/src/shared/components/org-select/org-select.component.html index 62207a9..55b46c4 100644 --- a/projects/cdk/src/shared/components/org-select/org-select.component.html +++ b/projects/cdk/src/shared/components/org-select/org-select.component.html @@ -1,10 +1,3 @@ - - - - \ No newline at end of file + + + diff --git a/projects/cdk/src/shared/components/org-select/org-select.component.ts b/projects/cdk/src/shared/components/org-select/org-select.component.ts index 2033c14..80358bd 100644 --- a/projects/cdk/src/shared/components/org-select/org-select.component.ts +++ b/projects/cdk/src/shared/components/org-select/org-select.component.ts @@ -1,13 +1,14 @@ -import { Component, OnInit } from "@angular/core"; -import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms"; -import { ApiService } from "@cdk/services"; -import { OptionItemInterface } from "@cdk/types"; -import { Subject, debounceTime, distinctUntilChanged, filter, switchMap, takeUntil } from "rxjs"; +import { Component, Input, OnInit } from '@angular/core' +import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' +import { ApiService } from '@cdk/services' +import { OptionItemInterface } from '@cdk/types' +import { NzSelectModeType } from 'ng-zorro-antd/select' +import { Subject, debounceTime, distinctUntilChanged, filter, switchMap, takeUntil } from 'rxjs' @Component({ - selector: "app-org-select", - templateUrl: "./org-select.component.html", - styleUrls: ["./org-select.component.less"], + selector: 'app-org-select', + templateUrl: './org-select.component.html', + styleUrls: ['./org-select.component.less'], providers: [ { provide: NG_VALUE_ACCESSOR, @@ -19,55 +20,57 @@ import { Subject, debounceTime, distinctUntilChanged, filter, switchMap, takeUnt export class OrgSelectComponent implements OnInit, ControlValueAccessor { constructor(private api: ApiService) {} - private destroy$ = new Subject(); + private destroy$ = new Subject() - private orgSearch$ = new Subject(); + private orgSearch$ = new Subject() - nzFilterOption = (): boolean => true; + @Input() mode: NzSelectModeType = 'default' - value?: string | string[]; + nzFilterOption = (): boolean => true - listOfOption: OptionItemInterface[] = []; + value?: string | string[] + + listOfOption: OptionItemInterface[] = [] ngOnInit(): void { this.api.getOrgList().subscribe((data) => { - const listOfOption: Array = []; + const listOfOption: Array = [] data.forEach((item) => { listOfOption.push({ value: String(item.id), label: item.name, - }); - }); - this.listOfOption = listOfOption; - }); + }) + }) + this.listOfOption = listOfOption + }) } ngOnDestroy(): void { - this.destroy$.next(); - this.destroy$.complete(); + this.destroy$.next() + this.destroy$.complete() } onSelectChange(v: any) { - this.onChange(v); + this.onChange(v) } searchOrg = (k: string) => { - this.orgSearch$.next(k); - }; + this.orgSearch$.next(k) + } onChange(v: number[]) {} ontouch(v: any) {} writeValue(v?: string[] | string): void { - this.value = v; + this.value = v } registerOnChange(fn: any): void { - this.onChange = fn; + this.onChange = fn } registerOnTouched(fn: any): void { - this.ontouch = fn; + this.ontouch = fn } } diff --git a/projects/client/src/app/components/app-layout/app-layout.component.html b/projects/client/src/app/components/app-layout/app-layout.component.html index 98c11eb..a2aa28f 100644 --- a/projects/client/src/app/components/app-layout/app-layout.component.html +++ b/projects/client/src/app/components/app-layout/app-layout.component.html @@ -7,10 +7,7 @@
- -
    + +
    • - + 使用流程
    • - + 大屏显示