15 changed files with 396 additions and 118 deletions
@ -0,0 +1,68 @@ |
|||||
|
<table-list [props]="tableList" [search]="searchTpl" [formGroup]="queryForm" |
||||
|
[renderColumns]="renderColumnsTpl"> |
||||
|
|
||||
|
<ng-template #actionTpl> |
||||
|
<button nz-button>批量删除</button> |
||||
|
</ng-template> |
||||
|
<ng-template #searchTpl> |
||||
|
<nz-form-item class="w-40"> |
||||
|
<nz-form-control> |
||||
|
<nz-select nzPlaceHolder="单位" [nzOptions]="[]"></nz-select> |
||||
|
</nz-form-control> |
||||
|
</nz-form-item> |
||||
|
<nz-form-item class="w-40"> |
||||
|
<nz-form-control> |
||||
|
<nz-select nzPlaceHolder="状态" [nzOptions]="[]"></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="'meals'"> |
||||
|
<nz-tag *ngFor="let item of data">{{item}}</nz-tag> |
||||
|
</ng-container> |
||||
|
<ng-container *ngSwitchCase="'day'"> |
||||
|
{{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"> |
||||
|
{{monthText[item]}} |
||||
|
</nz-tag> |
||||
|
</ng-container> |
||||
|
</div> |
||||
|
</ng-container> |
||||
|
<ng-container *ngSwitchDefault> |
||||
|
{{data}} |
||||
|
</ng-container> |
||||
|
</ng-container> |
||||
|
</ng-template> |
||||
|
</table-list> |
||||
|
|
||||
|
|
||||
|
<ng-template #reviewFailMenuTpl> |
||||
|
<div nz-form> |
||||
|
<nz-form-item> |
||||
|
<nz-form-label nzSpan="6"> |
||||
|
驳回原因 |
||||
|
</nz-form-label> |
||||
|
<nz-form-control nzSpan="12"> |
||||
|
<textarea nz-input placeholder="请输入驳回原因" [(ngModel)]="reason"></textarea> |
||||
|
</nz-form-control> |
||||
|
</nz-form-item> |
||||
|
</div> |
||||
|
</ng-template> |
@ -0,0 +1,139 @@ |
|||||
|
import { Component, Input, 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"; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: "app-ingredient-status-list", |
||||
|
templateUrl: "./ingredient-status-list.component.html", |
||||
|
styleUrls: ["./ingredient-status-list.component.less"], |
||||
|
}) |
||||
|
export class IngredientStatusListComponent { |
||||
|
constructor( |
||||
|
private drawer: NzDrawerService, |
||||
|
private api: ApiService, |
||||
|
private modal: NzModalService, |
||||
|
private msg: NzMessageService |
||||
|
) {} |
||||
|
|
||||
|
@Input() status!: number; |
||||
|
|
||||
|
reason = ""; |
||||
|
|
||||
|
@ViewChild("reviewFailMenuTpl") reviewFailMenuTpl!: TemplateRef<{}>; |
||||
|
|
||||
|
private drawerRef?: NzDrawerRef; |
||||
|
|
||||
|
public tableList = new TableListOption(this.fetchData.bind(this), { |
||||
|
frontPagination: false, |
||||
|
}); |
||||
|
|
||||
|
public queryForm = new FormGroup({ |
||||
|
name: new FormControl(""), |
||||
|
}); |
||||
|
|
||||
|
monthText = { |
||||
|
1: "一月", |
||||
|
2: "二月", |
||||
|
3: "三月", |
||||
|
4: "四月", |
||||
|
5: "五月", |
||||
|
6: "六月", |
||||
|
7: "七月", |
||||
|
8: "八月", |
||||
|
9: "九月", |
||||
|
10: "十月", |
||||
|
11: "十一月", |
||||
|
12: "十二月", |
||||
|
} as any; |
||||
|
|
||||
|
ngOnInit(): void { |
||||
|
this.initTableList(); |
||||
|
} |
||||
|
|
||||
|
initTableList() { |
||||
|
this.tableList.scroll = { x: null }; |
||||
|
this.tableList = this.tableList.setColumns([ |
||||
|
{ key: "name", title: "食谱名称" }, |
||||
|
{ key: "vender", title: "单位" }, |
||||
|
|
||||
|
{ key: "modify", title: "提交审核时间" }, |
||||
|
{ key: "modify", title: "提交人" }, |
||||
|
]); |
||||
|
|
||||
|
this.tableList = this.tableList.setOptions([ |
||||
|
{ |
||||
|
title: "详情", |
||||
|
premissions: [], |
||||
|
onClick: this.showFoodForm.bind(this), |
||||
|
}, |
||||
|
{ |
||||
|
title: "导出", |
||||
|
premissions: [], |
||||
|
onClick: this.showFoodForm.bind(this), |
||||
|
}, |
||||
|
{ |
||||
|
title: "通过", |
||||
|
premissions: [], |
||||
|
onClick: this.reviewSuccessMenu.bind(this), |
||||
|
visible: () => { |
||||
|
return this.status === 1; |
||||
|
}, |
||||
|
}, |
||||
|
{ |
||||
|
title: "驳回", |
||||
|
premissions: [], |
||||
|
onClick: this.reviewFailMenu.bind(this), |
||||
|
visible: () => { |
||||
|
return this.status === 1; |
||||
|
}, |
||||
|
}, |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
fetchData(query: AnyObject, pager: AnyObject) { |
||||
|
return this.api.getMenuStatusPage(pager, { ...query, status: this.status }); |
||||
|
} |
||||
|
|
||||
|
showFoodForm(food?: any) { |
||||
|
this.drawerRef = this.drawer.create({ |
||||
|
nzTitle: food ? "编辑菜品" : "新增菜品", |
||||
|
nzWidth: 700, |
||||
|
nzContent: DishFormComponent, |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
cancelFoodForm() { |
||||
|
this.drawerRef?.close(); |
||||
|
} |
||||
|
|
||||
|
reviewSuccessMenu({ id }: any) { |
||||
|
this.modal.confirm({ |
||||
|
nzTitle: "警告", |
||||
|
nzContent: `是否要通过审核该食谱?`, |
||||
|
nzOkDanger: true, |
||||
|
nzOnOk: async () => { |
||||
|
const res = await lastValueFrom(this.api.reviewMenu(id, true)); |
||||
|
this.msg.success(res.desc); |
||||
|
this.tableList.run(); |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
reviewFailMenu({ id }: any) { |
||||
|
this.modal.create({ |
||||
|
nzTitle: "审核驳回", |
||||
|
nzContent: this.reviewFailMenuTpl, |
||||
|
nzOnOk: async () => { |
||||
|
const res = await lastValueFrom(this.api.reviewMenu(id, false, this.reason)); |
||||
|
this.msg.success(res.desc); |
||||
|
this.tableList.run(); |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue