Browse Source

复制食谱

main
kely 2 years ago
parent
commit
c01f8b36f5
  1. 2
      projects/admin/src/app/pages/dish/dish.component.html
  2. 2
      projects/admin/src/app/pages/dish/dish.component.ts
  3. 196
      projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.html
  4. 44
      projects/admin/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts
  5. 2
      projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts
  6. 5
      projects/cdk/src/services/api.service.ts
  7. 11
      projects/cdk/src/shared/components/org-select/org-select.component.html
  8. 55
      projects/cdk/src/shared/components/org-select/org-select.component.ts
  9. 52
      projects/client/src/app/components/app-layout/app-layout.component.html
  10. 2
      projects/client/src/app/pages/dish/dish.component.html
  11. 2
      projects/client/src/app/pages/dish/dish.component.ts
  12. 199
      projects/client/src/app/pages/ingredients/ingredient-list/ingredient-list.component.ts

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

@ -64,7 +64,7 @@
{{ tableOrg[data] ? tableOrg[data].name : '-' }}
</ng-container>
<ng-container *ngSwitchCase="'label'">
<nz-tag *ngFor="let item of data ?? []">
<nz-tag *ngFor="let item of data ?? []" nzColor="blue">
{{ item }}
</nz-tag>
</ng-container>

2
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: '单位' },

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

@ -1,33 +1,38 @@
<app-page>
<ng-template #pageExtraTpl>
<nz-space>
<a *nzSpaceItem nz-button nzType="primary" target="_blank"
[routerLink]="['/','ingredient','item','form','create']">
<i nz-icon nzType="plus"></i>
创建食谱
</a>
</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"
optionWidth="300px">
<ng-template #actionTpl>
<button nz-button>批量删除</button>
</ng-template>
<ng-template #searchTpl>
<nz-form-item class="w-60">
<nz-form-control>
<app-org-select formControlName="vender"></app-org-select>
</nz-form-control>
</nz-form-item>
<!-- <nz-form-item class="w-40">
<ng-template #pageExtraTpl>
<nz-space>
<a
*nzSpaceItem
nz-button
nzType="primary"
target="_blank"
[routerLink]="['/', 'ingredient', 'item', 'form', 'create']"
>
<i nz-icon nzType="plus"></i>
创建食谱
</a>
</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"
optionWidth="300px"
>
<ng-template #actionTpl>
<button nz-button>批量删除</button>
</ng-template>
<ng-template #searchTpl>
<nz-form-item class="w-60">
<nz-form-control>
<app-org-select formControlName="vender"></app-org-select>
</nz-form-control>
</nz-form-item>
<!-- <nz-form-item class="w-40">
<nz-form-control>
<nz-select nzPlaceHolder="状态" formControlName="status" [nzAllowClear]="true">
<nz-option *ngFor="let item of globalEnum.menuStatus" [nzValue]="item.label"
@ -36,75 +41,72 @@
</nz-select>
</nz-form-control>
</nz-form-item> -->
<nz-form-item>
<nz-form-control>
<input nz-input placeholder="请输入食谱名称" formControlName="name" />
</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="'modify'">
{{data | date:'yyyy-MM-dd HH:mm:ss'}}
</ng-container>
<ng-container *ngSwitchCase="'vender'">
{{ tableOrg[data] ? tableOrg[data].name : '-'}}
</ng-container>
<ng-container *ngSwitchCase="'meals'">
<nz-tag *ngFor="let item of data">{{item}}</nz-tag>
</ng-container>
<ng-container *ngSwitchCase="'day'">
周{{data}}
</ng-container>
<ng-container *ngSwitchCase="'status'">
{{statusTextMap[data]}}
</ng-container>
<ng-container *ngSwitchCase="'month'">
<div class="flex flex-wrap">
<ng-container *ngIf="data.length === 12">
<nz-tag>
全年
</nz-tag>
</ng-container>
<ng-container *ngIf="data.length !== 12">
<nz-tag *ngFor="let item of data" class="mb-1">
{{item}}
</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="name" />
</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="'modify'">
{{ data | date : 'yyyy-MM-dd HH:mm:ss' }}
</ng-container>
<ng-container *ngSwitchCase="'vender'">
{{ tableOrg[data] ? tableOrg[data].name : '-' }}
</ng-container>
<ng-container *ngSwitchCase="'meals'">
<nz-tag *ngFor="let item of data">{{ item }}</nz-tag>
</ng-container>
<ng-container *ngSwitchCase="'day'"> 周{{ data }} </ng-container>
<ng-container *ngSwitchCase="'status'">
{{ statusTextMap[data] }}
</ng-container>
<ng-container *ngSwitchCase="'month'">
<div class="flex flex-wrap">
<ng-container *ngIf="data.length === 12">
<nz-tag> 全年 </nz-tag>
</ng-container>
<ng-container *ngIf="data.length !== 12">
<nz-tag *ngFor="let item of data" class="mb-1">
{{ item }}
</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 #releaseStartTimeTpl>
<div nz-form>
<nz-alert nzType="warning"
nzMessage="注意"
[nzDescription]="warnTpl">
<ng-template #warnTpl>
<div>
1、请在发布前确认配餐内容是否正确,发布即视为已完成食谱审核;
</div>
<div>
2、已发布的食谱无法修改,如需调整,需取消发布后进行编辑
</div>
</ng-template>
</nz-alert>
<nz-form-item class="mt-4">
<nz-form-label nzSpan="6" [nzRequired]="true">
发布日期
</nz-form-label>
<nz-form-control nzSpan="12">
<nz-date-picker class="w-full" nzPlaceHolder="请选择发布日期" [(ngModel)]="startTime"></nz-date-picker>
</nz-form-control>
</nz-form-item>
</div>
<div nz-form>
<nz-alert nzType="warning" nzMessage="注意" [nzDescription]="warnTpl">
<ng-template #warnTpl>
<div>1、请在发布前确认配餐内容是否正确,发布即视为已完成食谱审核;</div>
<div>2、已发布的食谱无法修改,如需调整,需取消发布后进行编辑</div>
</ng-template>
</nz-alert>
<nz-form-item class="mt-4">
<nz-form-label nzSpan="6" [nzRequired]="true"> 发布日期 </nz-form-label>
<nz-form-control nzSpan="12">
<nz-date-picker class="w-full" nzPlaceHolder="请选择发布日期" [(ngModel)]="startTime"></nz-date-picker>
</nz-form-control>
</nz-form-item>
</div>
</ng-template>
<ng-template #copyTpl>
<form nz-form [formGroup]="copyForm" nzLayout="vertical">
<nz-form-item class="mt-4">
<nz-form-label [nzRequired]="true">单位</nz-form-label>
<nz-form-control>
<app-org-select mode="multiple" formControlName="vendors"></app-org-select>
</nz-form-control>
</nz-form-item>
</form>
</ng-template>

44
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
},
})
}

2
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]

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

@ -558,6 +558,11 @@ export class ApiService {
return this.http.get<ResponseType>(`/api/menu/analysis?${params}`)
}
copyMenu(id: string, name: string, vendors: string = '') {
const params = Utils.objectToHttpParams({ id, name, vendors })
return this.http.put<ResponseType>(` /api/menu/copy`, params)
}
getAnalysisEnergy(id: string, day?: number, crow?: string) {
const params = Utils.objectStringify({ id, day, crow })
return this.http.get<ResponseType>(`/api/menu/analysis/energy?${params}`)

11
projects/cdk/src/shared/components/org-select/org-select.component.html

@ -1,10 +1,3 @@
<nz-select
nzPlaceHolder="请选择单位"
[(ngModel)]="value"
(ngModelChange)="onSelectChange($event)">
<nz-option *ngFor="let o of listOfOption" [nzLabel]="o.label"
[nzValue]="o.value">
</nz-option>
<nz-select nzPlaceHolder="请选择单位" [nzMode]="mode" [(ngModel)]="value" (ngModelChange)="onSelectChange($event)">
<nz-option *ngFor="let o of listOfOption" [nzLabel]="o.label" [nzValue]="o.value"> </nz-option>
</nz-select>

55
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<void>();
private destroy$ = new Subject<void>()
private orgSearch$ = new Subject<string>();
private orgSearch$ = new Subject<string>()
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<OptionItemInterface> = [];
const listOfOption: Array<OptionItemInterface> = []
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
}
}

52
projects/client/src/app/components/app-layout/app-layout.component.html

@ -7,10 +7,7 @@
<nz-header class="app-header">
<div class="flex items-center justify-between h-full">
<div class="logo flex items-center h-full">
<img
class="block h-[40px] mr-1"
src="../assets/images/jl-logo.png"
/>
<img class="block h-[40px] mr-1" src="../assets/images/jl-logo.png" />
<span class="text-lg text-white font-bold">
{{ appName }}
</span>
@ -26,31 +23,16 @@
{{ account.name }}
</button>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul
nz-menu
nzSelectable
>
<li
nz-menu-item
(click)="logout()"
>
退出登录
</li>
<ul nz-menu nzSelectable>
<li nz-menu-item (click)="logout()">退出登录</li>
</ul>
</nz-dropdown-menu>
</div>
</div>
</nz-header>
<nz-layout class="app-layout-main">
<nz-sider
nzWidth="200px"
class="sider-menu"
nzTheme="light"
>
<ul
nz-menu
nzMode="inline"
>
<nz-sider nzWidth="200px" class="sider-menu" nzTheme="light">
<ul nz-menu nzTheme="light" nzMode="inline">
<li
nz-menu-item
class="k-icon"
@ -58,11 +40,7 @@
nzMatchRouter
*ngxPermissionsOnly="['18']"
>
<span
nz-icon
nzType="question-circle"
nzTheme="outline"
></span>
<span nz-icon nzType="question-circle" nzTheme="outline"></span>
<span>使用流程</span>
</li>
<li
@ -72,11 +50,7 @@
nzMatchRouter
*ngxPermissionsOnly="['19', '20']"
>
<span
nz-icon
nzType="fund"
nzTheme="outline"
></span>
<span nz-icon nzType="fund" nzTheme="outline"></span>
<span>大屏显示</span>
</li>
<!-- <li nz-menu-item [routerLink]="['/','meal-setting']" nzMatchRouter
@ -91,11 +65,7 @@
nzMatchRouter
*ngxPermissionsOnly="['23', '24']"
>
<span
nz-icon
nzType="k-icon:carrot"
nzTheme="outline"
></span>
<span nz-icon nzType="k-icon:carrot" nzTheme="outline"></span>
<span>食材管理</span>
</li>
<li
@ -105,11 +75,7 @@
nzMatchRouter
*ngxPermissionsOnly="['25', '26']"
>
<span
nz-icon
nzType="k-icon:food"
nzTheme="outline"
></span>
<span nz-icon nzType="k-icon:food" nzTheme="outline"></span>
<span>菜品管理</span>
</li>

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

@ -73,7 +73,7 @@
{{ tableOrg[data] ? tableOrg[data].name : '-' }}
</ng-container>
<ng-container *ngSwitchCase="'label'">
<nz-tag *ngFor="let item of data ?? []">
<nz-tag *ngFor="let item of data ?? []" nzColor="blue">
{{ item }}
</nz-tag>
</ng-container>

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

@ -93,7 +93,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%' },
])

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

@ -1,18 +1,18 @@
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 { ApiService } from "@cdk/services";
import { NzModalService } from "ng-zorro-antd/modal";
import { lastValueFrom, tap } from "rxjs";
import { NzMessageService } from "ng-zorro-antd/message";
import { MyResponse } from "@cdk/types";
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, OrgDTO, TableListOption } from '@cdk/public-api'
import { ApiService } from '@cdk/services'
import { NzModalService } from 'ng-zorro-antd/modal'
import { lastValueFrom, tap } from 'rxjs'
import { NzMessageService } from 'ng-zorro-antd/message'
import { MyResponse } from '@cdk/types'
import { Router } from '@angular/router'
@Component({
selector: "app-ingredient-list",
templateUrl: "./ingredient-list.component.html",
styleUrls: ["./ingredient-list.component.less"],
selector: 'app-ingredient-list',
templateUrl: './ingredient-list.component.html',
styleUrls: ['./ingredient-list.component.less'],
})
export class IngredientListComponent {
constructor(
@ -20,77 +20,77 @@ export class IngredientListComponent {
private api: ApiService,
private modal: NzModalService,
private msg: NzMessageService,
private router: Router
private router: Router,
) {}
globalEnum = this.api.globalEnum;
globalEnum = this.api.globalEnum
statusTextMap: Record<string, string> = {};
statusTextMap: Record<string, string> = {}
@ViewChild("releaseStartTimeTpl") releaseStartTimeTpl!: TemplateRef<{}>;
@ViewChild('releaseStartTimeTpl') releaseStartTimeTpl!: TemplateRef<{}>
private drawerRef?: NzDrawerRef;
private drawerRef?: NzDrawerRef
public tableList = new TableListOption(this.fetchData.bind(this), {
frontPagination: false,
});
})
public queryForm = new FormGroup({
name: new FormControl(""),
vender: new FormControl(""),
status: new FormControl(""),
});
name: new FormControl(''),
vender: new FormControl(''),
status: new FormControl(''),
})
startTime: Date | null = null;
startTime: Date | null = null
tableOrg: { [k: number]: OrgDTO } = {};
tableOrg: { [k: number]: OrgDTO } = {}
monthText = {
1: "一月",
2: "二月",
3: "三月",
4: "四月",
5: "五月",
6: "六月",
7: "七月",
8: "八月",
9: "九月",
10: "十月",
11: "十一月",
12: "十二月",
} as any;
1: '一月',
2: '二月',
3: '三月',
4: '四月',
5: '五月',
6: '六月',
7: '七月',
8: '八月',
9: '九月',
10: '十月',
11: '十一月',
12: '十二月',
} as any
ngOnInit(): void {
this.statusTextMap = this.globalEnum.menuStatus.reduce((a, c) => {
return {
...a,
[String(c.label)]: c.value,
};
}, {} as Record<string, string>);
this.initTableList();
}
}, {} as Record<string, string>)
this.initTableList()
}
initTableList() {
this.tableList.scroll = { x: "900px" };
this.tableList.scroll = { x: '900px' }
this.tableList = this.tableList.setColumns([
{ key: "name", title: "食谱名称", width: "200px" },
{ key: 'name', title: '食谱名称', width: '200px' },
{ key: "meals", title: "包含餐次", width: "180px" },
{ key: "month", title: "适用月份" },
{ key: "day", title: "周期" },
{ key: "status", title: "状态", width: "120px" },
{ key: "modify", title: "更新时间", width: "170px" },
{ key: "operate", title: "创建人", width: "160px" },
]);
{ key: 'meals', title: '包含餐次', width: '180px' },
{ key: 'month', title: '适用月份' },
{ key: 'day', title: '周期' },
{ key: 'status', title: '状态', width: '120px' },
{ key: 'modify', title: '更新时间', width: '170px' },
{ key: 'operate', title: '创建人', width: '160px' },
])
this.tableList = this.tableList.setOptions([
{
title: "详情",
title: '详情',
premissions: [],
onClick: this.preview.bind(this),
},
{
title: "导出",
title: '导出',
premissions: [],
onClick: this.export.bind(this),
@ -109,11 +109,11 @@ export class IngredientListComponent {
// },
// },
{
title: "发布",
title: '发布',
premissions: [],
onClick: this.release.bind(this),
visible(v) {
return [0, 2].includes(v.status);
return [0, 2].includes(v.status)
},
},
// {
@ -125,97 +125,116 @@ export class IngredientListComponent {
// },
// },
{
title: "编辑",
title: '复制',
premissions: [],
onClick: this.copy.bind(this),
},
{
title: '编辑',
premissions: [],
onClick: (v) => {
this.router.navigate([`/ingredient/item/form/${v["id"]}`]);
this.router.navigate([`/ingredient/item/form/${v['id']}`])
},
visible(v) {
return [0, 3, 4].includes(v.status);
return [0, 3, 4].includes(v.status)
},
},
{
title: "删除",
title: '删除',
premissions: [],
onClick: this.deleteItem.bind(this),
},
]);
])
}
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()
},
})
}
fetchData(query: AnyObject, pager: AnyObject) {
return this.api.getMenuPage(pager, query).pipe();
return this.api.getMenuPage(pager, query).pipe()
}
preview({ id }: any) {
window.open(`/ingredient/preview?id=${id}`);
window.open(`/ingredient/preview?id=${id}`)
}
export({ id }: any) {
this.msg.loading("导出中...");
this.msg.loading('导出中...')
this.api.exportMenu(id).subscribe(() => {
setTimeout(() => {
this.msg.remove();
}, 1500);
});
this.msg.remove()
}, 1500)
})
}
cancelFoodForm() {
this.drawerRef?.close();
this.drawerRef?.close()
}
shenhe({ id }: any) {
this.modal.confirm({
nzTitle: "警告",
nzTitle: '警告',
nzContent: `是否要将该食谱提交审核?`,
nzOnOk: async () => {
const res = await lastValueFrom(this.api.submitMenuForReview(id));
this.msg.success(res.desc);
this.tableList.run();
const res = await lastValueFrom(this.api.submitMenuForReview(id))
this.msg.success(res.desc)
this.tableList.run()
},
});
})
}
release({ id, day }: any) {
this.modal.create({
nzTitle: "发布食谱",
nzTitle: '发布食谱',
nzContent: this.releaseStartTimeTpl,
nzOnOk: async () => {
if (!this.startTime) {
this.msg.error("请选择发布日期");
return false;
this.msg.error('请选择发布日期')
return false
}
console.log(id, day);
const res = await lastValueFrom(this.api.release(id, this.startTime, day));
this.msg.success(res.desc);
this.tableList.run();
return true;
console.log(id, day)
const res = await lastValueFrom(this.api.release(id, this.startTime, day))
this.msg.success(res.desc)
this.tableList.run()
return true
},
});
})
}
deleteItem({ id }: any) {
this.modal.confirm({
nzTitle: "警告",
nzTitle: '警告',
nzContent: `是否要删除该食谱?`,
nzOkDanger: true,
nzOnOk: async () => {
const res = await lastValueFrom(this.api.deleteMenu(id));
this.msg.success(res.desc);
this.tableList.run();
const res = await lastValueFrom(this.api.deleteMenu(id))
this.msg.success(res.desc)
this.tableList.run()
},
});
})
}
disableMenu({ id }: any) {
this.modal.confirm({
nzTitle: "警告",
nzTitle: '警告',
nzContent: `是否要禁用该食谱?`,
nzOkDanger: true,
nzOnOk: async () => {
const res = await lastValueFrom(this.api.disableMenu(id));
this.msg.success(res.desc);
this.tableList.run();
const res = await lastValueFrom(this.api.disableMenu(id))
this.msg.success(res.desc)
this.tableList.run()
},
});
})
}
}

Loading…
Cancel
Save