From 132a5ea209b3da135779beea39441425e2a30a06 Mon Sep 17 00:00:00 2001 From: kkerwin Date: Thu, 7 Sep 2023 22:13:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/admin/src/app/app-routing.module.ts | 66 ++++++++++- projects/admin/src/app/app.module.ts | 20 ++++ .../app-layout/app-layout.component.html | 12 +- .../app-layout/app-layout.component.less | 8 +- .../app-layout/app-layout.component.ts | 19 +++- .../app-page/app-page.component.html | 10 +- .../app-page/app-page.component.less | 3 +- .../components/app-page/app-page.component.ts | 48 +++++++- projects/admin/src/app/components/index.ts | 3 + .../role-permission.component.html | 25 +++++ .../role-permission.component.less | 0 .../role-permission.component.ts | 72 ++++++++++++ .../user-list/user-list.component.html | 49 +++++++++ .../user-list/user-list.component.less | 0 .../user-list/user-list.component.ts | 73 ++++++++++++ .../src/app/pages/food/food.component.html | 33 +++--- projects/admin/src/app/pages/index.ts | 9 ++ .../organization-form.component.html | 104 ++++++++++++++++++ .../organization-form.component.less | 0 .../organization-form.component.ts | 54 +++++++++ .../organization-list.component.html | 59 ++++++++++ .../organization-list.component.less | 0 .../organization-list.component.ts | 82 ++++++++++++++ .../standard-form.component.html | 59 ++++++++++ .../standard-form.component.less | 0 .../standard-form/standard-form.component.ts | 57 ++++++++++ .../standard-list.component.html | 52 +++++++++ .../standard-list.component.less | 0 .../standard-list/standard-list.component.ts | 76 +++++++++++++ .../standard-setting.component.html | 42 +++++++ .../standard-setting.component.less | 0 .../standard-setting.component.ts | 57 ++++++++++ .../user-manage/user-manage.component.html | 88 +++++++++++++++ .../user-manage/user-manage.component.less | 17 +++ .../user-manage/user-manage.component.ts | 68 ++++++++++++ projects/admin/src/styles.less | 20 ++++ 36 files changed, 1251 insertions(+), 34 deletions(-) create mode 100644 projects/admin/src/app/components/role-permission/role-permission.component.html create mode 100644 projects/admin/src/app/components/role-permission/role-permission.component.less create mode 100644 projects/admin/src/app/components/role-permission/role-permission.component.ts create mode 100644 projects/admin/src/app/components/user-list/user-list.component.html create mode 100644 projects/admin/src/app/components/user-list/user-list.component.less create mode 100644 projects/admin/src/app/components/user-list/user-list.component.ts create mode 100644 projects/admin/src/app/pages/organization/organization-form/organization-form.component.html create mode 100644 projects/admin/src/app/pages/organization/organization-form/organization-form.component.less create mode 100644 projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts create mode 100644 projects/admin/src/app/pages/organization/organization-list/organization-list.component.html create mode 100644 projects/admin/src/app/pages/organization/organization-list/organization-list.component.less create mode 100644 projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts create mode 100644 projects/admin/src/app/pages/standard/standard-form/standard-form.component.html create mode 100644 projects/admin/src/app/pages/standard/standard-form/standard-form.component.less create mode 100644 projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts create mode 100644 projects/admin/src/app/pages/standard/standard-list/standard-list.component.html create mode 100644 projects/admin/src/app/pages/standard/standard-list/standard-list.component.less create mode 100644 projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts create mode 100644 projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html create mode 100644 projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.less create mode 100644 projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts create mode 100644 projects/admin/src/app/pages/system/user-manage/user-manage.component.html create mode 100644 projects/admin/src/app/pages/system/user-manage/user-manage.component.less create mode 100644 projects/admin/src/app/pages/system/user-manage/user-manage.component.ts diff --git a/projects/admin/src/app/app-routing.module.ts b/projects/admin/src/app/app-routing.module.ts index 7861206..8e4caad 100644 --- a/projects/admin/src/app/app-routing.module.ts +++ b/projects/admin/src/app/app-routing.module.ts @@ -9,6 +9,12 @@ import { IngredientReleaseComponent, IngredientReviewComponent, LoginComponent, + OrganizationListComponent, + OrganizationFormComponent, + UserManageComponent, + StandardListComponent, + StandardFormComponent, + StandardSettingComponent, } from "./pages"; import { AppLayoutComponent } from "./components"; @@ -20,10 +26,33 @@ const routes: Routes = [ children: [ { path: "", pathMatch: "full", redirectTo: "home" }, { path: "home", component: HomeComponent }, - { path: "food", component: FoodComponent }, - { path: "dish", component: DishComponent }, + { path: "food", component: FoodComponent, title: "食材管理" }, + { path: "dish", component: DishComponent, title: "菜品管理" }, + { + path: "standard", + children: [ + { + path: "", + pathMatch: "full", + redirectTo: "list", + }, + { + path: "list", + component: StandardListComponent, + }, + { + path: "form/:id", + component: StandardFormComponent, + }, + { + path: "setting/:id", + component: StandardSettingComponent, + }, + ], + }, { path: "ingredient", + title: "食谱管理", children: [ { path: "", @@ -32,6 +61,7 @@ const routes: Routes = [ }, { path: "item", + title: "食谱库", children: [ { path: "", @@ -51,14 +81,46 @@ const routes: Routes = [ { path: "review", + title: "食谱审核", component: IngredientReviewComponent, }, { path: "release", + title: "食谱发布计划", component: IngredientReleaseComponent, }, ], }, + { + path: "organization", + title: "单位管理", + children: [ + { + path: "", + pathMatch: "full", + redirectTo: "list", + }, + { + path: "list", + component: OrganizationListComponent, + }, + { + path: "form/:id", + component: OrganizationFormComponent, + }, + ], + }, + { + path: "system", + title: "系统设置", + children: [ + { + path: "user", + title: "用户管理", + component: UserManageComponent, + }, + ], + }, ], }, ]; diff --git a/projects/admin/src/app/app.module.ts b/projects/admin/src/app/app.module.ts index c60af87..750fa44 100644 --- a/projects/admin/src/app/app.module.ts +++ b/projects/admin/src/app/app.module.ts @@ -19,6 +19,8 @@ import { FoodFormComponent, DishFormComponent, IngredientFormBasicComponent, + UserListComponent, + RolePermissionComponent, } from "./components"; import { HomeComponent, @@ -29,6 +31,12 @@ import { IngredientReleaseComponent, IngredientReviewComponent, IngredientFormComponent, + OrganizationListComponent, + OrganizationFormComponent, + UserManageComponent, + StandardListComponent, + StandardFormComponent, + StandardSettingComponent, } from "./pages"; import { HTTPInterceptor } from "./services/http.interceptor"; @@ -51,6 +59,18 @@ registerLocaleData(zh); IngredientReleaseComponent, IngredientReviewComponent, IngredientFormComponent, + + OrganizationListComponent, + OrganizationFormComponent, + + UserManageComponent, + + UserListComponent, + RolePermissionComponent, + + StandardListComponent, + StandardFormComponent, + StandardSettingComponent, ], imports: [ BrowserModule, diff --git a/projects/admin/src/app/components/app-layout/app-layout.component.html b/projects/admin/src/app/components/app-layout/app-layout.component.html index 9c39287..f00263a 100644 --- a/projects/admin/src/app/components/app-layout/app-layout.component.html +++ b/projects/admin/src/app/components/app-layout/app-layout.component.html @@ -23,29 +23,29 @@ -
  • +
  • -
  • +
  • 人群营养标准管理
  • -
  • +
  • 单位管理
  • -
  • +
  • - + diff --git a/projects/admin/src/app/components/app-layout/app-layout.component.less b/projects/admin/src/app/components/app-layout/app-layout.component.less index 2a0d1b2..5aa4d22 100644 --- a/projects/admin/src/app/components/app-layout/app-layout.component.less +++ b/projects/admin/src/app/components/app-layout/app-layout.component.less @@ -1,7 +1,7 @@ :host { display: flex; flex-direction: column; - min-height: 100%; + height: 100%; } @header-height: 48px; @@ -10,7 +10,7 @@ display: flex; flex-direction: column; flex: 1; - min-height: 100%; + height: 100%; } .app-header { @@ -42,7 +42,7 @@ } .app-layout-main { - min-height: 100%; + height: 100%; } .inner-layout { @@ -53,7 +53,7 @@ router-outlet+* { display: flex; flex-direction: column; - min-height: 100%; + height: 100%; } } } \ No newline at end of file diff --git a/projects/admin/src/app/components/app-layout/app-layout.component.ts b/projects/admin/src/app/components/app-layout/app-layout.component.ts index bd646e2..bb63ced 100644 --- a/projects/admin/src/app/components/app-layout/app-layout.component.ts +++ b/projects/admin/src/app/components/app-layout/app-layout.component.ts @@ -1,8 +1,25 @@ import { Component } from "@angular/core"; +import { NavigationEnd, Router } from "@angular/router"; +import { Subject, filter, takeUntil } from "rxjs"; @Component({ selector: "app-layout", templateUrl: "./app-layout.component.html", styleUrls: ["./app-layout.component.less"], }) -export class AppLayoutComponent {} +export class AppLayoutComponent { + constructor(private router: Router) { + this.router.events + .pipe( + takeUntil(this.unSubscribe$), + filter((e): e is NavigationEnd => e instanceof NavigationEnd) + ) + .subscribe((e) => { + this.currentUrl = e.url; + }); + } + + unSubscribe$ = new Subject(); + + currentUrl: string = ""; +} diff --git a/projects/admin/src/app/components/app-page/app-page.component.html b/projects/admin/src/app/components/app-page/app-page.component.html index 2c7899d..a7ddc7e 100644 --- a/projects/admin/src/app/components/app-page/app-page.component.html +++ b/projects/admin/src/app/components/app-page/app-page.component.html @@ -1,4 +1,4 @@ -
    +

    @@ -11,7 +11,13 @@

    -
    +
    + +
    \ No newline at end of file diff --git a/projects/admin/src/app/components/app-page/app-page.component.less b/projects/admin/src/app/components/app-page/app-page.component.less index 66797ff..1dce684 100644 --- a/projects/admin/src/app/components/app-page/app-page.component.less +++ b/projects/admin/src/app/components/app-page/app-page.component.less @@ -1,7 +1,8 @@ :host { display: flex; flex-direction: column; - min-height: 100%; + height: 100%; + overflow: auto; } .app-page { diff --git a/projects/admin/src/app/components/app-page/app-page.component.ts b/projects/admin/src/app/components/app-page/app-page.component.ts index b2695eb..56dc17e 100644 --- a/projects/admin/src/app/components/app-page/app-page.component.ts +++ b/projects/admin/src/app/components/app-page/app-page.component.ts @@ -1,16 +1,58 @@ -import { Component, Input, TemplateRef } from "@angular/core"; +import { Component, Input, OnDestroy, TemplateRef } from "@angular/core"; +import { ActivatedRoute, NavigationEnd, Router, Scroll } from "@angular/router"; +import { Subject, filter, startWith, take, takeUntil } from "rxjs"; + +interface BreadcrumbInterface { + label: string; + href?: string; +} @Component({ selector: "app-page", templateUrl: "./app-page.component.html", styleUrls: ["./app-page.component.less"], }) -export class AppPageComponent { - constructor() {} +export class AppPageComponent implements OnDestroy { + constructor(private route: ActivatedRoute, private router: Router) { + // this.router.events + // .pipe( + // takeUntil(this.unSubscribe$), + // filter((e) => e instanceof NavigationEnd || e instanceof Scroll) + // ) + // .subscribe(() => { + // this.genBreadcrumb(); + // }); + } @Input() pageTitle?: TemplateRef<{}> | string; @Input() full: boolean = false; + @Input() scroll: boolean = true; + @Input() pageExtra?: TemplateRef<{}> | string; + + unSubscribe$ = new Subject(); + + breadcrumb: BreadcrumbInterface[] = []; + + ngOnDestroy(): void { + this.unSubscribe$.next(); + this.unSubscribe$.complete(); + } + + genBreadcrumb() { + let route: ActivatedRoute | null = this.route; + this.breadcrumb = []; + while (route) { + if (route.routeConfig?.title) { + this.breadcrumb.unshift({ + label: route.routeConfig!.title as string, + href: route.routeConfig.path, + }); + } + route = route?.parent ?? null; + } + console.log("this.route", this.breadcrumb); + } } diff --git a/projects/admin/src/app/components/index.ts b/projects/admin/src/app/components/index.ts index 16c60bf..7396790 100644 --- a/projects/admin/src/app/components/index.ts +++ b/projects/admin/src/app/components/index.ts @@ -5,3 +5,6 @@ export * from "./food-form/food-form.component"; export * from "./dish-form/dish-form.component"; export * from "./ingredient-form-basic/ingredient-form-basic.component"; + +export * from "./user-list/user-list.component"; +export * from "./role-permission/role-permission.component"; diff --git a/projects/admin/src/app/components/role-permission/role-permission.component.html b/projects/admin/src/app/components/role-permission/role-permission.component.html new file mode 100644 index 0000000..26725c4 --- /dev/null +++ b/projects/admin/src/app/components/role-permission/role-permission.component.html @@ -0,0 +1,25 @@ +
    + +
    +
    + +
    +
    +
    + +
    +
    + + + +
    +
    + +
    \ No newline at end of file diff --git a/projects/admin/src/app/components/role-permission/role-permission.component.less b/projects/admin/src/app/components/role-permission/role-permission.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/components/role-permission/role-permission.component.ts b/projects/admin/src/app/components/role-permission/role-permission.component.ts new file mode 100644 index 0000000..364e846 --- /dev/null +++ b/projects/admin/src/app/components/role-permission/role-permission.component.ts @@ -0,0 +1,72 @@ +import { ApiService } from "@admin/app/services"; +import { Component } from "@angular/core"; +import { ActivatedRoute } from "@angular/router"; + +@Component({ + selector: "app-role-permission", + templateUrl: "./role-permission.component.html", + styleUrls: ["./role-permission.component.less"], +}) +export class RolePermissionComponent { + constructor(private api: ApiService, private route: ActivatedRoute) {} + + roleId: string | null = null; + + permissions = { + 食材管理: [ + { label: "食材列表-查看", value: "1-1" }, + { label: "食材-新增/编辑/删除", value: "1-2" }, + ], + 菜品管理: [ + { label: "菜品列表-查看", value: "2-1" }, + { label: "菜品-新增/编辑/删除", value: "2-2" }, + ], + 食谱管理: [ + { label: "食谱列表-查看", value: "3-1" }, + { label: "食谱-新增/编辑/删除", value: "3-2" }, + { label: "食谱审核列表-查看", value: "3-3" }, + { label: "食谱审核列表-通过/驳回", value: "3-4" }, + { label: "食谱发布计划-查看", value: "3-5" }, + { label: "食谱发布计划-发布/取消发布", value: "3-6" }, + ], + 人群营养标准管理: [ + { label: "模型列表-查看", value: "4-1" }, + { label: "营养标准模型-新增/编辑/删除", value: "4-2" }, + ], + 单位管理: [ + { label: "单位列表-查看", value: "5-1" }, + { label: "单位-新增/编辑/启用/禁用/删除", value: "5-2" }, + ], + 系统设置: [ + { label: "用户列表-查看", value: "6-1" }, + { label: "角色权限-新增/编辑/删除", value: "6-2" }, + { label: "用户-新增/编辑/删除", value: "6-3" }, + ], + }; + + hasPermissions = new Set(); + + ngOnInit(): void { + this.route.queryParamMap.subscribe((r) => { + this.roleId = r.get("roleId"); + if (this.roleId) { + } + }); + } + + returenZero() { + return 0; + } + + onPermissionChange(checked: boolean, key: string) { + if (!checked && this.hasPermissions.has(key)) { + this.hasPermissions.delete(key); + } else { + this.hasPermissions.add(key); + } + } + + onSubmit() { + console.log("this.hasPermissions", this.hasPermissions); + } +} diff --git a/projects/admin/src/app/components/user-list/user-list.component.html b/projects/admin/src/app/components/user-list/user-list.component.html new file mode 100644 index 0000000..b23f5c9 --- /dev/null +++ b/projects/admin/src/app/components/user-list/user-list.component.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + +
    + + + + 姓名 + + + + + + + + 账号 + + + + + + + + 密码 + + + + + +
    +
    \ No newline at end of file diff --git a/projects/admin/src/app/components/user-list/user-list.component.less b/projects/admin/src/app/components/user-list/user-list.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/components/user-list/user-list.component.ts b/projects/admin/src/app/components/user-list/user-list.component.ts new file mode 100644 index 0000000..856bd18 --- /dev/null +++ b/projects/admin/src/app/components/user-list/user-list.component.ts @@ -0,0 +1,73 @@ +import { ApiService } from "@admin/app/services"; +import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core"; +import { FormControl, FormGroup } from "@angular/forms"; +import { ActivatedRoute } from "@angular/router"; +import { AnyObject, TableListOption } from "@cdk/public-api"; +import { NzModalService } from "ng-zorro-antd/modal"; + +@Component({ + selector: "app-user-list", + templateUrl: "./user-list.component.html", + styleUrls: ["./user-list.component.less"], +}) +export class UserListComponent { + constructor(private api: ApiService, private route: ActivatedRoute, private modal: NzModalService) {} + + @ViewChild("userFormTpl") public userFormTpl!: TemplateRef; + + public tableList = new TableListOption(this.fetchData.bind(this), { + manual: true, + }); + + public queryForm = new FormGroup({ + name: new FormControl(""), + }); + + roleId: string | null = null; + + ngOnInit(): void { + this.route.queryParamMap.subscribe((r) => { + this.roleId = r.get("roleId"); + if (this.roleId) { + this.tableList.reset(); + } + }); + 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: "添加时间" }, + ]); + + this.tableList = this.tableList.setOptions([ + { + title: "编辑", + premissions: [], + onClick: this.openForm.bind(this), + }, + { + title: "删除", + premissions: [], + onClick: this.deleteItem.bind(this), + }, + ]); + } + + fetchData(query: AnyObject, pager: AnyObject) { + return this.api.page(pager, query); + } + + deleteItem() {} + + openForm(item?: any) { + this.modal.create({ + nzTitle: item ? "编辑用户" : "新增用户", + nzContent: this.userFormTpl, + }); + } +} diff --git a/projects/admin/src/app/pages/food/food.component.html b/projects/admin/src/app/pages/food/food.component.html index 00b9689..f64687b 100644 --- a/projects/admin/src/app/pages/food/food.component.html +++ b/projects/admin/src/app/pages/food/food.component.html @@ -1,4 +1,4 @@ - + @@ -36,22 +36,25 @@
    -
    +
    - - + +
    + - - - - - - - - - - - + + + + + + + + + + + +
    diff --git a/projects/admin/src/app/pages/index.ts b/projects/admin/src/app/pages/index.ts index 13f9110..9be1707 100644 --- a/projects/admin/src/app/pages/index.ts +++ b/projects/admin/src/app/pages/index.ts @@ -9,3 +9,12 @@ export * from "./ingredients/ingredient-list/ingredient-list.component"; export * from "./ingredients/ingredient-review/ingredient-review.component"; export * from "./ingredients/ingredient-release/ingredient-release.component"; export * from "./ingredients/ingredient-form/ingredient-form.component"; + +export * from "./organization/organization-list/organization-list.component"; +export * from "./organization/organization-form/organization-form.component"; + +export * from "./system/user-manage/user-manage.component"; + +export * from "./standard/standard-list/standard-list.component"; +export * from "./standard/standard-form/standard-form.component"; +export * from "./standard/standard-setting/standard-setting.component"; diff --git a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html new file mode 100644 index 0000000..2b14bb9 --- /dev/null +++ b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.html @@ -0,0 +1,104 @@ + +
    + + + + + 单位名称 + + + + + + + + 单位Logo + + + + + + + + 地址 + + + + + + + + 联系人 + + + + + + + + 联系电话 + + + + + + + + 邮箱 + + + + + + + + + + + + 账号 + + + + + + + + 初始密码 + + + + + + + + 账号到期时间 + + + + + + + + + + +
    + + + + +
    +
    + + + +
    \ No newline at end of file diff --git a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.less b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts new file mode 100644 index 0000000..64ce340 --- /dev/null +++ b/projects/admin/src/app/pages/organization/organization-form/organization-form.component.ts @@ -0,0 +1,54 @@ +import { Component } from "@angular/core"; +import { FormBuilder, FormGroup } from "@angular/forms"; +import { FormValidators } from "@cdk/validators"; + +@Component({ + selector: "app-organization-form", + templateUrl: "./organization-form.component.html", + styleUrls: ["./organization-form.component.less"], +}) +export class OrganizationFormComponent { + constructor(private fb: FormBuilder) {} + + formGroup!: FormGroup; + + uploadLoading = false; + + ngOnInit(): void { + this.formGroup = this.fb.group({ + id: this.fb.control("", [FormValidators.required()]), + name: this.fb.control("", [FormValidators.required()]), + unit: this.fb.control("", [FormValidators.required()]), + day: this.fb.control("1", [FormValidators.required()]), + logo: this.fb.control("", []), + month: this.fb.control([], []), + }); + } + onSubmit() {} + + onFileChange(e: Event) { + const target = e.target as HTMLInputElement; + const file = target.files![0]; + target.value = ""; + const formData = new FormData(); + const fileReader = new FileReader(); + fileReader.onload = () => { + const base64 = fileReader.result as string; + + const v = base64.split("base64,")[1]; + }; + formData.append("file", file); + this.uploadLoading = true; + // this.api + // .uploadLogo(formData) + // .pipe( + // finalize(() => { + // this.uploadLoading = false; + // }) + // ) + // .subscribe((r) => { + // this.msg.success(r.desc); + // fileReader.readAsDataURL(file); + // }); + } +} diff --git a/projects/admin/src/app/pages/organization/organization-list/organization-list.component.html b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.html new file mode 100644 index 0000000..469d132 --- /dev/null +++ b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.html @@ -0,0 +1,59 @@ + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{data}} + + + + + + +
    +
    + + + + + + + + \ No newline at end of file diff --git a/projects/admin/src/app/pages/organization/organization-list/organization-list.component.less b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts new file mode 100644 index 0000000..ee6ec2c --- /dev/null +++ b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts @@ -0,0 +1,82 @@ +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 "@admin/app/services"; + +@Component({ + selector: "app-organization-list", + templateUrl: "./organization-list.component.html", + styleUrls: ["./organization-list.component.less"], +}) +export class OrganizationListComponent { + constructor(private drawer: NzDrawerService, private api: ApiService) {} + + @ViewChild("formFooterTpl") formFooterTpl!: TemplateRef<{}>; + + private drawerRef?: NzDrawerRef; + + public tableList = new TableListOption(this.fetchData.bind(this), { + selectable: true, + }); + + 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: "地址", width: "30%" }, + { 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.deleteItem.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.formFooterTpl, + }); + } + + cancelFoodForm() { + this.drawerRef?.close(); + } + + deleteItem() {} +} diff --git a/projects/admin/src/app/pages/standard/standard-form/standard-form.component.html b/projects/admin/src/app/pages/standard/standard-form/standard-form.component.html new file mode 100644 index 0000000..14c7ac0 --- /dev/null +++ b/projects/admin/src/app/pages/standard/standard-form/standard-form.component.html @@ -0,0 +1,59 @@ + +
    + + + + + 营养标准名称 + + + + + + + + + 溢出范围 + + + + + + + + + + + 适用单位 + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    \ No newline at end of file diff --git a/projects/admin/src/app/pages/standard/standard-form/standard-form.component.less b/projects/admin/src/app/pages/standard/standard-form/standard-form.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts b/projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts new file mode 100644 index 0000000..df05c1b --- /dev/null +++ b/projects/admin/src/app/pages/standard/standard-form/standard-form.component.ts @@ -0,0 +1,57 @@ +import { Component } from "@angular/core"; +import { FormBuilder, FormGroup } from "@angular/forms"; +import { Router } from "@angular/router"; +import { FormValidators } from "@cdk/validators"; + +@Component({ + selector: "app-standard-form", + templateUrl: "./standard-form.component.html", + styleUrls: ["./standard-form.component.less"], +}) +export class StandardFormComponent { + constructor(private fb: FormBuilder, private router: Router) {} + + formGroup!: FormGroup; + + uploadLoading = false; + + ngOnInit(): void { + this.formGroup = this.fb.group({ + id: this.fb.control("", [FormValidators.required()]), + name: this.fb.control("", [FormValidators.required()]), + unit: this.fb.control("", [FormValidators.required()]), + day: this.fb.control("1", [FormValidators.required()]), + logo: this.fb.control("", []), + month: this.fb.control([], []), + }); + } + onSubmit() { + this.router.navigate(["/", "standard", "setting", "45"]); + } + + onFileChange(e: Event) { + const target = e.target as HTMLInputElement; + const file = target.files![0]; + target.value = ""; + const formData = new FormData(); + const fileReader = new FileReader(); + fileReader.onload = () => { + const base64 = fileReader.result as string; + + const v = base64.split("base64,")[1]; + }; + formData.append("file", file); + this.uploadLoading = true; + // this.api + // .uploadLogo(formData) + // .pipe( + // finalize(() => { + // this.uploadLoading = false; + // }) + // ) + // .subscribe((r) => { + // this.msg.success(r.desc); + // fileReader.readAsDataURL(file); + // }); + } +} diff --git a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html new file mode 100644 index 0000000..eeabe24 --- /dev/null +++ b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.html @@ -0,0 +1,52 @@ + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + {{data}} + + + + + + +
    +
    + + + + + + + + \ No newline at end of file diff --git a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.less b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts new file mode 100644 index 0000000..974c4b2 --- /dev/null +++ b/projects/admin/src/app/pages/standard/standard-list/standard-list.component.ts @@ -0,0 +1,76 @@ +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 "@admin/app/services"; + +@Component({ + selector: "app-standard-list", + templateUrl: "./standard-list.component.html", + styleUrls: ["./standard-list.component.less"], +}) +export class StandardListComponent { + constructor(private drawer: NzDrawerService, private api: ApiService) {} + + @ViewChild("formFooterTpl") formFooterTpl!: TemplateRef<{}>; + + private drawerRef?: NzDrawerRef; + + 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: "更新时间" }, + ]); + + this.tableList = this.tableList.setOptions([ + { + title: "标准设置", + premissions: [], + onClick: this.showFoodForm.bind(this), + }, + { + title: "编辑", + premissions: [], + onClick: this.showFoodForm.bind(this), + }, + { + title: "删除", + premissions: [], + onClick: this.deleteItem.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.formFooterTpl, + }); + } + + cancelFoodForm() { + this.drawerRef?.close(); + } + + deleteItem() {} +} diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html new file mode 100644 index 0000000..9285c49 --- /dev/null +++ b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.html @@ -0,0 +1,42 @@ + +
    + + +
    +
    + + + + +
    + add +
    +
    +
    +
    + + + + +
    + +
    +
    +
    +
    +
    + + + + + + +
    + + + +
    \ No newline at end of file diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.less b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.less new file mode 100644 index 0000000..e69de29 diff --git a/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts new file mode 100644 index 0000000..48b3862 --- /dev/null +++ b/projects/admin/src/app/pages/standard/standard-setting/standard-setting.component.ts @@ -0,0 +1,57 @@ +import { Component } from "@angular/core"; +import { FormBuilder, FormGroup } from "@angular/forms"; +import { Router } from "@angular/router"; +import { FormValidators } from "@cdk/validators"; + +@Component({ + selector: "app-standard-setting", + templateUrl: "./standard-setting.component.html", + styleUrls: ["./standard-setting.component.less"], +}) +export class StandardSettingComponent { + constructor(private fb: FormBuilder, private router: Router) {} + + formGroup!: FormGroup; + + uploadLoading = false; + + ngOnInit(): void { + this.formGroup = this.fb.group({ + id: this.fb.control("", [FormValidators.required()]), + name: this.fb.control("", [FormValidators.required()]), + unit: this.fb.control("", [FormValidators.required()]), + day: this.fb.control("1", [FormValidators.required()]), + logo: this.fb.control("", []), + month: this.fb.control([], []), + }); + } + onSubmit() { + this.router.navigate(["/", "standard", "setting", "45"]); + } + + onFileChange(e: Event) { + const target = e.target as HTMLInputElement; + const file = target.files![0]; + target.value = ""; + const formData = new FormData(); + const fileReader = new FileReader(); + fileReader.onload = () => { + const base64 = fileReader.result as string; + + const v = base64.split("base64,")[1]; + }; + formData.append("file", file); + this.uploadLoading = true; + // this.api + // .uploadLogo(formData) + // .pipe( + // finalize(() => { + // this.uploadLoading = false; + // }) + // ) + // .subscribe((r) => { + // this.msg.success(r.desc); + // fileReader.readAsDataURL(file); + // }); + } +} diff --git a/projects/admin/src/app/pages/system/user-manage/user-manage.component.html b/projects/admin/src/app/pages/system/user-manage/user-manage.component.html new file mode 100644 index 0000000..39c2ce2 --- /dev/null +++ b/projects/admin/src/app/pages/system/user-manage/user-manage.component.html @@ -0,0 +1,88 @@ + + +
    +
    + + + +
    + +
    +
    +
    +
    + + + + + + + + +
    + + +
    +
    + +
    +
    +
    + + + +
    + + + 角色名称 + + + + + +
    +
    \ No newline at end of file diff --git a/projects/admin/src/app/pages/system/user-manage/user-manage.component.less b/projects/admin/src/app/pages/system/user-manage/user-manage.component.less new file mode 100644 index 0000000..30c68b8 --- /dev/null +++ b/projects/admin/src/app/pages/system/user-manage/user-manage.component.less @@ -0,0 +1,17 @@ +.user-type { + border-right: 1px solid #e8e8e8; + + ::ng-deep { + .ant-menu-inline { + border-right: none; + } + } +} + +.role-head { + ::ng-deep { + .ant-card-extra { + padding: 10px 0; + } + } +} \ No newline at end of file diff --git a/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts b/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts new file mode 100644 index 0000000..4b61656 --- /dev/null +++ b/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts @@ -0,0 +1,68 @@ +import { FoodFormComponent } from "@admin/app/components"; +import { ApiService } from "@admin/app/services"; +import { Component, OnInit, TemplateRef, ViewChild } from "@angular/core"; +import { FormControl, FormGroup } from "@angular/forms"; +import { ActivatedRoute, Router } from "@angular/router"; +import { AnyObject, TableListOption } from "@cdk/public-api"; +import { NzDrawerRef, NzDrawerService } from "ng-zorro-antd/drawer"; +import { NzModalService } from "ng-zorro-antd/modal"; + +@Component({ + selector: "app-user-manage", + templateUrl: "./user-manage.component.html", + styleUrls: ["./user-manage.component.less"], +}) +export class UserManageComponent { + constructor( + private route: ActivatedRoute, + private api: ApiService, + private router: Router, + private modal: NzModalService + ) {} + + public tab = 0; + + public roleId: string | null = null; + + ngOnInit(): void { + this.roleId = this.route.snapshot.queryParamMap.get("roleId"); + this.tab = Number(this.route.snapshot.queryParamMap.get("tab")) || 0; + } + + onRoleChange(roleId: string) { + this.roleId = roleId; + this.router.navigate(["/system/user"], { + queryParams: { + roleId, + }, + queryParamsHandling: "merge", + }); + } + + onTabChange(index: number) { + this.tab = index; + this.router.navigate(["/system/user"], { + queryParams: { + tab: index, + }, + queryParamsHandling: "merge", + }); + } + + openForm(nzContent: TemplateRef<{}>, event: MouseEvent, roleId?: string) { + event.preventDefault(); + this.modal.create({ + nzTitle: roleId ? "编辑角色" : "新增角色", + nzContent, + }); + } + + deleteItem(event: MouseEvent, id: string) { + event.preventDefault(); + this.modal.confirm({ + nzTitle: "警告", + nzContent: "是否要删除该角色?", + nzOkDanger: true, + }); + } +} diff --git a/projects/admin/src/styles.less b/projects/admin/src/styles.less index 31eded4..a18a81e 100644 --- a/projects/admin/src/styles.less +++ b/projects/admin/src/styles.less @@ -36,4 +36,24 @@ li { font-size: 0; cursor: pointer; } +} + +.fixed-footter { + box-shadow: 0 0 10px -2px rgba(0, 0, 0, .25) +} + +.scroll-card-body { + height: 100%; + + &>.ant-card-body { + overflow: auto; + height: calc(100% - 60px); + padding: 0 + } + + &>.ant-card-head { + position: relative; + z-index: 10; + } + } \ No newline at end of file