|
|
|
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 { DishFormComponent } from "@admin/app/components";
|
|
|
|
import { ApiService } from "@cdk/services";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: "app-ingredient-release",
|
|
|
|
templateUrl: "./ingredient-release.component.html",
|
|
|
|
styleUrls: ["./ingredient-release.component.less"],
|
|
|
|
})
|
|
|
|
export class IngredientReleaseComponent {
|
|
|
|
constructor(private drawer: NzDrawerService, private api: ApiService) {}
|
|
|
|
|
|
|
|
@ViewChild("foofFormFooterTpl") foofFormFooterTpl!: TemplateRef<{}>;
|
|
|
|
|
|
|
|
private drawerRef?: NzDrawerRef;
|
|
|
|
|
|
|
|
tempImg = "https://cdn.pixabay.com/photo/2023/08/08/18/01/butterfly-8177925_1280.jpg";
|
|
|
|
|
|
|
|
public tableList = new TableListOption(this.fetchData.bind(this));
|
|
|
|
|
|
|
|
public queryForm = new FormGroup({
|
|
|
|
name: new FormControl(""),
|
|
|
|
});
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.initTableList();
|
|
|
|
}
|
|
|
|
|
|
|
|
initTableList() {
|
|
|
|
this.tableList.scroll = { x: null };
|
|
|
|
this.tableList = this.tableList.setColumns([
|
|
|
|
{ key: "name", title: "食谱名称" },
|
|
|
|
{ key: "name", title: "单位" },
|
|
|
|
{ key: "name", title: "包含餐次" },
|
|
|
|
{ key: "name", title: "周期" },
|
|
|
|
{ key: "name", title: "创建时间" },
|
|
|
|
{ key: "name", title: "应用时间" },
|
|
|
|
]);
|
|
|
|
|
|
|
|
this.tableList = this.tableList.setOptions([
|
|
|
|
{
|
|
|
|
title: "详情",
|
|
|
|
premissions: [],
|
|
|
|
onClick: this.showFoodForm.bind(this),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "导出食谱",
|
|
|
|
premissions: [],
|
|
|
|
onClick: this.showFoodForm.bind(this),
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
title: "取消发布",
|
|
|
|
premissions: [],
|
|
|
|
onClick: this.showFoodForm.bind(this),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchData(query: AnyObject, pager: AnyObject) {
|
|
|
|
return this.api.page(pager, query);
|
|
|
|
}
|
|
|
|
|
|
|
|
showFoodForm(food?: any) {
|
|
|
|
this.drawerRef = this.drawer.create({
|
|
|
|
nzTitle: food ? "编辑菜品" : "新增菜品",
|
|
|
|
nzWidth: 700,
|
|
|
|
nzContent: DishFormComponent,
|
|
|
|
nzFooter: this.foofFormFooterTpl,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
cancelFoodForm() {
|
|
|
|
this.drawerRef?.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteItem() {}
|
|
|
|
}
|