邵佳豪 4 years ago
parent
commit
38bb76ace8
  1. 6
      src/app/ui/plan-template/addKeyname.html
  2. 11
      src/app/ui/plan-template/addattinf.html
  3. 5
      src/app/ui/plan-template/addgroup.scss
  4. 28
      src/app/ui/plan-template/plan-template.component.html
  5. 224
      src/app/ui/plan-template/plan-template.component.ts
  6. 12
      src/app/ui/plan-template/upPlan.html

6
src/app/ui/plan-template/addKeyname.html

@ -4,18 +4,18 @@
* @Author: sueRimn
* @Date: 2021-05-20 16:11:57
* @LastEditors: sueRimn
* @LastEditTime: 2021-05-28 16:53:04
* @LastEditTime: 2021-05-29 10:30:48
-->
<div class="box">
<div class="top">
<span style="font-size: 20px;">新增预案模板</span>
</div>
<div class="queryField">
<!-- <div class="queryField">
<label style="margin-right: 10px;">预案名称:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入预案名称" name="companyName" autocomplete="off" [(ngModel)]="planname" required>
</mat-form-field>
</div>
</div> -->
<div class="queryField">

11
src/app/ui/plan-template/addattinf.html

@ -4,15 +4,20 @@
* @Author: sueRimn
* @Date: 2021-05-26 14:54:36
* @LastEditors: sueRimn
* @LastEditTime: 2021-05-26 15:05:10
* @LastEditTime: 2021-05-29 15:12:23
-->
<div class="box">
<div class="top">
<span>新增分组</span>
</div>
<div class="center">
<div class="center" *ngIf="this.data.surveyName=='单位基本信息'">
<div class="group" *ngFor="let item of addAttinf" >
<mat-checkbox class="example-margin" color='primary' [(ngModel)]="item.completed" >{{item.addAttinfName}}</mat-checkbox>
<mat-checkbox class="example-margin" color='primary' [(ngModel)]="item.completed" >{{item.propertyName}}</mat-checkbox>
</div>
</div>
<div class="center" *ngIf="this.data.surveyName=='建筑信息'">
<div class="group" *ngFor="let item of addAttinfBuild" >
<mat-checkbox class="example-margin" color='primary' [(ngModel)]="item.completed" >{{item.propertyName}}</mat-checkbox>
</div>
</div>
<div class="bottom">

5
src/app/ui/plan-template/addgroup.scss

@ -12,8 +12,9 @@
}
}
.center{
overflow: auto;
width: 100%;
height: 75%;
height: 80%;
.group{
height: 35px;
//margin-left: 20px;
@ -30,7 +31,7 @@
}
.bottom{
width: 100%;
margin-top: 40px;
margin-top: 20px;
button{
width: 80px;
height: 36px;

28
src/app/ui/plan-template/plan-template.component.html

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2021-05-19 15:50:20
* @LastEditors: sueRimn
* @LastEditTime: 2021-05-28 17:07:26
* @LastEditTime: 2021-05-29 16:52:44
-->
<div class="box">
<div class="boxleft">
@ -18,14 +18,14 @@
</div>
</div>
<div class="leftbox">
<div class="leftbody" [ngClass]="{'selectedTr': item.unitname == unitName}" *ngFor="let item of newleftTabledata;let i=index" (click)='planClick(item)'>
<div class="leftbody" [ngClass]="{'selectedTr':item.buildingTypeId==buildingTypeId&&item.planCategory==planCategory}" *ngFor="let item of newleftTabledata;let i=index" (click)='planClick(item)'>
<div class="bodyname">
<span>{{item.unitname}}</span>
</div>
<div class="bodycz">
<span>{{item.level==3?'Ⅲ级':item.level==4?'Ⅳ级':'Ⅴ级'}}</span>
<img [src]="item.unitname == unitName? '../../../assets/images/update.png':'../../../assets/images/updatehui.png'" (click)='upPlan(item,i)'>
<img [src]="item.unitname == unitName? '../../../assets/images/deleteblue.png':'../../../assets/images/deletehui.png'" (click)='deletePlan(i)'>
<span>{{item.planCategory==3?'Ⅲ级':item.planCategory==4?'Ⅳ级':'Ⅴ级'}}</span>
<img [src]="item.buildingTypeId == buildingTypeId&&item.planCategory==planCategory? '../../../assets/images/update.png':'../../../assets/images/updatehui.png'" (click)='upPlan(item,i)'>
<img [src]="item.buildingTypeId == buildingTypeId&&item.planCategory==planCategory? '../../../assets/images/deleteblue.png':'../../../assets/images/deletehui.png'" (click)='deletePlan(item.id,i)'>
</div>
</div>
</div>
@ -113,21 +113,15 @@
</table> -->
<table cellspacing="0" cellpadding="0">
<thead>
<th style="width: 20%;">名称</th>
<th style="width: 20%;">类型</th>
<th style="width: 10%;">默认值</th>
<th style="width: 10%;">必填</th>
<th style="width: 10%;">单位</th>
<th style="width: 20%;">操作</th>
<th style="width: 30%;">名称</th>
<th style="width: 30%;">类型</th>
<th style="width: 30%;">操作</th>
</thead>
<tbody>
<tr *ngFor="let attinf of element.attinf" >
<td *ngIf="attinf.completed" style="width: 20%;">{{attinf.addAttinfName}}</td>
<td *ngIf="attinf.completed" style="width: 20%;">{{attinf.level}}</td>
<td *ngIf="attinf.completed" style="width: 10%;">{{attinf.default}}</td>
<td *ngIf="attinf.completed" style="width: 10%;">{{attinf.must}}</td>
<td *ngIf="attinf.completed" style="width: 10%;">{{attinf.danwei}}</td>
<td *ngIf="attinf.completed" style="width: 20%;"><span style="color: #FF5D4A;margin-left: 4px"> 删除</span></td>
<td *ngIf="attinf.completed" style="width: 30%;">{{attinf.propertyName}}</td>
<td *ngIf="attinf.completed" style="width: 30%;">{{attinf.propertyType==0?'单行文本':attinf.propertyType==1?'多行文本':'数值'}}</td>
<td *ngIf="attinf.completed" style="width: 30%;"><span style="color: #FF5D4A;margin-left: 4px;cursor: pointer;"> 删除</span></td>
</tr>
</tbody>
</table>

224
src/app/ui/plan-template/plan-template.component.ts

@ -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",unitid: "5e7c9018a3050b1a840ed4b7",unitname:'地下建筑',group:[]}
/* {planCategory:3,basicCategoryId:"5e7c49e861550e2754d461ce",buildingTypeId: "5e7c8ffba3050b1a840ed4b6",unitname:'',data:[]},
{planCategory:5,basicCategoryId:"60127efe2757e904e5721d83",buildingTypeId: "5e7c9018a3050b1a840ed4b7",unitname:'地下建筑',data:[]} */
]
group=[]
getLeftdata(){
/* this.http.get("/api/PlanTemplate").subscribe((data:any)=>{
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:'340px',
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:'380px',
height:'340px',
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.planName==undefined){
if(this.unitName==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)
/* let groupName={
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].unitid,
planCategory:Number(this.newleftTabledata[this.leftclicki].level),
data:{}
buildingTypeId:this.newleftTabledata[this.leftclicki].buildingTypeId,
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].unitid==this.unitid&&this.data.plandata[i].level==this.level){
if(this.data.plandata[i].buildingTypeId==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,
unitid:this.unitid,
//name:this.planname,
planCategory:this.level,
buildingTypeId: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.unitid
unitid=this.data.item.buildingTypeId
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==''){
/* if(this.name==undefined||this.name==''){
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].unitid==this.unitid&&this.data.plandata[i].level==this.level){
if(this.data.plandata[i].buildingTypeId==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=[
{addAttinfName:'统一社会信用代码',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'},
{addAttinfName:'单位类型',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'},
{addAttinfName:'联系人',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'},
{addAttinfName:'联系电话',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'},
{addAttinfName:'辖区中队',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'},
{addAttinfName:'单位地址',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'},
{addAttinfName:'单位照片',completed:false,level:'单行文本',default:'-',must:'是',danwei:'-'}
{propertyName:'统一社会信用代码',completed:false,propertyType:0},
{propertyName:'单位类型',completed:false,propertyType:0},
{propertyName:'联系人',completed:false,propertyType:0},
{propertyName:'联系电话',completed:false,propertyType:0},
{propertyName:'辖区中队',completed:false,propertyType:0},
{propertyName:'单位地址',completed:false,propertyType:0},
{propertyName:'单位照片',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)
}
}

12
src/app/ui/plan-template/upPlan.html

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2021-05-21 10:43:28
* @LastEditors: sueRimn
* @LastEditTime: 2021-05-28 10:44:56
* @LastEditTime: 2021-05-29 10:52:11
-->
<!--
* @Descripttion:
@ -18,21 +18,21 @@
<div class="top">
<span style="font-size: 20px;">修改预案模板</span>
</div>
<div class="queryField">
<!-- <div class="queryField">
<label style="margin-right: 10px;">预案名称:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入预案名称" name="companyName" autocomplete="off" [(ngModel)]="name" required>
</mat-form-field>
</div>
</div> -->
<div class="queryField">
<label style="margin-right: 10px;">预案级别:</label>
<mat-form-field>
<mat-select placeholder='请选择预案级别' name="unittype" [(ngModel)]="level" required>
<mat-option value="Ⅲ级">Ⅲ级</mat-option>
<mat-option value="Ⅳ级">Ⅳ级</mat-option>
<mat-option value="Ⅴ级">Ⅴ级</mat-option>
<mat-option value="3">Ⅲ级</mat-option>
<mat-option value="4">Ⅳ级</mat-option>
<mat-option value="5">Ⅴ级</mat-option>
</mat-select>
</mat-form-field>
</div>

Loading…
Cancel
Save