From 92c844a2b578ca382123e476c0f309c14cde0971 Mon Sep 17 00:00:00 2001 From: Taric Xin Date: Fri, 17 Dec 2021 16:03:27 +0800 Subject: [PATCH] edit --- src/app/core/net/business.interceptor.ts | 9 +- .../pro/components/user/user.component.html | 4 +- .../routes/dashboard/dashboard.component.html | 9 -- .../routes/dashboard/dashboard.component.less | 6 - .../routes/dashboard/dashboard.component.ts | 64 +--------- .../staff-management.component.html | 4 +- .../staff-management.component.ts | 66 ++++++---- .../staff-modal/staff-modal.component.html | 2 +- .../staff-modal/staff-modal.component.ts | 81 +++++------- .../sys-setting/services/system.service.ts | 14 +++ src/assets/mocks/menu-data.json | 115 ++++++++---------- 11 files changed, 149 insertions(+), 225 deletions(-) diff --git a/src/app/core/net/business.interceptor.ts b/src/app/core/net/business.interceptor.ts index a30667bd..5a47a69a 100644 --- a/src/app/core/net/business.interceptor.ts +++ b/src/app/core/net/business.interceptor.ts @@ -5,7 +5,7 @@ import { HttpInterceptor, HttpRequest, HttpResponse, - HttpResponseBase, + HttpResponseBase } from '@angular/common/http'; import { Inject, Injectable, Optional } from '@angular/core'; import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth'; @@ -21,7 +21,7 @@ export class BusinessInterceptor implements HttpInterceptor { private eaUserSrv: EAUserService, @Optional() @Inject(DA_SERVICE_TOKEN) - private tokenSrv: ITokenService, + private tokenSrv: ITokenService ) {} intercept(req: HttpRequest, next: HttpHandler): Observable> { // 构造新的请求URL @@ -30,8 +30,8 @@ export class BusinessInterceptor implements HttpInterceptor { req = this.attachAdditionalHeaders(req); // 后续操作 return next.handle(req).pipe( - mergeMap((ev) => this.handlingBussinessResponseData(ev)), - catchError((err: HttpErrorResponse) => this.handlingBusinessErrors(err)), + mergeMap(ev => this.handlingBussinessResponseData(ev)), + catchError((err: HttpErrorResponse) => this.handlingBusinessErrors(err)) ); } @@ -56,6 +56,7 @@ export class BusinessInterceptor implements HttpInterceptor { const header: any = { appId: this.envSrv.env.appId, tenantId: this.envSrv.env.tenantId, + enterpriseId: '0' }; // 附加授权声明 diff --git a/src/app/layout/pro/components/user/user.component.html b/src/app/layout/pro/components/user/user.component.html index ed7633c0..cc3e9a80 100644 --- a/src/app/layout/pro/components/user/user.component.html +++ b/src/app/layout/pro/components/user/user.component.html @@ -8,14 +8,14 @@ 个人中心 -
+
  • diff --git a/src/app/routes/dashboard/dashboard.component.html b/src/app/routes/dashboard/dashboard.component.html index 8303d109..e69de29b 100644 --- a/src/app/routes/dashboard/dashboard.component.html +++ b/src/app/routes/dashboard/dashboard.component.html @@ -1,9 +0,0 @@ - - - - diff --git a/src/app/routes/dashboard/dashboard.component.less b/src/app/routes/dashboard/dashboard.component.less index dcb4cf4f..e69de29b 100644 --- a/src/app/routes/dashboard/dashboard.component.less +++ b/src/app/routes/dashboard/dashboard.component.less @@ -1,6 +0,0 @@ -@import '~@delon/theme/index'; - -:host { - ::ng-deep { - } -} diff --git a/src/app/routes/dashboard/dashboard.component.ts b/src/app/routes/dashboard/dashboard.component.ts index a069694d..fe11f0cf 100644 --- a/src/app/routes/dashboard/dashboard.component.ts +++ b/src/app/routes/dashboard/dashboard.component.ts @@ -1,66 +1,8 @@ -import { Component, ChangeDetectionStrategy, ChangeDetectorRef, TemplateRef, ViewChild } from '@angular/core'; -import { STComponent, STColumn, STData, STChange } from '@delon/abc/st'; -import { SFSchema, SFUISchema } from '@delon/form'; -import { _HttpClient } from '@delon/theme'; -import { NzSafeAny } from 'ng-zorro-antd/core/types'; -import { NzMessageService } from 'ng-zorro-antd/message'; -import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; -import { map, tap } from 'rxjs/operators'; +import { Component } from '@angular/core'; @Component({ selector: 'app-dashboard', templateUrl: './dashboard.component.html', - styleUrls: ['./dashboard.component.less'], - changeDetection: ChangeDetectionStrategy.OnPush + styleUrls: ['./dashboard.component.less'] }) -export class DashboardComponent { - @ViewChild('sf') - sf!: SFSchema; - record: any = {}; - i: any; - schema: any = { - properties: { - no: { type: 'string', title: '编号' }, - owner: { type: 'string', title: '姓名' }, - callNo: { type: 'number', title: '调用次数' }, - href: { type: 'string', title: '链接', format: 'uri', ui: { errors: { uri: '11' } } }, - description: { type: 'string', title: '描述' } - }, - required: ['owner', 'callNo', 'href', 'description'] - }; - ui: SFUISchema = { - '*': { - spanLabelFixed: 100, - grid: { span: 12 } - }, - $no: { - widget: 'text' - }, - $href: { - widget: 'string' - }, - $description: { - widget: 'textarea', - grid: { span: 24 } - } - }; - - constructor(private msgSrv: NzMessageService, public http: _HttpClient) {} - - ngOnInit(): void { - // if (this.record.id > 0) this.http.get(`/user/${this.record.id}`).subscribe(res => (this.i = res)); - } - - save(value: any): void { - console.log(this.sf.value); - - // this.http.post(`/user/${this.record.id}`, value).subscribe(res => { - // this.msgSrv.success('保存成功'); - // // this.modal.close(true); - // }); - } - - close(): void { - // this.modal.destroy(); - } -} +export class DashboardComponent {} diff --git a/src/app/routes/sys-setting/components/staff-management/staff-management.component.html b/src/app/routes/sys-setting/components/staff-management/staff-management.component.html index 4bd860b2..409e7d2b 100644 --- a/src/app/routes/sys-setting/components/staff-management/staff-management.component.html +++ b/src/app/routes/sys-setting/components/staff-management/staff-management.component.html @@ -32,8 +32,8 @@
    - diff --git a/src/app/routes/sys-setting/components/staff-management/staff-management.component.ts b/src/app/routes/sys-setting/components/staff-management/staff-management.component.ts index 81cc4922..09a2f96a 100644 --- a/src/app/routes/sys-setting/components/staff-management/staff-management.component.ts +++ b/src/app/routes/sys-setting/components/staff-management/staff-management.component.ts @@ -17,11 +17,9 @@ export class StaffManagementComponent implements OnInit { @ViewChild('sf', { static: false }) sf!: SFComponent; - url = `/rule?_allow_anonymous=true`; - searchSchema: SFSchema = { properties: { - receiveName: { + nameOrPhone: { type: 'string', title: '输入搜索', ui: { placeholder: '手机号码 / 成员姓名' } @@ -31,23 +29,21 @@ export class StaffManagementComponent implements OnInit { columns: STColumn[] = [ { title: '', index: 'key', type: 'checkbox' }, - { title: '员工姓名', index: 'no' }, - { title: '手机号码', index: 'description' }, - { title: '角色', index: 'description' }, + { title: '员工姓名', index: 'name' }, + { title: '手机号码', index: 'telephone' }, + { title: '角色', render: 'description' }, { title: '最后登录时间', - index: 'updatedAt', + index: 'lastLoginDate', type: 'date' }, { title: '成员状态', className: 'text-center', - index: 'status', + index: 'stateLocked', type: 'badge', badge: { 0: { text: '正常', color: 'success' }, - 2: { text: '废弃', color: 'warning' }, - 3: { text: '废弃', color: 'warning' }, 1: { text: '冻结', color: 'error' } } }, @@ -60,13 +56,13 @@ export class StaffManagementComponent implements OnInit { }, { text: '恢复', - iif: item => item.status === 1, - click: item => this.action(2) + iif: item => item.stateLocked === 1, + click: item => this.action(item, 2) }, { text: '冻结', - iif: item => item.status === 0, - click: item => this.action(1) + iif: item => item.stateLocked === 0, + click: item => this.action(item, 1) }, { text: '超管转授', @@ -75,8 +71,8 @@ export class StaffManagementComponent implements OnInit { }, { text: '删除', - iif: item => item.status === 1, - click: item => this.action(3) + iif: item => item.stateLocked === 0, + click: item => this.action(item, 3) } ] } @@ -84,8 +80,6 @@ export class StaffManagementComponent implements OnInit { selectedRows: any[] = []; - reqParams = { pageIndex: 1, pageSize: 10 }; - actionLabel = { 1: { title: '确认冻结?', text: '冻结后用户在本系统将无法登录使用,请谨慎操作!' }, 2: { title: '确认恢复?', text: '恢复后用户在本系统的权限将一并重新开启。' }, @@ -100,13 +94,10 @@ export class StaffManagementComponent implements OnInit { case 'checkbox': this.selectedRows = e.checkbox!; break; - case 'filter': - this.st.load(); - break; } } - action(type: 1 | 2 | 3) { + action(item: any, type: 1 | 2 | 3) { this.nzModalService.error({ nzTitle: this.actionLabel[type].title, nzContent: ``, @@ -115,6 +106,13 @@ export class StaffManagementComponent implements OnInit { nzOnOk: () => { switch (type) { case 1: + this.freeOrResumStaff({ appUserId: item.appUserId, freezeOrResume: true }); + break; + case 2: + this.freeOrResumStaff({ appUserId: item.appUserId, freezeOrResume: false }); + break; + case 3: + this.deleteStaff([item.appUserId]); break; default: @@ -138,11 +136,13 @@ export class StaffManagementComponent implements OnInit { staffAction(item?: any) { const modal = this.nzModalService.create({ nzContent: SystemStaffStaffModalComponent, - nzComponentParams: item ? { i: { ...item, roleId: '1,2,3', name: '用户名', phone: 18555555555 } } : { i: { id: 0 } }, + nzComponentParams: item ? { i: { ...item } } : { i: { userId: 0 } }, nzFooter: null }); modal.afterClose.subscribe(res => { - this.st.load(); + if (true) { + this.st.load(); + } }); } @@ -152,4 +152,22 @@ export class StaffManagementComponent implements OnInit { resetSF() { this.sf.reset(); } + + private deleteStaff(params: any) { + this.service.request(this.service.$api_delete_staff, params).subscribe(res => { + if (res) { + this.service.msgSrv.success('操作成功'); + this.st.load(); + } + }); + } + + private freeOrResumStaff(params: any) { + this.service.request(this.service.$api_free_or_resume_staff, params).subscribe(res => { + if (res) { + this.service.msgSrv.success('操作成功'); + this.st.load(); + } + }); + } } diff --git a/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.html b/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.html index f3d377e0..1d16b237 100644 --- a/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.html +++ b/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.html @@ -2,7 +2,7 @@
    - + diff --git a/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.ts b/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.ts index e9944ab5..b579a5bc 100644 --- a/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.ts +++ b/src/app/routes/sys-setting/components/staff-management/staff-modal/staff-modal.component.ts @@ -29,32 +29,31 @@ export class SystemStaffStaffModalComponent implements OnInit { ) {} ngOnInit(): void { - if (this.i?.id !== 0) { - this.i.roleIds = this.i.roleId !== '' ? this.i.roleId.split(',') : []; + if (this.i?.userId !== 0) { + // this.i.roleIds = this.i.roleId !== '' ? this.i.roleId.split(',') : []; } - + this.initSF(this.i); } initSF(staff: any) { - console.log(staff); this.schema = { properties: { - name: { + staffName: { title: '员工姓名', type: 'string', maxLength: 32, - ui: { widget: staff?.name ? 'text' : 'string', placeholder: '请输入员工姓名' }, + ui: { widget: staff?.appUserId ? 'text' : 'string', placeholder: '请输入员工姓名' }, default: staff.name }, - phone: { + telephone: { title: '手机号码', type: 'string', format: 'mobile', maxLength: 11, - ui: { widget: staff?.phone ? 'text' : 'string', placeholder: '请输入员工手机号' }, - default: staff.phone + ui: { widget: staff?.appUserId ? 'text' : 'string', placeholder: '请输入员工手机号' }, + default: staff.telephone }, - roleIds: { + roleId: { title: '角色', type: 'string', ui: { @@ -80,7 +79,7 @@ export class SystemStaffStaffModalComponent implements OnInit { default: staff?.roleIds } }, - required: ['name', 'phone', 'roleIds'] + required: ['staffName', 'telephone'] }; this.ui = { '*': { @@ -91,54 +90,36 @@ export class SystemStaffStaffModalComponent implements OnInit { } sure() { - if (!this.sf.value.roleIds || this.sf.value.roleIds.length === 0) { - this.service.msgSrv.error('员工角色不能为空!'); - return; - } - this.roleNames = []; - this.roleList.forEach((item: { id: any; roleName: string }) => { - this.sf.value.roleIds.forEach((ele: any) => { - if (ele === item.id) { - this.roleNames.push(item.roleName); - } - }); - }); - if (this.i.id === 0) { + // if (!this.sf.value.roleIds || this.sf.value.roleIds.length === 0) { + // this.service.msgSrv.error('员工角色不能为空!'); + // return; + // } + if (this.i.userId === 0) { const params: any = { ...this.sf.value, - roleId: this.sf.value.roleIds, - roleNames: this.roleNames.join(','), - telephone: this.sf.value.phone, - staffName: this.sf.value.name + enterpriseId: 0, + roleId: [] }; - // this.service.request(this.service.$api_addStaff, params).subscribe((res) => { - // console.log(res); - // if (res) { - // this.service.msgSrv.success('保存成功!'); - // this.modal.close(true); - // } - // // this.showInviteFlag = true; - // // this.inviteCode = res.inviteCode; - // }); + this.service.request(this.service.$api_add_staff, params).subscribe(res => { + if (res) { + this.service.msgSrv.success('保存成功!'); + this.modal.close(true); + } + }); } else { const params: any = { appUserId: this.i.appUserId, - staffName: this.sf.value.name, - roleId: this.sf.value.roleIds, - telephone: this.i.telephone + ...this.sf.value, + roleId: [] }; - // this.service.request(this.service.$api_editorStaff, params).subscribe((res) => { - // this.service.msgSrv.success('编辑成功!'); - // // this.loadMyIdentity(); - // this.modal.close(true); - // }); + this.service.request(this.service.$api_edit_staff, params).subscribe(res => { + if (res) { + this.service.msgSrv.success('编辑成功!'); + this.modal.close(true); + } + }); } } - loadMyIdentity() { - this.enterpriseSrv.loadEnterpises().subscribe((data: any[]) => { - this.enterpriseSrv.setCache(data); - }); - } close() { this.modal.destroy(); diff --git a/src/app/routes/sys-setting/services/system.service.ts b/src/app/routes/sys-setting/services/system.service.ts index 85b356d3..99a0c00b 100644 --- a/src/app/routes/sys-setting/services/system.service.ts +++ b/src/app/routes/sys-setting/services/system.service.ts @@ -5,6 +5,20 @@ import { BaseService } from 'src/app/shared/services'; providedIn: 'root' }) export class SystemService extends BaseService { + + + // 分页查询企业项目员工列表 + $api_get_enterprise_staff_page = '/api/mdc/cuc/userApp/getEnterpriseProjectStaffListPage'; + // 添加员工 + $api_add_staff = '/api/mdc/cuc/userApp/addStaff'; + // 编辑员工 + $api_edit_staff = '/api/mdc/cuc/userApp/editorStaff'; + // 删除应用用户(员工) + $api_delete_staff = '/api/mdc/cuc/userApp/deleteAppUser'; + // 冻结或恢复员工 + $api_free_or_resume_staff = '/api/mdc/cuc/userApp/freezeOrResumeStaff'; + + $api_getAllFunctionInfoByAppId: string = ''; $api_getRoleTemplateInfo: string = ''; $api_getFunctionButtonInfo: string = ''; diff --git a/src/assets/mocks/menu-data.json b/src/assets/mocks/menu-data.json index 15614a17..af6f1b9c 100644 --- a/src/assets/mocks/menu-data.json +++ b/src/assets/mocks/menu-data.json @@ -4,23 +4,6 @@ "text": "样例", "hideInBreadcrumb": true, "children": [ - { - "text": "样例", - "icon": "anticon anticon-dashboard", - "group": true, - "children": [ - { - "text": "Zorro案例", - "icon": "anticon anticon-dashboard", - "link": "/demo/zorro" - }, - { - "text": "Alain案例", - "icon": "anticon anticon-dashboard", - "link": "/demo/alain" - } - ] - }, { "text": "用户中心", "icon": "anticon anticon-dashboard", @@ -98,38 +81,27 @@ ] }, { - "text": "票务管理", + "text": "运力管理", "icon": "anticon anticon-dashboard", "group": true, "children": [ { - "text": "开票申请", - "link": "/ticket/invoice-requested" + "text": "车辆列表", + "link": "/vehicle/list" }, { - "text": "已开发票", - "link": "/ticket/invoice-list" + "hide": true, + "text": "车辆列表详情", + "link": "/vehicle/list/detail/:id" }, { - "text": "ETC发票", - "children": [ - { - "text": "申请发票", - "link": "/ticket/etc-invoice-requested" - }, - { - "text": "运单开票记录", - "link": "/ticket/etc-invoice-list" - }, - { - "text": "已开发票", - "link": "/ticket/etc-invoiced-logs" - }, - { - "text": "黑名单", - "link": "/ticket/etc-blacklist" - } - ] + "text": "车辆审核列表", + "link": "/vehicle/audit" + }, + { + "hide": true, + "text": "车辆审核列表详情", + "link": "/vehicle/audit/detail/:id" } ] }, @@ -272,31 +244,6 @@ } ] }, - { - "text": "运力管理", - "icon": "anticon anticon-dashboard", - "group": true, - "children": [ - { - "text": "车辆列表", - "link": "/vehicle/list" - }, - { - "hide": true, - "text": "车辆列表详情", - "link": "/vehicle/list/detail/:id" - }, - { - "text": "车辆审核列表", - "link": "/vehicle/audit" - }, - { - "hide": true, - "text": "车辆审核列表详情", - "link": "/vehicle/audit/detail/:id" - } - ] - }, { "text": "财务管理", "icon": "anticon anticon-dashboard", @@ -329,6 +276,42 @@ } ] }, + { + "text": "票务管理", + "icon": "anticon anticon-dashboard", + "group": true, + "children": [ + { + "text": "开票申请", + "link": "/ticket/invoice-requested" + }, + { + "text": "已开发票", + "link": "/ticket/invoice-list" + }, + { + "text": "ETC发票", + "children": [ + { + "text": "申请发票", + "link": "/ticket/etc-invoice-requested" + }, + { + "text": "运单开票记录", + "link": "/ticket/etc-invoice-list" + }, + { + "text": "已开发票", + "link": "/ticket/etc-invoiced-logs" + }, + { + "text": "黑名单", + "link": "/ticket/etc-blacklist" + } + ] + } + ] + }, { "text": "合同管理", "icon": "anticon anticon-dashboard",