From 728b11f6fd8fa47032291da8f098bef81c29ab9d Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 23 Apr 2024 15:40:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/data/common/dictionary.namespace.ts | 13 +++++++ .../sys-account/sys-account.component.html | 38 +++++++++--------- .../sys-account/sys-account.component.less | 2 +- .../sys-account/sys-account.component.ts | 8 +++- .../account/sys-role/sys-role.component.html | 10 ++--- src/app/pages/body/index/index.component.ts | 26 ++++++++++--- src/app/pages/system/menu/menu.component.html | 5 +-- src/app/pages/system/menu/menu.component.ts | 17 ++++---- .../pipes/account/sys-account-status.pipe.ts | 20 ---------- src/app/pipes/common/dictionary.pipe.ts | 39 +++++++++++++++++++ src/app/pipes/menu/menu-type.pipe.ts | 21 ---------- src/app/servies/common/common.service.ts | 29 ++++++++++++++ 12 files changed, 145 insertions(+), 83 deletions(-) create mode 100644 src/app/data/common/dictionary.namespace.ts delete mode 100644 src/app/pipes/account/sys-account-status.pipe.ts create mode 100644 src/app/pipes/common/dictionary.pipe.ts delete mode 100644 src/app/pipes/menu/menu-type.pipe.ts create mode 100644 src/app/servies/common/common.service.ts diff --git a/src/app/data/common/dictionary.namespace.ts b/src/app/data/common/dictionary.namespace.ts new file mode 100644 index 0000000..280d530 --- /dev/null +++ b/src/app/data/common/dictionary.namespace.ts @@ -0,0 +1,13 @@ +export interface Dictionary { + codeType: string; + codeValue: string; + codeName: string; + codeDesc: string; + sortId: number; + ext1: string; + ext2: string; + ext3: string; +} + +export const dictionaryData: Dictionary[] = []; + diff --git a/src/app/pages/account/sys-account/sys-account.component.html b/src/app/pages/account/sys-account/sys-account.component.html index 9c3ff04..549fdb8 100644 --- a/src/app/pages/account/sys-account/sys-account.component.html +++ b/src/app/pages/account/sys-account/sys-account.component.html @@ -1,42 +1,41 @@ -
+
-
+
用户名 - +
-
+
登录账户 - +
-
+
联系方式 - +
-
+
- 状态 + 账户状态 - - - + +
-
- +
+
@@ -44,6 +43,7 @@ 用户名 登录账户 联系方式 - 状态 + 账户状态 创建时间 更新时间 - 操作 + 操作 @@ -68,14 +68,14 @@ {{data.userName}} {{data.loginName}} {{data.telephone}} - {{data.status | sysAccountStatus}} + {{data.status | dictionary: 'SEC_USER_STATUS'}} {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} {{data.updateTime | date: 'yyyy-MM-dd HH:mm'}} - + 修改 - 更多操作 + 更多 diff --git a/src/app/pages/account/sys-account/sys-account.component.less b/src/app/pages/account/sys-account/sys-account.component.less index c26355e..cae9ae7 100644 --- a/src/app/pages/account/sys-account/sys-account.component.less +++ b/src/app/pages/account/sys-account/sys-account.component.less @@ -2,7 +2,7 @@ overflow: visible; } button { - margin-left: 8px; + margin-right: 8px; } .search-area { text-align: left; diff --git a/src/app/pages/account/sys-account/sys-account.component.ts b/src/app/pages/account/sys-account/sys-account.component.ts index 1183cbe..1fb178c 100644 --- a/src/app/pages/account/sys-account/sys-account.component.ts +++ b/src/app/pages/account/sys-account/sys-account.component.ts @@ -21,8 +21,9 @@ import {NzTreeComponent} from "ng-zorro-antd/tree"; import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; import {NzDropDownModule} from "ng-zorro-antd/dropdown"; import {NzIconDirective} from "ng-zorro-antd/icon"; -import {SysAccountStatusPipe} from "../../../pipes/account/sys-account-status.pipe"; import {RoleService} from "../../../servies/role/role.service"; +import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; +import {Dictionary} from "../../../data/common/dictionary.namespace"; @Component({ selector: 'app-sys-account', @@ -56,7 +57,7 @@ import {RoleService} from "../../../servies/role/role.service"; NzOptionComponent, NzDropDownModule, NzIconDirective, - SysAccountStatusPipe, + DictionaryPipe, ], templateUrl: './sys-account.component.html', styleUrl: './sys-account.component.less' @@ -69,6 +70,7 @@ export class SysAccountComponent { total: 0, list: [], }; + accountStatus: Dictionary[] = [] // 角色数据 roleData: any = []; // 搜索表单 @@ -101,6 +103,7 @@ export class SysAccountComponent { telephone: [''], roleId: ['', [Validators.required]], }); + this.accountStatus = new DictionaryPipe().getDictionaryList("SEC_USER_STATUS"); this.queryAllRole(); this.queryData(); } @@ -122,6 +125,7 @@ export class SysAccountComponent { queryData() { this.searchForm.value.pageNum = this.tablePageNum; this.searchForm.value.pageSize = 10; + this.searchForm.value.objectType = 1; this.searchForm.value.time = new Date().getTime(); this.sysAccountService.queryList(this.searchForm.value, (data: any) => { if (data['return_code'] == '000000') { diff --git a/src/app/pages/account/sys-role/sys-role.component.html b/src/app/pages/account/sys-role/sys-role.component.html index 93f20c7..5878c10 100644 --- a/src/app/pages/account/sys-role/sys-role.component.html +++ b/src/app/pages/account/sys-role/sys-role.component.html @@ -1,15 +1,15 @@ -
+
角色名称 - +
-
- +
+
@@ -31,7 +31,7 @@ 角色描述 创建时间 更新时间 - 操作 + 操作 diff --git a/src/app/pages/body/index/index.component.ts b/src/app/pages/body/index/index.component.ts index bd632ef..a81a079 100644 --- a/src/app/pages/body/index/index.component.ts +++ b/src/app/pages/body/index/index.component.ts @@ -10,9 +10,7 @@ import { import {NzBreadCrumbComponent, NzBreadCrumbItemComponent} from "ng-zorro-antd/breadcrumb"; import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; import {NzMenuDirective, NzMenuGroupComponent, NzMenuItemComponent, NzSubMenuComponent} from "ng-zorro-antd/menu"; -import {menuData} from "../../../data/menu/menu.namespace"; import {NgClass, NgForOf} from "@angular/common"; -import {animate, state, style, transition, trigger} from "@angular/animations"; import {NzIconDirective} from "ng-zorro-antd/icon"; import {NzTabComponent, NzTabSetComponent} from "ng-zorro-antd/tabs"; import {TabComponent} from "../tab/tab.component"; @@ -21,6 +19,8 @@ import {DATA, INIT_FLAG, LOGIN_DATA, USER_TOKEN} from "../../../data/login/local import {NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; import {LoginService} from "../../../servies/login/login.service"; import {NzMessageService} from "ng-zorro-antd/message"; +import {CommonService} from "../../../servies/common/common.service"; +import {dictionaryData} from "../../../data/common/dictionary.namespace"; @Component({ selector: 'app-index', @@ -62,22 +62,38 @@ export class IndexComponent { userInfo: any; // 左侧菜单栏数据 leftMenuData: any = []; - // 侧边菜单展示开关 isCollapse = true; - // 当前顶级菜单 currentParentMenu: any = {}; constructor( + private commonService: CommonService, private storage: BrowserStorageService, private message: NzMessageService, private router: Router, // 路由 private login: LoginService ) { + // 缓存数据字典 + this.commonService.queryDictionary('','',(data: any) => { + for (let item of data['return_data']) { + dictionaryData.push( + { + codeType: item.codeType, + codeValue: item.codeValue, + codeName: item.codeName, + codeDesc: item.codeDesc, + sortId: item.sortId, + ext1: item.ext1, + ext2: item.ext2, + ext3: item.ext3 + } + ); + } + }); + this.menuData = this.menuData.concat(this.storage.get(DATA)['menuTree']); this.userInfo = this.storage.get(DATA)['account']; - console.log("用户数据" , this.userInfo); } // 选择操作 diff --git a/src/app/pages/system/menu/menu.component.html b/src/app/pages/system/menu/menu.component.html index 8acaa3a..1718677 100644 --- a/src/app/pages/system/menu/menu.component.html +++ b/src/app/pages/system/menu/menu.component.html @@ -23,7 +23,7 @@ > {{menuDetail?.parentMenu?menuDetail.parentMenu.menuName:'无'}} {{menuDetail.menuName?menuDetail.menuName:'无'}} - {{menuDetail.menuType| menuType}} + {{menuDetail.menuType | dictionary: '菜单类型'}} {{menuDetail.menuUrl?menuDetail.menuUrl:'无'}} {{menuDetail.menuUrlImg?menuDetail.menuUrlImg:'无'}} {{menuDetail.menuDesc?menuDetail.menuDesc:'无'}} @@ -64,8 +64,7 @@ 菜单类型 - - + diff --git a/src/app/pages/system/menu/menu.component.ts b/src/app/pages/system/menu/menu.component.ts index a8324aa..24c34c0 100644 --- a/src/app/pages/system/menu/menu.component.ts +++ b/src/app/pages/system/menu/menu.component.ts @@ -14,7 +14,6 @@ import {NzCardComponent} from "ng-zorro-antd/card"; import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; import {NzButtonComponent} from "ng-zorro-antd/button"; import {NzDescriptionsComponent, NzDescriptionsItemComponent} from "ng-zorro-antd/descriptions"; -import {MenuTypePipe} from "../../../pipes/menu/menu-type.pipe"; import {NzFormDirective, NzFormLabelComponent, NzFormModule} from "ng-zorro-antd/form"; import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; import {NzInputDirective, NzInputGroupComponent} from "ng-zorro-antd/input"; @@ -25,6 +24,8 @@ import {NzInputNumberComponent} from "ng-zorro-antd/input-number"; import {NzMessageService} from "ng-zorro-antd/message"; import {NzSpinComponent} from "ng-zorro-antd/spin"; import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; +import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; +import {Dictionary} from "../../../data/common/dictionary.namespace"; @Component({ selector: 'app-menu', @@ -42,7 +43,6 @@ import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; NzRowDirective, NzColDirective, NzButtonComponent, - MenuTypePipe, NzModalModule, NzFormDirective, ReactiveFormsModule, @@ -58,7 +58,8 @@ import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; NgForOf, NzInputNumberComponent, NzSpinComponent, - NzTreeSelectComponent + NzTreeSelectComponent, + DictionaryPipe ], templateUrl: './menu.component.html', styleUrl: './menu.component.less' @@ -78,11 +79,15 @@ export class MenuComponent { editMenuTitle = ''; // 树视图展示状态 treeView= false; - + menuTypeArray:Dictionary[] = []; constructor(private menuService: MenuService, private fb: NonNullableFormBuilder, private modal: NzModalService, private message: NzMessageService) { + // 菜单类型 + this.menuTypeArray = new DictionaryPipe().getDictionaryList('MENU_TYPE'); + + // 获取菜单数据 this.queryMenuTree(); this.editMenuForm = this.fb.group({ @@ -114,7 +119,6 @@ export class MenuComponent { queryMenuData() { this.menuService.queryMenuList((data: any) => { this.menuData = data['return_data']; - console.log("父类菜单数据" , this.menuData); }); } @@ -148,7 +152,7 @@ export class MenuComponent { }; if (edit == false && this.menuDetail?.id == null) { - this.modal.confirm({ + this.modal.warning({ nzTitle: '提示', nzContent: '请点击需要修改的菜单', }); @@ -180,7 +184,6 @@ export class MenuComponent { submitEditMenuForm() { if (this.editMenuForm.valid) { this.treeView = false; - console.log(this.editMenuForm.value['menuPSid']); this.editMenuForm.value['menuPSid']!=null?this.editMenuForm.value['menuPSid']:null; this.menuService.editMenu(this.editMenuForm.value, (data: any) => { if (data['return_code'] == '000000') { diff --git a/src/app/pipes/account/sys-account-status.pipe.ts b/src/app/pipes/account/sys-account-status.pipe.ts deleted file mode 100644 index 7f7a6ab..0000000 --- a/src/app/pipes/account/sys-account-status.pipe.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; - -@Pipe({ - name: 'sysAccountStatus', - standalone: true -}) -export class SysAccountStatusPipe implements PipeTransform { - - transform(value: number): string { - switch (value) { - case 1: - return '正常'; - case 2: - return '禁用'; - default: - return '未知'; - } - } - -} diff --git a/src/app/pipes/common/dictionary.pipe.ts b/src/app/pipes/common/dictionary.pipe.ts new file mode 100644 index 0000000..3794b39 --- /dev/null +++ b/src/app/pipes/common/dictionary.pipe.ts @@ -0,0 +1,39 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import {dictionaryData, Dictionary} from "../../data/common/dictionary.namespace"; + +@Pipe({ + name: 'dictionary', + standalone: true +}) +export class DictionaryPipe implements PipeTransform { + + data: Dictionary[] = dictionaryData; + + /** + * 获取数据字典 + * @param codeType 码类型 + */ + getDictionaryList(codeType: string): any { + return this.data.filter(o => o.codeType == codeType); + } + + /** + * 获取数据字典 + * @param codeType 码类型 + * @param codeValue 码值 + */ + getDictionary(codeType: string, codeValue: string): any { + // 读取缓存数据 + return this.data.find(o => o.codeType == codeType && o.codeValue == codeValue); + } + + transform(codeValue: string,codeType: string): string { + const obj = this.getDictionary(codeType, codeValue); + if (obj == null) { + return '未知'; + } else { + return obj.codeName; + } + } +} + diff --git a/src/app/pipes/menu/menu-type.pipe.ts b/src/app/pipes/menu/menu-type.pipe.ts deleted file mode 100644 index 741705a..0000000 --- a/src/app/pipes/menu/menu-type.pipe.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; - -@Pipe({ - name: 'menuType', - standalone: true -}) -export class MenuTypePipe implements PipeTransform { - - // @ts-ignore - transform(value: number): string { - switch (value) { - case 1: - return '菜单'; - case 2: - return '按钮'; - default: - return '未知'; - } - } - -} diff --git a/src/app/servies/common/common.service.ts b/src/app/servies/common/common.service.ts new file mode 100644 index 0000000..50d5351 --- /dev/null +++ b/src/app/servies/common/common.service.ts @@ -0,0 +1,29 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../../../environments/environment"; +import {ObjectData} from "../../utils/objectData.service"; + +@Injectable({ + providedIn: 'root' +}) +export class CommonService { + + constructor(private http: HttpClient) { } + + /** + * + * 查询数据字典 + * @param codeType 【非必填】 码值类型 + * @param codeValue 【非必填】码值 + * @param callBack + */ + public queryDictionary(codeType: string, codeValue: string, callBack:any) { + const param = { + codeType: codeType, + codeValue: codeValue + }; + this.http.get(environment.baseUrl + 'common/queryDictionary?'+ObjectData.objectByString(param)).subscribe(data => { + callBack(data); + }); + } +}