parent
a55d0783d5
commit
f302704d82
@ -1,8 +1,10 @@ |
||||
import { Routes } from '@angular/router'; |
||||
import {SysAccountComponent} from "./sys-account/sys-account.component"; |
||||
import {SysRoleComponent} from "./sys-role/sys-role.component"; |
||||
import {OrgListComponent} from "../organization/org-list/org-list.component"; |
||||
|
||||
export const ACCOUNT_ROUTES: Routes = [ |
||||
{ path: 'sys_account', component: SysAccountComponent}, |
||||
{ path: 'sys_role', component: SysRoleComponent}, |
||||
{ path: 'org-config', component: OrgListComponent }, |
||||
]; |
||||
|
||||
@ -0,0 +1,148 @@ |
||||
<form nz-form [formGroup]="searchForm" class="search_form" [nzLayout]="'vertical'"> |
||||
<div nz-row [nzGutter]="24"> |
||||
|
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>审批平台</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-select formControlName="platform" nzAllowClear [nzPlaceHolder]="'请选择'"> |
||||
<nz-option *ngFor="let item of platformArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label>模板类型</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-select formControlName="typeCode" nzAllowClear [nzPlaceHolder]="'请选择'"> |
||||
<nz-option *ngFor="let item of tempTypeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="6"> |
||||
<nz-form-item> |
||||
<nz-form-label></nz-form-label> |
||||
<nz-form-control> |
||||
<button nz-button style="margin-right: 8px" [nzType]="'primary'" (click)="searchFormSubmit()">查询</button> |
||||
<button nz-button style="margin-right: 8px" (click)="searchFormReset()">重置</button> |
||||
<button nz-button style="margin-right: 8px" (click)="showEditModal(null)" [nzType]="'primary'" >新增模板</button> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
<nz-table #basicTable |
||||
[nzScroll]="{ x: '1500' }" |
||||
[nzBordered]="true" |
||||
[nzFrontPagination]="false" |
||||
[nzShowQuickJumper]="true" |
||||
[nzShowTotal]="totalTemplate" |
||||
[(nzPageIndex)]="tablePageNum" |
||||
(nzPageIndexChange)="queryData()" |
||||
nzShowSizeChanger |
||||
(nzPageSizeChange)="this.tablePageSize = $event;queryData()" |
||||
[nzPageSizeOptions]="[ 10, 20, 30, 50, 100 ]" |
||||
[nzTotal]="tableData.total" |
||||
[nzData]="tableData.list" > |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="100px">审批平台</th> |
||||
<th nzWidth="100px">审批类型</th> |
||||
<th nzWidth="100px">更新时间</th> |
||||
<th nzRight nzWidth="70px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data"> |
||||
<td>{{data.platform | dictionary : 'OA_PLATFORM'}}</td> |
||||
<td>{{data.typeCode | dictionary : 'OA_TEMPLATE_TYPE'}}</td> |
||||
<td>{{data.updateTime | date : 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight> |
||||
<a nz-dropdown [nzDropdownMenu]="menu"> |
||||
操作列表 |
||||
<span nz-icon nzType="down"></span> |
||||
</a> |
||||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
||||
<ul nz-menu nzSelectable> |
||||
<li nz-menu-item *ngIf="data.status != 2"><a (click)="showEditModal(data)">修改</a></li> |
||||
<li nz-menu-item *ngIf="data.status != 2"><a (click)="delCms(data.id)">删除</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu></td> |
||||
</tr> |
||||
</tbody> |
||||
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template> |
||||
</nz-table> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="editModal" |
||||
[nzWidth]="500" |
||||
nzTitle="{{this.editForm.controls['id'].value==null?'新增':'修改'}}" |
||||
[nzFooter]="null" |
||||
(nzOnCancel)="closeEditModal()"> |
||||
<ng-container *nzModalContent> |
||||
<form nz-form [formGroup]="editForm"> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>审批平台</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||
<nz-select formControlName="platform" [nzPlaceHolder]="'请选择'"> |
||||
<nz-option *ngFor="let item of platformArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>审批类型</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||
<nz-select formControlName="typeCode" [nzPlaceHolder]="'请选择'"> |
||||
<nz-option *ngFor="let item of tempTypeArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-divider nzText="审批流程配置"></nz-divider> |
||||
|
||||
<nz-timeline> |
||||
<nz-timeline-item *ngFor="let control of listOfControl;let i = index;"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzNoColon]="true">审核人</nz-form-label> |
||||
<nz-form-control > |
||||
<nz-tree-select |
||||
class="passenger-input" |
||||
[formControlName]="control.reviewerId" |
||||
[nzNodes]="orgDataTree" |
||||
[nzShowLine]="true" |
||||
[nzDefaultExpandAll]="true" |
||||
nzShowSearch |
||||
></nz-tree-select> |
||||
<span |
||||
nz-icon |
||||
nzType="minus-circle-o" |
||||
class="dynamic-delete-button" |
||||
(click)="removeField(control, $event)" |
||||
></span> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</nz-timeline-item> |
||||
</nz-timeline> |
||||
|
||||
|
||||
<nz-form-item style="text-align: center"> |
||||
<nz-form-control> |
||||
<button nz-button nzType="dashed" class="add-button" (click)="addField($event)"> |
||||
<span nz-icon nzType="plus"></span>增加审核人 |
||||
</button> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<div nz-flex style="margin-top: 15px" [nzJustify]="'center'"> |
||||
<button nz-button nzType="primary" (click)="submitData()" class="submit-btn">保存</button> |
||||
</div> |
||||
</form> |
||||
</ng-container> |
||||
</nz-modal> |
||||
@ -0,0 +1,33 @@ |
||||
[nz-form-label] { |
||||
overflow: visible; |
||||
} |
||||
button { |
||||
margin-left: 8px; |
||||
} |
||||
.submit-btn { |
||||
width: 150px; |
||||
} |
||||
.search-area { |
||||
margin-top: 30px; |
||||
} |
||||
.dynamic-delete-button { |
||||
cursor: pointer; |
||||
position: relative; |
||||
top: 4px; |
||||
font-size: 24px; |
||||
color: #999; |
||||
transition: all 0.3s; |
||||
} |
||||
|
||||
.dynamic-delete-button:hover { |
||||
color: #777; |
||||
} |
||||
|
||||
.passenger-input { |
||||
width: 80%; |
||||
margin-right: 8px; |
||||
} |
||||
|
||||
.add-button { |
||||
width: 60%; |
||||
} |
||||
@ -0,0 +1,23 @@ |
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { ApprovalTemplateComponent } from './approval-template.component'; |
||||
|
||||
describe('ApprovalTemplateComponent', () => { |
||||
let component: ApprovalTemplateComponent; |
||||
let fixture: ComponentFixture<ApprovalTemplateComponent>; |
||||
|
||||
beforeEach(async () => { |
||||
await TestBed.configureTestingModule({ |
||||
imports: [ApprovalTemplateComponent] |
||||
}) |
||||
.compileComponents(); |
||||
|
||||
fixture = TestBed.createComponent(ApprovalTemplateComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
||||
@ -0,0 +1,334 @@ |
||||
import { Component } from '@angular/core'; |
||||
import { |
||||
FormGroup, FormRecord, |
||||
FormsModule, |
||||
NonNullableFormBuilder, |
||||
ReactiveFormsModule, |
||||
Validators |
||||
} from "@angular/forms"; |
||||
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; |
||||
import {NzMessageService} from "ng-zorro-antd/message"; |
||||
import {BrowserStorageService} from "../../../utils/localStorage.service"; |
||||
import {CmsService} from "../../../services/cms/cms.service"; |
||||
import {CommonService} from "../../../services/common/common.service"; |
||||
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal"; |
||||
import {DATA} from "../../../data/login/localStorage.namespace"; |
||||
import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload"; |
||||
import {Observable, Observer} from "rxjs"; |
||||
import {DatePipe, NgForOf, NgIf} from "@angular/common"; |
||||
import {NzButtonComponent} from "ng-zorro-antd/button"; |
||||
import { |
||||
NzCellFixedDirective, |
||||
NzTableCellDirective, |
||||
NzTableComponent, NzTableModule, |
||||
NzTbodyComponent, NzTheadComponent, |
||||
NzThMeasureDirective, NzTrDirective |
||||
} from "ng-zorro-antd/table"; |
||||
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; |
||||
import {NzDividerComponent} from "ng-zorro-antd/divider"; |
||||
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; |
||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; |
||||
import {NzIconDirective} from "ng-zorro-antd/icon"; |
||||
import {NzInputDirective} from "ng-zorro-antd/input"; |
||||
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu"; |
||||
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; |
||||
import {NzFlexDirective} from "ng-zorro-antd/flex"; |
||||
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions"; |
||||
import {NzAvatarModule} from "ng-zorro-antd/avatar"; |
||||
import {NzImageModule} from "ng-zorro-antd/image"; |
||||
import {NzSwitchComponent} from "ng-zorro-antd/switch"; |
||||
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker"; |
||||
import {NzInputNumberModule} from "ng-zorro-antd/input-number"; |
||||
import {TemplateService} from "../../../services/oa/template.service"; |
||||
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; |
||||
import {OrganizationService} from "../../../services/oa/organization.service"; |
||||
import {NzTimelineModule} from "ng-zorro-antd/timeline"; |
||||
import {NzTypographyComponent} from "ng-zorro-antd/typography"; |
||||
|
||||
@Component({ |
||||
selector: 'app-approval-template', |
||||
standalone: true, |
||||
imports: [ |
||||
DatePipe, |
||||
DictionaryPipe, |
||||
FormsModule, |
||||
NgForOf, |
||||
NgIf, |
||||
NzButtonComponent, |
||||
NzCellFixedDirective, |
||||
NzColDirective, |
||||
NzDividerComponent, |
||||
NzDropDownADirective, |
||||
NzDropDownDirective, |
||||
NzDropdownMenuComponent, |
||||
NzFormControlComponent, |
||||
NzFormDirective, |
||||
NzFormItemComponent, |
||||
NzFormLabelComponent, |
||||
NzIconDirective, |
||||
NzInputDirective, |
||||
NzMenuDirective, |
||||
NzMenuItemComponent, |
||||
NzOptionComponent, |
||||
NzRowDirective, |
||||
NzSelectComponent, |
||||
NzTableCellDirective, |
||||
NzTableComponent, |
||||
NzTbodyComponent, |
||||
NzThMeasureDirective, |
||||
NzTheadComponent, |
||||
NzTrDirective, |
||||
ReactiveFormsModule, |
||||
NzTableModule, |
||||
NzModalModule, |
||||
NzFlexDirective, |
||||
NzDescriptionsModule, |
||||
NzUploadComponent, |
||||
NzAvatarModule, |
||||
NzImageModule, |
||||
NzSwitchComponent, |
||||
NzDatePickerComponent, |
||||
NzInputNumberModule, |
||||
NzTreeSelectComponent, |
||||
NzTimelineModule, |
||||
NzTypographyComponent |
||||
], |
||||
templateUrl: './approval-template.component.html', |
||||
styleUrl: './approval-template.component.less' |
||||
}) |
||||
export class ApprovalTemplateComponent { |
||||
logoUrl?: string; |
||||
// 表单页数
|
||||
tablePageNum = 1; |
||||
// 每页数量
|
||||
tablePageSize = 10; |
||||
// 表单数据
|
||||
tableData: any = { |
||||
total: 0, |
||||
list: [], |
||||
}; |
||||
accountType = null; |
||||
// 搜索表单
|
||||
searchForm: FormGroup; |
||||
// 编辑表单
|
||||
editForm: FormGroup; |
||||
editModal = false; |
||||
// 所属平台
|
||||
platformArray = new DictionaryPipe().getDictionaryList('OA_PLATFORM'); |
||||
// 模板类型
|
||||
tempTypeArray: any = []; |
||||
|
||||
listOfControl: Array<{sort: number, reviewerId: string}> = []; |
||||
// 菜单数据
|
||||
orgData: any = []; |
||||
// 菜单树形数据
|
||||
orgDataTree: any[] = []; |
||||
constructor(private fb: NonNullableFormBuilder, |
||||
private message: NzMessageService, |
||||
private storage: BrowserStorageService, |
||||
private orgService : OrganizationService, |
||||
private templateService: TemplateService, |
||||
private commonService: CommonService, |
||||
private modal: NzModalService) { |
||||
this.accountType = this.storage.get(DATA)['account']['objectType']; |
||||
|
||||
// 初始化搜索框
|
||||
this.searchForm = this.fb.group({ |
||||
platform: [null], |
||||
typeCode: [null], |
||||
}); |
||||
|
||||
this.editForm = this.fb.group({ |
||||
id: [null], |
||||
platform: ['', [Validators.required]], |
||||
typeCode: ['', [Validators.required]], |
||||
}); |
||||
|
||||
// 模板类型
|
||||
this.commonService.queryDictionary("OA_TEMPLATE_TYPE","", (data: any) => { |
||||
this.tempTypeArray = data['return_data']; |
||||
}); |
||||
// 查询数据
|
||||
this.queryData(); |
||||
// 组织数据
|
||||
this.queryMenuTree(); |
||||
} |
||||
|
||||
/** |
||||
* 获取菜单树 |
||||
*/ |
||||
queryMenuTree() { |
||||
this.orgService.queryOrgTree(true,(data: any) => { |
||||
this.orgDataTree = data['return_data']; |
||||
this.queryMenuData(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询菜单原始数据 |
||||
*/ |
||||
queryMenuData() { |
||||
this.orgService.queryAllOrg((data: any) => { |
||||
this.orgData = data['return_data']; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 获取数据 |
||||
*/ |
||||
queryData() { |
||||
this.searchForm.value.pageNum = this.tablePageNum; |
||||
this.searchForm.value.pageSize = this.tablePageSize; |
||||
this.searchForm.value.time = new Date().getTime(); |
||||
this.templateService.queryList(this.searchForm.value, (data: any) => { |
||||
if (data['return_code'] == '000000') { |
||||
this.tableData = data['return_data']; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 搜索表单提交 |
||||
*/ |
||||
searchFormSubmit(): void { |
||||
this.tablePageNum = 1; |
||||
this.queryData(); |
||||
} |
||||
|
||||
/** |
||||
* 搜索表单重置 |
||||
*/ |
||||
searchFormReset(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
|
||||
addField(e: MouseEvent): void { |
||||
e.preventDefault(); |
||||
const sort = this.listOfControl.length > 0 ? this.listOfControl[this.listOfControl.length - 1].sort + 1 : 0; |
||||
const control = { |
||||
sort : sort, |
||||
reviewerId: sort+"" |
||||
}; |
||||
const index = this.listOfControl.push(control); |
||||
console.log(this.listOfControl[this.listOfControl.length - 1]); |
||||
this.editForm.addControl( |
||||
this.listOfControl[sort].reviewerId, |
||||
this.fb.control('', Validators.required) |
||||
); |
||||
} |
||||
|
||||
removeField(i: { sort: number; reviewerId: string }, e: MouseEvent): void { |
||||
e.preventDefault(); |
||||
if (this.listOfControl.length > 1) { |
||||
const index = this.listOfControl.indexOf(i); |
||||
this.listOfControl.splice(index, 1); |
||||
console.log(this.listOfControl); |
||||
this.editForm.removeControl(i.sort+""); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
delCms(id: number) { |
||||
this.modal.confirm({ |
||||
nzTitle: '提示', |
||||
nzContent: '确定删除吗?未完结的审批不受影响', |
||||
nzOnOk: () => |
||||
this.templateService.delete({id: id}, (data: any) => { |
||||
if (data['return_code'] == '000000') { |
||||
// 刷新数据
|
||||
this.queryData(); |
||||
this.message.create('success', '操作成功'); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}) |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 打开编辑模态框 |
||||
*/ |
||||
showEditModal(data: any) { |
||||
if (data != null) { |
||||
data['platform'] = String(data['platform']); |
||||
data['typeCode'] = String(data['typeCode']); |
||||
|
||||
this.templateService.queryDetailById({id: data.id}, (respData: any) => { |
||||
|
||||
for (let obj of respData['return_data']['process']) { |
||||
const control = { |
||||
sort : obj.sort, |
||||
reviewerId: String(obj.sort) |
||||
}; |
||||
const index = this.listOfControl.push(control); |
||||
this.editForm.addControl( |
||||
obj.sort+"", |
||||
this.fb.control('', Validators.required) |
||||
); |
||||
this.editForm.controls[obj.sort+""].setValue(String(obj.reviewerId)); |
||||
} |
||||
this.editForm.patchValue(data); |
||||
}); |
||||
} |
||||
this.editForm.patchValue(data); |
||||
this.editModal = true; |
||||
} |
||||
|
||||
/** |
||||
* 提交数据 |
||||
*/ |
||||
submitData() { |
||||
if (this.editForm.valid) { |
||||
let processList: any = []; |
||||
for (let obj of this.listOfControl) { |
||||
processList.push({ |
||||
reviewerId: this.editForm.controls[obj.sort].value, |
||||
sort: obj.sort |
||||
}); |
||||
} |
||||
|
||||
let reqParam = { |
||||
platform: this.editForm.controls['platform'].value, |
||||
typeCode: this.editForm.controls['typeCode'].value, |
||||
processList: processList |
||||
} |
||||
this.templateService.config(reqParam, (data: any) => { |
||||
if (data['return_code'] == '000000') { |
||||
this.message.create('success', '操作成功'); |
||||
// 刷新数据
|
||||
this.queryData(); |
||||
// 关闭弹窗
|
||||
this.closeEditModal(); |
||||
// 表单重置
|
||||
this.editForm.reset(); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} else { |
||||
Object.values(this.editForm.controls).forEach(control => { |
||||
if (control.invalid) { |
||||
control.markAsDirty(); |
||||
control.updateValueAndValidity({ onlySelf: true }); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 关闭编辑任务模态框 |
||||
*/ |
||||
closeEditModal() { |
||||
this.editForm.reset(); |
||||
for (let obj of this.listOfControl) { |
||||
this.listOfControl.splice(obj.sort, 1); |
||||
this.editForm.removeControl(obj.sort+""); |
||||
} |
||||
this.listOfControl = []; |
||||
this.logoUrl = ''; |
||||
this.editModal = false; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [], |
||||
imports: [ |
||||
CommonModule |
||||
] |
||||
}) |
||||
export class ApprovalModule { } |
||||
@ -0,0 +1,6 @@ |
||||
import { Routes } from '@angular/router'; |
||||
import {ApprovalTemplateComponent} from "./approval-template/approval-template.component"; |
||||
|
||||
export const APPROVAL_ROUTES: Routes = [ |
||||
{ path: 'temp-list', component: ApprovalTemplateComponent}, |
||||
]; |
||||
@ -0,0 +1,65 @@ |
||||
<div nz-row [nzGutter]="16"> |
||||
|
||||
<div nz-col nzSpan="12"> |
||||
<nz-card nzTitle="公司组织"> |
||||
<nz-spin [nzSpinning]="!treeView"></nz-spin> |
||||
<nz-tree |
||||
*ngIf="orgDataTree.length > 0 && treeView" |
||||
[nzData]="orgDataTree" |
||||
[nzShowLine]="true" |
||||
[nzExpandAll]="true" |
||||
(nzClick)="clickNode($event)" |
||||
[nzMultiple]="false" |
||||
></nz-tree> |
||||
</nz-card> |
||||
</div> |
||||
|
||||
<div nz-col nzSpan="12"> |
||||
<nz-card nzTitle="组织详情" [nzExtra]="extraTemplate" [nzBodyStyle]="{ padding: '0px'}"> |
||||
<nz-descriptions nzBordered |
||||
nzLayout="vertical" |
||||
[nzSize]="'middle'" |
||||
[nzColumn]="{ xxl: 2, xl: 2, lg: 2, md: 2, sm: 2, xs: 1 }" |
||||
> |
||||
<nz-descriptions-item nzTitle="上级组织">{{orgDetail?.parentOrg?orgDetail.parentOrg.name:'无'}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="组织名称">{{orgDetail.name?orgDetail.name:'无'}}</nz-descriptions-item> |
||||
</nz-descriptions> |
||||
</nz-card> |
||||
<ng-template #extraTemplate> |
||||
<div nz-row [nzGutter]="12"> |
||||
<div nz-col nzSpan="8"><button nz-button nzType="primary" (click)="openEditMenu(true)">添加</button></div> |
||||
<div nz-col nzSpan="8"><button nz-button nzType="primary" (click)="openEditMenu(false)">修改</button></div> |
||||
<div nz-col nzSpan="8"><button nz-button nzType="primary" (click)="showDelMenu()" nzDanger>删除</button></div> |
||||
</div> |
||||
</ng-template> |
||||
</div> |
||||
</div> |
||||
|
||||
<nz-modal [(nzVisible)]="editOrgVisible" nzTitle="{{editOrgTitle}}" [nzFooter]="null" (nzOnCancel)="closeEditMenu()"> |
||||
<ng-container *nzModalContent> |
||||
<form nz-form [formGroup]="editOrgForm" (ngSubmit)="submitEditOrgForm()"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSm]="6" [nzXs]="24">上级组织</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24"> |
||||
<nz-tree-select |
||||
formControlName="parentId" |
||||
[nzNodes]="orgDataTree" |
||||
nzShowSearch |
||||
></nz-tree-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>组织名称</nz-form-label> |
||||
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="组织、部门名称"> |
||||
<input nz-input formControlName="name"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<div nz-flex [nzJustify]="'center'"> |
||||
<button nz-button nzType="primary" class="submit-btn">保存</button> |
||||
</div> |
||||
|
||||
</form> |
||||
</ng-container> |
||||
</nz-modal> |
||||
@ -0,0 +1,23 @@ |
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { OrgListComponent } from './org-list.component'; |
||||
|
||||
describe('OrgListComponent', () => { |
||||
let component: OrgListComponent; |
||||
let fixture: ComponentFixture<OrgListComponent>; |
||||
|
||||
beforeEach(async () => { |
||||
await TestBed.configureTestingModule({ |
||||
imports: [OrgListComponent] |
||||
}) |
||||
.compileComponents(); |
||||
|
||||
fixture = TestBed.createComponent(OrgListComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
||||
@ -0,0 +1,242 @@ |
||||
import { Component } from '@angular/core'; |
||||
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe"; |
||||
import {NgForOf, NgIf} from "@angular/common"; |
||||
import {NzButtonComponent} from "ng-zorro-antd/button"; |
||||
import {NzCardComponent} from "ng-zorro-antd/card"; |
||||
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid"; |
||||
import {NzDescriptionsComponent, NzDescriptionsItemComponent} from "ng-zorro-antd/descriptions"; |
||||
import {NzFlexDirective} from "ng-zorro-antd/flex"; |
||||
import { |
||||
NzFormDirective, |
||||
NzFormLabelComponent, |
||||
NzFormModule |
||||
} from "ng-zorro-antd/form"; |
||||
import {NzInputDirective, NzInputGroupComponent} from "ng-zorro-antd/input"; |
||||
import {NzInputNumberComponent} from "ng-zorro-antd/input-number"; |
||||
import {NzModalComponent, NzModalModule, NzModalService} from "ng-zorro-antd/modal"; |
||||
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; |
||||
import {NzSpinComponent} from "ng-zorro-antd/spin"; |
||||
import {NzTreeComponent} from "ng-zorro-antd/tree"; |
||||
import {NzTreeSelectComponent} from "ng-zorro-antd/tree-select"; |
||||
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms"; |
||||
import {NzIconDirective} from "ng-zorro-antd/icon"; |
||||
import {NzDropdownMenuComponent} from "ng-zorro-antd/dropdown"; |
||||
import { |
||||
NzTreeNodeCheckboxComponent, |
||||
NzTreeNodeComponent, |
||||
NzTreeNodeOptionComponent, |
||||
NzTreeViewComponent |
||||
} from "ng-zorro-antd/tree-view"; |
||||
import {NzMessageService} from "ng-zorro-antd/message"; |
||||
import {OrganizationService} from "../../../services/oa/organization.service"; |
||||
|
||||
@Component({ |
||||
selector: 'app-org-list', |
||||
standalone: true, |
||||
imports: [ |
||||
NzTreeComponent, |
||||
NgIf, |
||||
NzIconDirective, |
||||
NzDropdownMenuComponent, |
||||
NzTreeViewComponent, |
||||
NzTreeNodeComponent, |
||||
NzTreeNodeCheckboxComponent, |
||||
NzTreeNodeOptionComponent, |
||||
NzCardComponent, |
||||
NzRowDirective, |
||||
NzColDirective, |
||||
NzButtonComponent, |
||||
NzModalModule, |
||||
NzFormDirective, |
||||
ReactiveFormsModule, |
||||
NzFormLabelComponent, |
||||
NzInputDirective, |
||||
NzDescriptionsItemComponent, |
||||
NzDescriptionsComponent, |
||||
NzInputGroupComponent, |
||||
NzFormModule, |
||||
NzFlexDirective, |
||||
NzSelectComponent, |
||||
NzOptionComponent, |
||||
NgForOf, |
||||
NzInputNumberComponent, |
||||
NzSpinComponent, |
||||
NzTreeSelectComponent, |
||||
DictionaryPipe |
||||
], |
||||
templateUrl: './org-list.component.html', |
||||
styleUrl: './org-list.component.less' |
||||
}) |
||||
export class OrgListComponent { |
||||
// 菜单数据
|
||||
orgData: any = []; |
||||
// 菜单树形数据
|
||||
orgDataTree: any[] = []; |
||||
// 菜单详情
|
||||
orgDetail: any = {}; |
||||
// 编辑菜单弹出框
|
||||
editOrgVisible = false; |
||||
// 编辑菜单表单
|
||||
editOrgForm: FormGroup; |
||||
// 编辑菜单标题
|
||||
editOrgTitle = ''; |
||||
// 树视图展示状态
|
||||
treeView= false; |
||||
constructor(private orgService: OrganizationService, |
||||
private fb: NonNullableFormBuilder, |
||||
private modal: NzModalService, |
||||
private message: NzMessageService) { |
||||
// 获取菜单数据
|
||||
this.queryMenuTree(); |
||||
|
||||
this.editOrgForm = this.fb.group({ |
||||
id: [], |
||||
parentId: [null], |
||||
name: ['', [Validators.required]], |
||||
sort: ['1', [Validators.required]], |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 获取菜单树 |
||||
*/ |
||||
queryMenuTree() { |
||||
this.orgService.queryOrgTree(false,(data: any) => { |
||||
this.orgDataTree = data['return_data']; |
||||
this.treeView = true; |
||||
this.queryMenuData(); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询菜单原始数据 |
||||
*/ |
||||
queryMenuData() { |
||||
this.orgService.queryAllOrg((data: any) => { |
||||
this.orgData = data['return_data']; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 点击树节点 |
||||
* @param nodeData |
||||
*/ |
||||
clickNode(nodeData: any) { |
||||
const menuId = nodeData['keys'][0]; |
||||
if (menuId != null) { |
||||
const orgObj = this.orgData.find((o: any) => o.id == menuId); |
||||
if (orgObj != null && orgObj.parentId != null) { |
||||
// 获取父级菜单
|
||||
orgObj['parentOrg'] = this.orgData.find((o: any) => o.id == orgObj.parentId); |
||||
} |
||||
this.orgDetail = orgObj; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 编辑菜单 |
||||
* @param edit 编辑状态 true:增加 false:修改 |
||||
*/ |
||||
openEditMenu(edit: boolean) { |
||||
// 初始化表单
|
||||
this.editOrgTitle = '添加组织'; |
||||
this.editOrgForm.reset(); |
||||
let menu = { |
||||
parentId: '', |
||||
}; |
||||
|
||||
if (edit == false && this.orgDetail?.id == null) { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzContent: '请点击需要修改的组织', |
||||
}); |
||||
return; |
||||
} |
||||
|
||||
if (this.orgDetail != null) { |
||||
if (edit) { |
||||
// 增加
|
||||
menu = { |
||||
parentId: ""+this.orgDetail.id, |
||||
}; |
||||
} else { |
||||
// 修改
|
||||
this.editOrgTitle = '修改组织'; |
||||
menu = this.orgDetail; |
||||
menu['parentId'] = ""+menu['parentId'] |
||||
} |
||||
} |
||||
this.editOrgForm.patchValue(menu); |
||||
this.editOrgVisible = true; |
||||
} |
||||
|
||||
/** |
||||
* 提交表单 |
||||
*/ |
||||
submitEditOrgForm() { |
||||
if (this.editOrgForm.valid) { |
||||
this.treeView = false; |
||||
if (this.editOrgForm.controls['parentId'].value == 'undefined') { |
||||
this.editOrgForm.controls['parentId'].setValue(null); |
||||
} |
||||
this.orgService.editData(this.editOrgForm.value, (data: any) => { |
||||
if (data['return_code'] == '000000') { |
||||
// 刷新数据
|
||||
this.queryMenuTree(); |
||||
|
||||
this.message.create('success', '操作成功'); |
||||
|
||||
// 关闭弹窗
|
||||
this.closeEditMenu(); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} else { |
||||
Object.values(this.editOrgForm.controls).forEach(control => { |
||||
if (control.invalid) { |
||||
control.markAsDirty(); |
||||
control.updateValueAndValidity({ onlySelf: true }); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 关闭菜单 |
||||
*/ |
||||
closeEditMenu() { |
||||
this.editOrgVisible = false; |
||||
} |
||||
|
||||
/** |
||||
* 删除菜单 |
||||
*/ |
||||
showDelMenu() { |
||||
this.modal.confirm({ |
||||
nzTitle: '提示', |
||||
nzContent: '确实删除数据?', |
||||
nzOnOk: () => this.delMenu() |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 删除菜单 |
||||
*/ |
||||
delMenu() { |
||||
const param = { |
||||
id: this.orgDetail.id |
||||
} |
||||
this.treeView = false; |
||||
this.orgService.delOrg(param, (data: any) => { |
||||
if (data['return_code'] == '000000') { |
||||
// 刷新数据
|
||||
this.queryMenuTree(); |
||||
this.message.create('success', '操作成功'); |
||||
} else { |
||||
this.treeView = true; |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [], |
||||
imports: [ |
||||
CommonModule |
||||
] |
||||
}) |
||||
export class OrganizationModule { } |
||||
@ -0,0 +1,6 @@ |
||||
import { Routes } from '@angular/router'; |
||||
import {OrgListComponent} from "./org-list/org-list.component"; |
||||
|
||||
export const ORGANIZATION_ROUTES: Routes = [ |
||||
|
||||
]; |
||||
@ -0,0 +1,80 @@ |
||||
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 OrganizationService { |
||||
|
||||
constructor(private http: HttpClient) { } |
||||
|
||||
/** |
||||
* 编辑数据 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public editData(params: any, callBack:any) { |
||||
params.time = new Date().getTime(); |
||||
this.http.post(environment.baseUrl + 'oaOrg/editData', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 编辑数据 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public delOrg(params: any, callBack:any) { |
||||
params.time = new Date().getTime(); |
||||
this.http.post(environment.baseUrl + 'oaOrg/delOrg', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询详情 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public queryDetailById(id: any, callBack:any) { |
||||
let params = { |
||||
time: new Date().getTime(), |
||||
id: id |
||||
} |
||||
this.http.get(environment.baseUrl + 'oaOrg/editData'+ObjectData.objectByString(params)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询组织树 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public queryAllOrg(callBack:any) { |
||||
let params = { |
||||
time: new Date().getTime() |
||||
} |
||||
this.http.get(environment.baseUrl + 'oaOrg/queryAllOrg?'+ObjectData.objectByString(params)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询组织树 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public queryOrgTree(isUser: boolean, callBack:any) { |
||||
let params = { |
||||
isUser: isUser, |
||||
time: new Date().getTime() |
||||
} |
||||
this.http.get(environment.baseUrl + 'oaOrg/queryOrgTree?'+ObjectData.objectByString(params)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
||||
@ -0,0 +1,61 @@ |
||||
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 TemplateService { |
||||
|
||||
constructor(private http: HttpClient) { } |
||||
|
||||
/** |
||||
* 配置模板 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public config(params: any, callBack:any) { |
||||
params.time = new Date().getTime(); |
||||
this.http.post(environment.baseUrl + 'oaTemplate/config', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除模板 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public delete(params: any, callBack:any) { |
||||
params.time = new Date().getTime(); |
||||
this.http.post(environment.baseUrl + 'oaTemplate/delete', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询列表 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public queryList(params: any, callBack:any) { |
||||
params.time = new Date().getTime(); |
||||
this.http.get(environment.baseUrl + 'oaTemplate/queryList?'+ObjectData.objectByString(params)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询详情 |
||||
* @param params |
||||
* @param callBack |
||||
*/ |
||||
public queryDetailById(params: any, callBack:any) { |
||||
params.time = new Date().getTime(); |
||||
this.http.get(environment.baseUrl + 'oaTemplate/queryDetailById?'+ObjectData.objectByString(params)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue