上海预案管理平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

963 lines
32 KiB

/*
* @Descripttion:
* @version:
* @Author: sueRimn
* @Date: 2021-05-31 10:40:01
* @LastEditors: sueRimn
* @LastEditTime: 2021-08-04 15:30:24
*/
import { Component, Inject, OnInit,ViewEncapsulation } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {FlatTreeControl, NestedTreeControl} from '@angular/cdk/tree';
import {MatTreeFlatDataSource, MatTreeFlattener, MatTreeNestedDataSource} from '@angular/material/tree';
@Component({
selector: 'app-plan-template',
//encapsulation: ViewEncapsulation.None,
templateUrl: './plan-template.component.html',
styleUrls: ['./plan-template.component.scss']
})
export class PlanTemplateComponent implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) {
}
ngOnInit(): void {
this.getLeftdata()
this.tree = {
json:this.treedate,
config: this.treeConfig
};
}
groupPanle=true//分组展开
attPanle=true
//获取所有单位信息
newleftTabledata=[
/* {planCategory:3,basicCategoryId:"5e7c49e861550e2754d461ce",buildingTypeId: "5e7c8ffba3050b1a840ed4b6",unitname:'高层建筑',data:[]},
{planCategory:5,basicCategoryId:"60127efe2757e904e5721d83",buildingTypeId: "5e7c9018a3050b1a840ed4b7",unitname:'地下建筑',data:[]} */
]
//树形结构数据
treedate=[
{
"guid": "bc4c7a02-5379-4046-92be-12c67af4295a",
"displayName": "Elentrix",
"children": [
/* "85d412c2-ebc1-4d56-96c9-7da433ac9bb2",
"28aac445-83b1-464d-9695-a4157dab6eac" */
]
}
]
tree
treeConfig = {
nodeWidth: 90,
nodeHeight: 60
};
group=[]
getLeftdata(){
this.http.get("/api/PlanTemplate").subscribe((data:any)=>{
this.newleftTabledata=data
this.newleftTabledata.forEach((value,index,array)=>{
value.data= JSON.parse(value.data)
})
console.log(this.newleftTabledata)
this.http.get("/api/BuildingTypes").subscribe((buildData:any)=>{
this.newleftTabledata.forEach((value,index,array)=>{
buildData.forEach((element,i,buildArray) => {
if(value.buildingTypeId==element.id){
array[index].unitname=buildArray[i].name
array[index].facilityCategoryId=buildArray[i].facilityCategoryId
}
});
})
})
})
}
//新建模板弹窗
addKeyunit(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
const dialogRef = this.dialog.open(addPlanname, {//调用open方法打开对话框并且携带参数过去
width: '340px',
height:'340px',
disableClose:true,
data:{plandata:this.newleftTabledata}
});
dialogRef.afterClosed().subscribe(result => {
//console.log(result)
if(result!=undefined){
this.newleftTabledata.push(result)
let savaData={
basicCategoryId:result.basicCategoryId,
buildingTypeId:result.buildingTypeId,
planCategory:Number(result.planCategory),
data:null
}
this.http.post("/api/PlanTemplate",savaData).subscribe((data:any)=>{
this.newleftTabledata[this.newleftTabledata.length-1].id=''
this.newleftTabledata[this.newleftTabledata.length-1].id=data.id
//console.log(data,this.newleftTabledata)
this.snackBar.open('创建成功!','确定',config);
})
}
//console.log(this.newleftTabledata)
});
}
//删除模板
deletePlan(id,i){
console.log(id)
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
let isTrue = confirm('您确定要删除该模板吗')
if(isTrue){
if(id!=undefined){
this.http.delete(`/api/PlanTemplate/${id}`).subscribe((data:any)=>{
this.snackBar.open('删除模板成功!','确定',config);
this.newleftTabledata.splice(i,1)
})
}
else{
this.newleftTabledata.splice(i,1)
}
}
}
//修改模板
async upPlan(item,i,operation){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
const dialogRef = this.dialog.open(upPlanname, {//调用open方法打开对话框并且携带参数过去
width: '340px',
height:'340px',
disableClose:true,
data:{item:item,plandata:this.newleftTabledata}
});
dialogRef.afterClosed().subscribe(async result => {
console.log(result)
if(result!=undefined){
//this.newleftTabledata[i].name=result.name
if(operation=='edit'){
this.newleftTabledata[i].basicCategoryId=result.basicCategoryId
this.newleftTabledata[i].planCategory=result.planCategory
this.newleftTabledata[i].buildingTypeId=result.buildingTypeId
this.newleftTabledata[i].unitname=result.unitname
let body={
id:this.Id,
basicCategoryId:result.basicCategoryId,
buildingTypeId:result.buildingTypeId,
planCategory:Number(result.planCategory),
data:JSON.stringify(this.newleftTabledata[this.leftclicki].data)
}
this.http.put(`/api/PlanTemplate/${this.Id}`,body).subscribe((data:any)=>{
this.snackBar.open('修改成功!','确定',config);
console.log(data)
})
}else{
/* let newdata={
basicCategoryId:result.basicCategoryId,
buildingTypeId:result.buildingTypeId,
data:item.data,
planCategory:result.planCategory,
unitname:result.unitname
}
this.newleftTabledata.push(newdata) */
let savaData={
basicCategoryId:result.basicCategoryId,
buildingTypeId:result.buildingTypeId,
planCategory:Number(result.planCategory),
data:null
}
let aaa = await new Promise((resolve, reject)=>{
delete this.newleftTabledata[this.leftclicki].data[0].attribute[1].attinf
delete this.newleftTabledata[this.leftclicki].data[0].attribute[3].attinf
this.http.post("/api/PlanTemplate",savaData).subscribe((data:any)=>{
this.newleftTabledata[this.newleftTabledata.length-1].id=''
this.newleftTabledata[this.newleftTabledata.length-1].id=data.id
let body={
id:data.id,
basicCategoryId:result.basicCategoryId,
buildingTypeId:result.buildingTypeId,
planCategory:Number(result.planCategory),
data:JSON.stringify(this.newleftTabledata[this.leftclicki].data)
}
this.http.put(`/api/PlanTemplate/${data.id}`,body).subscribe((data:any)=>{
resolve(data)
this.snackBar.open('复制成功!','确定',config);
})
//this.getLeftdata()
})
})
this.getLeftdata()
}
}
console.log(this.newleftTabledata)
});
}
//左侧预案模板点击事件
Id
planCategory
buildingTypeId
unitName
leftclicki=-1//点了第几个模板
planClick(item){
this.Id=item.id
this.planCategory=item.planCategory
this.unitName=item.unitname
this.buildingTypeId=item.buildingTypeId
this.newleftTabledata.forEach((value,index,array)=>{
if(array[index].buildingTypeId==this.buildingTypeId&&array[index].planCategory==this.planCategory){
this.leftclicki=index
this.group=array[this.leftclicki].data
}
})
//console.log(item,this.leftclicki)
}
//右侧新增分组点击事件
addGroupClick(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.unitName==undefined){
this.snackBar.open('请选择预案模板!','确定',config);
}else{
/* this.newleftTabledata.forEach((value,index,array)=>{
if(array[index].buildingTypeId==this.buildingTypeId){
this.group=array[index].data
}
}) */
const dialogRef = this.dialog.open(addGroup, {//调用open方法打开对话框并且携带参数过去
width: '240px',
height:'620px',
disableClose:true,
data:this.newleftTabledata[this.leftclicki].data==null?null:this.newleftTabledata[this.leftclicki].data==0?null:this.newleftTabledata[this.leftclicki].data
});
dialogRef.afterClosed().subscribe(result => {
console.log(result,this.newleftTabledata)
this.newleftTabledata.forEach((value,index,array)=>{
if(array[index].buildingTypeId==this.buildingTypeId&&array[index].planCategory==this.planCategory){
if(result!=undefined){
result.forEach((valuer,i,rarr) => {
//添加分组名称
if(array[index].data==null||array[index].data.length==0){
array[index].data=result
}else{
array[index].data[i].completed=rarr[i].completed
}
});
}
this.group=array[index].data
}
//console.log(this.group)
})
});
}
console.log(this.newleftTabledata)
}
//删除分组
deleteGroup(groupName){
//console.log(this.group)
let isTrue = confirm('您确定要删除分组吗')
if(isTrue){
this.group.forEach((element,index,array)=>{
if(array[index].groupName==groupName){
this.group.splice(index,1)
}
})
}
this.newleftTabledata[this.leftclicki].data=this.group
}
//新增属性
groupName
addAttribute(groupName){
this.groupPanle=true
this.groupName=groupName
if(groupName=='单位概况'){
const dialogRef = this.dialog.open(adddwsurvey, {//调用open方法打开对话框并且携带参数过去
width: '240px',
height:'420px',
disableClose:true,
data:this.group
});
dialogRef.afterClosed().subscribe(result => {
console.log(result)
if(result!=undefined){
this.group.forEach((value,index,array)=>{
if(array[index].groupName=='单位概况'){
result.forEach((valuer,i,rarr) => {
//添加分组名称
if(array[index].attribute==null){
array[index].attribute=result
}else{
array[index].attribute[i].completed=rarr[i].completed
}
});
//array[index].attribute=result
}
})
}
//console.log(this.newleftTabledata)
});
}else{
const dialogRef = this.dialog.open(disaster, {//调用open方法打开对话框并且携带参数过去
width: '340px',
height:'450px',
disableClose:true,
data:this.group
});
dialogRef.afterClosed().subscribe(result => {
console.log(result)
if(result!=undefined){
this.group.forEach((value,index,array)=>{
if(array[index].groupName==groupName){
if(array[index].attribute==undefined){
array[index].attribute=[]
array[index].attribute.push(result)
}else{
array[index].attribute.push(result)
}
if(result.level==2){
for(var i=0;i<result.hNumber;i++){
array[index].attribute[array[index].attribute.length-1].tableth.push([{head:'',body:''}])
for(var j=0;j<result.lieNumber-1;j++){
array[index].attribute[array[index].attribute.length-1].tableth[i].push({head:'',body:''})
}
}
}
}
})
}
console.log(this.newleftTabledata)
});
}
}
//删除具体属性
delAttribute(groupName,surveyName){
let isTrue = confirm('您确定要删除吗')
if(isTrue){
this.group.forEach((value,index,array)=>{
if (array[index].groupName==groupName) {
array[index].attribute.forEach((element,i) => {
if(element.surveyName==surveyName){
array[index].attribute[i].completed=false
}
});
}
})
}
this.newleftTabledata[this.leftclicki].data=this.group
console.log(this.newleftTabledata)
}
//新增属性信息
danweiInfTable=[]
addAttInfo(surveyName){
if(surveyName=='进攻通道'){
if(this.group[0].attribute[4].attinf==undefined){
this.group[0].attribute[4].attinf=[]
this.group[0].attribute[4].attinf.push({head:'',tableth:[],completed:true})
}else{
this.group[0].attribute[4].attinf.push({head:'',tableth:[],completed:true})
}
}else{
this.attPanle=true
const dialogRef = this.dialog.open(addattinf, {//调用open方法打开对话框并且携带参数过去
width: '240px',
height:'400px',
disableClose:true,
data:{newleftTabledata:this.newleftTabledata,surveyName:surveyName,leftclicki:this.leftclicki}
});
dialogRef.afterClosed().subscribe(result => {
console.log(result)
if(result!=undefined){
this.newleftTabledata[this,this.leftclicki].data.forEach((value,index,array)=>{
if(value.groupName=='单位概况'){
array[index].attribute.forEach((element,i,attary) => {
if(element.surveyName==surveyName){
attary[i].attinf=result
}
});
}
})
this.group=this.newleftTabledata[this,this.leftclicki].data
//console.log(this.danweiInfTable)
}
console.log(this.newleftTabledata)
});
}
}
//删除属性信息
delAttInfo(groupName,surveyName,propertyName){
let isTrue = confirm('您确定要删除该条信息吗')
if(isTrue){
this.group.forEach((value,index,array)=>{
if (array[index].groupName==groupName) {
array[index].attribute.forEach((element,i,attarr) => {
if(element.surveyName==surveyName){
//array[index].attribute[i].completed=false
attarr[i].attinf.forEach((attinfValue,attinfi,attinfarr) => {
if(attinfValue.propertyName==propertyName){
attinfarr[attinfi].completed=false
}
});
}
});
}
})
}
this.newleftTabledata[this.leftclicki].data=this.group
console.log(this.newleftTabledata)
}
//消防设施表格具体属性编辑
fileAdd(facilityItems,filei){
if(facilityItems.length!=0){
const dialogRef = this.dialog.open(addattinf, {//调用open方法打开对话框并且携带参数过去
width: '240px',
height:'400px',
disableClose:true,
data:{facilityItems:facilityItems}
});
dialogRef.afterClosed().subscribe(result => {
console.log(result)
if(result!=undefined){
this.newleftTabledata[this,this.leftclicki].data.forEach((value,index,array)=>{
if(value.groupName=='单位概况'){
array[index].attribute.forEach((element,i,attary) => {
if(element.surveyName=='消防设施'){
attary[i].attinf[filei].facilityItems=result
}
});
}
})
this.group=this.newleftTabledata[this,this.leftclicki].data
}
console.log(this.newleftTabledata)
});
}
}
//消防设施表格具体属性删除
fileDel(i,f){
let isTrue = confirm('您确定要删除该条信息吗')
if(isTrue){
this.group[0].attribute[3].attinf[i].facilityItems[f].completed=false
}
}
//进攻通道
//进攻通道,灾情设定及其他增加表格数据
attackAdd(name,i,level){
//console.log(name,i)
if(name=='进攻通道'){
this.group[0].attribute[4].attinf[i].tableth.push('')
}else{
this.group.forEach((value,index,array)=>{
if (array[index].groupName==name) {
if(level==1){
this.group[index].attribute[i].tableth.push('')
}else if(level==2){
this.group[index].attribute[i].tableth.push({head:'',body:''})
}
}
})
}
console.log(this.newleftTabledata)
}
//进攻通道,消防设施一级菜单删除
delattAndfileOne(groupName,surveyName,indexOne){
let isTrue = confirm('您确定要删除该条信息吗')
if(isTrue){
this.group.forEach((value,index,array)=>{
if (array[index].groupName==groupName) {
array[index].attribute.forEach((element,i,attarr) => {
if(element.surveyName==surveyName){
if(surveyName=='消防设施'){
element.attinf[indexOne].completed=false
}
else{
element.attinf.splice(indexOne,1)
}
}
});
}
})
}
this.newleftTabledata[this.leftclicki].data=this.group
console.log(this.newleftTabledata)
}
//input key值,一个字符焦点消失问题
trackByFn(index){
return index
}
//灾情设定及其他删除一条
delDisaster(name,i){
let isTrue = confirm('您确定要删除该条信息吗')
if(isTrue){
this.group.forEach((value,index,array)=>{
if (array[index].groupName==name) {
this.group[index].attribute.splice(i,1)
}
})
}
}
//保存
save(){
console.log(this.newleftTabledata)
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
let body={
id:this.Id,
basicCategoryId:this.newleftTabledata[this.leftclicki].basicCategoryId,
buildingTypeId:this.newleftTabledata[this.leftclicki].buildingTypeId,
planCategory:Number(this.newleftTabledata[this.leftclicki].planCategory),
data:JSON.stringify(this.newleftTabledata[this.leftclicki].data)
}
console.log(`ary`, this.newleftTabledata, `key:`, this.leftclicki)
if(this.newleftTabledata[this.leftclicki].id==undefined){
/* this.http.post("/api/PlanTemplate",this.newleftTabledata[this.leftclicki]).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
console.log(data)
}) */
this.snackBar.open('请先创建模板!','确定',config);
}
else{
this.http.put(`/api/PlanTemplate/${this.Id}`,body).subscribe((data:any)=>{
this.snackBar.open('保存成功!','确定',config);
console.log(data)
})
}
}
//单位基本信息和建筑信息表格
displayedColumns: string[] = ['name','level','default','must', 'danwei','operation'];
}
//新建预案
@Component({
selector: 'addPlanname',
templateUrl: './addKeyname.html',
styleUrls: ['./addKeyname.scss']
})
export class addPlanname{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<addPlanname>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
planname//预案名称
level//预案级别
unitid//单位类型id
unitname//单位类型名称
allunittype//所有单位信息
basicCategoryId
facilityCategoryId//消防设施id
ngOnInit(): void {
this.getUnittype()
}
//获取单位类型
getUnittype(){
this.http.get("/api/BuildingTypes").subscribe((data:any)=>{
this.allunittype=data
console.log(this.allunittype)
})
}
//取消按钮
close(){
this.dialogRef.close();
}
newplan(){
this.unitname=document.getElementById('unit').innerText
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.level==undefined||this.level==''){
this.snackBar.open('请选择预案级别!','确定',config);
}else if(this.unitid==undefined||this.unitid==''){
this.snackBar.open('请选择单位类型!','确定',config);
}
else{
for(var i=0;i<this.data.plandata.length;i++){
if(this.data.plandata[i].buildingTypeId==this.unitid&&this.data.plandata[i].planCategory==this.level){
this.snackBar.open('预案模板重复请重新建立预案模板!','确定',config);
this.planname==''
this.level==''
this.unitid==''
this.unitname==''
return
}
}
this.allunittype.forEach(element => {
if(element.id==this.unitid){
this.basicCategoryId=element.basicCategoryId
this.facilityCategoryId=element.facilityCategoryId
}
});
let planData={
//name:this.planname,
planCategory:this.level,
buildingTypeId:this.unitid,
unitname:this.unitname,
basicCategoryId:this.basicCategoryId,
facilityCategoryId:this.facilityCategoryId,
data:[]
}
this.dialogRef.close(planData)
}
}
}
//修改预案名称和级别
@Component({
selector: 'upPlanname',
templateUrl: './upPlan.html',
styleUrls: ['./addKeyname.scss']
})
export class upPlanname{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<upPlanname>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
name//预案名称
level=this.data.item.planCategory//预案级别
unitName=this.data.item.unitname//单位类型
unitid=this.data.item.buildingTypeId
allunittype
basicCategoryId
ngOnInit(): void{
this.level=String(this.data.item.planCategory)
console.log(this.level)
this.getUnittype()
}
//获取单位类型
getUnittype(){
this.http.get("/api/BuildingTypes").subscribe((data:any)=>{
this.allunittype=data
//console.log(this.allunittype)
})
}
//取消按钮
close(){
this.dialogRef.close();
}
//确定按钮
upplan(){
this.unitName=document.getElementById('unit').innerText
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
/* if(this.name==undefined||this.name==''){
this.snackBar.open('请输入预案名称!','确定',config);
} */
if(this.level!=this.data.item.planCategory||this.unitid!=this.data.item.buildingTypeId){
//this.snackBar.open('请输入预案级别!','确定',config);
for(var i=0;i<this.data.plandata.length;i++){
if(this.data.plandata[i].buildingTypeId==this.unitid&&this.data.plandata[i].planCategory==this.level){
this.snackBar.open('预案模板重复请重新建立预案模板!','确定',config);
this.name==''
this.level==''
this.unitid==''
this.unitName==''
return
}
}
this.allunittype.forEach(element => {
if(element.id==this.unitid){
this.basicCategoryId=element.basicCategoryId
}
});
let planData={
//name:this.name,
planCategory:this.level,
buildingTypeId:this.unitid,
basicCategoryId:this.basicCategoryId,
unitname:this.unitName
}
this.dialogRef.close(planData)
}
}
}
//新增分组
@Component({
selector: 'addGroup',
templateUrl: './addgroup.html',
styleUrls: ['./addgroup.scss']
})
export class addGroup{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<addGroup>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
addgtoup=[
{groupName:'单位概况',completed:false},{groupName:'灾情设定',completed:false},{groupName:'力量调集',completed:false},
{groupName:'组织指挥',completed:false},{groupName:'作战行动',completed:false},{groupName:'社会联动',completed:false},
{groupName:'勤务保障',completed:false},{groupName:'特别警示',completed:false},{groupName:'辅助决策',completed:false},
{groupName:'交通水源',completed:false},{groupName:'重点图示',completed:false},{groupName:'处置要点',completed:false},
{groupName:'预案附件',completed:false}
]
groupName=[]
ngOnInit(): void{
console.log(this.data)
if(this.data!=null){
//this.addgtoup=this.data
this.data.forEach((datavalue,index,dataarr) => {
this.addgtoup.forEach((value,i,arr)=>{
if(dataarr[index].groupName==arr[i].groupName){
if(dataarr[index].completed==true&&arr[i].completed==false){
arr[i].completed= true
}
}
})
});
}
}
//取消按钮
close(){
this.dialogRef.close();
}
//复选框点击事件
clicki
checkClick(){
//this.clicki=i
//console.log(e,item)
/* if (e.checked) {
this.groupName.push(item)
}else {
this.groupName.forEach((value,index,array)=>{
if(value==item){
this.groupName.splice(index,1)
}
})
} */
console.log(this.data)
}
//确定提交
newGroup(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.addgtoup.forEach((value,index,arraay)=>{
if(arraay[index].completed){
this.groupName.push(arraay[index].groupName)
}
})
for(var i=0;i<this.groupName.length;i++){
for(var j=i+1;j<this.groupName.length;j++){
if(this.groupName[i]==this.groupName[j]){
this.groupName.splice(j,1)
}
}
}
this.dialogRef.close(this.addgtoup)
}
}
//单位概况新增弹窗
@Component({
selector: 'adddwsurvey',
templateUrl: './dwsurvey.html',
styleUrls: ['./addgroup.scss']
})
export class adddwsurvey{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<adddwsurvey>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
addwsurvey=[
{surveyName:'单位基本信息',completed:false},{surveyName:'建筑信息',completed:false},
{surveyName:'四周毗邻',completed:false,attinf:[{name:'东',value:''},{name:'西',value:''},{name:'南',value:''},{name:'北',value:''}]},
{surveyName:'消防设施',completed:false},{surveyName:'进攻通道',completed:false},
{surveyName:'重点部位',completed:false,attinf:[{heafName:'',body:[{name:'重点部位名称',value:''},{name:'重点部位所在位置',value:''},{name:'建筑结构',value:''},{name:'使用性质',value:''},{name:'主要危险性',value:''}]}]},
{surveyName:'功能分区',completed:false,attinf:[{name:'',value:''}]}
]
ngOnInit(): void{
console.log(this.data)
this.data.forEach(element => {
if(element.groupName=='单位概况'&&element.attribute!=undefined){
//this.addwsurvey=element.attribute
element.attribute.forEach((datavalue,index,dataarr) => {
this.addwsurvey.forEach((value,i,arr)=>{
if(dataarr[index].surveyName==arr[i].surveyName){
if(dataarr[index].completed==true&&arr[i].completed==false){
arr[i].completed= dataarr[index].completed
}
}
})
});
}
});
}
//取消按钮
close(){
this.dialogRef.close(undefined);
}
//确定按钮
defineClick(){
this.dialogRef.close(this.addwsurvey)
}
}
//编辑单位概况单位基本信息属性信息弹窗
@Component({
selector: 'addattinf',
templateUrl: './addattinf.html',
styleUrls: ['./addgroup.scss']
})
export class addattinf{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<addattinf>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
addAttinf=[
{propertyName:'统一社会信用代码',completed:false,propertyType:0,value:'',olddata:''},
{propertyName:'单位类型',completed:false,propertyType:0,value:'',olddata:''},
{propertyName:'联系人',completed:false,propertyType:0,value:'',olddata:''},
{propertyName:'联系电话',completed:false,propertyType:0,value:'',olddata:''},
{propertyName:'辖区中队',completed:false,propertyType:0,value:'',olddata:''},
{propertyName:'单位地址',completed:false,propertyType:0,value:'',olddata:''},
/* {propertyName:'单位照片',completed:false,propertyType:0,value:''} *///,default:'-',must:'是',danwei:'-'
]
addAttinfBuild
addAttinfFile
facilityItems
ngOnInit(): void{
console.log(this.data)
this.getattinf()
}
//获取弹窗信息
getattinf(){
if(this.data.facilityItems==undefined){
this.data.newleftTabledata[this.data.leftclicki].data.forEach(element => {
if(element.groupName=='单位概况'&&element.attribute!=undefined){
element.attribute.forEach(value => {
if(value.surveyName=='单位基本信息'&&value.attinf!=undefined){
//this.addAttinf=value.attinf
value.attinf.forEach((datavalue,index,dataarr) => {
this.addAttinf.forEach((value,i,arr)=>{
if(dataarr[index].propertyName==arr[i].propertyName){
if(dataarr[index].completed==true&&arr[i].completed==false){
arr[i].completed= dataarr[index].completed
arr[i].olddata=dataarr[index].value
}
}
})
});
}/* else if(value.surveyName=='单位基本信息'&&value.attinf==undefined){
this.addAttinf.forEach((data)=>{
data.olddata=data.value
})
} */
else if(value.surveyName=='建筑信息'&&value.attinf==undefined){
let paramsdata:any ={
categoryId:this.data.newleftTabledata[this.data.leftclicki].basicCategoryId
}
this.http.get("/api/BasicGroups",{params:paramsdata}).subscribe((data:any)=>{
this.addAttinfBuild=data[0].propertyInfos
this.addAttinfBuild.forEach(element => {
element.completed=false
element.olddata=element.propertyValue
});
console.log(this.addAttinfBuild)
})
}else if(value.surveyName=='建筑信息'&&value.attinf!=undefined){
this.addAttinfBuild=value.attinf
/* console.log(this.addAttinfBuild)
value.attinf.forEach((datavalue,index,dataarr) => {
this.addAttinfBuild.forEach((value,i,arr)=>{
if(dataarr[index].propertyName==arr[i].propertyName){
if(dataarr[index].completed==true&&arr[i].completed==false){
arr[i].completed= dataarr[index].completed
}
}
})
}); */
}else if(value.surveyName=='消防设施'&&value.attinf==undefined){
let paramsdata:any ={
categoryId:this.data.newleftTabledata[this.data.leftclicki].facilityCategoryId
}
this.http.get("/api/FacilityGroups",{params:paramsdata}).subscribe((data:any)=>{
console.log(data)
this.addAttinfFile=data
this.addAttinfFile.forEach(element => {
element.completed=false
element.value=''
});
console.log(this.addAttinfFile)
})
}else if(value.surveyName=='消防设施'&&value.attinf!=undefined){
this.addAttinfFile=value.attinf
}
});
}
});
}else{
this.facilityItems=this.data.facilityItems
console.log(this.facilityItems)
/* this.facilityItems.forEach(element => {
element.completed=false
}); */
}
}
//取消按钮
close(){
this.dialogRef.close();
}
//确定按钮
defineClick(){
this.dialogRef.close(this.data.surveyName=='单位基本信息'?this.addAttinf:this.data.surveyName=='建筑信息'?
this.addAttinfBuild:this.data.surveyName=='消防设施'?this.addAttinfFile:this.facilityItems)
}
}
//灾情设定弹窗
@Component({
selector: 'disaster',
templateUrl: './Disaster.html',
styleUrls: ['./addKeyname.scss']
})
export class disaster{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<disaster>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
ngOnInit(): void{
console.log(this.data)
}
level//类型
headName//表头名称
lieNumber//列数
hNumber//行数
//取消按钮
close(){
this.dialogRef.close();
}
//确定按钮
newdisaster(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.level==undefined||this.level==''){
this.snackBar.open('请选择类型!','确定',config);
}else if(this.headName==undefined||this.headName==''){
this.snackBar.open('请输入表头名称!','确定',config);
}else{
let tree={
json:[],
name: ''
}
let attrubute={
headName:this.headName,
level:this.level,
tableth:this.level==1||this.level==2?[]:this.level==3?'':tree,
lieNumber:this.lieNumber,
hNumber:this.hNumber
}
this.dialogRef.close(attrubute);
}
}
}