diff --git a/src/app/app.module.ts b/src/app/app.module.ts index af1315e..4919b50 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -17,10 +17,15 @@ import { ConfigFormDataService } from './service/configFormData.service'; import { registerLocaleData } from '@angular/common'; import { NzModalModule } from 'ng-zorro-antd/modal'; import zh from '@angular/common/locales/zh'; +import { MethodService } from './method.service'; +import { SelectUnitComponent } from './commonComponents/select-unit/select-unit.component'; +import { TestComponent } from './commonComponents/test/test.component'; registerLocaleData(zh); @NgModule({ declarations: [ - AppComponent + AppComponent, + SelectUnitComponent, + TestComponent ], imports: [ BrowserModule, @@ -35,7 +40,7 @@ registerLocaleData(zh); ], // providers: [httpInterceptorProviders, CacheTokenService, TreeService, ConfigFormDataService, // { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }], - providers: [httpInterceptorProviders, CacheTokenService, TreeService, ConfigFormDataService], + providers: [httpInterceptorProviders, CacheTokenService, TreeService, ConfigFormDataService, MethodService], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/app/commonComponents/select-unit/select-unit.component.html b/src/app/commonComponents/select-unit/select-unit.component.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/commonComponents/select-unit/select-unit.component.scss b/src/app/commonComponents/select-unit/select-unit.component.scss new file mode 100644 index 0000000..7d1c75b --- /dev/null +++ b/src/app/commonComponents/select-unit/select-unit.component.scss @@ -0,0 +1,53 @@ +.selectUnitPopover { + width: 550px; + height: 492px; + + nz-form-item { + margin: 12px 0; + } + + display: flex; + flex-direction: column; + + .popoverTitle { + display: flex; + align-items: center; + + span { + color: #C7CAD0; + cursor: pointer; + } + + .selectedspan { + color: #2C4DC0; + } + } + + .popoverContent { + flex: 1; + display: flex; + flex-direction: column; + overflow: hidden; + + .popoverContentitem { + flex: 1; + overflow-y: auto; + display: flex; + flex-direction: column; + + p { + text-align: center; + } + } + } + + .popoverBtn { + display: flex; + justify-content: flex-end; + margin-top: 16px; + + button { + margin-left: 18px; + } + } +} diff --git a/src/app/commonComponents/select-unit/select-unit.component.ts b/src/app/commonComponents/select-unit/select-unit.component.ts new file mode 100644 index 0000000..83b4486 --- /dev/null +++ b/src/app/commonComponents/select-unit/select-unit.component.ts @@ -0,0 +1,17 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-select-unit', + templateUrl: './select-unit.component.html', + styleUrls: ['./select-unit.component.scss'] +}) +export class SelectUnitComponent implements OnInit { + + constructor() { } + + + complaint + ngOnInit(): void { + } + +} diff --git a/src/app/commonComponents/test/test.component.html b/src/app/commonComponents/test/test.component.html new file mode 100644 index 0000000..941f267 --- /dev/null +++ b/src/app/commonComponents/test/test.component.html @@ -0,0 +1 @@ +

test works!

diff --git a/src/app/commonComponents/test/test.component.scss b/src/app/commonComponents/test/test.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/commonComponents/test/test.component.spec.ts b/src/app/commonComponents/test/test.component.spec.ts new file mode 100644 index 0000000..e0f9bcc --- /dev/null +++ b/src/app/commonComponents/test/test.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TestComponent } from './test.component'; + +describe('TestComponent', () => { + let component: TestComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ TestComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(TestComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/commonComponents/test/test.component.ts b/src/app/commonComponents/test/test.component.ts new file mode 100644 index 0000000..db9004b --- /dev/null +++ b/src/app/commonComponents/test/test.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-test', + templateUrl: './test.component.html', + styleUrls: ['./test.component.scss'] +}) +export class TestComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/home/task/station-task-apply/apply/apply.component.html b/src/app/home/task/station-task-apply/apply/apply.component.html index 226607b..5311375 100644 --- a/src/app/home/task/station-task-apply/apply/apply.component.html +++ b/src/app/home/task/station-task-apply/apply/apply.component.html @@ -53,11 +53,19 @@ +

+ + + + + 更多 + +

-
+ @@ -65,32 +73,41 @@ placeholder="请输入单位名称" [ngModelOptions]="{standalone: true}" /> +
- + - +
- {{ node.title }}
- - - - - - + + + + +
+ + + {{ node.title }} + +
diff --git a/src/app/home/task/station-task-apply/apply/apply.component.ts b/src/app/home/task/station-task-apply/apply/apply.component.ts index 4cf7a98..37f5e05 100644 --- a/src/app/home/task/station-task-apply/apply/apply.component.ts +++ b/src/app/home/task/station-task-apply/apply/apply.component.ts @@ -6,6 +6,7 @@ import { TreeService } from 'src/app/service/tree.service'; import { Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { NzMessageService } from 'ng-zorro-antd/message'; +import { NzFormatEmitEvent, NzTreeNodeOptions } from 'ng-zorro-antd/tree'; @Component({ selector: 'app-apply', templateUrl: './apply.component.html', @@ -36,14 +37,15 @@ export class ApplyComponent implements OnInit { assist: [null] }); this.newTree = this.nodes + this.getCompanies() + this.getAllOrganization() - - Promise.all([this.getCompanies(), this.getAllOrganization()]) - .then((results) => { - let arr = [...JSON.parse(JSON.stringify(this.allOrList)), ...JSON.parse(JSON.stringify(this.unitList))] - let nodes = [...this.toTree.toTree(arr)] - this.unitPopover.nodes = JSON.parse(JSON.stringify(nodes)) - }); + // Promise.all([this.getCompanies(), this.getAllOrganization()]) + // .then((results) => { + // let arr = [...JSON.parse(JSON.stringify(this.allOrList)), ...JSON.parse(JSON.stringify(this.unitList))] + // let nodes = [...this.toTree.toTree(arr)] + // this.unitPopover.nodes = JSON.parse(JSON.stringify(nodes)) + // }); } @@ -67,47 +69,24 @@ export class ApplyComponent implements OnInit { element.title = element.name element.selectable = false element.disableCheckbox = true + element.datatype = '机构' + element.level == 'squadron' ? element.disableCheckbox = false : null + }); - this.allOrList = JSON.parse(JSON.stringify(data.items)) - console.log(111, this.allOrList) - this.allOrList.forEach(element => { + data.items.forEach(element => { if (element.id == JSON.parse(sessionStorage.getItem('userData')).organizationId) { element.parentId = null } }); + this.allOrList = JSON.parse(JSON.stringify(data.items)) + this.nodes = [...this.toTree.toTree(JSON.parse(JSON.stringify(data.items)))] + this.unitPopover.nodes = JSON.parse(JSON.stringify(this.nodes)) + console.log(6666, data.items) resolve(data) }) }) } - unitList - async getCompanies(incomingData?: any) { - let params = { - CompanyName: incomingData ? incomingData.search1 : '', - OrganizationId: JSON.parse(sessionStorage.getItem('userData')).organizationId, - PageNumber: 1, - PageSize: 9999 - } - return new Promise((resolve, reject) => { - this.http.get('/api/Companies', { - params: params - }).subscribe((data: any) => { - data.items.forEach(element => { - element.label = element.companyName - element.value = element.id - element.parentId = element.organizationId - element.key = element.id - element.title = element.companyName - element.level = 4 - }); - this.unitList = data.items - this.unitPopover.unitList = JSON.parse(JSON.stringify(this.unitList)) - - - resolve(data) - }) - }) - } selectedUnitData = { @@ -118,19 +97,18 @@ export class ApplyComponent implements OnInit { e ? e.stopPropagation() : null let arr = [...data.search1Value, ...data.search2Value] let arrSet = [...new Set(arr)] - + console.log(arrSet) + console.log(this.unitPopover) if (arrSet.length > 1) { this.message.create('warning', '只能选择一个单位'); return } else { - this.unitList.forEach(element => { - if (element.id == arrSet[0]) { - this.selectedUnitData.name = element.companyName - this.selectedUnitData.id = element.id - } - }); - console.log(this.selectedUnitData) - console.log(this.unitPopover) + this.http.get(`/api/Companies/${arrSet[0]}`).subscribe((data: any) => { + console.log(data) + this.selectedUnitData.name = data.companyName + this.selectedUnitData.id = data.id + }) + this.unitPopover.isPopover = false } } @@ -149,6 +127,8 @@ export class ApplyComponent implements OnInit { data: [ ],//表格数据 nodes: [], + nodes2: [],//查询后展示的tree + isnodes: true, unitList: [] } isPopover(data, e?: any) { @@ -161,10 +141,132 @@ export class ApplyComponent implements OnInit { } //搜索框提交 submitForm(data): void { - console.log(data) data.unitList = [] + this.PageNumber = 1 this.getCompanies(data) } + totalCount: number + unitList = [] + PageNumber = 1 + async getCompanies(incomingData?: any) { + let params = { + CompanyName: incomingData ? incomingData.search1 : '', + PageNumber: this.PageNumber, + PageSize: 50 + } + return new Promise((resolve, reject) => { + this.http.get('/api/Companies', { + params: params + }).subscribe((data: any) => { + this.moreDataLoading = false + this.totalCount = data.totalCount + data.items.forEach(element => { + element.label = element.companyName + element.value = element.id + element.parentId = element.organizationId + element.key = element.id + element.title = element.companyName + element.level = 4 + }); + this.unitList = data.items + + this.unitPopover.unitList = this.unitPopover.unitList.concat(JSON.parse(JSON.stringify(data.items))); + this.unitPopover.unitList = [...this.unitPopover.unitList] + + resolve(data) + }) + }) + } + + moreDataLoading = false + + moreData() { + this.moreDataLoading = true + this.PageNumber += 1 + this.getCompanies() + } + onExpandChange(e: NzFormatEmitEvent): void { + const node = e.node; + if (node && node.getChildren().length === 0 && node.isExpanded) { + this.loadNode(node.origin.id).then(data => { + node.addChildren(data); + }); + } + } + + loadNode(id): Promise { + return new Promise(resolve => { + let params = { + OrganizationId: id, + PageNumber: 1, + PageSize: 9999 + } + this.http.get('/api/Companies', { + params: params + }).subscribe((data: any) => { + console.log(data.items) + data.items.forEach(element => { + element.key = element.id + element.title = element.companyName + element.level = 4 + element.isLeaf = true + }); + resolve(data.items) + }) + }); + } + + async getCompaniesByName(incomingData) { + console.log(incomingData.search2Value) + if (incomingData.search2) { + incomingData.isnodes = false + let params = { + CompanyName: incomingData.search2, + PageNumber: this.PageNumber, + PageSize: 9999 + } + return new Promise((resolve, reject) => { + this.http.get('/api/Companies', { + params: params + }).subscribe((data: any) => { + this.moreDataLoading = false + this.totalCount = data.totalCount + data.items.forEach(element => { + element.label = element.companyName + element.value = element.id + element.parentId = element.organizationId + element.key = element.id + element.title = element.companyName + element.level = 4 + element.isLeaf = true + incomingData.search2Value.forEach(item => { + item == element.id ? element.isChecked = true : null + }); + }); + if (data.items.length == 0) { + this.message.create('warning', '没有查询到任何单位'); + incomingData.isnodes = true + return + } + let allOrList = JSON.parse(JSON.stringify(this.allOrList)) + allOrList.forEach(element => { + element.expanded = true + }); + let arr = [...allOrList, ...data.items] + incomingData.nodes2 = [...this.toTree.toTree(arr)] + + resolve(data) + }) + }) + } else { + + // incomingData.search2Value = [] + incomingData.isnodes = true + } + + } + + log(data) { let arr = [] data.unitList.forEach(item => { @@ -173,6 +275,7 @@ export class ApplyComponent implements OnInit { data.search1Value = arr } orcheckbox(data, $event, node) { + // search2NameValue if ($event) { data.search2Value.push(node.origin.id) } else { @@ -183,6 +286,7 @@ export class ApplyComponent implements OnInit { index-- } } + } } } diff --git a/src/app/home/task/station-task-apply/station-task-apply.component.html b/src/app/home/task/station-task-apply/station-task-apply.component.html index d9b3566..002d85f 100644 --- a/src/app/home/task/station-task-apply/station-task-apply.component.html +++ b/src/app/home/task/station-task-apply/station-task-apply.component.html @@ -49,15 +49,16 @@
-
+ @@ -368,32 +404,40 @@ placeholder="请输入单位名称" [ngModelOptions]="{standalone: true}" /> +
- + - +
- {{ node.title }}
- - - - - - + + + + +
+ + + {{ node.title }} + +
@@ -457,10 +501,11 @@ - + - {{o.name}} @@ -543,13 +588,19 @@
- +

+ + + + + 更多 + +

-
+ @@ -557,32 +608,40 @@ placeholder="请输入单位名称" [ngModelOptions]="{standalone: true}" /> +
- + - +
- {{ node.title }}
- - - - - - + + + + +
+ + + {{ node.title }} + +
diff --git a/src/app/home/task/zhi-indicators/zhi-indicators.component.ts b/src/app/home/task/zhi-indicators/zhi-indicators.component.ts index 2308eb2..d61f871 100644 --- a/src/app/home/task/zhi-indicators/zhi-indicators.component.ts +++ b/src/app/home/task/zhi-indicators/zhi-indicators.component.ts @@ -105,6 +105,7 @@ export class ZhiIndicatorsComponent implements OnInit { this.rehearsal.data = [] } + //投诉举报 complaint = { name: '投诉举报', @@ -121,6 +122,8 @@ export class ZhiIndicatorsComponent implements OnInit { data: [ ],//表格数据 nodes: [], + nodes2: [],//查询后展示的tree + isnodes: true, unitList: [] } @@ -139,6 +142,8 @@ export class ZhiIndicatorsComponent implements OnInit { selectedMenu: 1,//选择单位气泡卡片 data: [],//表格数据 nodes: [], + nodes2: [],//查询后展示的tree + isnodes: true, unitList: [] } @@ -158,6 +163,8 @@ export class ZhiIndicatorsComponent implements OnInit { selectedMenu: 1,//选择单位气泡卡片 data: [],//表格数据 nodes: [], + nodes2: [],//查询后展示的tree + isnodes: true, unitList: [] } @@ -177,16 +184,14 @@ export class ZhiIndicatorsComponent implements OnInit { selectedMenu: 1,//选择单位气泡卡片 data: [],//表格数据 nodes: [], + nodes2: [],//查询后展示的tree + isnodes: true, unitList: [] } - PageNumber - moreData() { - this.PageNumber += 1 - this.getCompanies() - } + log(data) { @@ -215,12 +220,6 @@ export class ZhiIndicatorsComponent implements OnInit { } - //搜索框提交 - submitForm(data): void { - data.unitList = [] - this.PageNumber = 1 - this.getCompanies(data) - } // 弹出 tab popoverMenuSelect(data, type) { @@ -231,18 +230,26 @@ export class ZhiIndicatorsComponent implements OnInit { } + //搜索框提交 + submitForm(data): void { + data.unitList = [] + this.PageNumber = 1 + this.getCompanies(data) + } totalCount: number unitList = [] + PageNumber = 1 async getCompanies(incomingData?: any) { let params = { CompanyName: incomingData ? incomingData.search1 : '', - PageNumber: 1, - PageSize: 99999 + PageNumber: this.PageNumber, + PageSize: 50 } return new Promise((resolve, reject) => { this.http.get('/api/Companies', { params: params }).subscribe((data: any) => { + this.moreDataLoading = false this.totalCount = data.totalCount data.items.forEach(element => { element.label = element.companyName @@ -254,35 +261,42 @@ export class ZhiIndicatorsComponent implements OnInit { }); this.unitList = data.items - if (incomingData && incomingData.name == '投诉举报') { - this.complaint.unitList = JSON.parse(JSON.stringify(this.unitList)) - } else if (incomingData && incomingData.name == '行政许可') { - this.permission.unitList = JSON.parse(JSON.stringify(this.unitList)) - } else if (incomingData && incomingData.name == '双随机') { - this.doubleRandom.unitList = JSON.parse(JSON.stringify(this.unitList)) - } else if (incomingData && incomingData.name == '熟悉演练') { - this.rehearsal.unitList = JSON.parse(JSON.stringify(this.unitList)) - } else { - this.complaint.unitList = JSON.parse(JSON.stringify(this.unitList)) - this.permission.unitList = JSON.parse(JSON.stringify(this.unitList)) - this.doubleRandom.unitList = JSON.parse(JSON.stringify(this.unitList)) - this.rehearsal.unitList = JSON.parse(JSON.stringify(this.unitList)) - } - - // this.complaint.unitList = this.complaint.unitList.concat(JSON.parse(JSON.stringify(data.items))); - // this.complaint.unitList = [...this.complaint.unitList] - // this.permission.unitList = this.permission.unitList.concat(JSON.parse(JSON.stringify(data.items))); - // this.permission.unitList = [...this.permission.unitList] - // this.doubleRandom.unitList = this.doubleRandom.unitList.concat(JSON.parse(JSON.stringify(data.items))); - // this.doubleRandom.unitList = [...this.doubleRandom.unitList] - // this.rehearsal.unitList = this.rehearsal.unitList.concat(JSON.parse(JSON.stringify(data.items))); - // this.rehearsal.unitList = [...this.rehearsal.unitList] + // if (incomingData && incomingData.name == '投诉举报') { + // this.complaint.unitList = JSON.parse(JSON.stringify(this.unitList)) + // } else if (incomingData && incomingData.name == '行政许可') { + // this.permission.unitList = JSON.parse(JSON.stringify(this.unitList)) + // } else if (incomingData && incomingData.name == '双随机') { + // this.doubleRandom.unitList = JSON.parse(JSON.stringify(this.unitList)) + // } else if (incomingData && incomingData.name == '熟悉演练') { + // this.rehearsal.unitList = JSON.parse(JSON.stringify(this.unitList)) + // } else { + // this.complaint.unitList = JSON.parse(JSON.stringify(this.unitList)) + // this.permission.unitList = JSON.parse(JSON.stringify(this.unitList)) + // this.doubleRandom.unitList = JSON.parse(JSON.stringify(this.unitList)) + // this.rehearsal.unitList = JSON.parse(JSON.stringify(this.unitList)) + // } + + this.complaint.unitList = this.complaint.unitList.concat(JSON.parse(JSON.stringify(data.items))); + this.complaint.unitList = [...this.complaint.unitList] + this.permission.unitList = this.permission.unitList.concat(JSON.parse(JSON.stringify(data.items))); + this.permission.unitList = [...this.permission.unitList] + this.doubleRandom.unitList = this.doubleRandom.unitList.concat(JSON.parse(JSON.stringify(data.items))); + this.doubleRandom.unitList = [...this.doubleRandom.unitList] + this.rehearsal.unitList = this.rehearsal.unitList.concat(JSON.parse(JSON.stringify(data.items))); + this.rehearsal.unitList = [...this.rehearsal.unitList] resolve(data) }) }) } + moreDataLoading = false + + moreData() { + this.moreDataLoading = true + this.PageNumber += 1 + this.getCompanies() + } allOrList: any nodes @@ -302,12 +316,20 @@ export class ZhiIndicatorsComponent implements OnInit { element.disableCheckbox = true element.datatype = '机构' element.level == 'squadron' ? element.disableCheckbox = false : null + }); + this.allOrList = JSON.parse(JSON.stringify(data.items)) + this.nodes = [...this.toTree.toTree(JSON.parse(JSON.stringify(data.items)))] + this.complaint.nodes = JSON.parse(JSON.stringify(this.nodes)) + this.permission.nodes = JSON.parse(JSON.stringify(this.nodes)) + this.doubleRandom.nodes = JSON.parse(JSON.stringify(this.nodes)) + this.rehearsal.nodes = JSON.parse(JSON.stringify(this.nodes)) resolve(data) }) }) } + //获得除了检查员的其他用户 users async getUsers() { @@ -448,17 +470,17 @@ export class ZhiIndicatorsComponent implements OnInit { }); // this.getUsers() - - - Promise.all([this.getCompanies(), this.getAllOrganization()]) - .then((results) => { - let arr = [...JSON.parse(JSON.stringify(this.allOrList)), ...JSON.parse(JSON.stringify(this.unitList))] - this.nodes = [...this.toTree.toTree(arr)] - this.complaint.nodes = JSON.parse(JSON.stringify(this.nodes)) - this.permission.nodes = JSON.parse(JSON.stringify(this.nodes)) - this.doubleRandom.nodes = JSON.parse(JSON.stringify(this.nodes)) - this.rehearsal.nodes = JSON.parse(JSON.stringify(this.nodes)) - }); + this.getCompanies() + this.getAllOrganization() + // Promise.all([this.getCompanies(), this.getAllOrganization()]) + // .then((results) => { + // let arr = [...JSON.parse(JSON.stringify(this.allOrList)), ...JSON.parse(JSON.stringify(this.unitList))] + // this.nodes = [...this.toTree.toTree(arr)] + // this.complaint.nodes = JSON.parse(JSON.stringify(this.nodes)) + // this.permission.nodes = JSON.parse(JSON.stringify(this.nodes)) + // this.doubleRandom.nodes = JSON.parse(JSON.stringify(this.nodes)) + // this.rehearsal.nodes = JSON.parse(JSON.stringify(this.nodes)) + // }); this.getTaskList('投诉举报') @@ -567,7 +589,6 @@ export class ZhiIndicatorsComponent implements OnInit { }) } - async getTaskList(TaskType, carddata?: any) { TaskType == '投诉举报' ? this.complaint.isLoading = true : this.permission.isLoading = true // carddata ? carddata.isLoading = true : null @@ -620,22 +641,12 @@ export class ZhiIndicatorsComponent implements OnInit { // console.log('毁灭了') // this.doubleRandom.isPopover = false } - - nzEvent(event: NzFormatEmitEvent): any { - if (event.node.origin.companyName) { - return new Promise((resolve, reject) => { - resolve() - }) - } - if (event.node.origin.level === 'squadron' && !event.node.origin.companyName) { - const node = event.node; - console.log(node?.getChildren()) - console.log(888) - if (node?.getChildren().length === 0) { - this.loadNode(event.node.origin.id).then(data => { - node.addChildren(data); - }); - } + onExpandChange(e: NzFormatEmitEvent): void { + const node = e.node; + if (node && node.getChildren().length === 0 && node.isExpanded) { + this.loadNode(node.origin.id).then(data => { + node.addChildren(data); + }); } } @@ -654,12 +665,61 @@ export class ZhiIndicatorsComponent implements OnInit { element.key = element.id element.title = element.companyName element.level = 4 + element.isLeaf = true }); resolve(data.items) }) }); } + async getCompaniesByName(incomingData) { + // incomingData.search2Value + console.log(incomingData.search2Value) + if (incomingData.search2) { + incomingData.isnodes = false + let params = { + CompanyName: incomingData.search2, + PageNumber: this.PageNumber, + PageSize: 9999 + } + return new Promise((resolve, reject) => { + this.http.get('/api/Companies', { + params: params + }).subscribe((data: any) => { + this.moreDataLoading = false + this.totalCount = data.totalCount + data.items.forEach(element => { + element.label = element.companyName + element.value = element.id + element.parentId = element.organizationId + element.key = element.id + element.title = element.companyName + element.level = 4 + element.isLeaf = true + incomingData.search2Value.forEach(item => { + item == element.id ? element.isChecked = true : null + }); + }); + if (data.items.length == 0) { + this.message.create('warning', '没有查询到任何单位'); + incomingData.isnodes = true + return + } + let allOrList = JSON.parse(JSON.stringify(this.allOrList)) + allOrList.forEach(element => { + element.expanded = true + }); + let arr = [...allOrList, ...data.items] + incomingData.nodes2 = [...this.toTree.toTree(arr)] + + resolve(data) + }) + }) + } else { + incomingData.isnodes = true + } + + } assitantsupervisorList mainsupervisorList diff --git a/src/app/method.service.ts b/src/app/method.service.ts new file mode 100644 index 0000000..b807d2c --- /dev/null +++ b/src/app/method.service.ts @@ -0,0 +1,47 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class MethodService { + + constructor() { } + + /***倒计时 + @param {number} nowtime 当前时间时间戳 + @param {number} endtime 结束时间时间戳 + @example: countdown('当前时间时间戳', '结束时间时间戳', callback); +*/ + + timer = null + + countdown(nowtime, endtime, callback) { + var times = parseInt(String((endtime - nowtime) / 1000)); + this.timer = setInterval(function () { + var day: any = 0, hour: any = 0, minute: any = 0, second: any = 0;//时间默认值 + if (times > 0) { + day = Math.floor(times / (60 * 60 * 24)); + hour = Math.floor(times / (60 * 60)) - (day * 24); + minute = Math.floor(times / 60) - (day * 24 * 60) - (hour * 60); + second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60); + } + // if (day <= 9) day = '0' + day; + // if (hour <= 9) hour = '0' + hour; + // if (minute <= 9) minute = '0' + minute; + // if (second <= 9) second = '0' + second; + //console.log(minute+"分钟:"+second+"秒"); + // var new_time = day + '天' + hour + '小时' + minute + '分' + second + '秒'; + typeof callback == "function" ? callback({ day: day, hour: hour, minute: minute, second: second }) : ''; + times--; + }, 1000); + if (times <= 0) { + clearInterval(this.timer); + } + } + + cleartimer() { + clearTimeout(this.timer); + } + + +}