Browse Source

[新增]重点部位,功能分区,数据核验数据筛选tree渲染

master
邵佳豪 4 years ago
parent
commit
f390b79ae7
  1. 126
      src/app/examiner/create-test-score/create-test-score.component.html
  2. 361
      src/app/examiner/create-test-score/create-test-score.component.ts
  3. 32
      src/app/examiner/create-test-score/lookTreeNode.html

126
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">

361
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
}
}

32
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>
Loading…
Cancel
Save