Browse Source

[完善]基本信息功能全部完成

develop
邵佳豪 5 years ago
parent
commit
4839da86ed
  1. 27
      src/app/ui/basicinfo/basicinfo.component.html
  2. 312
      src/app/ui/basicinfo/basicinfo.component.ts
  3. 2
      src/styles.scss

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

@ -3,17 +3,12 @@
<mat-accordion>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false"
expanded>
<mat-expansion-panel-header>
<mat-panel-title>
企业信息
</mat-panel-title>
<mat-panel-description>
<mat-icon>
{{panelOpenState ?'expand_more' : 'chevron_right'}}
</mat-icon>
</mat-panel-description>
expanded
>
<mat-expansion-panel-header style="color: black;">
<mat-panel-title>
单位信息
</mat-panel-title>
</mat-expansion-panel-header>
<div class="topbox">
<form (ngSubmit)="onSubmit(form.value,form.invalid)" #form="ngForm" class="example-container" >
@ -25,7 +20,8 @@
<input matInput id="creditcode" name="creditcode" type='text'
required minlength="1" maxlength="18"
[(ngModel)]="unitinfo.usci"
(focus)="closeorganizationbox()">
(focus)="closeorganizationbox()"
pattern="^[0-9A-HJ-NP-RTUW-Y]{2}\d{6}[0-9A-HJ-NP-RTUW-Y]{10}$">
</mat-form-field>
</div>
<div class="inputbox">
@ -50,7 +46,7 @@
<span>联系电话:</span>
<mat-form-field>
<input matInput id="linkphone" name="linkphone" type='text'
required minlength="1"
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>
@ -61,7 +57,8 @@
<input matInput id="organization" name="organization" type='text'
required minlength="1"
[(ngModel)]="selectedorganization"
(focus)="openorganizationbox()" >
(focus)="openorganizationbox()"
readonly="value" >
</mat-form-field>
</div>
<div id="organizationbox" class="organizationbox" *ngIf="isorganizationbox">
@ -109,7 +106,7 @@
</div>
<div class="addbtn">
<button type="submit" color="primary" class="submit1" mat-button mat-raised-button >保存</button>
<button type="submit" color="primary" class="submit1" mat-button mat-raised-button [disabled]="!form.form.valid">保存</button>
</div>
</div>
<!-- <div class="mainright" (click)="closeorganizationbox()"> -->

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

@ -58,7 +58,7 @@ export class BasicinfoComponent implements OnInit {
] //单位类型
}
uploader:FileUploader = new FileUploader({
url: `/api/Objects/PlanPlatform`,
url: `/api/Objects/PlanPlatform/${this.unitinfo.id}`,
method: "POST",
itemAlias: "uploadedfile",
removeAfterUpload:true
@ -584,140 +584,145 @@ export class BasicinfoComponent implements OnInit {
this.snackBar.open('只剩唯一储罐,无法删除','确定',config);
}
}
//点击+号 增加建筑
addhouseinfo() {
const dialogRef = this.dialog.open(AddHouseInfo, {//调用open方法打开对话框并且携带参数过去
width: '260px',
data: {unitinfo:this.unitinfo}
});
dialogRef.afterClosed().subscribe(
data => {
if(data){
this.getunitallbuilding()
let yyy = this.changebuildingdata(data)
console.log(111,yyy)//需要拿着这个去请求模板
}
}
);
}
//新建建筑时把原始建筑数据放进来进行加工处理成可用数据
changebuildingdata(data){
async changebuildingdata(data){
let n = data
let yyy
this.http.get("/api/CompanyAccount/BasicInfos",{ // 需要请求建筑信息的模板
params:{
buildingId:data.id,
buildingType:data.buildingTypes[0].id
}
}).subscribe((data)=>{//此时的data才是模板详细信息
let _data = data
this.http.get("/api/CompanyAccount/BuildingCustomData",{params:{ //-----处理建筑自定义属性部分
buildingId:n.id
}}).subscribe(data=>{
if(data){
_data[0].isCustomData = true //如果data存在则把自定义属性isCustomData设为true
_data[0].buildingCustomData = data //把建筑自定义信息赋给buildingCustomData自定义属性
}else{
_data[0].isCustomData = false
_data[0].buildingCustomData ={ //否则设为false,并且把自定义信息属性赋值为空
id: "",
customProperties: [
{
name: "",
value: ""
}
],
buildingId: _data[0].buildingId
}
}
})
data[0].buildingtypeId = n.buildingTypes[0].id
data[0].buildtype = n.buildingTypes[0].name
data[0].name = n.name
data[0].username = n.name
data[0].tongyong = true
data[0].index = this.houses.length //////////////////
if(data[0].buildtype == "石油化工类"){
data[0].tongyong = false
data[0].isshiyou = true //如果是石油化工则启用石油化工的模板
this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息表格的初始数据,需要转换成datasource形式
var map = []
this.deviceinfodata.forEach((item,index) => {
if(item.tag == ""){
item.tag = "1"
}
if(!(item.tag in map)){
map[item.tag] = []
}
map[item.tag].push(item)
});
let zhuangzhiinfodatasource = []
map.forEach((item,index)=>{
zhuangzhiinfodatasource[index] = {}
item.forEach(i => {
if (i.propertyName == "装置区名称") {
zhuangzhiinfodatasource[index].name = i.propertyValue
}
if (i.propertyName == "工艺流程") {
zhuangzhiinfodatasource[index].flow = i.propertyValue
let result = await new Promise(resolve=>{
this.http.get("/api/CompanyAccount/BasicInfos",{ // 需要请求建筑信息的模板
params:{
buildingId:data.id,
buildingType:data.buildingTypes[0].id
}
}).subscribe((data)=>{//此时的data才是模板详细信息
let _data = data
this.http.get("/api/CompanyAccount/BuildingCustomData",{params:{ //-----处理建筑自定义属性部分
buildingId:n.id
}}).subscribe(data=>{
if(data){
_data[0].isCustomData = true //如果data存在则把自定义属性isCustomData设为true
_data[0].buildingCustomData = data //把建筑自定义信息赋给buildingCustomData自定义属性
}else{
_data[0].isCustomData = false
_data[0].buildingCustomData ={ //否则设为false,并且把自定义信息属性赋值为空
id: "",
customProperties: [
{
name: "",
value: ""
}
],
buildingId: _data[0].buildingId
}
if (i.propertyName == "火灾危险性") {
zhuangzhiinfodatasource[index].danger = i.propertyValue
}
})
data[0].buildingtypeId = n.buildingTypes[0].id
data[0].buildtype = n.buildingTypes[0].name
data[0].name = n.name
data[0].username = n.name
data[0].tongyong = true
data[0].index = this.houses.length //////////////////
if(data[0].buildtype == "石油化工类"){
data[0].tongyong = false
data[0].isshiyou = true //如果是石油化工则启用石油化工的模板
this.deviceinfodata = data[0].buildingBasicGroups[1].propertyInfos //存储装置信息表格的初始数据,需要转换成datasource形式
var map = []
this.deviceinfodata.forEach((item,index) => {
if(item.tag == ""){
item.tag = "1"
}
if (i.propertyName == "灭火注意事项") {
zhuangzhiinfodatasource[index].payattentionto = i.propertyValue
if(!(item.tag in map)){
map[item.tag] = []
}
map[item.tag].push(item)
});
})
this.newzhuangzhiinfodatasource =[] //数据去空
zhuangzhiinfodatasource.forEach(item=>{
if(item !== "" && item != undefined){
this.newzhuangzhiinfodatasource.push(item)
let zhuangzhiinfodatasource = []
map.forEach((item,index)=>{
zhuangzhiinfodatasource[index] = {}
item.forEach(i => {
if (i.propertyName == "装置区名称") {
zhuangzhiinfodatasource[index].name = i.propertyValue
}
if (i.propertyName == "工艺流程") {
zhuangzhiinfodatasource[index].flow = i.propertyValue
}
if (i.propertyName == "火灾危险性") {
zhuangzhiinfodatasource[index].danger = i.propertyValue
}
if (i.propertyName == "灭火注意事项") {
zhuangzhiinfodatasource[index].payattentionto = i.propertyValue
}
});
})
this.newzhuangzhiinfodatasource =[] //数据去空
zhuangzhiinfodatasource.forEach(item=>{
if(item !== "" && item != undefined){
this.newzhuangzhiinfodatasource.push(item)
}
})
this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) //强制渲染表格
data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource
//把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组
let bigtankgroups = data[0].buildingBasicGroups.slice(2)
let proportion = 2; //按照比例切割
let num = 0;
let bigfor =[];
for(let i=0;i<bigtankgroups.length;i++){
if(i % proportion == 0 && i != 0){
bigfor.push(bigtankgroups.slice(num,i));
num = i;
}
if((i+1)==bigtankgroups.length){
bigfor.push(bigtankgroups.slice(num,(i+1)));
}
}
})
this.devicedataSourcebox[data[0].buildingId] = new MatTableDataSource<any>(this.newzhuangzhiinfodatasource) //强制渲染表格
data[0].newzhuangzhiinfodatasource = this.newzhuangzhiinfodatasource
var map2 = []
let tankdetailindo = []
let noemptyArr = []
//把bigfor分组取出来 先大循环 (储罐信息---储罐信息/罐区情况)为一组
let bigtankgroups = data[0].buildingBasicGroups.slice(2)
let proportion = 2; //按照比例切割
let num = 0;
let bigfor =[];
for(let i=0;i<bigtankgroups.length;i++){
if(i % proportion == 0 && i != 0){
bigfor.push(bigtankgroups.slice(num,i));
num = i;
}
if((i+1)==bigtankgroups.length){
bigfor.push(bigtankgroups.slice(num,(i+1)));
}
//bigfor决定当前储罐分组有几个
bigfor.forEach(item=>{
item[1].propertyInfos.forEach(item => {
if(item.tag == ""){
item.tag = 1
}
});
item[1].propertyInfos = this.formatHandle(item[1].propertyInfos)
})
data[0].bigfor = bigfor
}
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)
})
data[0].bigfor = bigfor
if(data[0].buildtype == "地铁类"){
data[0].tongyong = false
data[0].ditie = true
}
if(data[0].buildtype == "地铁类"){
data[0].tongyong = false
data[0].ditie = true
}
yyy = data[0]
yyy = data[0]
resolve(yyy)
})
})
return yyy
return result
}
//点击+号 增加建筑
addhouseinfo() {
const dialogRef = this.dialog.open(AddHouseInfo, {//调用open方法打开对话框并且携带参数过去
width: '260px',
data: {unitinfo:this.unitinfo}
});
dialogRef.afterClosed().subscribe(
async data => {
if(data){
let newbuilding = await this.changebuildingdata(data)
this.houses.push(newbuilding)
}
}
);
}
ggg:any = [1]
//在模板中增加地铁线路分组
addloadgroup(){
@ -809,7 +814,7 @@ export class BasicinfoComponent implements OnInit {
this.isspinner = false
let tempRes = JSON.parse(response);
this.imgUrl = tempRes.objectName
this.imgsrc = `/api/Objects/PlanPlatform/${this.imgUrl}`
this.imgsrc = `/api/Objects/PlanPlatform/${this.imgUrl}?x-oss-process=image/resize,m_fill,h_170,w_299`
}else {
// 上传文件后获取服务器返回的数据错误
}
@ -866,12 +871,16 @@ export class BasicinfoComponent implements OnInit {
})
}
//删除具体建筑
deletedbuilding(node){
deletedbuilding(item){
var isdeleted = confirm("确定要删除此建筑吗?")
if(isdeleted){
//请求删除接口
this.http.delete(`/api/CompanyAccount/Buildings/${node.buildingId}`).subscribe(data=>{
this.getunitallbuilding()
this.http.delete(`/api/CompanyAccount/Buildings/${item.buildingId}`).subscribe(data=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除成功','确定',config);
this.houses.splice(item.index,1)
})
}
}
@ -885,28 +894,28 @@ export class BasicinfoComponent implements OnInit {
this.snackBar.open('请填写必填项','确定',config);
}else{
let time =new Date()
let body = {
id: this.unitinfo.id,
name: this.unitinfo.name,
usci: value.creditcode,
contacts: value.linkman,
phone: value.linkphone,
address: value.unitaddress,
imageUrl: this.imgsrc,
location: {
x: 0,
y: 0
},
modifiedTime: time,
organizationId: this.selectedorganizationid,
organizationName: null,
buildingTypes: [
{
id: value.unittype,
name: this.buildingTypesname
}
]
}
let body = {
id: this.unitinfo.id,
name: this.unitinfo.name,
usci: value.creditcode,
contacts: value.linkman,
phone: value.linkphone,
address: value.unitaddress,
imageUrl: this.imgsrc,
location: {
x: 0,
y: 0
},
modifiedTime: time,
organizationId: this.selectedorganizationid,
organizationName: null,
buildingTypes: [
{
id: value.unittype,
name: this.buildingTypesname
}
]
}
this.http.put("/api/CompanyAccount/Company",body).subscribe((data:any)=>{ //修改单位基本信息
this.getunitinfo()
if(!this.houses.length){
@ -932,13 +941,18 @@ export class BasicinfoComponent implements OnInit {
this.getunitallbuilding()
})
}else{
// alert("保存成功")
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);
}
}
}

2
src/styles.scss

@ -44,7 +44,7 @@ h1{
padding: 0px !important;
}
.mat-expansion-indicator::after {
color: white;
color: black;
}
.example-sidenav .mat-drawer-inner-container {
overflow: hidden;

Loading…
Cancel
Save