From fde7d60aabb395fd814c4e4e62026878670afff3 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Sat, 12 Dec 2020 10:34:39 +0800 Subject: [PATCH 1/6] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E5=9B=9B=E5=91=A8?= =?UTF-8?q?=E6=AF=97=E9=82=BBtree=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create-test-score.component.html | 10 +- .../create-test-score.component.ts | 148 +++++++++++++++--- .../create-test-score/lookTreeNode.html | 29 ++++ .../create-test-score/lookTreeNode.scss | 16 ++ src/app/examiner/examiner.module.ts | 4 +- src/styles.scss | 2 +- 6 files changed, 183 insertions(+), 26 deletions(-) create mode 100644 src/app/examiner/create-test-score/lookTreeNode.html create mode 100644 src/app/examiner/create-test-score/lookTreeNode.scss diff --git a/src/app/examiner/create-test-score/create-test-score.component.html b/src/app/examiner/create-test-score/create-test-score.component.html index 78d2e7b..702d53f 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.html +++ b/src/app/examiner/create-test-score/create-test-score.component.html @@ -74,7 +74,7 @@ </nz-tree> <ng-template #nzTreeTemplate let-node let-origin="origin"> <div class="treeNodeTemplate"> - <label title="{{node.origin.name}}" class="overflowText textNode">{{node.origin.name}}</label> + <label class="overflowText textNode">{{node.origin.name}}</label> <div class="scoreDiv" *ngIf="node.level == '0'"> <span class="colorspan lookitem" (click)="lookTreeNode(node)">查看</span> </div> @@ -85,7 +85,7 @@ </mat-expansion-panel> </mat-accordion> <!-- 四周毗邻 --> - <!-- <mat-accordion> + <mat-accordion *ngIf="unit.aroundNodes.length != 0"> <mat-expansion-panel style="box-shadow: 0 0 black;" expanded> <mat-expansion-panel-header collapsedHeight ='40px' expandedHeight='40px' style="position: relative;padding-left:20px;background: #F5FDFE;"> <mat-panel-title> @@ -116,16 +116,16 @@ </nz-tree> <ng-template #nzTreeTemplate let-node let-origin="origin"> <div class="treeNodeTemplate"> - <label title="{{node.origin.name}}" class="overflowText textNode">{{node.origin.name}}</label> + <label class="overflowText textNode">{{node.origin.title ? node.origin.title : node.origin.name}}</label> <div class="scoreDiv" *ngIf="node.level == '0'"> - <span class="colorspan lookitem">查看</span> + <span class="colorspan lookitem" (click)="lookTreeNode(node)">查看</span> </div> </div> </ng-template> </div> </mat-expansion-panel> - </mat-accordion> --> + </mat-accordion> </div> </div> <div class="fightdeploydiv" *ngIf="selectedTab == 2"> diff --git a/src/app/examiner/create-test-score/create-test-score.component.ts b/src/app/examiner/create-test-score/create-test-score.component.ts index cc63096..0d4c654 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.ts +++ b/src/app/examiner/create-test-score/create-test-score.component.ts @@ -17,8 +17,8 @@ export class CreateTestScoreComponent implements OnInit { this.selectedTab = index } ngOnInit(): void { - console.log(12345,) this.getUnitData() + this.getAround() } //模拟单位数据 @@ -91,7 +91,7 @@ export class CreateTestScoreComponent implements OnInit { element.basicInfoItemScore = 0 this.http.get(`/api/Companies/${element.id}`).subscribe((data:any)=>{ - console.log('单位信息',index,data) + // console.log('单位信息',index,data) let unitData = { name: '单位信息', type:'基本信息', @@ -137,7 +137,7 @@ export class CreateTestScoreComponent implements OnInit { buildingType:data[i].buildingTypes[0].id } }).subscribe((buildingsData:any)=>{ - console.log(1234,buildingsData) + // console.log(1234,buildingsData) buildingsData.name = data[i].name buildingsData.buildingType = data[i].buildingTypes[0].name @@ -173,7 +173,6 @@ export class CreateTestScoreComponent implements OnInit { }) y.tabledata = dest tabledata = dest - console.log('pppp',y) y.tabledata[0].data.forEach((x,key) => { if(x.propertyValue){ x.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5) @@ -192,36 +191,122 @@ export class CreateTestScoreComponent implements OnInit { } }) } - - element.basicInfoNodes.push({ - name:y.name != '基本信息' ? buildingsData.name + '-' + y.name : buildingsData.name , - type:'基本信息', - expanded: false, - key:(Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), - children:propertyInfosArr, - tabledata:tabledata ? tabledata : null - }) - - element.basicInfoNodes = [...element.basicInfoNodes] + if(propertyInfosArr.length != 0){ + element.basicInfoNodes.push({ + name:y.name != '基本信息' ? buildingsData.name + '-' + y.name : buildingsData.name , + type:'基本信息', + expanded: false, + key:(Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + children:propertyInfosArr, + tabledata:tabledata ? tabledata : null + }) + element.basicInfoNodes = [...element.basicInfoNodes] + } + }) resolve(i) }) }) } - console.log(987,this.unitId) + // console.log(987,this.unitId) }) }) }) } + //获取四周毗邻数据 + getAround(){ + this.unitId.forEach((element,index) => { + element.aroundScore = 0 + element.aroundItemScore = 0 + element.aroundNodes = [] + //获得当前单位的单位毗邻 + let id = {companyId:element.id} + this.http.get('/api/CompanyAdjoins',{params:id}).subscribe((data:any)=>{ + // console.log(index+'四周毗邻',data) + data.forEach(item => { + item.direction == 0 ? item.title = '东方向' : null + item.direction == 1 ? item.title = '西方向' : null + item.direction == 2 ? item.title = '南方向' : null + item.direction == 3 ? item.title = '北方向' : null + item.direction == 4 ? item.title = '东南方向' : null + item.direction == 5 ? item.title = '西南方向' : null + item.direction == 6 ? item.title = '东北方向' : null + item.direction == 7 ? item.title = '西北方向' : null + item.isLeaf = true + }) + //如果存在单位毗邻 + if(data.length != 0){ + this.unitId[index].aroundNodes.push({ + name: '单位毗邻', + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'四周毗邻', + children: data + }) + element.aroundNodes = [...element.aroundNodes] + } + + }) + //获得当前单位的建筑毗邻 + this.http.get('/api/Buildings',{params:id}).subscribe((data:any)=>{ + if (data.length) { + getAllArchitecture(data) + } + }) + let that = this + async function getAllArchitecture(buildongsdata){ + for (let i = 0, length = buildongsdata.length; i < length; i++){ + let id = {buildingId:buildongsdata[i].id} + let result = await new Promise((resolve, reject) => { + that.http.get('/api/BuildingAdjoins',{params:id}).subscribe((data:any)=>{ + data.forEach(item => { + item.direction == 0 ? item.title = '东方向' : null + item.direction == 1 ? item.title = '西方向' : null + item.direction == 2 ? item.title = '南方向' : null + item.direction == 3 ? item.title = '北方向' : null + item.direction == 4 ? item.title = '东南方向' : null + item.direction == 5 ? item.title = '西南方向' : null + item.direction == 6 ? item.title = '东北方向' : null + item.direction == 7 ? item.title = '西北方向' : null + item.isLeaf = true + }) + if(data.length != 0){ + that.unitId[index].aroundNodes.push({ + name: buildongsdata[i].name, + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'四周毗邻', + children: data + }) + element.aroundNodes = [...element.aroundNodes] + } + resolve('1') + }) + }) + } + + } + }) + } //查看树节点 lookTreeNode(node){ - console.log(node.origin) + // console.log(node.origin) + const dialogRef = this.dialog.open(LookTreeNodeDialog, { + // width: '380px', + // height: '136px', + id:'lookTreeNode', + data: node.origin + }); + + dialogRef.afterClosed().subscribe(result => { + console.log('The dialog was closed'); + }); } @@ -283,7 +368,7 @@ export class CreateTestScoreComponent implements OnInit { i.checked ? selectedNum.push(i) : '' }) }) - console.log(7894,selectedNum) + // console.log(7894,selectedNum) if(selectedNum.length != 0 ){ this.unitId[key].aroundScore ? this.unitId[key].aroundItemScore = this.unitId[key].aroundScore / selectedNum.length : null }else{ @@ -429,3 +514,30 @@ export class AddPlanTwoDialog { } } + + +//查看答案 +@Component({ + selector: 'lookTreeNode-dialog', + templateUrl: 'lookTreeNode.html', + styleUrls: ['lookTreeNode.scss'] +}) +export class LookTreeNodeDialog { + + constructor(public dialog: MatDialog,public dialogRef: MatDialogRef<LookTreeNodeDialog>,@Inject(MAT_DIALOG_DATA) public data: any) {} + + + ngOnInit(): void { + console.log(this.data) + } + + onNoClick(): void { + this.dialogRef.close(); + } + + //取消 + close(){ + this.dialogRef.close(); + } + +} \ No newline at end of file diff --git a/src/app/examiner/create-test-score/lookTreeNode.html b/src/app/examiner/create-test-score/lookTreeNode.html new file mode 100644 index 0000000..a268037 --- /dev/null +++ b/src/app/examiner/create-test-score/lookTreeNode.html @@ -0,0 +1,29 @@ +<div> + <!-- 非表格类 --> + <table *ngIf="!data.tabledata && data.type != '四周毗邻'"> + <tr> + <td *ngFor="let item of data.children">{{item.name}}</td> + </tr> + <tr> + <td *ngFor="let item of data.children">{{item.value || item.propertyValue}}</td> + </tr> + </table> + <!-- 表格类 --> + <table *ngIf="data.tabledata"> + <tr> + <td *ngFor="let item of data.tabledata">{{item.propertyName}}</td> + </tr> + <tr *ngFor="let item of data.tabledata[0].data;let key = index"> + <td *ngFor="let i of data.tabledata">{{i.data[key]. propertyValue}}</td> + </tr> + </table> + + <table *ngIf="data.type == '四周毗邻'"> + <tr> + <td *ngFor="let item of data.children">{{item.title}}</td> + </tr> + <tr> + <td *ngFor="let item of data.children">{{item.name}}</td> + </tr> + </table> +</div> \ No newline at end of file diff --git a/src/app/examiner/create-test-score/lookTreeNode.scss b/src/app/examiner/create-test-score/lookTreeNode.scss new file mode 100644 index 0000000..1c5e0ae --- /dev/null +++ b/src/app/examiner/create-test-score/lookTreeNode.scss @@ -0,0 +1,16 @@ +table,table tr th, table tr td { border: 1px solid #EEF1F5; } +table { text-align: center; border-collapse: collapse; padding:2px;} +table{ + width: 100%; + font-size: 15px; + tr{ + height: 35px; + td{ + box-sizing: border-box; + padding: 6px; + } + } + tr:nth-child(1){ + background: #F5FDFE; + } +} \ No newline at end of file diff --git a/src/app/examiner/examiner.module.ts b/src/app/examiner/examiner.module.ts index 96c7a81..588a71b 100644 --- a/src/app/examiner/examiner.module.ts +++ b/src/app/examiner/examiner.module.ts @@ -46,7 +46,7 @@ import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatPaginatorIntl } from '@angular/material/paginator'; import { myPaginator } from '../ui/my-paginator'; -import { AddPlanDialog, AddPlanTwoDialog, CreateTestScoreComponent } from './create-test-score/create-test-score.component'; +import { AddPlanDialog, AddPlanTwoDialog, CreateTestScoreComponent, LookTreeNodeDialog } from './create-test-score/create-test-score.component'; import { NavigationModule } from '../navigation/navigation.module'; import { NzTreeModule } from 'ng-zorro-antd/tree'; import { ExaminerIndexComponent } from './examiner-index/examiner-index.component'; @@ -54,7 +54,7 @@ import { ExaminerIndexComponent } from './examiner-index/examiner-index.componen @NgModule({ - declarations: [CreateTestScoreComponent,AddPlanDialog,AddPlanTwoDialog], + declarations: [CreateTestScoreComponent,AddPlanDialog,AddPlanTwoDialog,LookTreeNodeDialog], imports: [ CommonModule, examinerRoutingModule, diff --git a/src/styles.scss b/src/styles.scss index 6ba0a06..6be3e09 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -96,7 +96,7 @@ table td.mat-footer-cell:last-of-type{ } } //弹出框样式取消padding -#addPlanTwo{ +#addPlanTwo,#lookTreeNode{ padding: 0; .mat-elevation-z8{ box-shadow:none From d51f1193839c4d79aa66cfe931d2346df7f30323 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Sat, 12 Dec 2020 10:46:46 +0800 Subject: [PATCH 2/6] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E5=9B=9B=E5=91=A8?= =?UTF-8?q?=E6=AF=97=E9=82=BB=E5=88=86=E6=95=B0=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../examiner/create-test-score/create-test-score.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/examiner/create-test-score/create-test-score.component.ts b/src/app/examiner/create-test-score/create-test-score.component.ts index 0d4c654..510cceb 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.ts +++ b/src/app/examiner/create-test-score/create-test-score.component.ts @@ -334,7 +334,7 @@ export class CreateTestScoreComponent implements OnInit { //key代表第几个建筑 //计算整个单位的总分 - this.unitId[key].score = this.unitId[key].basicInfoScore + 0 + this.unitId[key].score = this.unitId[key].basicInfoScore + this.unitId[key].aroundScore //计算整个试卷的总分 let examScore = 0 @@ -368,7 +368,6 @@ export class CreateTestScoreComponent implements OnInit { i.checked ? selectedNum.push(i) : '' }) }) - // console.log(7894,selectedNum) if(selectedNum.length != 0 ){ this.unitId[key].aroundScore ? this.unitId[key].aroundItemScore = this.unitId[key].aroundScore / selectedNum.length : null }else{ From f390b79ae77c75cf3c332d12ae004a11685071e1 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Sat, 12 Dec 2020 18:49:19 +0800 Subject: [PATCH 3/6] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E9=87=8D=E7=82=B9?= =?UTF-8?q?=E9=83=A8=E4=BD=8D=EF=BC=8C=E5=8A=9F=E8=83=BD=E5=88=86=E5=8C=BA?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E6=8D=AE=E6=A0=B8=E9=AA=8C=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=AD=9B=E9=80=89tree=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create-test-score.component.html | 126 ++++++ .../create-test-score.component.ts | 361 ++++++++++++++++-- .../create-test-score/lookTreeNode.html | 32 +- 3 files changed, 489 insertions(+), 30 deletions(-) diff --git a/src/app/examiner/create-test-score/create-test-score.component.html b/src/app/examiner/create-test-score/create-test-score.component.html index 702d53f..b5d129d 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.html +++ b/src/app/examiner/create-test-score/create-test-score.component.html @@ -126,6 +126,132 @@ </div> </mat-expansion-panel> </mat-accordion> + <!-- 重点部位 --> + <mat-accordion *ngIf="unit.keySiteNodes.length != 0"> + <mat-expansion-panel style="box-shadow: 0 0 black;" expanded> + <mat-expansion-panel-header collapsedHeight ='40px' expandedHeight='40px' style="position: relative;padding-left:20px;background: #F5FDFE;"> + <mat-panel-title> + 重点部位 + <span style="margin-left: 20px;"> + 总分值: <input class="scoreInput" type="number" (click)="stopPropagation($event)" + [(ngModel)]="unit.keySiteScore" (input)="sumScore('重点部位',key)"> 分, + 单项 <span style="color: #FF8678;"> + {{unit.keySiteItemScore ? unit.keySiteItemScore : 0}} + </span> 分 + </span> + </mat-panel-title> + </mat-expansion-panel-header> + + <div style="box-sizing: border-box;padding: 10px;"> + <nz-tree + [nzData]="unit.keySiteNodes" + nzCheckable + nzMultiple + [nzCheckedKeys]="defaultCheckedKeys" + [nzExpandedKeys]="defaultExpandedKeys" + [nzSelectedKeys]="defaultSelectedKeys" + (nzClick)="nzEvent($event,key)" + (nzExpandChange)="nzEvent($event,key)" + (nzCheckBoxChange)="nzEvent($event,key)" + [nzTreeTemplate]="nzTreeTemplate" + > + </nz-tree> + <ng-template #nzTreeTemplate let-node let-origin="origin"> + <div class="treeNodeTemplate"> + <label class="overflowText textNode">{{node.origin.title ? node.origin.title : node.origin.name}}</label> + <div class="scoreDiv" *ngIf="node.level == '0'"> + <span class="colorspan lookitem" (click)="lookTreeNode(node)">查看</span> + </div> + + </div> + </ng-template> + </div> + </mat-expansion-panel> + </mat-accordion> + <!-- 功能分区 --> + <mat-accordion *ngIf="unit.funDivNodes.length != 0"> + <mat-expansion-panel style="box-shadow: 0 0 black;" expanded> + <mat-expansion-panel-header collapsedHeight ='40px' expandedHeight='40px' style="position: relative;padding-left:20px;background: #F5FDFE;"> + <mat-panel-title> + 功能分区 + <span style="margin-left: 20px;"> + 总分值: <input class="scoreInput" type="number" (click)="stopPropagation($event)" + [(ngModel)]="unit.funDivScore" (input)="sumScore('功能分区',key)"> 分, + 单项 <span style="color: #FF8678;"> + {{unit.funDivItemScore ? unit.funDivItemScore : 0}} + </span> 分 + </span> + </mat-panel-title> + </mat-expansion-panel-header> + + <div style="box-sizing: border-box;padding: 10px;"> + <nz-tree + [nzData]="unit.funDivNodes" + nzCheckable + nzMultiple + [nzCheckedKeys]="defaultCheckedKeys" + [nzExpandedKeys]="defaultExpandedKeys" + [nzSelectedKeys]="defaultSelectedKeys" + (nzClick)="nzEvent($event,key)" + (nzExpandChange)="nzEvent($event,key)" + (nzCheckBoxChange)="nzEvent($event,key)" + [nzTreeTemplate]="nzTreeTemplate" + > + </nz-tree> + <ng-template #nzTreeTemplate let-node let-origin="origin"> + <div class="treeNodeTemplate"> + <label class="overflowText textNode">{{node.origin.region ? node.origin.region : node.origin.name}}</label> + <div class="scoreDiv" *ngIf="node.level == '0'"> + <span class="colorspan lookitem" (click)="lookTreeNode(node)">查看</span> + </div> + + </div> + </ng-template> + </div> + </mat-expansion-panel> + </mat-accordion> + <!-- 数据核验(消防设施) --> + <mat-accordion *ngIf="unit.fireFacNodes .length != 0"> + <mat-expansion-panel style="box-shadow: 0 0 black;" expanded> + <mat-expansion-panel-header collapsedHeight ='40px' expandedHeight='40px' style="position: relative;padding-left:20px;background: #F5FDFE;"> + <mat-panel-title> + 数据核验 + <span style="margin-left: 20px;"> + 总分值: <input class="scoreInput" type="number" (click)="stopPropagation($event)" + [(ngModel)]="unit.fireFacScore " (input)="sumScore('数据核验',key)"> 分, + 单项 <span style="color: #FF8678;"> + {{unit.fireFacItemScore ? unit.fireFacItemScore : 0}} + </span> 分 + </span> + </mat-panel-title> + </mat-expansion-panel-header> + + <div style="box-sizing: border-box;padding: 10px;"> + <nz-tree + [nzData]="unit.fireFacNodes" + nzCheckable + nzMultiple + [nzCheckedKeys]="defaultCheckedKeys" + [nzExpandedKeys]="defaultExpandedKeys" + [nzSelectedKeys]="defaultSelectedKeys" + (nzClick)="nzEvent($event,key)" + (nzExpandChange)="nzEvent($event,key)" + (nzCheckBoxChange)="nzEvent($event,key)" + [nzTreeTemplate]="nzTreeTemplate" + > + </nz-tree> + <ng-template #nzTreeTemplate let-node let-origin="origin"> + <div class="treeNodeTemplate"> + <label class="overflowText textNode">{{node.origin.name}}</label> + <div class="scoreDiv" *ngIf="node.level == '0'"> + <span class="colorspan lookitem" (click)="lookTreeNode(node)">查看</span> + </div> + + </div> + </ng-template> + </div> + </mat-expansion-panel> + </mat-accordion> </div> </div> <div class="fightdeploydiv" *ngIf="selectedTab == 2"> diff --git a/src/app/examiner/create-test-score/create-test-score.component.ts b/src/app/examiner/create-test-score/create-test-score.component.ts index 510cceb..50830ad 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.ts +++ b/src/app/examiner/create-test-score/create-test-score.component.ts @@ -19,6 +19,9 @@ export class CreateTestScoreComponent implements OnInit { ngOnInit(): void { this.getUnitData() this.getAround() + this.getKeySite() + this.getFunDiv() + this.getFireFac() } //模拟单位数据 @@ -72,18 +75,13 @@ export class CreateTestScoreComponent implements OnInit { // {name:'富丽华大酒店2',score:0,basicInfoScore:0} ] - //上个页面传过来的单位数据 unitId:any = [{name:'最最最最最',id:'5fb76c42919f2b44e464016f'}, {name:'华南城集团有限公司',id:'5ee19fe06f91049f5e23e937'}, {name:'贵港油库',id:'5fa35d68f8eb762cb03c662e'} ] - - - - - //获取单位数据 + //获取单位基本信息 getUnitData(){ this.unitId.forEach((element,index) => { element.score = 0 @@ -235,7 +233,8 @@ export class CreateTestScoreComponent implements OnInit { item.direction == 5 ? item.title = '西南方向' : null item.direction == 6 ? item.title = '东北方向' : null item.direction == 7 ? item.title = '西北方向' : null - item.isLeaf = true + item.isLeaf = true, + item.key = item.id }) //如果存在单位毗邻 if(data.length != 0){ @@ -258,9 +257,9 @@ export class CreateTestScoreComponent implements OnInit { } }) let that = this - async function getAllArchitecture(buildongsdata){ - for (let i = 0, length = buildongsdata.length; i < length; i++){ - let id = {buildingId:buildongsdata[i].id} + async function getAllArchitecture(buildingsdata){ + for (let i = 0, length = buildingsdata.length; i < length; i++){ + let id = {buildingId:buildingsdata[i].id} let result = await new Promise((resolve, reject) => { that.http.get('/api/BuildingAdjoins',{params:id}).subscribe((data:any)=>{ data.forEach(item => { @@ -273,10 +272,11 @@ export class CreateTestScoreComponent implements OnInit { item.direction == 6 ? item.title = '东北方向' : null item.direction == 7 ? item.title = '西北方向' : null item.isLeaf = true + item.key = item.id }) if(data.length != 0){ that.unitId[index].aroundNodes.push({ - name: buildongsdata[i].name, + name: buildingsdata[i].name, key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), expanded: false, type:'四周毗邻', @@ -292,33 +292,248 @@ export class CreateTestScoreComponent implements OnInit { } }) } + //获取重点部位 + getKeySite(){ + let that = this + this.unitId.forEach((element,index) =>{ + element.keySiteScore = 0 + element.keySiteItemScore = 0 + element.keySiteNodes = [] + //获得单位重点部位 + let id = {companyId:element.id} + this.http.get('/api/CompanyImportantLocations',{params:id}).subscribe((data:any)=>{ + //如果存在单位毗邻 + let newData = [] + data.forEach(item => { + item.isLeaf = true + item.key = item.id + item.name ? newData.push(item) : null + }) + if(data.length != 0){ + this.unitId[index].keySiteNodes.push({ + name: '单位重点部位', + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'重点部位', + children: newData + }) + element.keySiteNodes = [...element.keySiteNodes] + }}) + + //获得建筑重点部位 + this.http.get('/api/Buildings',{params:id}).subscribe((data:any)=>{ + if (data.length) { + getAllBuildingPositon(data) + } + }) + //获取当前单位所有建筑重点部位 + async function getAllBuildingPositon (buildingsdata) { + for (let i = 0, length = buildingsdata.length; i < length; i++){ + let id = {buildingId:buildingsdata[i].id} + let result = await new Promise((resolve, reject) =>{ + that.http.get('/api/BuildingImportantLocations',{params:id}).subscribe((data:any)=>{ + let newData = [] + data.forEach(item => { + item.isLeaf = true + item.key = item.id + item.name ? newData.push(item) : null + }) + if(newData.length != 0){ + that.unitId[index].keySiteNodes.push({ + name: buildingsdata[i].name, + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'重点部位', + children: newData + }) + element.keySiteNodes = [...element.keySiteNodes] + } + resolve('2') + }) + }) + + } + } + }) + //获取单位重点部位 + + + } + //获取功能分区 + getFunDiv(){ + let that = this + this.unitId.forEach((element,index) =>{ + element.funDivScore = 0 + element.funDivItemScore = 0 + element.funDivNodes = [] + let id = {companyId:element.id} + //单位功能分区 + this.http.get('/api/CompanyFunctionalDivisions',{params:id}).subscribe((data:any)=>{ + //如果存在单位的单位功能分区 + let newData = [] + data.forEach(item => { + item.isLeaf = true + item.key = item.id + item.region ? newData.push(item) : null + }) + if(data.length != 0){ + this.unitId[index].funDivNodes.push({ + name: '单位功能分区', + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'功能分区', + children: newData + }) + element.funDivNodes = [...element.funDivNodes] + } + }) + + //建筑功能分区 + this.http.get('/api/Buildings',{params:id}).subscribe((data:any)=>{ + if (data.length) { + getAllBuildingFunDiv(data) + } + }) + //获取当前单位所有建筑功能分区 + async function getAllBuildingFunDiv (buildingsdata) { + for (let i = 0, length = buildingsdata.length; i < length; i++){ + let id = {buildingId:buildingsdata[i].id} + let result = await new Promise((resolve, reject) =>{ + that.http.get('/api/BuildingFunctionalDivisions',{params:id}).subscribe((data:any)=>{ + let newData = [] + data.forEach(item => { + item.isLeaf = true + item.key = item.id + item.region ? newData.push(item) : null + + }) + if(newData.length != 0){ + that.unitId[index].funDivNodes.push({ + name: buildingsdata[i].name, + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'功能分区', + children: newData + }) + element.funDivNodes = [...element.funDivNodes] + } + resolve('2') + }) + }) + + } + } + + }) + } + //获取消防设施 + getFireFac(){ + let that = this + this.unitId.forEach((element,index) =>{ + element.fireFacScore = 0 + element.fireFacItemScore = 0 + element.fireFacNodes = [] + let companyId = element.id + //获取单位级别消防设施 + this.http.get(`/api/Companies/${companyId}`).subscribe((data:any)=>{ + if (data.buildingTypes.length) { + let newData = {buildingType: data.buildingTypes[0].id,companyId : companyId} + this.http.get('/api/CompanyFacilities',{params:newData}).subscribe((data:any)=>{ //获得单位的消防设施 + + data[0].summary.companyFacilityGroups.forEach(element => { //循环单位内置分组项 + element.facilityItems.forEach((elements,index) => { + elements.total = element.facilityCount[index] + }); + }); + let newData = [] + data[0].summary.companyFacilityGroups.forEach(item => { + item.facilityItems.forEach(i => { + i.isLeaf = true + i.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + (i.total && (i.total!= '总数:0' && i.total!= '总数:0')) ? newData.push(i) : null + }) + }) + if(newData.length != 0){ + this.unitId[index].fireFacNodes.push({ + name: '单位消防设施', + key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + expanded: false, + type:'消防设施', + children: newData + }) + element.fireFacNodes = [...element.fireFacNodes] + } + }) + } + }) + + //获取各建筑消防设施 + this.http.get('/api/Buildings',{params:{ + companyId:companyId + }}).subscribe((data:any)=>{ + if (data.length != 0) { getAllBuildingFireFac(data) } + }) + async function getAllBuildingFireFac (buildingsdata) { + console.log('建筑'+index,buildingsdata) + for (let i = 0, length = buildingsdata.length; i < length; i++){ + let header = {buildingId: buildingsdata[i].id, buildingType: buildingsdata[i].buildingTypes[0].id,companyId:buildingsdata[i].companyId} + let result = await new Promise((resolve, reject) =>{ + that.http.get('/api/BuildingFacilities',{params:header}).subscribe((data:any)=>{ + console.log(index+'消防设施'+ i,data) + + data[0].summary.buildingFacilityGroups.forEach(element => { //循环单位内置分组项 + element.facilityItems.forEach((elements,index) => { + elements.total = element.facilityCount[index] + }); + }); + let newData = [] + data[0].summary.buildingFacilityGroups.forEach(item => { + item.facilityItems.forEach(i => { + i.isLeaf = true + i.key = (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5), + (i.total && (i.total!= '总数:0' && i.total!= '总数:0')) ? newData.push(i) : null + }) + }) + if(newData.length != 0){ + that.unitId[index].fireFacNodes.push({ + name: buildingsdata[i].name, + key: buildingsdata[i].id, + expanded: false, + type:'消防设施', + children: newData + }) + element.fireFacNodes = [...element.fireFacNodes] + } + resolve('消防设施') + }) + }) + + } + } + }) + } //查看树节点 lookTreeNode(node){ - // console.log(node.origin) const dialogRef = this.dialog.open(LookTreeNodeDialog, { - // width: '380px', - // height: '136px', id:'lookTreeNode', data: node.origin }); - dialogRef.afterClosed().subscribe(result => { console.log('The dialog was closed'); }); } - //阻止input事件冒泡 stopPropagation($event){ $event.stopPropagation() } //模拟预案数据 planDatas:any = [ - {name:'5楼电路故障灾情扑救',or:'上海总队',time:'2020-09-24',isOpen:'未公开',level:'总队',scroe:0}, - {name:'6楼电路故障灾情扑救',or:'上海总队',time:'2020-09-24',isOpen:'未公开',level:'总队',scroe:0}, - {name:'7楼电路故障灾情扑救',or:'上海总队',time:'2020-09-24',isOpen:'未公开',level:'总队',scroe:0} + {name:'5楼电路故障灾情扑救',or:'上海总队',time:'2020-09-24',isOpen:'未公开',level:'总队',score:0}, + {name:'6楼电路故障灾情扑救',or:'上海总队',time:'2020-09-24',isOpen:'未公开',level:'总队',score:0}, + {name:'7楼电路故障灾情扑救',or:'上海总队',time:'2020-09-24',isOpen:'未公开',level:'总队',score:0} ] defaultCheckedKeys = []; //指定选中复选框的树节点 key值 @@ -334,14 +549,19 @@ export class CreateTestScoreComponent implements OnInit { //key代表第几个建筑 //计算整个单位的总分 - this.unitId[key].score = this.unitId[key].basicInfoScore + this.unitId[key].aroundScore + this.unitId[key].score = this.unitId[key].basicInfoScore + this.unitId[key].aroundScore + this.unitId[key].keySiteScore + this.unitId[key].funDivScore + this.unitId[key].fireFacScore //计算整个试卷的总分 - let examScore = 0 - this.unitId.forEach(element => { - examScore += Number(element.score) - }) - this.examScore = examScore + //计算整个试卷的总分 + let examScore = 0 + this.unitId.forEach(element => { + examScore += element.score + }) + let examScore2 = 0 + this.planDatas.forEach(element => { + examScore2 += Number(element.score) + }) + this.examScore = examScore + examScore2 } //tree的选择事件 @@ -374,6 +594,45 @@ export class CreateTestScoreComponent implements OnInit { this.unitId[key].aroundItemScore = 0 } } + if(event.node.origin.type == '重点部位' || (event.node.parentNode && event.node.parentNode.origin.type == '重点部位')){ + let selectedNum = [] + this.unitId[key].keySiteNodes.forEach(item => { + item.children.forEach(i => { + i.checked ? selectedNum.push(i) : '' + }) + }) + if(selectedNum.length != 0 ){ + this.unitId[key].keySiteScore ? this.unitId[key].keySiteItemScore = this.unitId[key].keySiteScore / selectedNum.length : null + }else{ + this.unitId[key].keySiteItemScore = 0 + } + } + if(event.node.origin.type == '功能分区' || (event.node.parentNode && event.node.parentNode.origin.type == '功能分区')){ + let selectedNum = [] + this.unitId[key].funDivNodes .forEach(item => { + item.children.forEach(i => { + i.checked ? selectedNum.push(i) : '' + }) + }) + if(selectedNum.length != 0 ){ + this.unitId[key].funDivScore ? this.unitId[key].funDivItemScore = this.unitId[key].funDivScore / selectedNum.length : null + }else{ + this.unitId[key].funDivItemScore = 0 + } + } + if(event.node.origin.type == '消防设施' || (event.node.parentNode && event.node.parentNode.origin.type == '消防设施')){ + let selectedNum = [] + this.unitId[key].fireFacNodes.forEach(item => { + item.children.forEach(i => { + i.checked ? selectedNum.push(i) : '' + }) + }) + if(selectedNum.length != 0 ){ + this.unitId[key].fireFacScore ? this.unitId[key].fireFacItemScore = this.unitId[key].fireFacScore / selectedNum.length : null + }else{ + this.unitId[key].fireFacItemScore = 0 + } + } } //单位各项总分数动态计算 @@ -391,7 +650,6 @@ export class CreateTestScoreComponent implements OnInit { }else{ this.unitId[key].basicInfoItemScore = 0 } - } if(type == '四周毗邻'){ let selectedNum = 0 @@ -405,7 +663,45 @@ export class CreateTestScoreComponent implements OnInit { }else{ this.unitId[key].aroundItemScore = 0 } - + } + if(type == '重点部位'){ + let selectedNum = 0 + this.unitId[key].keySiteNodes.forEach(item => { + item.children.forEach(i => { + i.checked ? selectedNum++ : '' + }) + }) + if(selectedNum != 0){ + this.unitId[key].keySiteItemScore = this.unitId[key].keySiteScore / selectedNum + }else{ + this.unitId[key].keySiteItemScore = 0 + } + } + if(type == '功能分区'){ + let selectedNum = 0 + this.unitId[key].funDivNodes.forEach(item => { + item.children.forEach(i => { + i.checked ? selectedNum++ : '' + }) + }) + if(selectedNum != 0){ + this.unitId[key].funDivItemScore = this.unitId[key].funDivScore / selectedNum + }else{ + this.unitId[key].funDivItemScore = 0 + } + } + if(type == '消防设施'){ + let selectedNum = 0 + this.unitId[key].fireFacNodes.forEach(item => { + item.children.forEach(i => { + i.checked ? selectedNum++ : '' + }) + }) + if(selectedNum != 0){ + this.unitId[key].fireFacItemScore = this.unitId[key].fireFacScore / selectedNum + }else{ + this.unitId[key].fireFacItemScore = 0 + } } this.calculateScore(key)//更新标题栏分数 @@ -425,7 +721,16 @@ export class CreateTestScoreComponent implements OnInit { } //每条预案分数增加在试卷分数 planItemScore(item){ - this.examScore += item.score + //计算整个试卷的总分 + let examScore = 0 + this.unitId.forEach(element => { + examScore += element.score + }) + let examScore2 = 0 + this.planDatas.forEach(element => { + examScore2 += Number(element.score) + }) + this.examScore = examScore + examScore2 } } diff --git a/src/app/examiner/create-test-score/lookTreeNode.html b/src/app/examiner/create-test-score/lookTreeNode.html index a268037..f05b3eb 100644 --- a/src/app/examiner/create-test-score/lookTreeNode.html +++ b/src/app/examiner/create-test-score/lookTreeNode.html @@ -1,11 +1,11 @@ <div> <!-- 非表格类 --> - <table *ngIf="!data.tabledata && data.type != '四周毗邻'"> + <table *ngIf="!data.tabledata && data.type != '四周毗邻' && data.type != '重点部位' && data.type != '功能分区'"> <tr> <td *ngFor="let item of data.children">{{item.name}}</td> </tr> <tr> - <td *ngFor="let item of data.children">{{item.value || item.propertyValue}}</td> + <td *ngFor="let item of data.children">{{item.value || item.propertyValue || item.total}}</td> </tr> </table> <!-- 表格类 --> @@ -26,4 +26,32 @@ <td *ngFor="let item of data.children">{{item.name}}</td> </tr> </table> + <table *ngIf="data.type == '重点部位'"> + <tr> + <td>重点部位名称</td> + <td>重点部位所在位置</td> + <td>建筑结构</td> + <td>使用性质</td> + <td>主要危险性</td> + </tr> + <tr *ngFor="let item of data.children"> + <td>{{item.name || '无'}}</td> + <td>{{item.position || '无'}}</td> + <td>{{item.structure || '无'}}</td> + <td>{{item.nature || '无'}}</td> + <td>{{item.hazards || '无'}}</td> + </tr> + </table> + <table *ngIf="data.type == '功能分区'"> + <tr> + <td>区域</td> + <td>面积</td> + <td>基本情况</td> + </tr> + <tr *ngFor="let item of data.children"> + <td>{{item.region || '无'}}</td> + <td>{{item.area || '无'}}</td> + <td>{{item.details || '无'}}</td> + </tr> + </table> </div> \ No newline at end of file From 5c8f0fbe5ffdcab3d53e6d1894588546ceb95f28 Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Sun, 13 Dec 2020 15:51:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=20=E7=BC=96=E5=88=B6?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E4=BF=AE=E6=94=B9=E5=9F=BA=E6=9C=AC=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collection-tools.component.html | 10 +- .../collection-tools.component.ts | 25 ++++- .../examinationQuestions.html | 33 +++++++ .../collection-tools/examinationQuestions.ts | 93 +++++++++++++++++++ src/app/ui/collection-tools/saveOne.html | 6 +- .../ui/collection-tools/uploadQuestions.html | 45 +++++++++ src/app/ui/ui.module.ts | 3 +- 7 files changed, 204 insertions(+), 11 deletions(-) create mode 100644 src/app/ui/collection-tools/examinationQuestions.html create mode 100644 src/app/ui/collection-tools/examinationQuestions.ts create mode 100644 src/app/ui/collection-tools/uploadQuestions.html diff --git a/src/app/ui/collection-tools/collection-tools.component.html b/src/app/ui/collection-tools/collection-tools.component.html index 59ff229..32493aa 100644 --- a/src/app/ui/collection-tools/collection-tools.component.html +++ b/src/app/ui/collection-tools/collection-tools.component.html @@ -1,13 +1,13 @@ <div class="content"> <!-- header头部 --> <div class="header"> - <div class="headerTitle">富丽华大酒店</div> - <div class="headerCenter"> <input type="text" placeholder="请输入考试要点"> </div> + <div class="headerTitle">{{examMsg.conpanyName}}</div> + <div class="headerCenter"> <input type="text" placeholder="请输入考试要点" [(ngModel)]="examMsg.keynote"> </div> <div class="headerRight"> - <label class="fraction">总分<input type="text">分</label> - <button style="border: 1px solid #07CDCF; border-radius: 5px; margin: 0 15px;"><mat-icon>visibility</mat-icon>消防设施考题设定</button> + <label class="fraction">总分<input type="text" [(ngModel)]="examMsg.grade">分</label> + <button style="border: 1px solid #07CDCF; border-radius: 5px; margin: 0 15px;" (click)='openFireExamination()'><mat-icon>visibility</mat-icon>消防设施考题设定</button> <button (click)="saveSite()"><mat-icon>description</mat-icon>保存</button> - <button><mat-icon>open_in_browser</mat-icon>上传</button> + <button (click)="openUploadQuestions()"><mat-icon>open_in_browser</mat-icon>上传</button> </div> </div> <!-- header头部 --> diff --git a/src/app/ui/collection-tools/collection-tools.component.ts b/src/app/ui/collection-tools/collection-tools.component.ts index e2b8397..af86678 100644 --- a/src/app/ui/collection-tools/collection-tools.component.ts +++ b/src/app/ui/collection-tools/collection-tools.component.ts @@ -16,6 +16,7 @@ import { delay } from 'rxjs/operators'; import { windows } from 'src/app/interface'; import { GameMode } from 'src/app/working-area/model/gameMode'; import { ActivatedRoute, Router } from '@angular/router'; +import { examinationQuestions,uploadQuestions } from './examinationQuestions' @@ -627,6 +628,11 @@ export class CollectionToolsComponent implements OnInit { isSixShow = true isSixbtn = true //控制想定作业编辑按钮 isxxx = true //控制查看编辑模式的编辑模式按钮 + examMsg = { //单位,考试信息 + conpanyName: '富丽华大酒店', //单位名称 + keynote: '', //考试要点 + grade: '', //分数 + } ngOnInit(): void { sessionStorage.setItem('companyId','5fa2512ef8eb762cb03c65fb') @@ -658,7 +664,8 @@ export class CollectionToolsComponent implements OnInit { ngAfterViewInit(): void { - this.getSitePlan() + this.getSitePlan() //获取总平面图/楼层 + // 监听canvas组件选中素材事件 this.canvas.on("select",obj=>{ //选中素材属性注入函数 @@ -1306,6 +1313,20 @@ export class CollectionToolsComponent implements OnInit { // }; } + //打开消防设施考题设定 + openFireExamination () { + let treeData = JSON.parse( JSON.stringify(this.dataSource.data) ) + let data = { treeData: treeData } + let dialogRef = this.dialog.open(examinationQuestions,{data}); + } + + //上传考题 + openUploadQuestions () { + let treeData = JSON.parse( JSON.stringify(this.dataSource.data) ) + let data = { treeData: treeData, question: JSON.parse( JSON.stringify(this.examMsg) ) } + let dialogRef = this.dialog.open(uploadQuestions,{data}); + } + //封装 刷新 tree 数据 async renovateTreeData (isRefresh:boolean = true) { this.allFireElements[this.allFireElements.length-1].children = [] @@ -1348,7 +1369,7 @@ export class CollectionToolsComponent implements OnInit { toggleExpandPanel:boolean = false; //左侧可展开面板展开或关闭 toggleExpandPanelRight:boolean = false; //右侧可展开面板展开或关闭 togglePlane:boolean = true; //可展开面板平面图 显隐 - toggleMaterialBank:boolean = false; //可展开面板素材库 显隐 + toggleMaterialBank:boolean = true; //可展开面板素材库 显隐 toggleHandlePlans:boolean = true; //可展开面板处置预案 显隐 //可展开面板展开或关闭 toggle () { diff --git a/src/app/ui/collection-tools/examinationQuestions.html b/src/app/ui/collection-tools/examinationQuestions.html new file mode 100644 index 0000000..aa5e6f3 --- /dev/null +++ b/src/app/ui/collection-tools/examinationQuestions.html @@ -0,0 +1,33 @@ +<div style="min-width: 240px;"> + <div style="text-align: center;font-weight: 550;">消防设施考题设定</div> + <div style="max-height: 300px;overflow-y: auto; margin: 25px 0;"> + <!-- 消防列表树 --> + <mat-tree [dataSource]="dataSource" [treeControl]="treeControl" cdkDropList [cdkDropListData]="dataSource"> + + <mat-tree-node cdkDrag cdkDragDisabled="false" [ngClass]="{'isLookPattern': !node.isLookPattern}" *matTreeNodeDef="let node;" matTreeNodePadding cdkTreeNodePaddingIndent='26' class="treeNode"> + <button mat-icon-button disabled></button> + <span title="{{node.name}}" [ngClass]="{'treeText': !node.isTemplate}"> + {{node.name}} + </span> + <span *ngIf="node.isTemplate">({{node.children.length}})</span> + <mat-checkbox style="margin-left: auto;" color=primary></mat-checkbox> + </mat-tree-node> + + <mat-tree-node cdkDrag cdkDragDisabled="false" [ngClass]="{'isLookPattern': !node.isLookPattern}" *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding class="treeNode" > + <button mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name"> + <mat-icon class="mat-icon-rtl-mirror"> + {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}} + </mat-icon> + </button> + <span title="{{node.name}}" [ngClass]="{'treeText': !node.isTemplate}"> + {{node.name}} + </span> + <span *ngIf="node.isTemplate && node.isNewElement">({{node.children.length}})</span> + <mat-checkbox style="margin-left: auto;" color=primary></mat-checkbox> + </mat-tree-node> + + </mat-tree> + <!-- 消防列表树 --> + </div> + <div style="text-align: center;"><button mat-stroked-button style="border: none;background-color: #FF8678;color: #fff;" mat-dialog-close>退出</button></div> +</div> \ No newline at end of file diff --git a/src/app/ui/collection-tools/examinationQuestions.ts b/src/app/ui/collection-tools/examinationQuestions.ts new file mode 100644 index 0000000..d441b0b --- /dev/null +++ b/src/app/ui/collection-tools/examinationQuestions.ts @@ -0,0 +1,93 @@ +import { Component, OnInit, Inject } from '@angular/core'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; +import {CanvasShareDataService,DisposalNodeData} from '../../canvas-share-data.service' //引入服务 +import { FlatTreeControl } from '@angular/cdk/tree'; +import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; + +@Component({ + selector: 'dialog-examination-questions', + templateUrl: './examinationQuestions.html', + styleUrls: ['./collection-tools.component.scss',] +}) +export class examinationQuestions { + + constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, + @Inject(MAT_DIALOG_DATA) public data) {} + // tree配置 + private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数 + return { + expandable: !!node.children && node.children.length > 0, + name: node.name || node.Name, + level: level, + id: node.id || node.Id, + children:node.children, + isTemplate:node.isTemplate, + isNewElement:node.isNewElement, + isLook:node.isLook, + isLookPattern:node.isLookPattern || null + }; + } + treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + ngOnInit(): void { + this.dataSource.data = this.data.treeData + this.treeControl.expandAll() + } + +} + +@Component({ + selector: 'dialog-upload-questions', + templateUrl: './uploadQuestions.html', + styleUrls: ['./collection-tools.component.scss',] +}) +export class uploadQuestions { + + constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, + @Inject(MAT_DIALOG_DATA) public data) {} + // tree配置 + private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数 + return { + expandable: !!node.children && node.children.length > 0, + name: node.name || node.Name, + level: level, + id: node.id || node.Id, + children:node.children, + isTemplate:node.isTemplate, + isNewElement:node.isNewElement, + isLook:node.isLook, + isLookPattern:node.isLookPattern || null + }; + } + treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); + treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); + dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); + hasChild = (_: number, node: any) => node.expandable; + + ngOnInit(): void { + this.dataSource.data = this.data.treeData + this.treeControl.expandAll() + } + + //上传 + submit () { + if (this.data.question.grade && this.data.question.keynote) { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('上传成功','确定',config); + this.dialogRef.close() + } else { + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请填写必填项','确定',config); + } + } + +} \ No newline at end of file diff --git a/src/app/ui/collection-tools/saveOne.html b/src/app/ui/collection-tools/saveOne.html index a6b0b32..9017f65 100644 --- a/src/app/ui/collection-tools/saveOne.html +++ b/src/app/ui/collection-tools/saveOne.html @@ -1,5 +1,5 @@ -<div mat-dialog-title>处置节点保存</div> +<div style="text-align: center; margin-bottom: 25px; font-weight: 550;">处置节点保存</div> <div style="display: flex;"> - <button mat-stroked-button style="margin-right: 5px;" (click)="saveType('new')">新建节点并保存</button> - <button mat-stroked-button (click)="saveType('old')">保存到已有节点</button> + <button mat-stroked-button style="margin-right: 15px; color: #fff; background-color: #07CDCF; border: none;" (click)="saveType('new')">新建节点并保存</button> + <button mat-stroked-button style="margin-left: 15px; color: #fff; background-color: #FF8678; border: none;" (click)="saveType('old')">保存到已有节点</button> </div> \ No newline at end of file diff --git a/src/app/ui/collection-tools/uploadQuestions.html b/src/app/ui/collection-tools/uploadQuestions.html new file mode 100644 index 0000000..6e0988b --- /dev/null +++ b/src/app/ui/collection-tools/uploadQuestions.html @@ -0,0 +1,45 @@ +<div style="min-width: 260px;"> + <div style="text-align: center;font-weight: 550;">上传</div> + <div style="padding-left: 10px; font-size: 14px; font-weight: 550;margin: 5px 0;">设置分数</div> + <div style="margin-bottom: 25px;"> + <input type="text" style="width: 100%;border-radius: 5px;height: 26px;background-color: #dfe0e0;" placeholder="请填写考试分数" [(ngModel)]="data.question.grade"> + </div> + <div style="padding-left: 10px; font-size: 14px; font-weight: 550;margin: 5px 0;">考试要点</div> + <div style="margin-bottom: 25px;"> + <textarea style="width: 100%;background-color: #dfe0e0;border: none;outline: none;height: 50px;border-radius: 5px;resize: none;" placeholder="请填写考试要点" [(ngModel)]="data.question.keynote"></textarea> + </div> + <div style="padding-left: 10px; font-size: 14px; font-weight: 550;margin: 5px 0;">考核消防设施</div> + <div style="max-height: 200px;overflow-y: auto;margin-bottom: 25px;"> + <!-- 消防列表树 --> + <mat-tree [dataSource]="dataSource" [treeControl]="treeControl" cdkDropList [cdkDropListData]="dataSource"> + + <mat-tree-node cdkDrag cdkDragDisabled="false" [ngClass]="{'isLookPattern': !node.isLookPattern}" *matTreeNodeDef="let node;" matTreeNodePadding cdkTreeNodePaddingIndent='26' class="treeNode"> + <button mat-icon-button disabled></button> + <span title="{{node.name}}" [ngClass]="{'treeText': !node.isTemplate}"> + {{node.name}} + </span> + <span *ngIf="node.isTemplate">({{node.children.length}})</span> + <mat-checkbox style="margin-left: auto;" color=primary></mat-checkbox> + </mat-tree-node> + + <mat-tree-node cdkDrag cdkDragDisabled="false" [ngClass]="{'isLookPattern': !node.isLookPattern}" *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding class="treeNode" > + <button mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name"> + <mat-icon class="mat-icon-rtl-mirror"> + {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}} + </mat-icon> + </button> + <span title="{{node.name}}" [ngClass]="{'treeText': !node.isTemplate}"> + {{node.name}} + </span> + <span *ngIf="node.isTemplate && node.isNewElement">({{node.children.length}})</span> + <mat-checkbox style="margin-left: auto;" color=primary></mat-checkbox> + </mat-tree-node> + + </mat-tree> + <!-- 消防列表树 --> + </div> + <div style="text-align: center;"> + <button mat-stroked-button style="margin-right: 15px;border: none;background: #07CDCF;color: #fff;" (click)='submit()'>确定</button> + <button mat-stroked-button style="margin-left: 15px;border: none;background: #dfe0e0;" mat-dialog-close>取消</button> + </div> +</div> \ No newline at end of file diff --git a/src/app/ui/ui.module.ts b/src/app/ui/ui.module.ts index e0a90db..c2d4739 100644 --- a/src/app/ui/ui.module.ts +++ b/src/app/ui/ui.module.ts @@ -70,8 +70,9 @@ import {leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeCo import {saveOneDialog,saveTwoDialog} from './collection-tools/save' import {WorkingAreaComponent} from '../working-area/working-area.component' import { NzTreeModule } from 'ng-zorro-antd/tree'; +import { examinationQuestions,uploadQuestions } from './collection-tools/examinationQuestions' @NgModule({ - declarations: [FolderDialog,ViewDetails,ChangepasswordComponent,SizePipe,NamePipe,NamePipe2,NamePipe3,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, UploadFilesComponent,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser,TeacherManagementComponent,editTeacher,AddTeacher,seeTeacher, LearningRecordDetailsComponent, EhartsStatisticsComponent, CreateExamComponent, LookOverTestComponent, StatisticAnalysisComponent, JoinExamComponent, TestRecordsComponent,testState,CreateDialog,CollectionToolsComponent,CreateBuilding,EditBuilding,ViewDetailss,leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeComponent,editDisposalNodeComponent,saveOneDialog,saveTwoDialog,WorkingAreaComponent], + declarations: [FolderDialog,ViewDetails,ChangepasswordComponent,SizePipe,NamePipe,NamePipe2,NamePipe3,ConfirmpswDirective, AllFileComponent, ChangeuserdataComponent, UploadFilesComponent,AddEnterpriserUser,EnterpriseuserComponent,editenterpriseuser,seeenterpriseuser,TeacherManagementComponent,editTeacher,AddTeacher,seeTeacher, LearningRecordDetailsComponent, EhartsStatisticsComponent, CreateExamComponent, LookOverTestComponent, StatisticAnalysisComponent, JoinExamComponent, TestRecordsComponent,testState,CreateDialog,CollectionToolsComponent,CreateBuilding,EditBuilding,ViewDetailss,leftFunctionalDomainComponent,editPlaneFigureComponent,addDisposalNodeComponent,editDisposalNodeComponent,saveOneDialog,saveTwoDialog,WorkingAreaComponent,examinationQuestions,uploadQuestions], imports: [ NzDatePickerModule, From 100960811713fdec70f3fd05076958acb9bdd6b5 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Mon, 14 Dec 2020 09:05:51 +0800 Subject: [PATCH 5/6] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E4=BF=9D=E5=AD=98=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create-test-score.component.html | 2 +- .../create-test-score.component.ts | 281 +++++++++++++++++- src/assets/css/ngZorroTree.css | 5 +- 3 files changed, 282 insertions(+), 6 deletions(-) diff --git a/src/app/examiner/create-test-score/create-test-score.component.html b/src/app/examiner/create-test-score/create-test-score.component.html index b5d129d..660ffad 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.html +++ b/src/app/examiner/create-test-score/create-test-score.component.html @@ -293,7 +293,7 @@ <div class="btn"> 上一步 </div> - <div class="btn"> + <div class="btn" (click)="save()"> 完成 </div> </div> diff --git a/src/app/examiner/create-test-score/create-test-score.component.ts b/src/app/examiner/create-test-score/create-test-score.component.ts index 50830ad..78a3f2e 100644 --- a/src/app/examiner/create-test-score/create-test-score.component.ts +++ b/src/app/examiner/create-test-score/create-test-score.component.ts @@ -1,9 +1,9 @@ import { SelectionModel } from '@angular/cdk/collections'; import { HttpClient } from '@angular/common/http'; -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, Inject, OnInit, ViewChild } from '@angular/core'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatTableDataSource } from '@angular/material/table'; -import { NzFormatEmitEvent } from 'ng-zorro-antd/tree'; +import { NzFormatEmitEvent, NzTreeComponent } from 'ng-zorro-antd/tree'; @Component({ selector: 'app-create-test-score', templateUrl: './create-test-score.component.html', @@ -475,12 +475,12 @@ export class CreateTestScoreComponent implements OnInit { if (data.length != 0) { getAllBuildingFireFac(data) } }) async function getAllBuildingFireFac (buildingsdata) { - console.log('建筑'+index,buildingsdata) + // console.log('建筑'+index,buildingsdata) for (let i = 0, length = buildingsdata.length; i < length; i++){ let header = {buildingId: buildingsdata[i].id, buildingType: buildingsdata[i].buildingTypes[0].id,companyId:buildingsdata[i].companyId} let result = await new Promise((resolve, reject) =>{ that.http.get('/api/BuildingFacilities',{params:header}).subscribe((data:any)=>{ - console.log(index+'消防设施'+ i,data) + // console.log(index+'消防设施'+ i,data) data[0].summary.buildingFacilityGroups.forEach(element => { //循环单位内置分组项 element.facilityItems.forEach((elements,index) => { @@ -732,6 +732,279 @@ export class CreateTestScoreComponent implements OnInit { }) this.examScore = examScore + examScore2 } + @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; + //保存 + save(){ + let copyDatas = JSON.parse(JSON.stringify(this.unitId)) + + //循环每个建筑处理数据筛选出选中数据 + copyDatas.forEach(item => { + //建筑的基本信息模块处理 + item.basicInfoNodes.forEach((i,key) => { + //如果顶级节点未选中则需要筛除没有选中的数据 + if(!i.checked){ + // console.log(i) + let newArr = [] + i.children.forEach(element => { + element.checked ? newArr.push(element) : null + }) + let discard = []//即将废弃的数组 + // newArr.length == 0 ? item.basicInfoNodes.splice(key,1) : i.children = newArr + newArr.length == 0 ? discard.push(i) : i.children = newArr + item.basicInfoNodes = item.basicInfoNodes.filter(items => { + if (!discard.includes(items)) return items; + }) + } + //将children处理成指定形式 + if(i.name =='单位信息'){ + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + newChildrenItem.name = element.name//题目名称 + newChildrenItem.result = element.value//题目答案 + newChildrenItem.physicalUnit = element.physicalUnit || ''//计量单位 + newChildrenItem.propertyType = 0//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + }else if(!i.tabledata){ + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + newChildrenItem.name = element.propertyName//题目名称 + newChildrenItem.result = element.propertyValue//题目答案 + newChildrenItem.physicalUnit = element.physicalUnit || ''//计量单位 + newChildrenItem.propertyType = element.propertyType//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + }else if(i.tabledata){//如果是表格类 + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + newChildrenItem.name = element.propertyValue//题目名称 + newChildrenItem.result = element.tag//代表第几行 + newChildrenItem.physicalUnit = ''//计量单位 + newChildrenItem.propertyType = ''//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + i.tabledata.forEach(element => { + let newData = [] + element.data.forEach(ele => { + let newObj:any = {} + newObj.name = ele.propertyName//题目名称 + newObj.result = ele.propertyValue//代表第几行 + newObj.physicalUnit = ele.physicalUnit//计量单位 + newObj.propertyType = ele.propertyType//输入框类型 + newObj.tag = ele.tag//第几行 + newData.push(newObj) + }) + element.data = newData + }) + } + delete i.selected + + }) + //建筑的四周毗邻模块处理 + item.aroundNodes.forEach((i,key) => { + //如果顶级节点未选中则需要筛除没有选中的数据 + if(!i.checked){ + let newArr = [] + i.children.forEach(element => { + element.checked ? newArr.push(element) : null + }) + let discard = []//即将废弃的数组 + newArr.length == 0 ? discard.push(i) : i.children = newArr + item.aroundNodes = item.aroundNodes.filter(items => { + if (!discard.includes(items)) return items; + }) + } + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + newChildrenItem.name = element.title//题目名称 + newChildrenItem.result = element.name//题目答案 + newChildrenItem.physicalUnit = ''//计量单位 + newChildrenItem.propertyType = 0//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + delete i.selected + }) + //建筑的重点部位模块处理 + item.keySiteNodes.forEach((i,key) => { + i.selected ? i.selected = null : null + //如果顶级节点未选中则需要筛除没有选中的数据 + if(!i.checked){ + let newArr = [] + i.children.forEach(element => { + element.checked ? newArr.push(element) : null + }) + let discard = []//即将废弃的数组 + newArr.length == 0 ? discard.push(i) : i.children = newArr + item.keySiteNodes = item.keySiteNodes.filter(items => { + if (!discard.includes(items)) return items; + }) + } + i.tabledata = [{propertyName: "重点部位名称",data:[]}, + {propertyName: "重点部位所在位置",data:[]}, + {propertyName: "建筑结构",data:[]}, + {propertyName: "使用性质",data:[]}, + {propertyName: "主要危险性",data:[]}] + i.children.forEach(element => { + i.tabledata[0].data.push({ + name: "重点部位名称", + physicalUnit: '', + propertyType: 0, + result: element.name, + tag: "" + }) + i.tabledata[1].data.push({ + name: "重点部位所在位置", + physicalUnit: '', + propertyType: 0, + result: element.position, + tag: "" + }) + i.tabledata[2].data.push({ + name: "建筑结构", + physicalUnit: '', + propertyType: 0, + result: element.structure, + tag: "" + }) + i.tabledata[3].data.push({ + name: "使用性质", + physicalUnit: '', + propertyType: 0, + result: element.nature, + tag: "" + }) + i.tabledata[4].data.push({ + name: "主要危险性", + physicalUnit: '', + propertyType: 0, + result: element.hazards, + tag: "" + }) + }) + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + // newChildrenItem.name = element.name//重点部位题目名称 + // newChildrenItem.position = element.position//重点部位所在位置 + // newChildrenItem.structure = element.structure//重点部位建筑结构 + // newChildrenItem.nature = element.nature//重点部位使用性质 + // newChildrenItem.hazards = element.hazards//重点部位主要危险性 + newChildrenItem.name = element.name//题目名称 + newChildrenItem.result = element.position + element.structure + element.nature + element.hazards//题目答案 + newChildrenItem.physicalUnit = element.physicalUnit || ''//计量单位 + newChildrenItem.propertyType = 0//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + delete i.selected + + + }) + //建筑的功能分区模块处理 + item.funDivNodes.forEach((i,key) => { + + //如果顶级节点未选中则需要筛除没有选中的数据 + if(!i.checked){ + let newArr = [] + i.children.forEach(element => { + element.checked ? newArr.push(element) : null + }) + let discard = []//即将废弃的数组 + newArr.length == 0 ? discard.push(i) : i.children = newArr + item.funDivNodes = item.funDivNodes.filter(items => { + if (!discard.includes(items)) return items; + }) + } + + i.tabledata = [{propertyName: "区域",data:[]}, + {propertyName: "面积",data:[]}, + {propertyName: "基本情况",data:[]}] + i.children.forEach(element => { + i.tabledata[0].data.push({ + name: "区域", + physicalUnit: '', + propertyType: 0, + result: element.region, + tag: "" + }) + i.tabledata[1].data.push({ + name: "面积", + physicalUnit: '', + propertyType: 0, + result: element.area, + tag: "" + }) + i.tabledata[2].data.push({ + name: "基本情况", + physicalUnit: '', + propertyType: 0, + result: element.details, + tag: "" + }) + }) + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + // newChildrenItem.name = element.region//功能分区题目名称 + // newChildrenItem.area = element.area//功能分区面积 + // newChildrenItem.details = element.details//功能分区基本情况 + newChildrenItem.name = element.region//题目名称 + newChildrenItem.result = element.area + element.details//题目答案 + newChildrenItem.physicalUnit = element.physicalUnit || ''//计量单位 + newChildrenItem.propertyType = 0//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + delete i.selected + }) + //建筑的数据核验模块处理 + item.fireFacNodes.forEach((i,key) => { + i.selected ? i.selected = null : null + //如果顶级节点未选中则需要筛除没有选中的数据 + if(!i.checked){ + let newArr = [] + i.children.forEach(element => { + element.checked ? newArr.push(element) : null + }) + let discard = []//即将废弃的数组 + newArr.length == 0 ? discard.push(i) : i.children = newArr + item.fireFacNodes = item.fireFacNodes.filter(items => { + if (!discard.includes(items)) return items; + }) + } + let newChildren = [] + i.children.forEach((element,index) => { + let newChildrenItem:any= {} + newChildrenItem.name = element.name//题目名称 + newChildrenItem.result = element.total//题目答案 + newChildrenItem.physicalUnit = ''//计量单位 + newChildrenItem.propertyType = 0//输入框类型 + newChildren.push(newChildrenItem) + }) + i.children = newChildren + delete i.selected + }) + }) + + //循环每个建筑处理数据 + console.log(copyDatas) + // copyDatas.forEach(item =>{ + // //建筑的基本信息模块处理 + // item.basicInfoNodes.forEach((i,key) => { + + // }) + + + // }) + } } //添加预案1 diff --git a/src/assets/css/ngZorroTree.css b/src/assets/css/ngZorroTree.css index 3f270a6..8f8eecf 100644 --- a/src/assets/css/ngZorroTree.css +++ b/src/assets/css/ngZorroTree.css @@ -344,6 +344,9 @@ text-align: center; cursor: pointer } +#createtestscore .ant-tree .ant-tree-switcher { + line-height: 22px; +} .ant-tree .ant-tree-switcher .ant-select-tree-switcher-icon, .ant-tree .ant-tree-switcher .ant-tree-switcher-icon { @@ -474,4 +477,4 @@ nz-tree { display: block -} \ No newline at end of file +} From 049faf91152d8d878b6109897837a7fef356cd20 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Mon, 14 Dec 2020 09:11:01 +0800 Subject: [PATCH 6/6] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E7=99=BB=E9=99=86?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E8=B7=B3=E8=BD=AC=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/lockscreen/lockscreen.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/pages/lockscreen/lockscreen.component.ts b/src/app/pages/lockscreen/lockscreen.component.ts index 19a09b4..53a6b47 100644 --- a/src/app/pages/lockscreen/lockscreen.component.ts +++ b/src/app/pages/lockscreen/lockscreen.component.ts @@ -34,7 +34,7 @@ export class LockscreenComponent implements OnInit { sessionStorage.setItem("token",data.token); sessionStorage.setItem("refreshToken",data.refreshToken); this.token.startUp(); //登陆成功启动定时器刷新token - this.router.navigate(['/home/createexam']) //登陆成功跳转页面 + this.router.navigate(['/home/createexam-index']) //登陆成功跳转页面 },(err) => {this.errmsg = err}) }