配餐项目前端文件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.1 KiB

2 years ago
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";
2 years ago
import { ApiService } from "@cdk/services";
2 years ago
@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() {}
}