Browse Source

[完善]根据模板变化追踪完善基本信息页面

develop
邵佳豪 5 years ago
parent
commit
51b9d63747
  1. 2
      proxy.config.json
  2. 182
      src/app/ui/basicinfo/basicinfo.component.html
  3. 145
      src/app/ui/basicinfo/basicinfo.component.ts

2
proxy.config.json

@ -1,6 +1,6 @@
{
"/api": {
"target": "http://59.111.63.117:8090",
"target": "http://39.106.78.171:8088",
"secure": false,
"changeOrigin": true
}

182
src/app/ui/basicinfo/basicinfo.component.html

@ -166,38 +166,48 @@
</mat-form-field>
<span style="color: red;">*</span>
</div>
<h1 style="font-size: 22px;">{{item.buildingBasicGroups[0].name}}</h1>
<div class="houseinfoinput" *ngFor="let i of item.buildingBasicGroups[0].propertyInfos;let key = index" style="float: left;margin-left: 250px;position: relative;">
<span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span></span>
<!-- 如果类型是文本 -->
<mat-form-field *ngIf="i.propertyType == 0">
<input matInput id="floorspace" name="{{i.propertyName}}" type='text'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue">
</mat-form-field>
<!-- 如果类型是数字 -->
<mat-form-field *ngIf="i.propertyType == 2">
<input matInput id="floorspace" name="{{i.propertyName}}" type='number'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue"
(change)="inputchange($event,i.ruleName,i.ruleValue,i)"
>
<!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> -->
</mat-form-field>
<!-- 如果类型是多行文本 -->
<textarea *ngIf="i.propertyType == 1" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}"></textarea>
<span style="color: red;" *ngIf="i.required">*</span>
<div *ngIf="i.isshowrule" style=" position: absolute;
left: 205px;
top: 45px;
font-size: 11px;
color: red;">
<span>{{i.rulevalue}}</span>
<div *ngFor="let item of item.buildingBasicGroups" style="float: left;">
<h1 style="font-size: 22px;">{{item.name}}</h1>
<div class="houseinfoinput" *ngFor="let i of item.propertyInfos;let key = index" style="float: left;margin-left: 250px;position: relative;">
<span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span></span>
<!-- 如果类型是文本 -->
<mat-form-field *ngIf="i.propertyType == 0">
<input matInput id="floorspace" name="{{i.propertyName}}" type='text'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue">
</mat-form-field>
<!-- 如果类型是数字 -->
<mat-form-field *ngIf="i.propertyType == 2">
<input matInput id="floorspace" name="{{i.propertyName}}" type='number'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue"
(change)="inputchange($event,i.ruleName,i.ruleValue,i)"
>
<!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> -->
</mat-form-field>
<!-- 如果类型是多行文本 -->
<textarea *ngIf="i.propertyType == 1" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}"></textarea>
<span style="color: red;" *ngIf="i.required">*</span>
<div *ngIf="i.isshowrule" style=" position: absolute;
left: 205px;
top: 45px;
font-size: 11px;
color: red;">
<span>{{i.rulevalue}}</span>
</div>
</div>
</div>
<div class="CustomData" style="width: 200px;">
<mat-checkbox (change)="checkCustomData($event)" name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox>
<h1 style="font-size: 22px;width: 200px;">自定义信息</h1>
@ -510,119 +520,7 @@
</div>
<!-- 地铁类 -->
<div class="highinfo" *ngIf="item.ditie">
<div class="subwayinfo">
<div class="houseinfoinput">
<span>建筑名称:</span>
<mat-form-field>
<input matInput id="housename" name="housename" type='text'
required minlength="1" [(ngModel)]="item.name"
>
</mat-form-field>
<span style="color: red;">*</span>
</div>
<div class="houseinfoinput">
<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-select>
</mat-form-field>
<span style="color: red;">*</span>
</div>
<p style="font-size: 22px; width: 200px;">{{item.buildingBasicGroups[0].name}}</p>
<div class="houseinfoinput" *ngFor="let i of item.buildingBasicGroups[0].propertyInfos;let key = index" style="float: left;margin-left: 250px;position: relative;">
<span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span></span>
<!-- 如果类型是文本 -->
<mat-form-field *ngIf="i.propertyType == 0">
<input matInput id="floorspace" name="{{i.propertyName}}" type='text'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue">
</mat-form-field>
<!-- 如果类型是数字 -->
<mat-form-field *ngIf="i.propertyType == 2">
<input matInput id="floorspace" name="{{i.propertyName}}" type='number'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue"
(change)="inputchange($event,i.ruleName,i.ruleValue,i)"
>
<!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> -->
</mat-form-field>
<!-- 如果类型是多行文本 -->
<textarea *ngIf="i.propertyType == 1" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}"></textarea>
<span style="color: red;" *ngIf="i.required">*</span>
<div *ngIf="i.isshowrule" style=" position: absolute;
left: 205px;
top: 45px;
font-size: 11px;
color: red;">
<span>{{i.rulevalue}}</span>
</div>
</div>
</div>
<p style="font-size: 22px; width: 200px;">{{item.buildingBasicGroups[1].name}}</p>
<!-- <button type="button" mat-raised-button (click)="addloadgroup()">增加线路分组</button> -->
<div class="roadinfo">
<div class="houseinfoinput" *ngFor="let i of item.buildingBasicGroups[1].propertyInfos;let key = index" style="float: left;margin-left: 250px;position: relative;">
<span>{{i.propertyName}}<span *ngIf="i.physicalUnit">({{i.physicalUnit}})</span></span>
<!-- 如果类型是文本 -->
<mat-form-field *ngIf="i.propertyType == 0">
<input matInput id="floorspace" name="{{i.propertyName}}" type='text'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue">
</mat-form-field>
<!-- 如果类型是数字 -->
<mat-form-field *ngIf="i.propertyType == 2">
<input matInput id="floorspace" name="{{i.propertyName}}" type='number'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue"
(change)="inputchange($event,i.ruleName,i.ruleValue,i)"
>
<!-- <mat-error *ngIf="isshowrule">{{rulevalue}}</mat-error> -->
</mat-form-field>
<!-- 如果类型是多行文本 -->
<textarea *ngIf="i.propertyType == 1" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}"></textarea>
<span style="color: red;" *ngIf="i.required">*</span>
<div *ngIf="i.isshowrule" style=" position: absolute;
left: 205px;
top: 45px;
font-size: 11px;
color: red;">
<span>{{i.rulevalue}}</span>
</div>
</div>
</div>
<div class="CustomData" style="width: 200px;">
<mat-checkbox (change)="checkCustomData($event)" name="checkbuilding" [(ngModel)]="item.isCustomData" style="float: left;margin-right: 10px;"></mat-checkbox>
<h1 style="font-size: 22px;width: 200px;">自定义信息</h1>
</div>
<div *ngIf="item.isCustomData" style="position: relative;">
<button style="position: absolute;left: 0;" type="button" mat-icon-button (click)="addCustomData(item)" class="addCustomData"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button>
<button style="position: absolute;left:60px;" type="button" mat-icon-button (click)="deleteCustomData(item)" class="deleteCustomData"><mat-icon style="font-size: 38px;">remove_circle_outline</mat-icon></button>
<div class="houseinfoinput" style="float: left;margin-left: 250px;" *ngFor="let i of item.buildingCustomData.customProperties;let key = index">
<mat-form-field>
<input matInput type='text' name="{{key}}1CustomData"
required
[(ngModel)]="i.name">
</mat-form-field>
<span>:</span>
<mat-form-field>
<input matInput type='text' name="{{key}}2CustomData"
required
[(ngModel)]="i.value">
</mat-form-field>
<span style="color: red;" *ngIf="i.required">*</span>
</div>
</div>
</div>
<div class="infobtnbox">
<!-- <button type="button" color="primary" mat-raised-button>编辑</button> -->
<button type="submit()" mat-button mat-raised-button color="primary" >保存</button>

145
src/app/ui/basicinfo/basicinfo.component.ts

@ -91,6 +91,7 @@ export class BasicinfoComponent implements OnInit {
// this.getorganization()
this.getunitinfo()
this.getunitallbuilding()
}
//获得所有单位类型
getallunittype() {
@ -113,6 +114,13 @@ export class BasicinfoComponent implements OnInit {
this.getorganization()
setTimeout(() => {
this.http.get("/api/CompanyAccount/Company").subscribe((data:any)=>{
// console.log(111,data.buildingTypes.length)
if(data.buildingTypes.length){
sessionStorage.setItem('buildingTypeId',data.buildingTypes[0].id)
}else{
sessionStorage.setItem('buildingTypeId',"")
}
let node
this.allorganizing.forEach(item => {
if(item.id == data.organizationId){
@ -156,7 +164,7 @@ export class BasicinfoComponent implements OnInit {
this.buildingTypesname = data.buildingTypes[0].name
}
})
}, 500);
}, 1000);
}
//获得建筑自定义信息
@ -168,6 +176,7 @@ export class BasicinfoComponent implements OnInit {
//石油化工 装置信息 勾选框
checkboxchange(item,e){
// console.log(122,item)
if(item.buildingBasicGroups){
item.buildingBasicGroups.forEach(item=>{
if(item.name != "基本信息" && item.name != "装置信息"){
@ -299,7 +308,15 @@ export class BasicinfoComponent implements OnInit {
//把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组
let bigtankgroups = data[0].buildingBasicGroups.slice(2)
let noemptybigfordata = data[0].buildingBasicGroups
// if(noemptybigfordata.length > 4){
// noemptybigfordata.forEach((item,index) => {
// if(!item.submitted && item.name !="装置信息"){
// noemptybigfordata.splice(index, 1)
// }
// })
// }
let bigtankgroups = noemptybigfordata.slice(2)
// console.log("bigtankgroups",bigtankgroups)
let proportion = 2; //按照比例切割
let num = 0;
@ -331,8 +348,8 @@ export class BasicinfoComponent implements OnInit {
data[0].bigfor = bigfor
}
if(data[0].buildtype == "地铁类"){
data[0].tongyong = false
data[0].ditie = true
data[0].tongyong = true
// data[0].ditie = true
}
return data[0]
}
@ -405,12 +422,22 @@ export class BasicinfoComponent implements OnInit {
data[0].tongyong = false
data[0].isshiyou = true
this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息的初始数据,需要转换成datasource形式
let noemptydeviceArr = data[0].buildingBasicGroups[1].propertyInfos
noemptydeviceArr.forEach((item,index) => {
if(item.tag == ""){
noemptydeviceArr.splice(index,1)
}
});
this.deviceinfodata = noemptydeviceArr //存储装置信息的初始数据,需要转换成datasource形式
var map = []
this.deviceinfodata.forEach((item,index) => {
if(item.tag == ""){
item.tag = "1"
if(!data[0].buildingBasicGroups[1].submitted){
if(item.tag == ""){
item.tag = "1"
}
}
if(!(item.tag in map)){
map[item.tag] = []
}
@ -444,7 +471,15 @@ export class BasicinfoComponent implements OnInit {
data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource
//把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组
let bigtankgroups = data[0].buildingBasicGroups.slice(2)
let noemptybigfordata = data[0].buildingBasicGroups
// if(noemptybigfordata.length > 4){
// noemptybigfordata.forEach((item,index) => {
// if(!item.submitted && item.name !="装置信息"){
// noemptybigfordata.splice(index, 1)
// }
// })
// }
let bigtankgroups = noemptybigfordata.slice(2)
// console.log("bigtankgroups",bigtankgroups)
let proportion = 2; //按照比例切割
let num = 0;
@ -458,24 +493,33 @@ export class BasicinfoComponent implements OnInit {
bigfor.push(bigtankgroups.slice(num,(i+1)));
}
}
// var map2 = []
// let tankdetailindo = []
// let noemptyArr = []
//bigfor决定当前储罐分组有几个
bigfor.forEach(item=>{
item[1].propertyInfos.forEach(item => {
if(item.tag == ""){
item.tag = 1
}
});
item[1].propertyInfos = this.formatHandle(item[1].propertyInfos)
// console.log(bigfor)
bigfor.forEach((item,index)=>{
// if(item.length != 2){
// bigfor.splice(index,1)
// }else{
// if(item[1].propertyInfos){
// item[1].propertyInfos.forEach(item => {
// if(item.tag == ""){
// item.tag = 1
// }
// });
// }
item[1].propertyInfos = this.formatHandle(item[1].propertyInfos)
// }
})
data[0].bigfor = bigfor
}
if(data[0].buildtype == "地铁类"){
data[0].tongyong = false
data[0].ditie = true
data[0].tongyong = true
// data[0].ditie = true
}
resolve(data[0]) //把数据传递出去
})
@ -519,15 +563,19 @@ export class BasicinfoComponent implements OnInit {
item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos]
}
removedeviceinfo3(e,item){//点击减一行
if(item.bigfor[e][1].propertyInfos.length > 1){
item.bigfor[e][1].propertyInfos.pop()
}else{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('只剩一行,无法删除','确定',config);
var isdeleted = confirm("确定要删除末行吗?")
if(isdeleted){
if(item.bigfor[e][1].propertyInfos.length > 1){
item.bigfor[e][1].propertyInfos.pop()
}else{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('只剩一行,无法删除','确定',config);
}
item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos]
}
item.bigfor[e][1].propertyInfos = [...item.bigfor[e][1].propertyInfos]
}
@ -545,7 +593,7 @@ export class BasicinfoComponent implements OnInit {
}
}).subscribe((data:any)=>{
// console.log(1314,data)
console.log(777,data[0])
// console.log(777,data[0])
item.bigfor.push([
{
id: "",
@ -570,7 +618,7 @@ export class BasicinfoComponent implements OnInit {
enabled: true,
basicGroupId:'',
id: "",
name: "罐区" + (item.bigfor.length+ 1) +"/罐区情况",
name: "罐区" + (item.bigfor.length+ 1) +"/储罐信息",
order: item.bigfor.length+3,
propertyInfos: [
{
@ -725,8 +773,8 @@ export class BasicinfoComponent implements OnInit {
data[0].bigfor = bigfor
}
if(data[0].buildtype == "地铁类"){
data[0].tongyong = false
data[0].ditie = true
data[0].tongyong = true
// data[0].ditie = true
}
yyy = data[0]
resolve(yyy)
@ -986,6 +1034,7 @@ export class BasicinfoComponent implements OnInit {
config.duration = 3000
this.snackBar.open('请填写必填项','确定',config);
}else{
sessionStorage.setItem('buildingTypeId',value.unittype)
let time =new Date()
let body = {
id: this.unitinfo.id,
@ -1159,7 +1208,6 @@ export class BasicinfoComponent implements OnInit {
]
}).subscribe((data:any)=>{
this.houses[item.index].username = item.name
},
err=>{
alert("名称和类型保存失败")
@ -1208,10 +1256,6 @@ export class BasicinfoComponent implements OnInit {
alert("自定义信息保存失败")
})
}
if(item.buildtype != "石油化工类" && item.buildtype != "地铁类"){
@ -1241,7 +1285,7 @@ export class BasicinfoComponent implements OnInit {
let body = newObj
let newbody = []
newbody.push(body)
console.log(123,newbody)
// console.log(123,newbody)
if(newbody[0].buildingBasicGroups.length){
this.http.post("/api/CompanyAccount/BasicInfos",newbody,{
params:{
@ -1276,6 +1320,7 @@ export class BasicinfoComponent implements OnInit {
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
@ -1411,7 +1456,7 @@ export class BasicinfoComponent implements OnInit {
if(bodyObj.buildingBasicGroups[2].submitted){ //如果没有勾选储罐信息 则直接提交当前bodyObj
if(bodyObj.buildingBasicGroups[2].submitted){ //如果勾选储罐信息 则直接提交当前bodyObj
var map = {}; //用于存储石油化工要提交的储罐信息表单
for (let key in value) {
if (key.indexOf('tanker') != -1) {
@ -1454,7 +1499,7 @@ export class BasicinfoComponent implements OnInit {
tag: ""
},
{
propertyName: "区位置",
propertyName: "区位置",
propertyValue: map[key][1],
propertyType: 0,
required: true,
@ -1480,7 +1525,7 @@ export class BasicinfoComponent implements OnInit {
tag: ""
},
{
propertyName: "电话",
propertyName: "部门负责人电话",
propertyValue: map[key][3],
propertyType: 0,
required: true,
@ -1506,7 +1551,7 @@ export class BasicinfoComponent implements OnInit {
tag: ""
},
{
propertyName: "电话",
propertyName: "罐区负责人电话",
propertyValue: map[key][5],
propertyType: 0,
required: true,
@ -1540,9 +1585,7 @@ export class BasicinfoComponent implements OnInit {
bodyObj.buildingBasicGroups.push(basictankinfobody)
}
let basictankchildinfobody:any = []//-------------后续储罐信息以及储罐信息/罐区情况都push到这个数组中
item.bigfor.forEach(item => {
basictankchildinfobody.push(item[1].propertyInfos)
@ -1764,7 +1807,7 @@ export class BasicinfoComponent implements OnInit {
});
basictankchildinfobody={//
id: null,
name: "罐区" + Number(index+1) + "/罐区情况",
name: "罐区" + Number(index+1) + "/储罐信息",
type: 1,
addMode: 2,
basicGroupId:'',
@ -1781,6 +1824,8 @@ export class BasicinfoComponent implements OnInit {
bodyObj.buildingBasicGroups.push(basictankchildinfobody)
});
}else{
bodyObj.buildingBasicGroups[2].buildingId = item.buildingId
bodyObj.buildingBasicGroups[2].companyId = this.unitinfo.id
bodyObj.buildingBasicGroups[2].propertyInfos.forEach(item=>{
@ -1997,14 +2042,16 @@ export class BasicinfoComponent implements OnInit {
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

Loading…
Cancel
Save