From a0cb971fd01fe7e2736ddf927442b02b6e82b962 Mon Sep 17 00:00:00 2001 From: kkerwin Date: Tue, 12 Dec 2023 22:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=8F=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ingredient-list.component.html | 6 + .../ingredient-list.component.ts | 16 +- .../standard-list.component.html | 95 ++++----- .../standard-list/standard-list.component.ts | 44 ++-- .../ingredient-list.component.html | 190 +++++++++--------- .../ingredient-list.component.ts | 44 +++- 6 files changed, 229 insertions(+), 166 deletions(-) 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 32dd623..136df85 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 @@ -102,6 +102,12 @@
+ + 名称 + + + + 单位 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 293b346..774a31e 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, Utils } from '@cdk/public-api' +import { AnyObject, FormValidators, OrgDTO, TableListOption, Utils } from '@cdk/public-api' import { ApiService } from '@cdk/services' import { NzModalService } from 'ng-zorro-antd/modal' import { lastValueFrom, tap } from 'rxjs' @@ -44,7 +44,8 @@ export class IngredientListComponent { }) public copyForm = new FormGroup({ - vendors: new FormControl([]), + name: new FormControl('', [FormValidators.required('请输入食谱名称')]), + vendors: new FormControl([], [FormValidators.required('请选择单位')]), }) startTime: Date | null = null @@ -197,14 +198,19 @@ export class IngredientListComponent { } copy(v: AnyObject) { + const copyName = v['name'] + '【复制】' + this.copyForm.patchValue({ + name: copyName, + }) this.modal.create({ nzTitle: '复制食谱', nzContent: this.copyTpl, nzOnOk: async () => { 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)) + const val = this.copyForm.value + const name = val.name! + const vendors = val.vendors?.join(',') + const res = await lastValueFrom(this.api.copyMenu(v['id'], name, vendors)) this.msg.success(res.desc) this.tableList.run() return true diff --git a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html index 6676700..3536d21 100644 --- a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html +++ b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html @@ -1,47 +1,52 @@ - - - - - -
+ + + + + +
+ + + + + + + + + + + + + {{ data | date : 'yyyy-MM-dd HH:mm:ss' }} + + {{ data.length }}个单位 + {{ data.length }}个人群 + + {{ data }} + + + + + +
+ - - - - - - - - - - - - - - - - {{ data|date:'yyyy-MM-dd HH:mm:ss'}} - - - {{ data.length }}个单位 - - - {{ data.length }}个人群 - - - {{data}} - - - - - -
-
\ No newline at end of file + + + + 名称 + + + + + + diff --git a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts index d0f9e43..9213f94 100644 --- a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts +++ b/projects/admin/src/app/pages/standard/standard-list/standard-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, TableListOption } from '@cdk/public-api' +import { AnyObject, FormValidators, TableListOption, Utils } from '@cdk/public-api' import { DishFormComponent } from '@admin/app/components' import { ApiService } from '@cdk/services' import { NzModalService } from 'ng-zorro-antd/modal' @@ -28,6 +28,12 @@ export class StandardListComponent { frontPagination: false, }) + public copyForm = new FormGroup({ + name: new FormControl('', [FormValidators.required('请输入名称')]), + }) + + @ViewChild('copyTpl') copyTpl!: TemplateRef<{}> + public queryForm = new FormGroup({ keyword: new FormControl(''), }) @@ -73,20 +79,30 @@ export class StandardListComponent { return this.api.getStandardPage(pager, query) } - copy(standard: AnyObject) { - this.modal.confirm({ - nzTitle: '警告', - nzContent: '是否要复制该标准?', + copy(v: AnyObject) { + const copyName = v['name'] + '【复制】' + this.copyForm.patchValue({ + name: copyName, + }) + this.modal.create({ + nzTitle: '复制营养标准', + nzContent: this.copyTpl, nzOnOk: async () => { - const res = await lastValueFrom( - this.api.saveStandard({ - ...standard, - name: standard['name'] + '【复制】', - id: null, - }), - ) - this.msg.success(res.desc) - this.tableList.run() + if (Utils.validateFormGroup(this.copyForm)) { + const val = this.copyForm.value + const name = val.name! + const res = await lastValueFrom( + this.api.saveStandard({ + ...v, + name, + id: null, + }), + ) + this.msg.success(res.desc) + this.tableList.run() + return true + } + return false }, }) } diff --git a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html b/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html index b3ffe2b..5f08cc5 100644 --- a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html +++ b/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html @@ -1,29 +1,33 @@ - - - - - 创建食谱 - - - -
- - - - - - - - - - - - - - - - - - - - {{data | date:'yyyy-MM-dd HH:mm:ss'}} - - - {{ tableOrg[data] ? tableOrg[data].name : '-'}} - + + + + + + + + + + {{ data | date : 'yyyy-MM-dd HH:mm:ss' }} + + + {{ tableOrg[data] ? tableOrg[data].name : '-' }} + - - {{item}} - - - 周{{data}} - - - {{statusTextMap[data]}} - - -
- - - 全年 - - - - - {{item}} - - -
-
- - {{data}} - -
-
-
-
-
+ + {{ item }} + + 周{{ data }} + + {{ statusTextMap[data] }} + + +
+ + 全年 + + + + {{ item }} + + +
+
+ + {{ data }} + + +
+ + + - -
- - -
- 1、请在发布前确认配餐内容是否正确,发布即视为已完成食谱审核; -
-
- 2、已发布的食谱无法修改,如需调整,需取消发布后进行编辑 -
-
-
- - - 发布日期 - - - - - -
-
\ No newline at end of file +
+ + +
1、请在发布前确认配餐内容是否正确,发布即视为已完成食谱审核;
+
2、已发布的食谱无法修改,如需调整,需取消发布后进行编辑
+
+
+ + 发布日期 + + + + +
+ + + +
+ + 名称 + + + + +
+
diff --git a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts b/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts index 6579dfe..8232b69 100644 --- a/projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts +++ b/projects/client/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, FormValidators, 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,12 +29,18 @@ export class IngredientListComponent { @ViewChild('releaseStartTimeTpl') releaseStartTimeTpl!: TemplateRef<{}> + @ViewChild('copyTpl') copyTpl!: TemplateRef<{}> + private drawerRef?: NzDrawerRef public tableList = new TableListOption(this.fetchData.bind(this), { frontPagination: false, }) + public copyForm = new FormGroup({ + name: new FormControl('', [FormValidators.required('请输入食谱名称')]), + }) + public queryForm = new FormGroup({ name: new FormControl(''), vender: new FormControl(''), @@ -148,15 +154,37 @@ export class IngredientListComponent { ]) } + // copy(v: AnyObject) { + // this.modal.confirm({ + // nzTitle: '警告', + // nzContent: '是否要复制该食谱?', + // nzOnOk: async () => { + // const copyName = v['name'] + '【复制】' + // const res = await lastValueFrom(this.api.copyMenu(v['id'], copyName)) + // this.msg.success(res.desc) + // this.tableList.run() + // }, + // }) + // } + copy(v: AnyObject) { - this.modal.confirm({ - nzTitle: '警告', - nzContent: '是否要复制该食谱?', + const copyName = v['name'] + '【复制】' + this.copyForm.patchValue({ + name: copyName, + }) + this.modal.create({ + nzTitle: '复制食谱', + nzContent: this.copyTpl, nzOnOk: async () => { - const copyName = v['name'] + '【复制】' - const res = await lastValueFrom(this.api.copyMenu(v['id'], copyName)) - this.msg.success(res.desc) - this.tableList.run() + if (Utils.validateFormGroup(this.copyForm)) { + const val = this.copyForm.value + const name = val.name! + const res = await lastValueFrom(this.api.copyMenu(v['id'], name)) + this.msg.success(res.desc) + this.tableList.run() + return true + } + return false }, }) }