|
|
|
@ -18,98 +18,91 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//模拟预案数据
|
|
|
|
|
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} |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
|
|
|
|
|
defaultExpandedKeys = []; //展开指定的树节点 key值
|
|
|
|
|
defaultSelectedKeys = []; //指定选中的树节点 key值
|
|
|
|
|
|
|
|
|
|
examScore:any = 0//整个试卷的总分
|
|
|
|
|
|
|
|
|
|
//模拟单位数据
|
|
|
|
|
unitDatas:any = [ |
|
|
|
|
{name:'富丽华大酒店1',score:0,basicInfoScore:0,basicInfoNodes : [ |
|
|
|
|
{name:'富丽华大酒店1',score:0,basicInfoScore:0,basicInfoItemScore:0,basicInfoNodes : [ |
|
|
|
|
{ |
|
|
|
|
title: '单位信息', |
|
|
|
|
name: '单位信息', |
|
|
|
|
key: '0-0', |
|
|
|
|
type:'基本信息', |
|
|
|
|
expanded: true, |
|
|
|
|
zIndex : '0', |
|
|
|
|
itemScore: 0, |
|
|
|
|
sumScore: 0, |
|
|
|
|
children: [ |
|
|
|
|
{title: '统一社会信用代码',key: '1',isLeaf:true}, |
|
|
|
|
{title: '单位类型',key: '2',isLeaf:true}, |
|
|
|
|
{title: '联系人',key: '3',isLeaf:true}, |
|
|
|
|
{title: '联系电话',key: '4',isLeaf:true}, |
|
|
|
|
{title: '辖区中队',key: '5',isLeaf:true}, |
|
|
|
|
{title: '单位地址',key: '6',isLeaf:true} |
|
|
|
|
{name: '统一社会信用代码',key: '1',isLeaf:true}, |
|
|
|
|
{name: '单位类型',key: '2',isLeaf:true}, |
|
|
|
|
{name: '联系人',key: '3',isLeaf:true}, |
|
|
|
|
{name: '联系电话',key: '4',isLeaf:true}, |
|
|
|
|
{name: '辖区中队',key: '5',isLeaf:true}, |
|
|
|
|
{name: '单位地址',key: '6',isLeaf:true} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '建筑信息', |
|
|
|
|
name: '建筑信息', |
|
|
|
|
key: '0-1', |
|
|
|
|
type:'基本信息', |
|
|
|
|
expanded: true, |
|
|
|
|
zIndex : '0', |
|
|
|
|
itemScore: 0, |
|
|
|
|
sumScore: 0, |
|
|
|
|
children: [ |
|
|
|
|
{ title: '面积', key: '0-1-0-0',isLeaf:true}, |
|
|
|
|
{ title: '高度', key: '0-1-0-1',isLeaf:true}, |
|
|
|
|
{ title: '层数', key: '0-1-0-2',isLeaf:true} |
|
|
|
|
{ name: '面积', key: '0-1-0-0',isLeaf:true}, |
|
|
|
|
{ name: '高度', key: '0-1-0-1',isLeaf:true}, |
|
|
|
|
{ name: '层数', key: '0-1-0-2',isLeaf:true} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
],aroundScore:0,aroundNodes :[ |
|
|
|
|
],aroundScore:0,aroundItemScore:0,aroundNodes :[ |
|
|
|
|
{ |
|
|
|
|
title: '单位四周毗邻', |
|
|
|
|
name: '单位四周毗邻', |
|
|
|
|
key: '11', |
|
|
|
|
expanded: true, |
|
|
|
|
zIndex : '0', |
|
|
|
|
itemScore: 0, |
|
|
|
|
sumScore: 0, |
|
|
|
|
type:'四周毗邻', |
|
|
|
|
children: [ |
|
|
|
|
{title: '东方向',key: '55',isLeaf:true}, |
|
|
|
|
{name: '东方向',key: '55',isLeaf:true}, |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '建筑四周毗邻', |
|
|
|
|
name: '建筑四周毗邻', |
|
|
|
|
key: '22', |
|
|
|
|
expanded: true, |
|
|
|
|
zIndex : '0', |
|
|
|
|
itemScore: 0, |
|
|
|
|
sumScore: 0, |
|
|
|
|
type:'四周毗邻', |
|
|
|
|
children: [ |
|
|
|
|
{title: '东方向',key: '55',isLeaf:true}, |
|
|
|
|
{name: '东方向',key: '55',isLeaf:true}, |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
]}, |
|
|
|
|
{name:'富丽华大酒店2',score:0,basicInfoScore:0} |
|
|
|
|
// {name:'富丽华大酒店2',score:0,basicInfoScore:0}
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
unitId:any = [{name:'富丽华大酒店1'}] |
|
|
|
|
//获取单位数据
|
|
|
|
|
getUnitData(){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//阻止input事件冒泡
|
|
|
|
|
stopPropagation($event){ |
|
|
|
|
console.log($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} |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
|
|
|
|
|
defaultExpandedKeys = []; //展开指定的树节点 key值
|
|
|
|
|
defaultSelectedKeys = []; //指定选中的树节点 key值
|
|
|
|
|
|
|
|
|
|
examScore:any = 0//整个试卷的总分
|
|
|
|
|
|
|
|
|
|
calculateScore(key){//计算分数
|
|
|
|
|
//key代表第几个建筑
|
|
|
|
|
//计算当前建筑基本信息分数
|
|
|
|
|
var basicInfoScore = 0 |
|
|
|
|
this.unitDatas[key].basicInfoNodes.forEach(element => { |
|
|
|
|
basicInfoScore += Number(element.sumScore)
|
|
|
|
|
}) |
|
|
|
|
this.unitDatas[key].basicInfoScore = basicInfoScore |
|
|
|
|
//计算当前建筑四周毗邻分数
|
|
|
|
|
var aroundScore = 0 |
|
|
|
|
this.unitDatas[key].aroundNodes.forEach(element => { |
|
|
|
|
aroundScore += Number(element.sumScore)
|
|
|
|
|
}) |
|
|
|
|
this.unitDatas[key].aroundScore = aroundScore |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计算分数
|
|
|
|
|
calculateScore(key){ |
|
|
|
|
//key代表第几个建筑
|
|
|
|
|
//计算整个单位的总分
|
|
|
|
|
var unitScore = 0 |
|
|
|
|
this.unitDatas[key].score = basicInfoScore + aroundScore + 0 |
|
|
|
|
|
|
|
|
|
this.unitDatas[key].score = this.unitDatas[key].basicInfoScore + this.unitDatas[key].aroundScore |
|
|
|
|
|
|
|
|
|
//计算整个试卷的总分
|
|
|
|
|
let examScore = 0 |
|
|
|
@ -121,51 +114,67 @@ export class CreateTestScoreComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
//tree的选择事件
|
|
|
|
|
nzEvent(event: NzFormatEmitEvent,key): void { |
|
|
|
|
if(event.node.level == 0){//如果点击第一层
|
|
|
|
|
let itemTrue = [] |
|
|
|
|
event.node.origin.children.forEach(item => { |
|
|
|
|
if(item.checked){ |
|
|
|
|
itemTrue.push(item) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
event.node.origin.sumScore = event.node.origin.itemScore * itemTrue.length |
|
|
|
|
|
|
|
|
|
this.calculateScore(key)//更新标题栏分数
|
|
|
|
|
|
|
|
|
|
if(event.node.origin.type == '基本信息' || (event.node.parentNode && event.node.parentNode.origin.type == '基本信息')){ |
|
|
|
|
let selectedNum = [] |
|
|
|
|
this.unitDatas[key].basicInfoNodes.forEach(item => { |
|
|
|
|
item.children.forEach(i => { |
|
|
|
|
i.checked ? selectedNum.push(i) : '' |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
if(selectedNum.length != 0 ){ |
|
|
|
|
this.unitDatas[key].basicInfoScore ? this.unitDatas[key].basicInfoItemScore = this.unitDatas[key].basicInfoScore / selectedNum.length : null |
|
|
|
|
}else{ |
|
|
|
|
let itemTrue = [] |
|
|
|
|
event.node.parentNode.origin.children.forEach(item => { |
|
|
|
|
if(item.checked){ |
|
|
|
|
itemTrue.push(item) |
|
|
|
|
this.unitDatas[key].basicInfoItemScore = 0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(event.node.origin.type == '四周毗邻' || (event.node.parentNode && event.node.parentNode.origin.type == '四周毗邻')){ |
|
|
|
|
let selectedNum = [] |
|
|
|
|
this.unitDatas[key].aroundNodes.forEach(item => { |
|
|
|
|
item.children.forEach(i => { |
|
|
|
|
i.checked ? selectedNum.push(i) : '' |
|
|
|
|
}) |
|
|
|
|
event.node.parentNode.origin.sumScore = event.node.parentNode.origin.itemScore * itemTrue.length |
|
|
|
|
this.calculateScore(key)//更新标题栏分数
|
|
|
|
|
}) |
|
|
|
|
console.log(7894,selectedNum) |
|
|
|
|
if(selectedNum.length != 0 ){ |
|
|
|
|
this.unitDatas[key].aroundScore ? this.unitDatas[key].aroundItemScore = this.unitDatas[key].aroundScore / selectedNum.length : null |
|
|
|
|
}else{ |
|
|
|
|
this.unitDatas[key].aroundItemScore = 0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//单位各项总分数动态计算
|
|
|
|
|
sumScore(type,key){ |
|
|
|
|
//key代表第几个建筑 type代表哪个部分
|
|
|
|
|
if(type == '基本信息'){ |
|
|
|
|
let selectedNum = 0 |
|
|
|
|
this.unitDatas[key].basicInfoNodes.forEach(item => { |
|
|
|
|
item.children.forEach(i => { |
|
|
|
|
i.checked ? selectedNum++ : '' |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
if(selectedNum != 0){ |
|
|
|
|
this.unitDatas[key].basicInfoItemScore = this.unitDatas[key].basicInfoScore / selectedNum |
|
|
|
|
}else{ |
|
|
|
|
this.unitDatas[key].basicInfoItemScore = 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//每项分数动态计算
|
|
|
|
|
itemScore(node,key){ |
|
|
|
|
let itemTrue = [] |
|
|
|
|
node.origin.children.forEach(item => { |
|
|
|
|
if(item.checked){ |
|
|
|
|
itemTrue.push(item) |
|
|
|
|
} |
|
|
|
|
if(type == '四周毗邻'){ |
|
|
|
|
let selectedNum = 0 |
|
|
|
|
this.unitDatas[key].aroundNodes.forEach(item => { |
|
|
|
|
item.children.forEach(i => { |
|
|
|
|
i.checked ? selectedNum++ : '' |
|
|
|
|
}) |
|
|
|
|
node.origin.sumScore = node.origin.itemScore * itemTrue.length |
|
|
|
|
this.calculateScore(key)//更新标题栏分数
|
|
|
|
|
}) |
|
|
|
|
if(selectedNum != 0){ |
|
|
|
|
this.unitDatas[key].aroundItemScore = this.unitDatas[key].aroundScore / selectedNum |
|
|
|
|
}else{ |
|
|
|
|
this.unitDatas[key].aroundItemScore = 0 |
|
|
|
|
} |
|
|
|
|
//总分数动态计算
|
|
|
|
|
sumScore(node,key){ |
|
|
|
|
//key代表第几个建筑
|
|
|
|
|
let itemTrue = [] |
|
|
|
|
node.origin.children.forEach(item => { |
|
|
|
|
if(item.checked){ |
|
|
|
|
itemTrue.push(item) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
node.origin.itemScore = node.origin.sumScore / itemTrue.length |
|
|
|
|
this.calculateScore(key)//更新标题栏分数
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -258,7 +267,15 @@ export class AddPlanTwoDialog {
|
|
|
|
|
onNoClick(): void { |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
} |
|
|
|
|
//确定
|
|
|
|
|
confirm(){ |
|
|
|
|
if(this.planType == 1){ |
|
|
|
|
console.log(this.selection) |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//取消
|
|
|
|
|
close(){ |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
} |
|
|
|
|