上海预案管理平台
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.
 
 
 
 
 

168 lines
4.7 KiB

/*
* @Descripttion:
* @version:
* @Author: sueRimn
* @Date: 2021-05-19 15:50:20
* @LastEditors: sueRimn
* @LastEditTime: 2021-05-21 16:27:07
*/
import { Component, Inject, OnInit } 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';
@Component({
selector: 'app-plan-template',
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 {
}
//获取左侧单位信息
newleftTabledata=[]
getLeftdata(){
/* this.http.get("/api/PlanTemplate").subscribe((data:any)=>{
this.leftTabledata=data
console.log(this.leftTabledata)
}) */
}
//新建预案弹窗
addKeyunit(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
const dialogRef = this.dialog.open(addPlanname, {//调用open方法打开对话框并且携带参数过去
width: '340px',
height:'330px',
disableClose:true,
data:{plandata:this.newleftTabledata}
});
dialogRef.afterClosed().subscribe(result => {
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)
}
}
}
});
}
//删除预案
deletePlan(i){
let isTrue = confirm('您确定要删除该条预案吗')
if(isTrue){
this.newleftTabledata.splice(i,1)
}
}
//修改预案名称和级别
upPlan(item,i){
const dialogRef = this.dialog.open(upPlanname, {//调用open方法打开对话框并且携带参数过去
width: '340px',
height:'330px',
disableClose:true,
data:{item:item}
});
dialogRef.afterClosed().subscribe(result => {
console.log(result)
if(result!=undefined){
this.newleftTabledata[i].name=result.name
this.newleftTabledata[i].level=result.level
}
});
}
//左侧预案模板点击事件
planName
planClick(item){
console.log(item)
this.planName=item.name
}
}
//新建预案
@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) {}
unitname//预案名称
level//预案级别
ngOnInit(): void {
console.log(this.data)
}
//取消按钮
close(){
this.dialogRef.close();
}
newplan(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.unitname==undefined||this.unitname==''){
this.snackBar.open('请输入预案名称!','确定',config);
}
else if(this.level==undefined||this.level==''){
this.snackBar.open('请输入预案级别!','确定',config);
}else{
for(var i=0;i<this.data.plandata.length;i++){
if(this.data.plandata[i].name==this.unitname){
this.snackBar.open('预案名称重复请重新建立预案模板!','确定',config);
this.unitname==''
this.level==''
}
}
let planData={
name:this.unitname,
level:this.level
}
this.dialogRef.close(planData)
}
}
}
//修改预案名称和级别
@Component({
selector: 'upPlanname',
templateUrl: './upPlan.html',
styleUrls: ['./addKeyname.scss']
})
export class upPlanname{
constructor(private http: HttpClient,public dialogRef: MatDialogRef<addPlanname>,@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) {}
unitname=this.data.item.name//预案名称
level=this.data.item.level//预案级别
ngOnInit(): void{
/* this.unitname=this.data.name
this.level=this.data.level */
}
//取消按钮
close(){
this.dialogRef.close();
}
//确定按钮
upplan(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.unitname==undefined||this.unitname==''){
this.snackBar.open('请输入预案名称!','确定',config);
}
else if(this.level==undefined||this.level==''){
this.snackBar.open('请输入预案级别!','确定',config);
}else{
let planData={
name:this.unitname,
level:this.level
}
this.dialogRef.close(planData)
}
}
}