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