|
|
@ -4,6 +4,10 @@ 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"; |
|
|
|
import { Router } from "@angular/router"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: "app-standard-list", |
|
|
@ -11,16 +15,17 @@ import { ApiService } from "@cdk/services"; |
|
|
|
styleUrls: ["./standard-list.component.less"], |
|
|
|
}) |
|
|
|
export class StandardListComponent { |
|
|
|
constructor(private drawer: NzDrawerService, private api: ApiService) {} |
|
|
|
|
|
|
|
@ViewChild("formFooterTpl") formFooterTpl!: TemplateRef<{}>; |
|
|
|
|
|
|
|
private drawerRef?: NzDrawerRef; |
|
|
|
constructor( |
|
|
|
private api: ApiService, |
|
|
|
private modal: NzModalService, |
|
|
|
private msg: NzMessageService, |
|
|
|
private router: Router |
|
|
|
) {} |
|
|
|
|
|
|
|
public tableList = new TableListOption(this.fetchData.bind(this)); |
|
|
|
|
|
|
|
public queryForm = new FormGroup({ |
|
|
|
name: new FormControl(""), |
|
|
|
keyword: new FormControl(""), |
|
|
|
}); |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
@ -31,21 +36,21 @@ export class StandardListComponent { |
|
|
|
this.tableList.scroll = { x: null }; |
|
|
|
this.tableList = this.tableList.setColumns([ |
|
|
|
{ key: "name", title: "营养标准名称" }, |
|
|
|
{ key: "name", title: "人群细分" }, |
|
|
|
{ key: "name", title: "适用单位" }, |
|
|
|
{ key: "name", title: "更新时间" }, |
|
|
|
{ key: "people", title: "人群细分" }, |
|
|
|
{ key: "vendors", title: "适用单位" }, |
|
|
|
{ key: "time", title: "更新时间" }, |
|
|
|
]); |
|
|
|
|
|
|
|
this.tableList = this.tableList.setOptions([ |
|
|
|
{ |
|
|
|
title: "标准设置", |
|
|
|
premissions: [], |
|
|
|
onClick: this.showFoodForm.bind(this), |
|
|
|
onClick: this.toSetting.bind(this), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "编辑", |
|
|
|
premissions: [], |
|
|
|
onClick: this.showFoodForm.bind(this), |
|
|
|
onClick: this.toEdit.bind(this), |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: "删除", |
|
|
@ -56,21 +61,31 @@ export class StandardListComponent { |
|
|
|
} |
|
|
|
|
|
|
|
fetchData(query: AnyObject, pager: AnyObject) { |
|
|
|
return this.api.page(pager, query); |
|
|
|
return this.api.getStandardPage(pager, query); |
|
|
|
} |
|
|
|
|
|
|
|
showFoodForm(food?: any) { |
|
|
|
this.drawerRef = this.drawer.create({ |
|
|
|
nzTitle: food ? "编辑菜品" : "新增菜品", |
|
|
|
nzWidth: 700, |
|
|
|
nzContent: DishFormComponent, |
|
|
|
nzFooter: this.formFooterTpl, |
|
|
|
toEdit(d: AnyObject) { |
|
|
|
this.router.navigate([`/standard/form/${d["id"]}`], { |
|
|
|
state: d, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
cancelFoodForm() { |
|
|
|
this.drawerRef?.close(); |
|
|
|
toSetting(d: AnyObject) { |
|
|
|
this.router.navigate([`/standard/setting/${d["id"]}`], { |
|
|
|
state: d, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
deleteItem() {} |
|
|
|
deleteItem(v: any) { |
|
|
|
this.modal.confirm({ |
|
|
|
nzTitle: "警告", |
|
|
|
nzContent: `是否要删除该营养标准?`, |
|
|
|
nzOkDanger: true, |
|
|
|
nzOnOk: async () => { |
|
|
|
const res = await lastValueFrom(this.api.deleteStandard(v.id)); |
|
|
|
this.msg.success(res.desc); |
|
|
|
this.tableList.run(); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|