diff --git a/src/app/ui/basicinfo/addhouseinfo.component.ts b/src/app/ui/basicinfo/addhouseinfo.component.ts index 25063b9..47166fa 100644 --- a/src/app/ui/basicinfo/addhouseinfo.component.ts +++ b/src/app/ui/basicinfo/addhouseinfo.component.ts @@ -29,27 +29,41 @@ import { MatSnackBar } from '@angular/material/snack-bar'; }) } onSubmit(value){ - let buildingTypename = "" - this.allunittype.forEach(item => { - if(item.id == value.unittype){ - buildingTypename = item.name + this.http.get("/api/CompanyAccount/Buildings").subscribe((data:any)=>{ + let allBuildings = data + let order + if(allBuildings.length == 0){ + order = 0 + }else{ + order = allBuildings[allBuildings.length-1].order + 1 } - }); - this.http.post("/api/CompanyAccount/Buildings",{ - id: "", - name: value.name, - order: 0, - enabled: true, - companyId: this.data.unitinfo.id, - buildingTypes: [ - { - id: value.unittype, - name: buildingTypename + let buildingTypename = "" + this.allunittype.forEach(item => { + if(item.id == value.unittype){ + buildingTypename = item.name } - ] - }).subscribe(data=>{ - this.dialogRef.close(data); + }); + this.http.post("/api/CompanyAccount/Buildings",{ + id: "", + name: value.name, + order: order, + enabled: true, + companyId: this.data.unitinfo.id, + buildingTypes: [ + { + id: value.unittype, + name: buildingTypename + } + ] + }).subscribe(data=>{ + this.dialogRef.close(data); + }) + }) + + + + } } \ No newline at end of file diff --git a/src/app/ui/basicinfo/basicinfo.component.html b/src/app/ui/basicinfo/basicinfo.component.html index 3be283e..f368979 100644 --- a/src/app/ui/basicinfo/basicinfo.component.html +++ b/src/app/ui/basicinfo/basicinfo.component.html @@ -151,7 +151,7 @@ <span>建筑类型:</span> <mat-form-field> <mat-select name="unittype" [(ngModel)]="item.buildtype"> - <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templatebuildtype(n,item)">{{n.name}}</mat-option> + <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templatebuildtype(n,item,key)">{{n.name}}</mat-option> </mat-select> </mat-form-field> <span style="color: red;">*</span> @@ -234,7 +234,7 @@ <span>建筑类型:</span> <mat-form-field> <mat-select required name="unittype" [(ngModel)]="item.buildtype"> - <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templatebuildtype(n,item)">{{n.name}}</mat-option> + <mat-option [value]="n.name" *ngFor="let n of allunittype" (click)="templatebuildtype(n,item,key)">{{n.name}}</mat-option> </mat-select> </mat-form-field> <span style="color: red;">*</span> diff --git a/src/app/ui/basicinfo/basicinfo.component.ts b/src/app/ui/basicinfo/basicinfo.component.ts index 4d27043..d6ee466 100644 --- a/src/app/ui/basicinfo/basicinfo.component.ts +++ b/src/app/ui/basicinfo/basicinfo.component.ts @@ -355,9 +355,12 @@ export class BasicinfoComponent implements OnInit { item.buildingCustomData.customProperties.pop() } //得到建筑信息数据并进行处理 + allBuildings : any getunitallbuilding(){ this.houses = [] this.http.get("/api/CompanyAccount/Buildings").subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 + this.allBuildings = data + // console.log(666,data) if(data.length != 0){ this.basicCategoryId = data[0].buildingTypes[0].id this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id @@ -510,6 +513,7 @@ export class BasicinfoComponent implements OnInit { } } // console.log(1314,this.houses) + }) } @@ -1114,903 +1118,852 @@ export class BasicinfoComponent implements OnInit { } //切换建筑类型 - templatebuildtype(n ,item){ - // console.log(n,item) - this.http.put(`/api/CompanyAccount/Buildings/${item.buildingId}`,{ //修改当前建筑类型 - id: item.buildingId, - name: item.housename, - order: 0, - enabled: true, - companyId: this.unitinfo.id, - buildingTypes: [ - { - id: n.id, - name: n.name - } - ] - }).subscribe(data=>{ - this.http.get("/api/CompanyAccount/BasicInfos",{//请求当前建筑类型的模板信息保存到数组中 - params:{ - buildingId:item.buildingId, - buildingType:n.id - } - }).subscribe(data=>{ - this.getunithouse(data,n,item) - this.houses[item.index] = data[0] + templatebuildtype(n ,item,key){ - let _data = data - this.http.get("/api/CompanyAccount/BuildingCustomData",{params:{ - buildingId:item.buildingId - }}).subscribe((data:any)=>{ - _data[0].buildingCustomData = data - if(data && data.customProperties.length != 0){ - _data[0].isCustomData = true - }else{ - _data[0].isCustomData = false - _data[0].buildingCustomData ={ - id: "", - customProperties: [ - { - name: "", - value: "" - } - ], - buildingId: _data[0].buildingId - } + this.http.get("/api/CompanyAccount/Buildings").subscribe((data:any)=>{ + let allBuildings = data + this.http.put(`/api/CompanyAccount/Buildings/${item.buildingId}`,{ //修改当前建筑类型 + id: item.buildingId, + name: item.housename, + order: allBuildings[key].order, + enabled: true, + companyId: this.unitinfo.id, + buildingTypes: [ + { + id: n.id, + name: n.name + } + ] + }).subscribe(data=>{ + this.http.get("/api/CompanyAccount/BasicInfos",{//请求当前建筑类型的模板信息保存到数组中 + params:{ + buildingId:item.buildingId, + buildingType:n.id } + }).subscribe(data=>{ + this.getunithouse(data,n,item) + this.houses[item.index] = data[0] + + let _data = data + this.http.get("/api/CompanyAccount/BuildingCustomData",{params:{ + buildingId:item.buildingId + }}).subscribe((data:any)=>{ + _data[0].buildingCustomData = data + if(data && data.customProperties.length != 0){ + _data[0].isCustomData = true + }else{ + _data[0].isCustomData = false + _data[0].buildingCustomData ={ + id: "", + customProperties: [ + { + name: "", + value: "" + } + ], + buildingId: _data[0].buildingId + } + } + }) }) }) }) + + } deviceinfo=[] //用于存储石头化工的第一个表格 //提交单位模板信息 onSubmit2(value,item,key,invalid){ - if(invalid){ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请填写必填项','确定',config); - }else{ - this.http.put(`/api/CompanyAccount/Buildings/${item.buildingId}`,{ //(通用)只修改建筑名称和建筑类型 - id: item.buildingId, - name: value.housename, - order: 0, - enabled: true, - companyId: this.unitinfo.id, - buildingTypes: [ - { - id: item.buildingtypeId, - name: item.buildtype - } - ] - }).subscribe((data:any)=>{ - this.houses[item.index].username = item.name - }, - err=>{ - alert("名称和类型保存失败") - }) - - if(value.checkbuilding){//如果勾选了自定义信息的checkbox - var CustomDataval = [] - for (const key in value) { - if (key.indexOf("CustomData") != -1) { - CustomDataval.push(value[key]) - } - } - let newCustomData = this.FunData(CustomDataval) - let newCustomDataval = [] - newCustomData.forEach(n=>{ - newCustomDataval.push({ - name:n[0], - value:n[1] - }) - }) - let CustomDatabody = { - id: "", - customProperties: newCustomDataval, - buildingId: item.buildingId - } - this.http.post("/api/CompanyAccount/BuildingCustomData",CustomDatabody,{params:{ - buildingId:item.buildingId - }}).subscribe(data=>{ - - }, - err=>{ - alert("自定义信息保存失败") - }) + this.http.get("/api/CompanyAccount/Buildings").subscribe((data:any)=>{ + let allBuildings = data + + if(invalid){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请填写必填项','确定',config); }else{ - let CustomDatabody = { - id: "", - customProperties: [], - buildingId: item.buildingId - } - this.http.post("/api/CompanyAccount/BuildingCustomData",CustomDatabody,{params:{ - buildingId:item.buildingId - }}).subscribe(data=>{ - + this.http.put(`/api/CompanyAccount/Buildings/${item.buildingId}`,{ //(通用)只修改建筑名称和建筑类型 + id: item.buildingId, + name: value.housename, + order: allBuildings[key].order, + enabled: true, + companyId: this.unitinfo.id, + buildingTypes: [ + { + id: item.buildingtypeId, + name: item.buildtype + } + ] + }).subscribe((data:any)=>{ + this.houses[item.index].username = item.name }, err=>{ - alert("自定义信息保存失败") + alert("名称和类型保存失败") }) - } - - - if(item.buildtype != "石油化工类" && item.buildtype != "地铁类"){ - // console.log(this.houses[key]) - // console.log(value) - this.houses[key].buildingBasicGroups[0].propertyInfos.forEach(item => { - - if(item.propertyValue || item.propertyValue == 0){ - // item.propertyValue = "" + value[key] - item.propertyValue = String(item.propertyValue) + + if(value.checkbuilding){//如果勾选了自定义信息的checkbox + var CustomDataval = [] + for (const key in value) { + if (key.indexOf("CustomData") != -1) { + CustomDataval.push(value[key]) + } } - - }); - let newObj = _.cloneDeep(this.houses[key]) //把数据深拷贝取出来进行操作 - newObj.buildingBasicGroups[0].buildingId = item.buildingId - newObj.buildingBasicGroups[0].companyId = this.unitinfo.id - newObj.buildingBasicGroups[0].submitted = true //把是否提交过变为true - delete newObj.name - delete newObj.username - delete newObj.buildtype - delete newObj.tongyong - delete newObj.index - delete newObj.isCustomData - delete newObj.buildingCustomData - newObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - delete item.isshowrule - delete item.rulevalue - }); - - let body = newObj - let newbody = [] - newbody.push(body) - // console.log(123,newbody) - if(newbody[0].buildingBasicGroups.length){ - this.http.post("/api/CompanyAccount/BasicInfos",newbody,{ - params:{ - buildingId :newbody[0].buildingId + let newCustomData = this.FunData(CustomDataval) + let newCustomDataval = [] + newCustomData.forEach(n=>{ + newCustomDataval.push({ + name:n[0], + value:n[1] + }) + }) + let CustomDatabody = { + id: "", + customProperties: newCustomDataval, + buildingId: item.buildingId } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); + this.http.post("/api/CompanyAccount/BuildingCustomData",CustomDatabody,{params:{ + buildingId:item.buildingId + }}).subscribe(data=>{ + }, err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); + alert("自定义信息保存失败") + }) + }else{ + let CustomDatabody = { + id: "", + customProperties: [], + buildingId: item.buildingId + } + this.http.post("/api/CompanyAccount/BuildingCustomData",CustomDatabody,{params:{ + buildingId:item.buildingId + }}).subscribe(data=>{ + + }, + err=>{ + alert("自定义信息保存失败") }) } - } - if(item.buildtype == "石油化工类"){ - // console.log(888,item) - let bodyObj = _.cloneDeep(item) - delete bodyObj.name - delete bodyObj.username - delete bodyObj.isshiyou - delete bodyObj.newzhuangzhiinfodatasource - delete bodyObj.tongyong - delete bodyObj.buildtype - delete bodyObj.buildingtypeId - delete bodyObj.bigfor - delete bodyObj.index - delete bodyObj.isCustomData - delete bodyObj.buildingCustomData - // console.log(456,bodyObj) - bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - delete item.isshowrule - delete item.rulevalue - }); - //修改基本信息 - bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - for (const key in value) { - if (item.propertyName == key) { + + + if(item.buildtype != "石油化工类" && item.buildtype != "地铁类"){ + + this.houses[key].buildingBasicGroups[0].propertyInfos.forEach(item => { + if(item.propertyValue || item.propertyValue == 0){ // item.propertyValue = "" + value[key] - item.propertyValue = String(value[key]) + item.propertyValue = String(item.propertyValue) } - + + }); + let newObj = _.cloneDeep(this.houses[key]) //把数据深拷贝取出来进行操作 + newObj.buildingBasicGroups[0].buildingId = item.buildingId + newObj.buildingBasicGroups[0].companyId = this.unitinfo.id + newObj.buildingBasicGroups[0].submitted = true //把是否提交过变为true + delete newObj.name + delete newObj.username + delete newObj.buildtype + delete newObj.tongyong + delete newObj.index + delete newObj.isCustomData + delete newObj.buildingCustomData + newObj.buildingBasicGroups[0].propertyInfos.forEach(item => { + delete item.isshowrule + delete item.rulevalue + }); + + let body = newObj + let newbody = [] + newbody.push(body) + // console.log(123,newbody) + if(newbody[0].buildingBasicGroups.length){ + this.http.post("/api/CompanyAccount/BasicInfos",newbody,{ + params:{ + buildingId :newbody[0].buildingId } + }).subscribe((data:any)=>{ + this.houses[key].id = data[0].id + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('建筑信息保存成功','确定',config); + }, + err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请检查输入数据是否有误','确定',config); + }) } - }); - bodyObj.buildingBasicGroups[0].submitted = true - bodyObj.buildingBasicGroups[0].buildingId = item.buildingId - bodyObj.buildingBasicGroups[0].companyId = this.unitinfo.id - //石油化工类的 装置信息 就提交这个表单——————————————————————————————this.deviceinfo 记得清空 - // console.log(this.deviceinfodata) - if(bodyObj.buildingBasicGroups[1].submitted){ //如果用户点击了并填写了装置信息就提交这个表格数据 - this.deviceinfo = [] - item.newzhuangzhiinfodatasource.forEach((element,index) => { - this.deviceinfo.push({ + } + if(item.buildtype == "石油化工类"){ + // console.log(888,item) + let bodyObj = _.cloneDeep(item) + delete bodyObj.name + delete bodyObj.username + delete bodyObj.isshiyou + delete bodyObj.newzhuangzhiinfodatasource + delete bodyObj.tongyong + delete bodyObj.buildtype + delete bodyObj.buildingtypeId + delete bodyObj.bigfor + delete bodyObj.index + delete bodyObj.isCustomData + delete bodyObj.buildingCustomData + // console.log(456,bodyObj) + bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { + delete item.isshowrule + delete item.rulevalue + }); + //修改基本信息 + bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => { + for (const key in value) { + if (item.propertyName == key) { + if(item.propertyValue || item.propertyValue == 0){ + // item.propertyValue = "" + value[key] + item.propertyValue = String(value[key]) + } + + } + } + }); + bodyObj.buildingBasicGroups[0].submitted = true + bodyObj.buildingBasicGroups[0].buildingId = item.buildingId + bodyObj.buildingBasicGroups[0].companyId = this.unitinfo.id + //石油化工类的 装置信息 就提交这个表单——————————————————————————————this.deviceinfo 记得清空 + // console.log(this.deviceinfodata) + if(bodyObj.buildingBasicGroups[1].submitted){ //如果用户点击了并填写了装置信息就提交这个表格数据 + this.deviceinfo = [] + item.newzhuangzhiinfodatasource.forEach((element,index) => { + this.deviceinfo.push({ + propertyName: "装置区名称", + propertyValue: element.name, + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order:0, + enabled: true, + visible: true, + tag: String(index + 1) + }, + { + propertyName: "工艺流程", + propertyValue: element.flow, + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order:1, + enabled: true, + visible: true, + tag: String(index + 1) + }, + { + propertyName: "火灾危险性", + propertyValue: element.danger, + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order:2, + enabled: true, + visible: true, + tag: String(index + 1) + }, + { + propertyName: "灭火注意事项", + propertyValue: element.payattentionto, + propertyType: 1, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order:3, + enabled: true, + visible: true, + tag: String(index + 1) + }) + }); + }else{//否则就传一个空的 + this.deviceinfo = [ + { propertyName: "装置区名称", - propertyValue: element.name, + propertyValue: "", propertyType: 0, required: true, ruleName: "", ruleValue: "", physicalUnit: "", - order:0, + order: 0, enabled: true, visible: true, - tag: String(index + 1) + tag: "1" }, { propertyName: "工艺流程", - propertyValue: element.flow, + propertyValue: "", propertyType: 0, required: true, ruleName: "", ruleValue: "", physicalUnit: "", - order:1, + order: 0, enabled: true, visible: true, - tag: String(index + 1) + tag: "1" }, { propertyName: "火灾危险性", - propertyValue: element.danger, + propertyValue: "", propertyType: 0, required: true, ruleName: "", ruleValue: "", physicalUnit: "", - order:2, + order: 0, enabled: true, visible: true, - tag: String(index + 1) + tag: "1" }, { propertyName: "灭火注意事项", - propertyValue: element.payattentionto, + propertyValue: "", propertyType: 1, required: false, ruleName: "", ruleValue: "", physicalUnit: "", - order:3, + order: 0, enabled: true, visible: true, - tag: String(index + 1) - }) - }); - }else{//否则就传一个空的 - this.deviceinfo = [ - { - propertyName: "装置区名称", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "工艺流程", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "火灾危险性", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" - }, - { - propertyName: "灭火注意事项", - propertyValue: "", - propertyType: 1, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag: "1" + tag: "1" + } + ] } - ] - } - bodyObj.buildingBasicGroups[1].propertyInfos = this.deviceinfo - bodyObj.buildingBasicGroups[1].buildingId = item.buildingId - bodyObj.buildingBasicGroups[1].companyId = this.unitinfo.id + bodyObj.buildingBasicGroups[1].propertyInfos = this.deviceinfo + bodyObj.buildingBasicGroups[1].buildingId = item.buildingId + bodyObj.buildingBasicGroups[1].companyId = this.unitinfo.id - - if(bodyObj.buildingBasicGroups[2].submitted){ //如果勾选了储罐信息 则直接提交当前bodyObj - var map = {}; //用于存储石油化工要提交的储罐信息表单 - for (let key in value) { - if (key.indexOf('tanker') != -1) { - const list = key.split('-'); // 2,tanker,1 - const orderKey = list[0]; // 2 or 3 - if (!(orderKey in map)) { - map[orderKey] = []; // map[2] or map[3] = []; + + if(bodyObj.buildingBasicGroups[2].submitted){ //如果勾选了储罐信息 则直接提交当前bodyObj + var map = {}; //用于存储石油化工要提交的储罐信息表单 + for (let key in value) { + if (key.indexOf('tanker') != -1) { + const list = key.split('-'); // 2,tanker,1 + const orderKey = list[0]; // 2 or 3 + if (!(orderKey in map)) { + map[orderKey] = []; // map[2] or map[3] = []; + } + map[orderKey][list[2]] = value[key]; // map[2][1] = xxxxx } - map[orderKey][list[2]] = value[key]; // map[2][1] = xxxxx } - } - - bodyObj.buildingBasicGroups.splice( 2 , bodyObj.buildingBasicGroups.length) - - // console.log(123, item) + + bodyObj.buildingBasicGroups.splice( 2 , bodyObj.buildingBasicGroups.length) + + // console.log(123, item) - let basictankinfobody:any = {} + let basictankinfobody:any = {} - for(let key in map){//------------------------------------------------------------石油化工 储罐信息 + for(let key in map){//------------------------------------------------------------石油化工 储罐信息 - - basictankinfobody = { - id: null, - name: "罐区" + (Number(key)-1), - type: 0, - addMode: 2, - basicGroupId:'', - submitted:true, - isOptional:true, - order: Number(key), - enabled: true, - propertyInfos: item.bigfor[Number(key)-2][0].propertyInfos, - basicCategoryId: item.basicCategoryId, - buildingBasicId: null, - buildingId: item.buildingId,//当前建筑id - companyId: this.unitinfo.id//当前企业id - } + + basictankinfobody = { + id: null, + name: "罐区" + (Number(key)-1), + type: 0, + addMode: 2, + basicGroupId:'', + submitted:true, + isOptional:true, + order: Number(key), + enabled: true, + propertyInfos: item.bigfor[Number(key)-2][0].propertyInfos, + basicCategoryId: item.basicCategoryId, + buildingBasicId: null, + buildingId: item.buildingId,//当前建筑id + companyId: this.unitinfo.id//当前企业id + } - bodyObj.buildingBasicGroups.push(basictankinfobody) - } - + bodyObj.buildingBasicGroups.push(basictankinfobody) + } + - let basictankchildinfobody:any = []//-------------后续储罐信息以及储罐信息/罐区情况都push到这个数组中 - item.bigfor.forEach(item => { - basictankchildinfobody.push(item[1].propertyInfos) - }); - var _item = item - basictankchildinfobody.forEach((item,index) => { - let tankfieldArr = [] - item.forEach((element,key) => { - tankfieldArr.push( - { - propertyName: "罐区", - propertyValue: element.tank, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储罐编号", - propertyValue: element.tankid, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储存介质", - propertyValue: element.tankmedium, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "储罐类型", - propertyValue: element.tanktype, - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "容量", - propertyValue: element.tankcapacity, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "㎡", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "直径", - propertyValue:element.tankdiameter, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "高度", - propertyValue: element.tankheight, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, + let basictankchildinfobody:any = []//-------------后续储罐信息以及储罐信息/罐区情况都push到这个数组中 + item.bigfor.forEach(item => { + basictankchildinfobody.push(item[1].propertyInfos) + }); + var _item = item + basictankchildinfobody.forEach((item,index) => { + let tankfieldArr = [] + item.forEach((element,key) => { + tankfieldArr.push( + { + propertyName: "罐区", + propertyValue: element.tank, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "储罐编号", + propertyValue: element.tankid, + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "储存介质", + propertyValue: element.tankmedium, + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "储罐类型", + propertyValue: element.tanktype, + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "容量", + propertyValue: element.tankcapacity, + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "㎡", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "直径", + propertyValue:element.tankdiameter, + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "m", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "高度", + propertyValue: element.tankheight, + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "m", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "顶盖形式", + propertyValue: element.tanktectum, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "浮盘材质", + propertyValue: element.tanktexture, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "浮盘类型", + propertyValue: element.platetype, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "泡沫产生器型号", + propertyValue: element.foamgeneratorid, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "泡沫产生器形式", + propertyValue: element.foamgeneratortype, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "是否设置氮封惰化保护装置", + propertyValue: element.isprotect, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "防护堤高度", + propertyValue: element.fendinggroyneheight, + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "m", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "半固定泡沫灭火接口数量", + propertyValue: element.portnum, + propertyType: 2, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "个", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + }, + { + propertyName: "其它设施", + propertyValue: element.else, + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:String(key + 1) + } + ) + }); + basictankchildinfobody={// + id: null, + name: "罐区" + Number(index+1) + "/储罐信息", + type: 1, + addMode: 2, + basicGroupId:'', + order: Number(index + 2), + enabled: true, + submitted:true, + isOptional:true, + propertyInfos: tankfieldArr, + basicCategoryId: _item.basicCategoryId, + buildingBasicId: null, + buildingId: _item.buildingId, + companyId: this.unitinfo.id + } + bodyObj.buildingBasicGroups.push(basictankchildinfobody) + }); + }else{ + + + bodyObj.buildingBasicGroups[2].buildingId = item.buildingId + bodyObj.buildingBasicGroups[2].companyId = this.unitinfo.id + bodyObj.buildingBasicGroups[2].propertyInfos.forEach(item=>{ + item.propertyValue = "" + }) + bodyObj.buildingBasicGroups[3].buildingId = item.buildingId + bodyObj.buildingBasicGroups[3].companyId = this.unitinfo.id + bodyObj.buildingBasicGroups[3].propertyInfos = [ { - propertyName: "顶盖形式", - propertyValue: element.tanktectum, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "浮盘材质", - propertyValue: element.tanktexture, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "浮盘类型", - propertyValue: element.platetype, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "泡沫产生器型号", - propertyValue: element.foamgeneratorid, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "泡沫产生器形式", - propertyValue: element.foamgeneratortype, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "是否设置氮封惰化保护装置", - propertyValue: element.isprotect, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "防护堤高度", - propertyValue: element.fendinggroyneheight, - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "半固定泡沫灭火接口数量", - propertyValue: element.portnum, - propertyType: 2, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "个", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - }, - { - propertyName: "其它设施", - propertyValue: element.else, - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:String(key + 1) - } - ) - }); - basictankchildinfobody={// - id: null, - name: "罐区" + Number(index+1) + "/储罐信息", - type: 1, - addMode: 2, - basicGroupId:'', - order: Number(index + 2), - enabled: true, - submitted:true, - isOptional:true, - propertyInfos: tankfieldArr, - basicCategoryId: _item.basicCategoryId, - buildingBasicId: null, - buildingId: _item.buildingId, - companyId: this.unitinfo.id - } - bodyObj.buildingBasicGroups.push(basictankchildinfobody) - }); - }else{ - - - bodyObj.buildingBasicGroups[2].buildingId = item.buildingId - bodyObj.buildingBasicGroups[2].companyId = this.unitinfo.id - bodyObj.buildingBasicGroups[2].propertyInfos.forEach(item=>{ - item.propertyValue = "" - }) - bodyObj.buildingBasicGroups[3].buildingId = item.buildingId - bodyObj.buildingBasicGroups[3].companyId = this.unitinfo.id - bodyObj.buildingBasicGroups[3].propertyInfos = [ + propertyName: "罐区", + propertyValue: "", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, { - propertyName: "罐区", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储罐编号", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储存介质", - propertyValue: "", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "储罐类型", - propertyValue:"", - propertyType: 0, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "容量", - propertyValue: "", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "㎡", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "直径", - propertyValue:"", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "高度", - propertyValue: "", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "顶盖形式", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "浮盘材质", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "浮盘类型", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "泡沫产生器型号", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "泡沫产生器形式", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "是否设置氮封惰化保护装置", - propertyValue:"", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "防护堤高度", - propertyValue:"", - propertyType: 2, - required: true, - ruleName: "", - ruleValue: "", - physicalUnit: "m", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "半固定泡沫灭火接口数量", - propertyValue: "", - propertyType: 2, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "个", - order: 0, - enabled: true, - visible: true, - tag:"1" - }, - { - propertyName: "其它设施", - propertyValue: "", - propertyType: 0, - required: false, - ruleName: "", - ruleValue: "", - physicalUnit: "", - order: 0, - enabled: true, - visible: true, - tag:"1" - } - ] - // console.log(888,bodyObj) - bodyObj.buildingBasicGroups.splice(4,bodyObj.buildingBasicGroups.length) - } - - - - let newbodyObj = [] - newbodyObj.push(bodyObj) - // console.log(1111,newbodyObj) - this.http.post("/api/CompanyAccount/BasicInfos",newbodyObj,{ - params:{ - buildingId :item.buildingId - } - }).subscribe((data:any)=>{ - this.houses[key].id = data[0].id - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('建筑信息保存成功','确定',config); - // alert("建筑信息保存成功") - }, - err=>{ - const config = new MatSnackBarConfig(); - config.verticalPosition = 'top'; - config.duration = 3000 - this.snackBar.open('请检查输入数据是否有误','确定',config); - }) - } - if(item.buildtype == "地铁类"){ - let newObj = _.cloneDeep(item) - delete newObj.username - delete newObj.name - delete newObj.tongyong - delete newObj.ditie - delete newObj.buildtype - delete newObj.isCustomData - delete newObj.buildingCustomData - newObj.buildingBasicGroups.forEach(item => { - item.propertyInfos.forEach(element => { - delete element.isshowrule - delete element.rulevalue - if( element.propertyValue || element.propertyValue == 0){ - element.propertyValue = String(element.propertyValue) + propertyName: "储罐编号", + propertyValue: "", + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "储存介质", + propertyValue: "", + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "储罐类型", + propertyValue:"", + propertyType: 0, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "容量", + propertyValue: "", + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "㎡", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "直径", + propertyValue:"", + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "m", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "高度", + propertyValue: "", + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "m", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "顶盖形式", + propertyValue: "", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "浮盘材质", + propertyValue:"", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "浮盘类型", + propertyValue: "", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "泡沫产生器型号", + propertyValue:"", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "泡沫产生器形式", + propertyValue: "", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "是否设置氮封惰化保护装置", + propertyValue:"", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "防护堤高度", + propertyValue:"", + propertyType: 2, + required: true, + ruleName: "", + ruleValue: "", + physicalUnit: "m", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "半固定泡沫灭火接口数量", + propertyValue: "", + propertyType: 2, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "个", + order: 0, + enabled: true, + visible: true, + tag:"1" + }, + { + propertyName: "其它设施", + propertyValue: "", + propertyType: 0, + required: false, + ruleName: "", + ruleValue: "", + physicalUnit: "", + order: 0, + enabled: true, + visible: true, + tag:"1" } - }); - item.buildingId = newObj.buildingId - item.companyId = this.unitinfo.id - item.submitted = true - }); - // newObj.buildingBasicGroups[0].propertyInfos.forEach(item => { - // delete item.isshowrule - // delete item.rulevalue - // item.propertyValue = String(item.propertyValue) - // }); - // newObj.buildingBasicGroups[1].propertyInfos.forEach(item => { - // delete item.isshowrule - // delete item.rulevalue - // item.propertyValue = String(item.propertyValue) - // }); - // newObj.buildingBasicGroups[0].buildingId = newObj.buildingId - // newObj.buildingBasicGroups[0].companyId = this.unitinfo.id - // newObj.buildingBasicGroups[1].buildingId = newObj.buildingId - // newObj.buildingBasicGroups[1].companyId = this.unitinfo.id - // newObj.buildingBasicGroups[0].submitted = true - // newObj.buildingBasicGroups[1].submitted = true - let newbodyObj2 = [] - newbodyObj2.push(newObj) - this.http.post("/api/CompanyAccount/BasicInfos",newbodyObj2,{ + ] + // console.log(888,bodyObj) + bodyObj.buildingBasicGroups.splice(4,bodyObj.buildingBasicGroups.length) + } + + + + let newbodyObj = [] + newbodyObj.push(bodyObj) + // console.log(1111,newbodyObj) + this.http.post("/api/CompanyAccount/BasicInfos",newbodyObj,{ params:{ - buildingId :newObj.buildingId + buildingId :item.buildingId } }).subscribe((data:any)=>{ this.houses[key].id = data[0].id @@ -2018,6 +1971,7 @@ export class BasicinfoComponent implements OnInit { config.verticalPosition = 'top'; config.duration = 3000 this.snackBar.open('建筑信息保存成功','确定',config); + // alert("建筑信息保存成功") }, err=>{ const config = new MatSnackBarConfig(); @@ -2025,7 +1979,67 @@ export class BasicinfoComponent implements OnInit { config.duration = 3000 this.snackBar.open('请检查输入数据是否有误','确定',config); }) - + } + if(item.buildtype == "地铁类"){ + let newObj = _.cloneDeep(item) + delete newObj.username + delete newObj.name + delete newObj.tongyong + delete newObj.ditie + delete newObj.buildtype + delete newObj.isCustomData + delete newObj.buildingCustomData + newObj.buildingBasicGroups.forEach(item => { + item.propertyInfos.forEach(element => { + delete element.isshowrule + delete element.rulevalue + if( element.propertyValue || element.propertyValue == 0){ + element.propertyValue = String(element.propertyValue) + } + }); + item.buildingId = newObj.buildingId + item.companyId = this.unitinfo.id + item.submitted = true + }); + // newObj.buildingBasicGroups[0].propertyInfos.forEach(item => { + // delete item.isshowrule + // delete item.rulevalue + // item.propertyValue = String(item.propertyValue) + // }); + // newObj.buildingBasicGroups[1].propertyInfos.forEach(item => { + // delete item.isshowrule + // delete item.rulevalue + // item.propertyValue = String(item.propertyValue) + // }); + // newObj.buildingBasicGroups[0].buildingId = newObj.buildingId + // newObj.buildingBasicGroups[0].companyId = this.unitinfo.id + // newObj.buildingBasicGroups[1].buildingId = newObj.buildingId + // newObj.buildingBasicGroups[1].companyId = this.unitinfo.id + // newObj.buildingBasicGroups[0].submitted = true + // newObj.buildingBasicGroups[1].submitted = true + let newbodyObj2 = [] + newbodyObj2.push(newObj) + this.http.post("/api/CompanyAccount/BasicInfos",newbodyObj2,{ + params:{ + buildingId :newObj.buildingId + } + }).subscribe((data:any)=>{ + this.houses[key].id = data[0].id + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('建筑信息保存成功','确定',config); + }, + err=>{ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请检查输入数据是否有误','确定',config); + }) + + } } - } + }) + + }} \ No newline at end of file