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

117 lines
3.4 KiB

/*
* @Descripttion:
* @version:
* @Author: sueRimn
* @Date: 2021-06-16 13:56:54
* @LastEditors: sueRimn
* @LastEditTime: 2021-06-17 15:15:17
*/
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
@Component({
selector: 'app-create-plan-online-five',
templateUrl: './create-plan-online-five.component.html',
styleUrls: ['./create-plan-online-five.component.scss']
})
export class CreatePlanOnlineFiveComponent implements OnInit {
constructor(private http: HttpClient, private route: ActivatedRoute,public snackBar: MatSnackBar) { }
planName: string //预案名称
ngOnInit(): void {
this.planName = this.route.snapshot.queryParams.planName
this.getTemplateData()
this.getUnitData()
}
//获得单位信息
unitData:any
getUnitData() {
let paramsdata: any = {
Name: this.route.snapshot.queryParams.unitName || '',
}
this.http.get("/api/Companies", { params: paramsdata }).subscribe((data: any) => {
data.items.forEach(element => {
if (element.id == this.route.snapshot.queryParams.companyId) {
this.unitData = element
console.log('单位列表信息', this.unitData)
}
});
})
}
selectedItem: string = '封面'
clickTitleItem(item) {
this.addNumber=-1
item == '封面' ? this.selectedItem = '封面' : this.selectedItem = item.groupName
}
planTemplateData: any
//获得模板信息
getTemplateData() {
this.http.get('/api/PlanTemplate').subscribe(data => {
this.planTemplateData = JSON.parse(data[2].data).filter(item =>
item.completed == true
)
console.log(this.planTemplateData)
})
}
//input key值,一个字符焦点消失问题
trackByFn(index){
return index
}
//表格增加一行
addNumber=-1
addTd(key,i){
this.addNumber++
//this.planTemplateData[key].attribute[i].push({tabletr:[]})
if(this.planTemplateData[key].attribute[i].tabletr==undefined){
this.planTemplateData[key].attribute[i].tabletr=[]
}
this.planTemplateData[key].attribute[i].tabletr.push({tabletd:[]})
for(var j=0;j<this.planTemplateData[key].attribute[i].tableth.length;j++){
if(this.planTemplateData[key].attribute[i].tabletr!=undefined){
this.planTemplateData[key].attribute[i].tabletr[this.planTemplateData[key].attribute[i].tabletr.length-1].tabletd.push('')
}
else{
this.planTemplateData[key].attribute[i].tabletr[this.addNumber].tabletd.push('')
}
}
console.log(this.planTemplateData)
}
//表格删除一行
delTd(key,i){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.planTemplateData[key].attribute[i].tabletr!=undefined){
this.planTemplateData[key].attribute[i].tabletr.splice(this.planTemplateData[key].attribute[i].tabletr.length-1,1)
this.addNumber--
if(this.planTemplateData[key].attribute[i].tabletr.length==0){
this.addNumber=-1
}
}else{
this.snackBar.open('请先增加一行!','确定',config);
}
}
}
export interface unitData {
name: string,
organizationName: number,
buildingTypes: buildingTypes[]
}
export interface buildingTypes {
id: string,
name: string,
}