Browse Source

[修正]修正基本信息无法正常保存问题

develop
邵佳豪 5 years ago
parent
commit
8118c8c030
  1. 260
      src/app/ui/basicinfo/basicinfo.component.html
  2. 74
      src/app/ui/basicinfo/basicinfo.component.ts

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

@ -1,5 +1,5 @@
<div style="height: 100%;display: flex; flex-direction: column;">
<!-- header -->
<mat-accordion>
<mat-expansion-panel expanded>
<mat-expansion-panel-header style="color: black;">
@ -8,137 +8,127 @@
</mat-panel-title>
</mat-expansion-panel-header>
<div class="topbox">
<form (ngSubmit)="onSubmit(form.value,form.invalid,form)" #form="ngForm" class="example-container" >
<div class="mainbox" >
<div class="mainleft">
<div class="inputbox" >
<span style="color: red;">*</span>
<span>统一社会信用代码:</span>
<mat-form-field>
<input matInput id="creditcode" name="creditcode" type='text' #usci="ngModel"
required minlength="1" maxlength="18"
[(ngModel)]="unitinfo.usci"
(focus)="closeorganizationbox()"
pattern="^[0-9A-HJ-NP-RTUW-Y]{2}\d{6}[0-9A-HJ-NP-RTUW-Y]{10}$">
</mat-form-field>
<div *ngIf="usci.invalid && (usci.dirty || usci.touched)" class="alert-danger">
<div *ngIf="usci.errors.pattern" class="alert-danger">
统一社会信用代码格式不正确
<form (ngSubmit)="onSubmit(form.value,form.invalid,form)" #form="ngForm" class="example-container">
<div class="mainbox" >
<div class="mainleft">
<div class="inputbox" >
<span style="color: red;">*</span>
<span>统一社会信用代码:</span>
<mat-form-field>
<input matInput id="creditcode" name="creditcode" type='text' #usci="ngModel"
required minlength="1" maxlength="18"
[(ngModel)]="unitinfo.usci"
(focus)="closeorganizationbox()"
pattern="^[0-9A-HJ-NP-RTUW-Y]{2}\d{6}[0-9A-HJ-NP-RTUW-Y]{10}$">
</mat-form-field>
<div *ngIf="usci.invalid && (usci.dirty || usci.touched)" class="alert-danger">
<div *ngIf="usci.errors.pattern" class="alert-danger">
统一社会信用代码格式不正确
</div>
</div>
</div>
</div>
<div class="inputbox">
<span style="color: red;">*</span>
<span>单位类型:</span>
<mat-form-field (click)="closeorganizationbox()">
<mat-select required name="unittype" [(ngModel)]="defaultbuildingTypes">
<mat-option [value]="item.id" *ngFor="let item of allunittype">{{item.name}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="inputbox">
<span style="color: red;">*</span>
<span>联系人:</span>
<mat-form-field>
<input matInput id="linkman" name="linkman" type='text'
required minlength="1"
[(ngModel)]="unitinfo.contacts"
(focus)="closeorganizationbox()"
<div class="inputbox">
<span style="color: red;">*</span>
<span>单位类型:</span>
<mat-form-field (click)="closeorganizationbox()">
<mat-select required name="unittype" [(ngModel)]="defaultbuildingTypes">
<mat-option [value]="item.id" *ngFor="let item of allunittype">{{item.name}}</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="inputbox">
<span style="color: red;">*</span>
<span>联系人:</span>
<mat-form-field>
<input matInput id="linkman" name="linkman" type='text'
required minlength="1"
[(ngModel)]="unitinfo.contacts"
(focus)="closeorganizationbox()"
>
</mat-form-field>
</div>
<div class="inputbox">
<span style="color: red;">*</span>
<span>联系电话:</span>
<mat-form-field>
<input matInput id="linkphone" name="linkphone" type='text' #linkphone="ngModel"
required pattern="^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0135-9]\d{2}|66\d{2})\d{6}$"
[(ngModel)]="unitinfo.phone"
(focus)="closeorganizationbox()"
>
</mat-form-field>
</div>
<div class="inputbox">
<span style="color: red;">*</span>
<span>联系电话:</span>
<mat-form-field>
<input matInput id="linkphone" name="linkphone" type='text' #linkphone="ngModel"
required pattern="^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0135-9]\d{2}|66\d{2})\d{6}$"
[(ngModel)]="unitinfo.phone"
(focus)="closeorganizationbox()"
>
</mat-form-field>
<div *ngIf="linkphone.invalid && (linkphone.dirty || linkphone.touched)" class="alert-danger">
<div *ngIf="linkphone.errors.pattern" class="alert-danger">
电话号码格式不正确
</mat-form-field>
<div *ngIf="linkphone.invalid && (linkphone.dirty || linkphone.touched)" class="alert-danger">
<div *ngIf="linkphone.errors.pattern" class="alert-danger">
电话号码格式不正确
</div>
</div>
</div>
</div>
<div class="inputbox" style="width: 700px;">
<span style="color: red;">*</span>
<span>辖区中队:</span>
<mat-form-field style="width: 538px;">
<input matInput id="organization" name="organization" type='text'
required minlength="1"
[(ngModel)]="selectedorganization"
(focus)="openorganizationbox()"
readonly="value" >
</mat-form-field>
</div>
<div id="organizationbox" class="organizationbox" *ngIf="isorganizationbox">
<!-- <div style="position: absolute;right: 0;">
<button type="button" style="cursor: pointer;">
<mat-icon>clear</mat-icon>
</button>
</div> -->
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='add(node)' class="organizationlist">
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='add(node)' class="organizationlist">
<button
type="button"
mat-icon-button
matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
<div class="inputbox" style="width: 700px;">
<span style="color: red;">*</span>
<span>单位地址:</span>
<mat-form-field style="width: 538px;">
<input matInput id="unitaddress" name="unitaddress" type='text'
required minlength="1"
[(ngModel)]="unitinfo.address"
(focus)="closeorganizationbox()">
</mat-form-field>
</div>
<div class="uploadimg" (click)="lookmaster()">
<span>单位照片:</span>
<div class="uploadingimg">
<img [src]="imgsrc" alt="" style="width: 299px; height: 170px;" >
<div class="inputbox" style="width: 700px;">
<span style="color: red;">*</span>
<span>辖区中队:</span>
<mat-form-field style="width: 538px;">
<input matInput id="organization" name="organization" type='text'
required minlength="1"
[(ngModel)]="selectedorganization"
(focus)="openorganizationbox()"
readonly="value" >
</mat-form-field>
</div>
<div id="organizationbox" class="organizationbox" *ngIf="isorganizationbox">
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)='add(node)' class="organizationlist">
<button type="button" mat-icon-button disabled ></button>
<li>{{node.name}}</li>
</mat-tree-node>
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)='add(node)' class="organizationlist">
<button
type="button"
mat-icon-button
matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
<li>{{node.name}}</li>
</mat-tree-node>
</mat-tree>
</div>
<div class="inputbox" style="width: 700px;">
<span style="color: red;">*</span>
<span>单位地址:</span>
<mat-form-field style="width: 538px;">
<input matInput id="unitaddress" name="unitaddress" type='text'
required minlength="1"
[(ngModel)]="unitinfo.address"
(focus)="closeorganizationbox()">
</mat-form-field>
</div>
<div class="uploadimg" (click)="lookmaster()">
<span>单位照片:</span>
<div class="uploadingimg">
<img [src]="imgsrc" alt="" style="width: 299px; height: 170px;" >
</div>
<mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner>
</div>
<div class="image" (click)="closeorganizationbox()">
<input id="selectedfile" type="file" ng2FileSelect [uploader]="uploader" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp">
</div>
<div class="addbtn">
<button type="submit" color="primary" class="submit1" mat-button mat-raised-button>保存</button>
</div>
<mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner>
</div>
<div class="image" (click)="closeorganizationbox()">
<input id="selectedfile" type="file" ng2FileSelect [uploader]="uploader" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp">
</div>
<div class="addbtn">
<button type="submit" color="primary" class="submit1" mat-button mat-raised-button>保存</button>
</div>
<!-- <div class="mainright" (click)="closeorganizationbox()"> -->
<!-- 地图预留位置 -->
<!-- </div> -->
</div>
<!-- <div class="mainright" (click)="closeorganizationbox()"> -->
<!-- 地图预留位置 -->
<!-- </div> -->
</div>
</form>
</div>
</form>
</div>
</mat-expansion-panel>
</mat-accordion>
<!-- body -->
<div class="bottombox" style="flex: 70%;overflow-y: auto;" >
<div class="houseinfobox" style="height: 100%; overflow-y: auto;padding-bottom: 64px; box-sizing:border-box">
<button type="button" mat-icon-button (click)="addhouseinfo()" class="addhouseinfo"><mat-icon style="font-size: 38px;">add_circle_outline</mat-icon></button>
@ -167,20 +157,21 @@
<span style="color: red;">*</span>
</div>
<div *ngFor="let item of item.buildingBasicGroups" style="float: left;">
<div *ngFor="let item of item.buildingBasicGroups;let www = index" 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;">
<div class="houseinfoinput" *ngFor="let i of item.propertyInfos" 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'
<input matInput id="floorspace" name="{{i.propertyName}}{{www}}" 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'
<input matInput id="floorspace" name="{{i.propertyName}}{{www}}" type='number'
required="{{ i.required==true ? 'true' : 'false' }}"
[(ngModel)]="i.propertyValue"
(change)="inputchange($event,i.ruleName,i.ruleValue,i)"
@ -189,10 +180,10 @@
</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>
<textarea *ngIf="i.propertyType == 1" style="width: 180px;height: 60px;" required="{{ i.required==true ? 'true' : 'false' }}" [(ngModel)]="i.propertyValue" name="{{i.propertyName}}{{key}}"></textarea>
<span style="color: red;" *ngIf="i.required">*</span>
<div *ngIf="i.isshowrule" style=" position: absolute;
<div *ngIf="i.isshowrule" style="position: absolute;
left: 205px;
top: 45px;
font-size: 11px;
@ -202,12 +193,6 @@
</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>
@ -229,10 +214,9 @@
</mat-form-field>
<span style="color: red;" *ngIf="i.required">*</span>
</div>
</div>
</div>
</div>
<!-- 石油化工 -->
<div class="highinfo" *ngIf="item.isshiyou;let bigkey = index">
@ -366,7 +350,6 @@
罐区 </th>
<td mat-cell *matCellDef="let element;let key = index">
<input style="height:45px" class="tankinfo" name="{{www}}{{element.tank}}tank{{key}}" type='text'
[(ngModel)]="element.tank">
</td>
</ng-container>
@ -522,7 +505,6 @@
<div class="infobtnbox">
<!-- <button type="button" color="primary" mat-raised-button>编辑</button> -->
<button type="submit()" mat-button mat-raised-button color="primary" >保存</button>
<button type="button" mat-raised-button (click)="deletedbuilding(item)" color="warn">删除</button>
</div>

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

@ -499,19 +499,19 @@ export class BasicinfoComponent implements OnInit {
})
data[0].bigfor = bigfor
}
if(data[0].buildtype == "地铁类"){
data[0].tongyong = true
// data[0].ditie = true
}
// if(data[0].buildtype == "地铁类"){
// data[0].tongyong = true
// // data[0].ditie = true
// }
resolve(data[0]) //把数据传递出去
})
})
this.houses.push(result) // 并且把他添加到 tab 总体数组中
}
}
// console.log(1314,this.houses)
})
// console.log(1314,this.houses)
}
unitinfotemplate:any //存储选择不同单位类型时的模板信息
@ -1237,12 +1237,18 @@ export class BasicinfoComponent implements OnInit {
if(item.buildtype != "石油化工类" && item.buildtype != "地铁类"){
// console.log(this.houses[key])
// console.log(value)
this.houses[key].buildingBasicGroups[0].propertyInfos.forEach(item => {
for (const key in value) {
if(item.propertyName == key){
item.propertyValue = String(value[key])
}
// for (const key in value) {
// if(item.propertyName == key){
// }
// }
if(item.propertyValue){
item.propertyValue = String(item.propertyValue)
}
});
let newObj = _.cloneDeep(this.houses[key]) //把数据深拷贝取出来进行操作
newObj.buildingBasicGroups[0].buildingId = item.buildingId
@ -1307,7 +1313,10 @@ export class BasicinfoComponent implements OnInit {
bodyObj.buildingBasicGroups[0].propertyInfos.forEach(item => {
for (const key in value) {
if (item.propertyName == key) {
item.propertyValue = String(value[key])
// if(item.propertyValue){
item.propertyValue = String(value[key])
// }
}
}
});
@ -2058,22 +2067,35 @@ export class BasicinfoComponent implements OnInit {
delete newObj.buildtype
delete newObj.isCustomData
delete newObj.buildingCustomData
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.forEach(item => {
item.propertyInfos.forEach(element => {
delete element.isshowrule
delete element.rulevalue
if(element.propertyValue){
element.propertyValue = String(element.propertyValue)
}
});
item.buildingId = newObj.buildingId
item.companyId = this.unitinfo.id
item.submitted = true
});
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
// 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,{

Loading…
Cancel
Save