@ -4,7 +4,7 @@
* @Author : sueRimn
* @Date : 2021 - 05 - 19 15 :50 : 20
* @LastEditors : sueRimn
* @LastEditTime : 2021 - 05 - 28 17 :11 : 44
* @LastEditTime : 2021 - 05 - 29 16 :50 : 13
* /
import { Component , Inject , OnInit } from '@angular/core' ;
import { HttpClient } from '@angular/common/http'
@ -21,30 +21,42 @@ export class PlanTemplateComponent implements OnInit {
constructor ( private http :HttpClient , public dialog : MatDialog , public snackBar : MatSnackBar ) { }
ngOnInit ( ) : void {
this . getLeftdata ( )
}
groupPanle = true //分组展开
attPanle = true
//获取所有单位信息
newleftTabledata = [
{ name : "333" , level :3 , basicCategoryId : "5e7c49e861550e2754d461ce" , unitid : "5e7c8ffba3050b1a840ed4b6" , unitname : '高层建筑' , group : [ ] } , //{groupName: "单位概况"}
{ name : "444" , level :5 , basicCategoryId : "60127efe2757e904e5721d83" , uniti d: "5e7c9018a3050b1a840ed4b7" , unitname : '地下建筑' , group : [ ] }
/ * { p l a n C a t e g o r y : 3 , b a s i c C a t e g o r y I d : " 5 e 7 c 4 9 e 8 6 1 5 5 0 e 2 7 5 4 d 4 6 1 c e " , b u i l d i n g T y p e I d : " 5 e 7 c 8 f f b a 3 0 5 0 b 1 a 8 4 0 e d 4 b 6 " , u n i t n a m e : ' 高 层 建 筑 ' , d a t a : [ ] } ,
{ planCategory :5 , basicCategoryId : "60127efe2757e904e5721d83" , buildingTypeI d: "5e7c9018a3050b1a840ed4b7" , unitname : '地下建筑' , data : [ ] } * /
]
group = [ ]
getLeftdata ( ) {
/ * t h i s . h t t p . g e t ( " / a p i / P l a n T e m p l a t e " ) . s u b s c r i b e ( ( d a t a : a n y ) = > {
this . leftTabledata = data
console . log ( this . leftTabledata )
} ) * /
this . http . get ( "/api/PlanTemplate" ) . subscribe ( ( data :any ) = > {
this . newleftTabledata = data
this . newleftTabledata . forEach ( ( value , index , array ) = > {
value . data = JSON . parse ( value . data )
} )
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
}
} ) ;
} )
} )
} )
}
//新建预案弹窗
//新建模板 弹窗
addKeyunit ( ) {
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
const dialogRef = this . dialog . open ( addPlanname , { //调用open方法打开对话框并且携带参数过去
width : '340px' ,
height : '380px' ,
height : '34 0px' ,
disableClose :true ,
data : { plandata :this.newleftTabledata }
} ) ;
@ -52,66 +64,88 @@ export class PlanTemplateComponent implements OnInit {
//console.log(result)
if ( result != undefined ) {
this . newleftTabledata . push ( result )
for ( var i = 0 ; i < this.newleftTabledata.length - 2 ; i + + ) {
if ( this . newleftTabledata [ i ] . name == result . name ) {
this . newleftTabledata . splice ( this . newleftTabledata . length - 1 , 1 )
}
let savaData = {
basicCategoryId :result.basicCategoryId ,
buildingTypeId :result.buildingTypeId ,
planCategory :Number ( result . planCategory ) ,
data :null
}
this . http . post ( "/api/PlanTemplate" , savaData ) . subscribe ( ( data :any ) = > {
this . snackBar . open ( '创建成功!' , '确定' , config ) ;
} )
}
//console.log(this.newleftTabledata)
} ) ;
}
//删除预案
deletePlan ( i ) {
let isTrue = confirm ( '您确定要删除该条预案吗' )
//删除模板
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 )
}
}
}
//修改预案名称和级别
//修改模板
upPlan ( item , i ) {
const dialogRef = this . dialog . open ( upPlanname , { //调用open方法打开对话框并且携带参数过去
width : '340px' ,
height : '38 0px' ,
height : '34 0px' ,
disableClose :true ,
data : { item :item , plandata :this.newleftTabledata }
} ) ;
dialogRef . afterClosed ( ) . subscribe ( result = > {
if ( result != undefined ) {
this . newleftTabledata [ i ] . name = result . name
this . newleftTabledata [ i ] . level = result . level
this . newleftTabledata [ i ] . unitid = result . unitid
//this.newleftTabledata[i].name=result.name
this . newleftTabledata [ i ] . basicCategoryId = result . basicCategoryId
this . newleftTabledata [ i ] . planCategory = result . planCategory
this . newleftTabledata [ i ] . buildingTypeId = result . buildingTypeId
this . newleftTabledata [ i ] . unitname = result . unitname
}
} ) ;
}
//左侧预案模板点击事件
planName
Id
planCategory
buildingTypeId
unitName
leftclicki = - 1 //点了第几个模板
planClick ( item ) {
//console.log(item)
this . planName = item . name
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 ] . unitname == this . unitName ) {
this . group = array [ index ] . group
if ( array [ index ] . buildingTypeId == this . buildingTypeId ) {
this . group = array [ index ] . data
this . leftclicki = index
}
} )
}
//右侧新增分组点击事件
addGroupClick ( ) {
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
if ( this . plan Name== undefined ) {
if ( this . unit Name== undefined ) {
this . snackBar . open ( '请选择预案模板!' , '确定' , config ) ;
} else {
this . newleftTabledata . forEach ( ( value , index , array ) = > {
if ( array [ index ] . name == this . planName ) {
this . group = array [ index ] . group
if ( array [ index ] . buildingTypeId == this . buildingTypeId ) {
this . group = array [ index ] . data
}
} )
const dialogRef = this . dialog . open ( addGroup , { //调用open方法打开对话框并且携带参数过去
@ -123,27 +157,15 @@ export class PlanTemplateComponent implements OnInit {
dialogRef . afterClosed ( ) . subscribe ( result = > {
//console.log(result,this.newleftTabledata)
this . newleftTabledata . forEach ( ( value , index , array ) = > {
if ( array [ index ] . name == this . planName ) {
if ( array [ index ] . buildingTypeId == this . buildingTypeId ) {
if ( result != undefined ) {
result . forEach ( ( valuer , i , rarr ) = > {
//console.log(valuer)
/ * l e t g r o u p N a m e = {
groupName :valuer
} * /
//添加分组名称
array [ index ] . group = rarr
array [ index ] . data = rarr
} ) ;
}
//去重
for ( var i = 0 ; i < array [ index ] .group.length ; i + + ) {
for ( var j = i + 1 ; j < array [ index ] .group.length ; j + + ) {
if ( array [ index ] . group [ i ] . groupName == array [ index ] . group [ j ] . groupName ) {
array [ index ] . group . splice ( j , 1 )
}
}
}
this . group = array [ index ] . group
this . group = array [ index ] . data
}
//console.log(this.group)
} )
@ -211,7 +233,7 @@ export class PlanTemplateComponent implements OnInit {
width : '240px' ,
height : '400px' ,
disableClose :true ,
data : { group :this.group , surveyName :surveyName }
data : { newleftTabledata :this.newleftTabledata , surveyName :surveyName , leftclicki :this.leftclicki }
} ) ;
dialogRef . afterClosed ( ) . subscribe ( result = > {
//console.log(result)
@ -221,7 +243,7 @@ export class PlanTemplateComponent implements OnInit {
array [ index ] . attribute = result
}
} ) * /
this . newleftTabledata [ this , this . leftclicki ] . group . forEach ( ( value , index , array ) = > {
this . newleftTabledata [ this , this . leftclicki ] . data . forEach ( ( value , index , array ) = > {
if ( value . groupName == '单位概况' ) {
array [ index ] . attribute . forEach ( ( element , i , attary ) = > {
if ( element . surveyName == surveyName ) {
@ -230,7 +252,7 @@ export class PlanTemplateComponent implements OnInit {
} ) ;
}
} )
this . group = this . newleftTabledata [ this , this . leftclicki ] . group
this . group = this . newleftTabledata [ this , this . leftclicki ] . data
//console.log(this.danweiInfTable)
}
console . log ( this . newleftTabledata )
@ -243,16 +265,26 @@ export class PlanTemplateComponent implements OnInit {
config . verticalPosition = 'top' ;
config . duration = 3000
let body = {
id :this.Id ,
basicCategoryId :this.newleftTabledata [ this . leftclicki ] . basicCategoryId ,
buildingTypeId :this.newleftTabledata [ this . leftclicki ] . uniti d,
planCategory :Number ( this . newleftTabledata [ this . leftclicki ] . level ) ,
data : { }
buildingTypeId :this.newleftTabledata [ this . leftclicki ] . buildingTypeI d,
planCategory :Number ( this . newleftTabledata [ this . leftclicki ] . planCategory ) ,
data :JSON.stringify ( this . newleftTabledata [ this . leftclicki ] . data )
}
this . http . post ( "/api/PlanTemplate" , body ) . subscribe ( ( data :any ) = > {
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 )
} )
}
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' ] ;
@ -290,17 +322,14 @@ export class addPlanname{
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
if ( this . planname == undefined || this . planname == '' ) {
this . snackBar . open ( '请输入预案名称!' , '确定' , config ) ;
}
else if ( this . level == undefined || this . level == '' ) {
this . snackBar . open ( '请输入预案级别!' , '确定' , config ) ;
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 ] . uniti d== this . unitid && this . data . plandata [ i ] . level == this . level ) {
if ( this . data . plandata [ i ] . buildingTypeI d== this . unitid && this . data . plandata [ i ] . planCategory == this . level ) {
this . snackBar . open ( '预案模板重复,请重新建立预案模板!' , '确定' , config ) ;
this . planname == ''
this . level == ''
@ -315,12 +344,12 @@ export class addPlanname{
}
} ) ;
let planData = {
name :this.planname ,
level :this.level ,
uniti d :this.unitid ,
//name:this.planname,
planCategory :this.level ,
buildingTypeI d :this.unitid ,
unitname :this.unitname ,
basicCategoryId :this.basicCategoryId ,
group : [ ]
data : [ ]
}
this . dialogRef . close ( planData )
}
@ -334,12 +363,15 @@ export class addPlanname{
} )
export class upPlanname {
constructor ( private http : HttpClient , public dialogRef : MatDialogRef < addPlanname > , @Inject ( MAT_DIALOG_DATA ) public data , public snackBar : MatSnackBar ) { }
name = this . data . item . name //预案名称
level = this . data . item . level //预案级别
name //预案名称
level = this . data . item . planCategory //预案级别
unitName = this . data . item . unitname //单位类型
unitid = this . data . item . uniti d
unitid = this . data . item . buildingTypeI d
allunittype
basicCategoryId
ngOnInit ( ) : void {
this . level = String ( this . data . item . planCategory )
console . log ( this . level )
this . getUnittype ( )
}
//获取单位类型
@ -359,14 +391,13 @@ export class upPlanname{
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
if ( this . name == undefined || this . name == '' ) {
/ * i f ( t h i s . n a m e = = u n d e f i n e d | | t h i s . n a m e = = ' ' ) {
this . snackBar . open ( '请输入预案名称!' , '确定' , config ) ;
}
else if ( this . level == undefined || this . level == '' ) {
this . snackBar . open ( '请输入预案级别!' , '确定' , config ) ;
} else {
} * /
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 ] . uniti d== this . unitid && this . data . plandata [ i ] . level == this . level ) {
if ( this . data . plandata [ i ] . buildingTypeI d== this . unitid && this . data . plandata [ i ] . planCategory == this . level ) {
this . snackBar . open ( '预案模板重复,请重新建立预案模板!' , '确定' , config ) ;
this . name == ''
this . level == ''
@ -375,10 +406,16 @@ export class upPlanname{
return
}
}
this . allunittype . forEach ( element = > {
if ( element . id == this . unitid ) {
this . basicCategoryId = element . basicCategoryId
}
} ) ;
let planData = {
name :this.name ,
level :this.level ,
unitid :this.unitid ,
//name:this.name,
planCategory :this.level ,
buildingTypeId :this.unitid ,
basicCategoryId :this.basicCategoryId ,
unitname :this.unitName
}
this . dialogRef . close ( planData )
@ -409,7 +446,8 @@ export class addGroup{
}
} ) ;
} ) * /
if ( this . data . length > 0 ) {
console . log ( this . data )
if ( this . data != null ) {
this . addgtoup = this . data
}
@ -491,21 +529,39 @@ defineClick(){
export class addattinf {
constructor ( private http : HttpClient , public dialogRef : MatDialogRef < addPlanname > , @Inject ( MAT_DIALOG_DATA ) public data , public snackBar : MatSnackBar ) { }
addAttinf = [
{ addAttinf Name: '统一社会信用代码' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' } ,
{ addAttinf Name: '单位类型' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' } ,
{ addAttinf Name: '联系人' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' } ,
{ addAttinf Name: '联系电话' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' } ,
{ addAttinf Name: '辖区中队' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' } ,
{ addAttinf Name: '单位地址' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' } ,
{ addAttinf Name: '单位照片' , completed :false , level : '单行文本' , default : '-' , must : '是' , danwei : '-' }
{ property Name: '统一社会信用代码' , completed :false , propertyType :0 } ,
{ property Name: '单位类型' , completed :false , propertyType :0 } ,
{ property Name: '联系人' , completed :false , propertyType :0 } ,
{ property Name: '联系电话' , completed :false , propertyType :0 } ,
{ property Name: '辖区中队' , completed :false , propertyType :0 } ,
{ property Name: '单位地址' , completed :false , propertyType :0 } ,
{ property Name: '单位照片' , completed :false , propertyType :0 } //,default:'-',must:'是',danwei:'-'
]
addAttinfBuild
ngOnInit ( ) : void {
//console.log(this.data)
this . data . group . forEach ( element = > {
this . getattinf ( )
}
//获取弹窗信息
getattinf ( ) {
this . data . newleftTabledata [ this . data . leftclicki ] . data . forEach ( element = > {
if ( element . groupName == '单位概况' && element . attribute != undefined ) {
element . attribute . forEach ( value = > {
if ( this . data . surveyName == '单位基本信息' && value . attinf != undefined ) {
if ( value . surveyName == '单位基本信息' && value . attinf != undefined ) {
this . addAttinf = value . attinf
} 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
} ) ;
console . log ( this . addAttinfBuild )
} )
} else if ( value . surveyName == '建筑信息' && value . attinf != undefined ) {
this . addAttinfBuild = value . attinf
}
} ) ;
}
@ -517,6 +573,6 @@ close(){
}
//确定按钮
defineClick ( ) {
this . dialogRef . close ( this . addAttinf )
this . dialogRef . close ( this . data . surveyName == '单位基本信息' ? this . addAttinf :this.addAttinfBuild )
}
}