Browse Source

[完善]完整度

master
邵佳豪 1 year ago
parent
commit
4d9547941f
  1. 4
      proxy.config.json
  2. 21
      src/app/service/tabbar-and-score.service.ts
  3. 260
      src/app/tabbar/tabbar.component.html
  4. 332
      src/app/tabbar/tabbar.component.scss
  5. 133
      src/app/tabbar/tabbar.component.ts
  6. 1650
      src/app/ui/basicinfo/basicinfo.component.ts
  7. 3279
      src/app/ui/collection-tools-building/collection-tools.component.ts
  8. 3267
      src/app/ui/collection-tools/collection-tools.component.ts
  9. 1264
      src/app/ui/fire-fighting-device/fire-fighting-device.component.ts
  10. 487
      src/app/ui/function-division/function-division.component.ts
  11. 380
      src/app/ui/key-site/key-site.component.ts
  12. 802
      src/app/ui/realistic-picture/realistic-picture.component.ts
  13. 624
      src/app/ui/uploading-cad/uploading-cad.component.ts

4
proxy.config.json

@ -1,6 +1,8 @@
{
"/api": {
"target": "http://183.194.244.232:8088/",
"target": "http://121.36.37.70:8207/",
"测试": "http://121.36.37.70:8207/",
"生产": "http://183.194.244.232:8088/",
"secure": false,
"changeOrigin": true
}

21
src/app/service/tabbar-and-score.service.ts

@ -0,0 +1,21 @@
import { Injectable } from "@angular/core";
import { Observable, ReplaySubject } from "rxjs";
@Injectable({
providedIn: "root",
})
export class TabbarAndScoreService {
constructor() {}
private _sendMessage: ReplaySubject<any> = new ReplaySubject<any>(1);
/** * **
* @param message *
* @returns {Observavle<any>} */
public sendMessage(message: any) {
this._sendMessage.next(message);
}
public getMessage(): Observable<any> {
return this._sendMessage.asObservable();
}
}

260
src/app/tabbar/tabbar.component.html

@ -1,35 +1,239 @@
<mat-toolbar [color]="'primary'">
<!-- <mat-toolbar> -->
<h1 *ngIf="companyName">{{companyName}}</h1>
<!-- <mat-toolbar> -->
<h1 *ngIf="companyName">{{companyName}}</h1>
<!--分数框-->
<div class="grade" *ngIf="companyIntegrityScore" onmouseover="xiangqing.style.display='block';"
onmouseout="xiangqing.style.display='none';">
<a class="active"><span><a></a>{{(companyIntegrityScore.totalScore.toFixed(2) * 100).toFixed()}} %</span></a>
</div>
<div class="integrityDetails" id="xiangqing" *ngIf="companyIntegrityScore">
<div class="integrityDetailsTop">
<span class="span1">分类名称</span>
<span class="span2">占比</span>
<span class="span3">总占比</span>
</div>
<div class="integrityDetailsBody">
<ul>
<li>
<div class="name">单位信息</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.basicInfoScore * 5).toFixed(1),5)">
</div>
</div>
<span>{{(companyIntegrityScore.basicInfoScore * 5).toFixed(1)}}%</span>
</div>
<div class="number">5%</div>
</li>
<li>
<div class="name">建筑信息</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.buildingInfoScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.buildingInfoScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
<li>
<div class="name">平面图</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.planImageScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.planImageScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
<li>
<div class="name">四周毗邻</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.adjoinScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.adjoinScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
<li>
<div class="name">消防设施</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.facilityScore * 25).toFixed(1),25)">
</div>
</div>
<span>{{(companyIntegrityScore.facilityScore * 25).toFixed(1)}}%</span>
</div>
<div class="number">25%</div>
</li>
<li>
<div class="name">重点部位</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.importantLocationScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.importantLocationScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
<li>
<div class="name">功能分区</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.functionalDivisionScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.functionalDivisionScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
<li>
<div class="name">实景图</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon"
[style]="integrityDetails((companyIntegrityScore.realityImageScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.realityImageScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
<li>
<div class="name">CAD上传</div>
<div class="colorDiv">
<div class="colorDivBac">
<div class="colorDivCon" [style]="integrityDetails((companyIntegrityScore.cadScore * 10).toFixed(1),10)">
</div>
</div>
<span>{{(companyIntegrityScore.cadScore * 10).toFixed(1)}}%</span>
</div>
<div class="number">10%</div>
</li>
</ul>
</div>
<div style="width: 100%;text-align: center;font-size: 13px;position: relative;">
仅供参考
<span class="closeScore" style="position: absolute;right: 12px;top: 0px;"
onmouseover="xiangqing.style.display='none';">关闭</span>
</div>
</div>
<div class="scoringRule" *ngIf="companyIntegrityScore">
<span class="name" (click)="scoringRule()">
信息完整度规则
</span>
<div class="scoringRuleImg" *ngIf="scoringRuleImg">
<div class="topbox">
<span style="font-size: 18px;margin-left: 20px;font-weight: 600;">信息完整度规则 &nbsp;</span>
<!-- <span style="font-size: 12px;">单位基本信息部分共计100分</span> -->
<span class="imgbox">
<img src="../../assets/images/ruletopimg.png" alt="">
</span>
<span class="close" (click)="closebtn()">
<mat-icon>clear</mat-icon>
</span>
</div>
<div class="tablebox">
<table>
<tr>
<td>名称</td>
<td>占比</td>
<td>规则说明</td>
</tr>
<tr>
<td>单位信息</td>
<td class="bulecolor">5%</td>
<td>填写项平分该项占比分值,信息填写完整即可</td>
</tr>
<tr>
<td>建筑信息</td>
<td class="bulecolor">10%</td>
<td>根据创建的建筑个数平分该分值,每个建筑根据实际填写的完整度再进行评判</td>
</tr>
<tr>
<td>平面图</td>
<td class="bulecolor">10%</td>
<td>总平面图<span class="bulecolor">1</span>张,层平面图<span class="bulecolor">1</span></td>
</tr>
<tr>
<td>四周毗邻</td>
<td class="bulecolor">10%</td>
<td><span class="bulecolor">4</span>个方向均分,每个方向的属性信息要填写完整,并且包含图片</td>
</tr>
<tr>
<td>消防设施</td>
<td class="bulecolor">25%</td>
<td>消防水源占<span class="bulecolor">30%</span> &nbsp;&nbsp;安全疏散设施/消防泡沫系统/安全疏散模块占<span
class="bulecolor">30%</span> <br> 消防水系统/自动消防设施/消防设施/消防灭火给水系统/消火栓系统模块占<span class="bulecolor">30%</span>
&nbsp;&nbsp;&nbsp; 内部消防力量占<span class="bulecolor">10%</span></td>
</tr>
<tr>
<td>重点部位</td>
<td class="bulecolor">10%</td>
<td>层平面图中重点部位数量大于1个,并且属性信息填写完整(包含图片)</td>
</tr>
<tr>
<td>功能分区</td>
<td class="bulecolor">10%</td>
<td>任意建筑下功能分区信息填写两条以上并且信息填写完整</td>
</tr>
<tr>
<td>实景图</td>
<td class="bulecolor">10%</td>
<td>外观,保证有<span class="bulecolor">2</span>张照片(占<span class="bulecolor">30%</span>);
重点部位,保证有<span class="bulecolor">2</span>张照片(占<span class="bulecolor">30%</span>);安全出口,保证有<span
class="bulecolor">2</span>张照片(占<span class="bulecolor">40%</span></td>
</tr>
<tr>
<td>CAD上传</td>
<td class="bulecolor">10%</td>
<td>保证至少有<span class="bulecolor">1</span>个文件,格式不限</td>
</tr>
<!-- 帮助文档按钮 -->
<button mat-icon-button [matMenuTriggerFor]="appSet" class="help" title="帮助">
<mat-icon>help</mat-icon>
</table>
</div>
</div>
</div>
<!-- 帮助文档按钮 -->
<button mat-icon-button [matMenuTriggerFor]="appSet" class="help" title="帮助">
<mat-icon>help</mat-icon>
</button>
<mat-menu #appSet="matMenu" yPosition="below" xPosition="after">
<button mat-menu-item (click)='downloadHelpFile()'>
<mat-icon>save_alt</mat-icon>
<span>下载帮助文档</span>
</button>
<mat-menu #appSet="matMenu" yPosition="below" xPosition="after">
<button mat-menu-item (click)='downloadHelpFile()'>
<mat-icon>save_alt</mat-icon>
<span>下载帮助文档</span>
</button>
</mat-menu>
</mat-menu>
<!-- 登录信息按钮 -->
<button mat-icon-button [matMenuTriggerFor]="appMenu" class="login">
<mat-icon>account_circle</mat-icon>
<!-- 登录信息按钮 -->
<button mat-icon-button [matMenuTriggerFor]="appMenu" class="login">
<mat-icon>account_circle</mat-icon>
</button>
<mat-menu #appMenu="matMenu">
<button mat-menu-item [routerLink]="['/datacollection/userdata']">
<mat-icon>perm_identity</mat-icon>
<span>个人资料</span>
</button>
<button mat-menu-item (click)='changpsw()'>
<mat-icon>verified_user</mat-icon>
<span>修改密码</span>
</button>
<button mat-menu-item (click)='signOut()'>
<mat-icon>power_settings_new</mat-icon>
<span>退出系统</span>
</button>
<mat-menu #appMenu="matMenu">
<button mat-menu-item [routerLink]="['/datacollection/userdata']" >
<mat-icon>perm_identity</mat-icon>
<span>个人资料</span>
</button>
<button mat-menu-item (click)='changpsw()'>
<mat-icon>verified_user</mat-icon>
<span>修改密码</span>
</button>
<button mat-menu-item (click)='signOut()'>
<mat-icon>power_settings_new</mat-icon>
<span>退出系统</span>
</button>
</mat-menu>
</mat-menu>
</mat-toolbar>

332
src/app/tabbar/tabbar.component.scss

@ -1,45 +1,315 @@
mat-toolbar{
position: relative;
padding-left: 65px;
mat-toolbar {
position: relative;
padding-left: 65px;
}
.logo{
height: 64px;
widows: 64px;
.logo {
height: 64px;
widows: 64px;
}
h1{
line-height: 64px;
color: white;
h1 {
line-height: 64px;
color: white;
}
mat-icon{
color: white;
mat-icon {
color: white;
}
.login{
position: absolute;
right:30px;
.login {
position: absolute;
right: 30px;
}
.fullscreen{
position: absolute;
right:60px;
.fullscreen {
position: absolute;
right: 60px;
}
.help {
position: absolute;
right:90px;
position: absolute;
right: 90px;
}
.setting{
position: absolute;
right:120px;
.setting {
position: absolute;
right: 120px;
}
.lockscreen{
position: absolute;
right:160px;
.lockscreen {
position: absolute;
right: 160px;
}
.darktheme{
position: absolute;
right:140px;
.darktheme {
position: absolute;
right: 140px;
display: none;
}
.boxed {
width: 1200px;
}
.grade {
width: 120px;
height: 45px;
//border:1px solid #F00;
position: absolute;
text-align: center;
margin-left: 220px;
margin-top: 0px;
-webkit-transform: rotate(-10deg);
-moz-transform: rotate(-10deg);
transform: text;
a {
box-sizing: border-box;
display: inline-block;
color: #fff;
//padding: 12px 5px;
text-decoration: none;
cursor: pointer;
}
span {
text-align: center;
font-size: 36px;
line-height: 45px;
font-family: "STXinwei";
color: #FFA500;
cursor: default;
text-decoration: underline;
padding-bottom: 5px;
}
a.active>span,
a:hover>span {
//padding-bottom: 8px;
border-bottom: 3px solid #FFA500;
}
}
//鼠标移入详情页面显示
.integrityDetails {
position: absolute;
z-index: 999;
color: black;
display: none;
width: 350px;
height: 290px;
left: 390px;
top: 30px;
border: 1px solid rgba(0, 0, 0, 0.22);
background-color: white;
.integrityDetailsTop {
width: 100%;
height: 23px;
line-height: 23px;
border-bottom: 1px solid rgba(0, 0, 0, 0.22);
margin-bottom: 1px;
font-size: 14px;
span {
display: inline-block;
text-align: center;
font-weight: 800;
}
.span1 {
width: 25%;
}
.span2 {
width: 60%;
}
.span3 {
width: 15%;
}
}
.integrityDetailsBody {
ul {
li {
width: 100%;
height: 23px;
line-height: 23px;
margin: 3px 15px;
div {
float: left;
font-size: 13px;
}
.name {
width: 25%;
height: 100%;
}
.colorDiv {
width: 60%;
height: 100%;
position: relative;
.colorDivBac {
width: 90%;
height: 100%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: #dfe5ec;
border-radius: 5px;
.colorDivCon {
border-radius: 5px;
height: 100%;
background-color: #2398f1;
}
}
span {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
// color: white;
font-weight: 600;
}
}
.number {
width: 15%;
height: 100%;
}
}
}
}
.closeScore {
display: none;
}
@media screen and (max-width:1400px) {
.closeScore {
display: block;
}
}
}
.boxed{
width: 1200px;
}
//计分规则按钮
.scoringRule,
.isUpdates {
position: absolute;
left: 440px;
cursor: pointer;
.name {
background-color: #fff;
border-radius: 6px;
color: #2196F3;
display: inline-block;
width: 128px;
height: 36px;
text-align: center;
line-height: 36px;
font-size: 14px;
margin: 0;
padding: 0;
}
.span {
font-size: 18px;
margin-left: 12px;
}
.scoringRuleImg {
z-index: 999;
position: absolute;
left: 0;
top: 38px;
border: 1px solid #2196F3;
background-color: #fff;
.topbox {
position: relative;
background-color: #2196F3;
height: 40px;
line-height: 40px;
font-size: 16px;
.imgbox {
position: absolute;
right: 48px;
}
.close {
position: absolute;
right: 8px;
top: 10px;
}
}
.tablebox {
width: 610px;
color: #333333;
table {
display: block;
width: 100%;
font-size: 14px;
tr {
display: block;
width: 600px;
td {
white-space: normal;
display: inline-block;
width: 15%;
text-align: center;
}
td:last-child {
width: 70%;
line-height: 28px;
}
}
tr:nth-child(even) {
background: #f6faff;
}
}
.bulecolor {
color: #2196f3;
}
}
}
}
@media screen and (max-width:1400px) {
.scoringRule {
.scoringRuleImg {
left: -230px;
// .tablebox{
// width: 450px;
// table{
// tr{
// width: 450px;
// }
// }
// }
}
}
}

133
src/app/tabbar/tabbar.component.ts

@ -1,72 +1,115 @@
import { Component, OnInit,Output,EventEmitter } from '@angular/core';
import { HttpClient } from '@angular/common/http'
import { Router,ActivatedRoute } from '@angular/router'
import {HelpFileService} from './help-file.service' //引入服务
import {CacheTokenService} from '../http-interceptors/cache-token.service' //引入服务
import { MatDialog } from '@angular/material/dialog';
import {ChangepasswordComponent} from '../ui/changepassword/changepassword.component'
import { MatSnackBar } from '@angular/material/snack-bar';
import { CookieService } from 'ngx-cookie-service';
import { Component, OnInit, Output, EventEmitter } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { Router, ActivatedRoute } from "@angular/router";
import { HelpFileService } from "./help-file.service"; //引入服务
import { CacheTokenService } from "../http-interceptors/cache-token.service"; //引入服务
import { MatDialog } from "@angular/material/dialog";
import { ChangepasswordComponent } from "../ui/changepassword/changepassword.component";
import { MatSnackBar } from "@angular/material/snack-bar";
import { CookieService } from "ngx-cookie-service";
import { TabbarAndScoreService } from "../service/tabbar-and-score.service";
@Component({
selector: 'app-tabbar',
templateUrl: './tabbar.component.html',
styleUrls: ['./tabbar.component.scss']
selector: "app-tabbar",
templateUrl: "./tabbar.component.html",
styleUrls: ["./tabbar.component.scss"],
})
export class TabbarComponent implements OnInit {
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public dialog: MatDialog,public snackBar: MatSnackBar,
private cookieService: CookieService,private help: HelpFileService) { }
constructor(
private http: HttpClient,
private router: Router,
private route: ActivatedRoute,
public token: CacheTokenService,
public dialog: MatDialog,
public snackBar: MatSnackBar,
private cookieService: CookieService,
private help: HelpFileService,
private tabbarService: TabbarAndScoreService
) {}
ngOnInit() {
this.getUserInfo()
this.getUserInfo();
this.getIntegrityScore();
this.tabbarService.getMessage().subscribe((message: any) => {
this.getIntegrityScore();
});
}
companyName:any; //企业name
companyName: any; //企业name
//获取用户信息
getUserInfo () {
this.http.get('/api/CompanyAccount/Profiles').subscribe((data:any)=>{
sessionStorage.setItem('companyId',data.companyId)
this.companyName = data.companyName
})
getUserInfo() {
this.http.get("/api/CompanyAccount/Profiles").subscribe((data: any) => {
sessionStorage.setItem("companyId", data.companyId);
this.companyName = data.companyName;
});
}
//退出系统
signOut = () => {
let out = confirm("您确定要退出吗")
if(out) {
this.http.post('/api/CompanyAccount/SignOut',{}).subscribe(
data=> {
this.token.delete()
sessionStorage.clear()
window.localStorage.clear()
this.cookieService.set("token",'',new Date(new Date().getTime() + 1),'/');
this.cookieService.set("refreshToken",'',new Date(new Date().getTime() + 1),'/');
this.snackBar.open('成功退出', '确定', {
duration: 3000
});
this.router.navigate(['/login'])
}
)
let out = confirm("您确定要退出吗");
if (out) {
this.http.post("/api/CompanyAccount/SignOut", {}).subscribe((data) => {
this.token.delete();
sessionStorage.clear();
window.localStorage.clear();
this.cookieService.set(
"token",
"",
new Date(new Date().getTime() + 1),
"/"
);
this.cookieService.set(
"refreshToken",
"",
new Date(new Date().getTime() + 1),
"/"
);
this.snackBar.open("成功退出", "确定", {
duration: 3000,
});
this.router.navigate(["/login"]);
});
}
}
};
//修改密码
changpsw() {
let dialogRef = this.dialog.open(ChangepasswordComponent,
{width:'348px'});
let dialogRef = this.dialog.open(ChangepasswordComponent, {
width: "348px",
});
dialogRef.afterClosed().subscribe();
dialogRef.afterClosed().subscribe();
}
//下载帮助文档
downloadHelpFile () {
this.help.getFileMSG()
downloadHelpFile() {
this.help.getFileMSG();
}
//根据usci获取当前单位的分数信息
companyIntegrityScore;
getIntegrityScore() {
// let unitId = sessionStorage.getItem("companyId");
this.http.get(`/api/CompanyAccount/Company`).subscribe((data: any) => {
console.log("信息完整度", data);
this.companyIntegrityScore = data.companyIntegrityScore;
});
}
integrityDetails(width, zong) {
let style: any = {};
style.width = (width / zong) * 100 + "%";
return style;
}
//计分规则
scoringRuleImg: boolean = false;
scoringRule() {
this.scoringRuleImg = !this.scoringRuleImg;
}
closebtn() {
this.scoringRuleImg = false;
}
}

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

File diff suppressed because it is too large Load Diff

3279
src/app/ui/collection-tools-building/collection-tools.component.ts

File diff suppressed because it is too large Load Diff

3267
src/app/ui/collection-tools/collection-tools.component.ts

File diff suppressed because it is too large Load Diff

1264
src/app/ui/fire-fighting-device/fire-fighting-device.component.ts

File diff suppressed because it is too large Load Diff

487
src/app/ui/function-division/function-division.component.ts

@ -1,310 +1,389 @@
import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { Component, OnInit, Inject } from "@angular/core";
import { HttpClient, HttpHeaders } from "@angular/common/http";
import {
MatDialog,
MatDialogRef,
MAT_DIALOG_DATA,
} from "@angular/material/dialog";
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar";
import { TabbarAndScoreService } from "src/app/service/tabbar-and-score.service";
@Component({
selector: 'app-function-division',
templateUrl: './function-division.component.html',
styleUrls: ['./function-division.component.scss']
selector: "app-function-division",
templateUrl: "./function-division.component.html",
styleUrls: ["./function-division.component.scss"],
})
export class FunctionDivisionComponent implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
constructor(
private http: HttpClient,
public dialog: MatDialog,
public snackBar: MatSnackBar,
private tabbarService: TabbarAndScoreService
) {}
ngOnInit(): void {
this.companyId = sessionStorage.getItem('companyId')
this.getAllBuilding()
this.companyId = sessionStorage.getItem("companyId");
this.getAllBuilding();
}
displayedColumns: string[] = ['checked', 'region', 'measure', 'situation'];
displayedColumns: string[] = ["checked", "region", "measure", "situation"];
companyId:any; //单位编号
companyFunctionalZoning:any=[]; //所有单位功能分区属性
selectFunctionalZoning:any=[]; //选中的单位功能分区属性
companyId: any; //单位编号
companyFunctionalZoning: any = []; //所有单位功能分区属性
selectFunctionalZoning: any = []; //选中的单位功能分区属性
//获得所有单位功能分区属性
getAllCompany () {
this.http.get('/api/CompanyAccount/CompanyFunctionalDivisions').subscribe((data:any)=>{
this.companyFunctionalZoning = data
this.selectFunctionalZoning = []
})
getAllCompany() {
this.http
.get("/api/CompanyAccount/CompanyFunctionalDivisions")
.subscribe((data: any) => {
this.companyFunctionalZoning = data;
this.selectFunctionalZoning = [];
});
}
//新建单位功能分区属性
addCompany () {
let data = {companyId:this.companyId, region:'', area:0, details:''}
this.companyFunctionalZoning.push(data)
this.preservation()
addCompany() {
let data = { companyId: this.companyId, region: "", area: 0, details: "" };
this.companyFunctionalZoning.push(data);
this.preservation();
}
//保存单位功能分区属性
preservation () {
preservation() {
if (this.companyFunctionalZoning.length) {
this.http.post('/api/CompanyAccount/CompanyFunctionalDivisions/Batch',this.companyFunctionalZoning).subscribe(data=>{
this.getAllCompany()
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
})
this.http
.post(
"/api/CompanyAccount/CompanyFunctionalDivisions/Batch",
this.companyFunctionalZoning
)
.subscribe((data) => {
this.getAllCompany();
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("数据更新成功", "确定", config);
});
}
}
//单位功能分区checked选择
changeCompany (ele,e) {
changeCompany(ele, e) {
if (e.checked) {
this.selectFunctionalZoning.push(ele.id)
this.selectFunctionalZoning.push(ele.id);
} else {
this.selectFunctionalZoning.splice(this.selectFunctionalZoning.findIndex(item => item === ele.id), 1)
this.selectFunctionalZoning.splice(
this.selectFunctionalZoning.findIndex((item) => item === ele.id),
1
);
}
}
//删除单位功能分区属性
delete () {
delete() {
if (this.selectFunctionalZoning.length) {
let isDelete = confirm('您确定要删除吗')
let isDelete = confirm("您确定要删除吗");
if (isDelete) {
this.http.post('/api/CompanyAccount/CompanyFunctionalDivisions/Batch',this.companyFunctionalZoning).subscribe(data=>{
const options = {
headers: new HttpHeaders({'Content-Type': 'application/json',}),
body:this.selectFunctionalZoning}
this.http.delete(`/api/CompanyAccount/CompanyFunctionalDivisions/Batch`,options).subscribe(data=>{
this.getAllCompany()
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
})
})
this.http
.post(
"/api/CompanyAccount/CompanyFunctionalDivisions/Batch",
this.companyFunctionalZoning
)
.subscribe((data) => {
const options = {
headers: new HttpHeaders({ "Content-Type": "application/json" }),
body: this.selectFunctionalZoning,
};
this.http
.delete(
`/api/CompanyAccount/CompanyFunctionalDivisions/Batch`,
options
)
.subscribe((data) => {
this.getAllCompany();
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("数据更新成功", "确定", config);
});
});
}
} else if (!this.selectFunctionalZoning.length) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择单位功能分区','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("请选择单位功能分区", "确定", config);
}
}
//建筑功能分区↓
allBuilding:any = []; //所有建筑
allBuildingFunctionalZoning:any = []; //所有建筑的功能分区
selectBuildingFunctionalZoning:any = []; //选中的建筑的功能分区
allBuilding: any = []; //所有建筑
allBuildingFunctionalZoning: any = []; //所有建筑的功能分区
selectBuildingFunctionalZoning: any = []; //选中的建筑的功能分区
//获得所有建筑
getAllBuilding () {
this.http.get(`/api/CompanyAccount/Buildings`).subscribe((data:any)=>{
this.allBuilding = data
getAllBuilding() {
this.http.get(`/api/CompanyAccount/Buildings`).subscribe((data: any) => {
this.allBuilding = data;
if (data.length) {
this.allBuilding.forEach(element => { //为每个建筑添加一个 功能分区对象
element.functionalZoning = null
this.allBuilding.forEach((element) => {
//为每个建筑添加一个 功能分区对象
element.functionalZoning = null;
});
this.getAllBuildingFunctionalZoning()
this.getAllBuildingFunctionalZoning();
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无建筑数据','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("暂无建筑数据", "确定", config);
}
})
});
}
noDataList = [] //没有 创建功能分区 的建筑
noDataList = []; //没有 创建功能分区 的建筑
//获得所有建筑的功能分区
getAllBuildingFunctionalZoning () {
this.selectBuildingFunctionalZoning = []
this.allBuildingFunctionalZoning = []
this.noDataList = []
this.allBuilding.forEach(element => {
let data={buildingId: element.id}
this.http.get(`/api/CompanyAccount/BuildingFunctionalDivisions`,{params:data}).subscribe((data:any)=>{
if (data.length) {
element.functionalZoning = data
this.selectBuildingFunctionalZoning.push([]) //拥有建筑功能分区的提前push空数组
this.allBuildingFunctionalZoning.push(element)
this.noDataList.push(true)
} else {
this.noDataList.push(false)
}
if (this.noDataList.length === this.allBuilding.length) { this.addVoluntarilyPartition() }
})
getAllBuildingFunctionalZoning() {
this.selectBuildingFunctionalZoning = [];
this.allBuildingFunctionalZoning = [];
this.noDataList = [];
this.allBuilding.forEach((element) => {
let data = { buildingId: element.id };
this.http
.get(`/api/CompanyAccount/BuildingFunctionalDivisions`, {
params: data,
})
.subscribe((data: any) => {
if (data.length) {
element.functionalZoning = data;
this.selectBuildingFunctionalZoning.push([]); //拥有建筑功能分区的提前push空数组
this.allBuildingFunctionalZoning.push(element);
this.noDataList.push(true);
} else {
this.noDataList.push(false);
}
if (this.noDataList.length === this.allBuilding.length) {
this.addVoluntarilyPartition();
}
});
});
}
// 没有 创建 建筑功能分区时 自动创建
addVoluntarilyPartition () {
let isNotHave:boolean = false
this.noDataList.forEach(item=> {
addVoluntarilyPartition() {
let isNotHave: boolean = false;
this.noDataList.forEach((item) => {
if (item === true) {
isNotHave = true
return
isNotHave = true;
return;
}
})
if (!isNotHave) { //所有建筑都没有 功能分区时
let bodyData = [{
});
if (!isNotHave) {
//所有建筑都没有 功能分区时
let bodyData = [
{
buildingId: this.allBuilding[0].id,
region: "",
area: 0,
details: ""
}]
let params = {buildingId:this.allBuilding[0].id}
this.http.post('/api/CompanyAccount/BuildingFunctionalDivisions/Batch',bodyData,{params:params}).subscribe(datas=>{
this.http.get(`/api/CompanyAccount/BuildingFunctionalDivisions`,{params:params}).subscribe((data:any)=>{
this.allBuilding[0].functionalZoning = data
this.selectBuildingFunctionalZoning.push([]) //拥有建筑功能分区的提前push空数组
this.allBuildingFunctionalZoning.push(this.allBuilding[0])
})
})
details: "",
},
];
let params = { buildingId: this.allBuilding[0].id };
this.http
.post(
"/api/CompanyAccount/BuildingFunctionalDivisions/Batch",
bodyData,
{ params: params }
)
.subscribe((datas) => {
this.http
.get(`/api/CompanyAccount/BuildingFunctionalDivisions`, {
params: params,
})
.subscribe((data: any) => {
this.allBuilding[0].functionalZoning = data;
this.selectBuildingFunctionalZoning.push([]); //拥有建筑功能分区的提前push空数组
this.allBuildingFunctionalZoning.push(this.allBuilding[0]);
});
});
}
}
//封装函数刷新当前建筑功能分区
updateCurrent (e,index) {
let data= {buildingId: e.id}
this.http.get(`/api/CompanyAccount/BuildingFunctionalDivisions`,{params:data}).subscribe((data:any)=>{
this.selectBuildingFunctionalZoning[index] = []
this.allBuildingFunctionalZoning[index].functionalZoning = data
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据更新成功','确定',config);
})
updateCurrent(e, index) {
let data = { buildingId: e.id };
this.http
.get(`/api/CompanyAccount/BuildingFunctionalDivisions`, { params: data })
.subscribe((data: any) => {
this.selectBuildingFunctionalZoning[index] = [];
this.allBuildingFunctionalZoning[index].functionalZoning = data;
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("数据更新成功", "确定", config);
});
}
//创建建筑功能分区
addPartition () {
let data = this.allBuilding
let dialogRef = this.dialog.open(addPartition,{data});
dialogRef.afterClosed().subscribe(data=>{
if (data) {this.getAllBuilding()}
});
addPartition() {
let data = this.allBuilding;
let dialogRef = this.dialog.open(addPartition, { data });
dialogRef.afterClosed().subscribe((data) => {
if (data) {
this.getAllBuilding();
}
});
}
//创建建筑功能分区属性
addBuilding (e,index) {
let data = {buildingId:e.id, region:'', area:0, details:''}
this.http.post('/api/CompanyAccount/BuildingFunctionalDivisions',data).subscribe(data=>{
this.preservationBuilding(e,index)
})
addBuilding(e, index) {
let data = { buildingId: e.id, region: "", area: 0, details: "" };
this.http
.post("/api/CompanyAccount/BuildingFunctionalDivisions", data)
.subscribe((data) => {
this.preservationBuilding(e, index);
});
}
//保存建筑功能分区属性
preservationBuilding (e,index) {
let data ={buildingId:e.id}
this.http.post(`/api/CompanyAccount/BuildingFunctionalDivisions/Batch`,this.allBuildingFunctionalZoning[index].functionalZoning,{params:data}).subscribe(data=>{
this.updateCurrent(e,index)
})
preservationBuilding(e, index) {
let data = { buildingId: e.id };
this.http
.post(
`/api/CompanyAccount/BuildingFunctionalDivisions/Batch`,
this.allBuildingFunctionalZoning[index].functionalZoning,
{ params: data }
)
.subscribe((data) => {
this.updateCurrent(e, index);
this.tabbarService.sendMessage("changeScore"); //通知服务改变分数
});
}
//建筑功能分区checked选择
changeBuilding (ele,e,index) {
changeBuilding(ele, e, index) {
if (e.checked) {
this.selectBuildingFunctionalZoning[index].push(ele.id)
this.selectBuildingFunctionalZoning[index].push(ele.id);
} else {
this.selectBuildingFunctionalZoning[index].splice(this.selectBuildingFunctionalZoning[index].findIndex(item => item === ele.id), 1)
this.selectBuildingFunctionalZoning[index].splice(
this.selectBuildingFunctionalZoning[index].findIndex(
(item) => item === ele.id
),
1
);
}
}
//删除建筑功能分区
deleteBuilding (e,index) {
deleteBuilding(e, index) {
if (this.selectBuildingFunctionalZoning[index].length) {
let isDelete = confirm('您确定要删除吗')
let isDelete = confirm("您确定要删除吗");
if (isDelete) {
let data ={buildingId:e.id}
this.http.post(`/api/CompanyAccount/BuildingFunctionalDivisions/Batch`,this.allBuildingFunctionalZoning[index].functionalZoning,{params:data}).subscribe(data=>{
const options = {
headers: new HttpHeaders({'Content-Type': 'application/json',}),
body:this.selectBuildingFunctionalZoning[index],
params:{buildingId:e.id}}
this.http.delete(`/api/CompanyAccount/BuildingFunctionalDivisions/Batch`,options).subscribe(data=>{
this.selectBuildingFunctionalZoning[index].forEach((element,newIndex) => {
this.allBuildingFunctionalZoning[index].functionalZoning.splice(this.allBuildingFunctionalZoning[index].functionalZoning.findIndex(item=>item.id==element),1)
if (newIndex==this.selectBuildingFunctionalZoning[index].length-1) {
if (this.allBuildingFunctionalZoning[index].functionalZoning.length) {
this.updateCurrent(e,index)
} else {
this.selectBuildingFunctionalZoning.splice(index,1)
this.allBuildingFunctionalZoning.splice(index,1)}
}
});
})
})
let data = { buildingId: e.id };
this.http
.post(
`/api/CompanyAccount/BuildingFunctionalDivisions/Batch`,
this.allBuildingFunctionalZoning[index].functionalZoning,
{ params: data }
)
.subscribe((data) => {
const options = {
headers: new HttpHeaders({ "Content-Type": "application/json" }),
body: this.selectBuildingFunctionalZoning[index],
params: { buildingId: e.id },
};
this.http
.delete(
`/api/CompanyAccount/BuildingFunctionalDivisions/Batch`,
options
)
.subscribe((data) => {
this.selectBuildingFunctionalZoning[index].forEach(
(element, newIndex) => {
this.allBuildingFunctionalZoning[
index
].functionalZoning.splice(
this.allBuildingFunctionalZoning[
index
].functionalZoning.findIndex(
(item) => item.id == element
),
1
);
if (
newIndex ==
this.selectBuildingFunctionalZoning[index].length - 1
) {
if (
this.allBuildingFunctionalZoning[index].functionalZoning
.length
) {
this.updateCurrent(e, index);
} else {
this.selectBuildingFunctionalZoning.splice(index, 1);
this.allBuildingFunctionalZoning.splice(index, 1);
}
}
}
);
});
});
}
} else if (!this.selectBuildingFunctionalZoning[index].length) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择建筑功能分区','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("请选择建筑功能分区", "确定", config);
}
}
}
//创建建筑功能分区组件
@Component({
selector: 'app-addPartition',
templateUrl: './addPartition.html',
styleUrls: ['./function-division.component.scss']
selector: "app-addPartition",
templateUrl: "./addPartition.html",
styleUrls: ["./function-division.component.scss"],
})
export class addPartition {
constructor(
private http: HttpClient,
public dialog: MatDialog,
public dialogRef: MatDialogRef<addPartition>,
@Inject(MAT_DIALOG_DATA) public data
) {}
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<addPartition>,
@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {}
ngOnInit(): void {
}
selected:any; //选中的建筑
selected: any; //选中的建筑
//创建建筑功能分区
onSubmit (e) {
onSubmit(e) {
let data = {
buildingId:e.buildingId,
buildingId: e.buildingId,
region: "",
area: 0,
details: ""
}
this.http.post('/api/CompanyAccount/BuildingFunctionalDivisions',data).subscribe(data=>{
this.dialogRef.close(data);
})
details: "",
};
this.http
.post("/api/CompanyAccount/BuildingFunctionalDivisions", data)
.subscribe((data) => {
this.dialogRef.close(data);
});
}
}
//暂时无用
@Component({
selector: 'app-addPartitionAttribute',
templateUrl: './addPartitionAttribute.html',
styleUrls: ['./function-division.component.scss']
selector: "app-addPartitionAttribute",
templateUrl: "./addPartitionAttribute.html",
styleUrls: ["./function-division.component.scss"],
})
export class addPartitionAttribute {
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<addPartitionAttribute>,
@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
}
constructor(
private http: HttpClient,
public dialog: MatDialog,
public dialogRef: MatDialogRef<addPartitionAttribute>,
@Inject(MAT_DIALOG_DATA) public data
) {}
ngOnInit(): void {}
}

380
src/app/ui/key-site/key-site.component.ts

@ -1,227 +1,289 @@
import { Component, OnInit, ViewChild, Inject } from '@angular/core';
import {HttpClient} from '@angular/common/http'
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { KeySiteImgs } from './keysiteimgs.component'
import { Component, OnInit, ViewChild, Inject } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import {
MatDialogRef,
MatDialog,
MAT_DIALOG_DATA,
} from "@angular/material/dialog";
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar";
import { KeySiteImgs } from "./keysiteimgs.component";
import { TabbarAndScoreService } from "src/app/service/tabbar-and-score.service";
@Component({
selector: 'app-key-site',
templateUrl: './key-site.component.html',
styleUrls: ['./key-site.component.scss']
selector: "app-key-site",
templateUrl: "./key-site.component.html",
styleUrls: ["./key-site.component.scss"],
})
export class KeySiteComponent implements OnInit {
constructor(
public http: HttpClient,
public dialog: MatDialog,
public snackBar: MatSnackBar,
private tabbarService: TabbarAndScoreService
) {}
constructor(public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
displayedColumns: string[] = ['mainname', 'position', 'construction', 'nature', 'danger', 'img'];
displayedColumns: string[] = [
"mainname",
"position",
"construction",
"nature",
"danger",
"img",
];
ngOnInit(): void {
this.getAllBuilding()
this.getAllBuilding();
}
allCompanyPosition:any = []; //所有单位重点部位
companyTips:any; //所有单位重点提示
companyInput:any; //单位重点提示数据
allBuilding:any = []; //所有建筑 + 建筑重点部位 + 建筑重点提示
allCompanyPosition: any = []; //所有单位重点部位
companyTips: any; //所有单位重点提示
companyInput: any; //单位重点提示数据
allBuilding: any = []; //所有建筑 + 建筑重点部位 + 建筑重点提示
//获取单位重点部位
getCompanyPostion () {
this.http.get('/api/CompanyAccount/CompanyImportantLocations').subscribe(data=>{
this.allCompanyPosition = data
})
getCompanyPostion() {
this.http
.get("/api/CompanyAccount/CompanyImportantLocations")
.subscribe((data) => {
this.allCompanyPosition = data;
});
}
//获取单位重点提示
getCompanyTips () {
this.http.get('/api/CompanyAccount/CompanyImportantTips').subscribe((data:any)=>{
if (data) {
this.companyTips = data
this.companyInput = data.details}
})
getCompanyTips() {
this.http
.get("/api/CompanyAccount/CompanyImportantTips")
.subscribe((data: any) => {
if (data) {
this.companyTips = data;
this.companyInput = data.details;
}
});
}
//获取所有建筑
getAllBuilding () {
this.http.get('/api/CompanyAccount/Buildings').subscribe((data:any)=>{
this.allBuilding = data
getAllBuilding() {
this.http.get("/api/CompanyAccount/Buildings").subscribe((data: any) => {
this.allBuilding = data;
if (data.length) {
this.allBuilding.forEach(element => {
element.position = [] //建筑重点部位
element.tips = null //建筑重点提示
element.companyInput = null }) //建筑重点提示数据
this.getAllBuildingPositon()
this.getAllBuildingTips()
this.allBuilding.forEach((element) => {
element.position = []; //建筑重点部位
element.tips = null; //建筑重点提示
element.companyInput = null;
}); //建筑重点提示数据
this.getAllBuildingPositon();
this.getAllBuildingTips();
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无建筑数据','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("暂无建筑数据", "确定", config);
}
})
});
}
//获取所有建筑重点部位
getAllBuildingPositon () {
this.allBuilding.forEach(element => {
let id = {buildingId:element.id}
this.http.get('/api/CompanyAccount/BuildingImportantLocations',{params:id}).subscribe(data=>{
element.position = data
})
getAllBuildingPositon() {
this.allBuilding.forEach((element) => {
let id = { buildingId: element.id };
this.http
.get("/api/CompanyAccount/BuildingImportantLocations", { params: id })
.subscribe((data) => {
element.position = data;
});
});
}
//获取所有建筑重点提示
getAllBuildingTips () {
this.allBuilding.forEach(element => {
let id = {buildingId:element.id}
this.http.get('/api/CompanyAccount/BuildingImportantTips',{params:id}).subscribe((data:any)=>{
if (data) {
element.tips = data
element.companyInput = data.details}
})
getAllBuildingTips() {
this.allBuilding.forEach((element) => {
let id = { buildingId: element.id };
this.http
.get("/api/CompanyAccount/BuildingImportantTips", { params: id })
.subscribe((data: any) => {
if (data) {
element.tips = data;
element.companyInput = data.details;
}
});
});
}
//保存单位重点提示
Preservation () {
if (this.companyTips) { //编辑单位重点提示
Preservation() {
if (this.companyTips) {
//编辑单位重点提示
let data = {
companyId: this.companyTips.companyId,
id: this.companyTips.id,
details: this.companyInput}
this.http.put(`/api/CompanyAccount/CompanyImportantTips/${this.companyTips.id}`,data).subscribe(data=>{
this.getCompanyTips()
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据修改成功','确定',config);
})
} else { //新增单位重点提示
details: this.companyInput,
};
this.http
.put(
`/api/CompanyAccount/CompanyImportantTips/${this.companyTips.id}`,
data
)
.subscribe((data) => {
this.getCompanyTips();
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("数据修改成功", "确定", config);
});
} else {
//新增单位重点提示
let data = {
companyId: sessionStorage.getItem('companyId'),
id : "",
details: this.companyInput || ""}
this.http.post('/api/CompanyAccount/CompanyImportantTips',data).subscribe(data=>{
this.getCompanyTips()
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据修改成功','确定',config);
})
companyId: sessionStorage.getItem("companyId"),
id: "",
details: this.companyInput || "",
};
this.http
.post("/api/CompanyAccount/CompanyImportantTips", data)
.subscribe((data) => {
this.getCompanyTips();
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("数据修改成功", "确定", config);
});
}
}
//保存建筑重点提示
PreservationBuilding (e) {
if (e.tips) { //编辑建筑重点提示
PreservationBuilding(e) {
if (e.tips) {
//编辑建筑重点提示
let data = {
buildingId: e.id,
id: e.tips.id,
details: e.companyInput}
this.http.put(`/api/CompanyAccount/BuildingImportantTips/${e.tips.id}`,data).subscribe(data=>{
this.toUpdate(e)
})
} else { //新增重点单位提示
details: e.companyInput,
};
this.http
.put(`/api/CompanyAccount/BuildingImportantTips/${e.tips.id}`, data)
.subscribe((data) => {
this.toUpdate(e);
this.tabbarService.sendMessage("changeScore"); //通知服务改变分数
});
} else {
//新增重点单位提示
let data = {
buildingId: e.id,
details: e.companyInput || ""}
this.http.post('/api/CompanyAccount/BuildingImportantTips',data).subscribe(data=>{
this.toUpdate(e)
})
details: e.companyInput || "",
};
this.http
.post("/api/CompanyAccount/BuildingImportantTips", data)
.subscribe((data) => {
this.toUpdate(e);
this.tabbarService.sendMessage("changeScore"); //通知服务改变分数
});
}
}
//查看图片
seeImg (e) {
seeImg(e) {
if (e.imageUrls.length != 0) {
let data = e
const dialogRef = this.dialog.open(KeySiteImgs, {//调用open方法打开对话框并且携带参数过去
width: '1600px',
height:'900px',data});
let data = e;
const dialogRef = this.dialog.open(KeySiteImgs, {
//调用open方法打开对话框并且携带参数过去
width: "1600px",
height: "900px",
data,
});
dialogRef.afterClosed().subscribe();
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂无图片数据','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("暂无图片数据", "确定", config);
}
}
//封装方法获取更新当前tab页重点提示
toUpdate (e) {
let id = {buildingId:e.id}
this.http.get('/api/CompanyAccount/BuildingImportantTips',{params:id}).subscribe((data:any)=>{
if (data) {
this.allBuilding.forEach(element => {
if (element.id === e.id) {
element.tips = data
element.companyInput = data.details}
});
} // if
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据修改成功','确定',config);
})
toUpdate(e) {
let id = { buildingId: e.id };
this.http
.get("/api/CompanyAccount/BuildingImportantTips", { params: id })
.subscribe((data: any) => {
if (data) {
this.allBuilding.forEach((element) => {
if (element.id === e.id) {
element.tips = data;
element.companyInput = data.details;
}
});
} // if
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("数据修改成功", "确定", config);
});
}
objectName:any //上传对象名
keySiteItem:any
keySiteItemImgList:any //重点部位图片集合
Limit(element){
console.log(element)
objectName: any; //上传对象名
keySiteItem: any;
keySiteItemImgList: any; //重点部位图片集合
Limit(element) {
console.log(element);
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('图片已达上限','确定',config)
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("图片已达上限", "确定", config);
}
//上传素材图片
selectFile(element,e){
let imgFile = e.target.files[0] || null //上传的文件
this.keySiteItemImgList = element.imageUrls ? element.imageUrls : []
this.keySiteItem = element
console.log(this.keySiteItem)
this.startUploading(imgFile)
selectFile(element, e) {
let imgFile = e.target.files[0] || null; //上传的文件
this.keySiteItemImgList = element.imageUrls ? element.imageUrls : [];
this.keySiteItem = element;
console.log(this.keySiteItem);
this.startUploading(imgFile);
}
startUploading (imgFile) {
let _this = this
let file = imgFile || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB一个分片
let companyId = sessionStorage.getItem("companyId")
if (file && fileSize <= shardSize) { //上传文件<=5MB时
let formData = new FormData()
formData.append("file",file)
this.http.post(`api/Objects/WebPlan2D/${companyId}`,formData).subscribe((data:any)=>{
this.objectName = data.objectName
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传成功','确定',config)
this.keySiteItemImgList.push("/api/Objects/WebPlan2D/" + this.objectName)
this.keySiteItem.imageUrls = this.keySiteItemImgList
this.http.put(`/api/CompanyAccount/BuildingImportantLocations/${this.keySiteItem.id}`,this.keySiteItem,{
// params:{
// companyId : companyId
// }
}).subscribe((data)=>{
// console.log(666,'修改成功')
startUploading(imgFile) {
let _this = this;
let file = imgFile || null; //获取上传的文件
let fileSize = file.size || null; //上传文件的总大小
let shardSize = 5 * 1024 * 1024; //5MB一个分片
let companyId = sessionStorage.getItem("companyId");
if (file && fileSize <= shardSize) {
//上传文件<=5MB时
let formData = new FormData();
formData.append("file", file);
this.http
.post(`api/Objects/WebPlan2D/${companyId}`, formData)
.subscribe((data: any) => {
this.objectName = data.objectName;
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('修改成功','确定',config)
})
})
} else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("上传成功", "确定", config);
this.keySiteItemImgList.push(
"/api/Objects/WebPlan2D/" + this.objectName
);
this.keySiteItem.imageUrls = this.keySiteItemImgList;
this.http
.put(
`/api/CompanyAccount/BuildingImportantLocations/${this.keySiteItem.id}`,
this.keySiteItem,
{
// params:{
// companyId : companyId
// }
}
)
.subscribe((data) => {
// console.log(666,'修改成功')
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("修改成功", "确定", config);
});
});
} else if (file && fileSize > shardSize) {
//上传文件>5MB时,分块上传
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传图片文件不允许大于5mb','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("上传图片文件不允许大于5mb", "确定", config);
}
}
}

802
src/app/ui/realistic-picture/realistic-picture.component.ts

File diff suppressed because it is too large Load Diff

624
src/app/ui/uploading-cad/uploading-cad.component.ts

@ -1,407 +1,469 @@
import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import { Component, OnInit, Inject } from "@angular/core";
import { HttpClient, HttpHeaders } from "@angular/common/http";
import {
MatDialog,
MAT_DIALOG_DATA,
MatDialogRef,
} from "@angular/material/dialog";
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar";
import { TabbarAndScoreService } from "src/app/service/tabbar-and-score.service";
@Component({
selector: 'app-uploading-cad',
templateUrl: './uploading-cad.component.html',
styleUrls: ['./uploading-cad.component.scss']
selector: "app-uploading-cad",
templateUrl: "./uploading-cad.component.html",
styleUrls: ["./uploading-cad.component.scss"],
})
export class UploadingCADComponent implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
constructor(
private http: HttpClient,
public dialog: MatDialog,
public snackBar: MatSnackBar,
private tabbarService: TabbarAndScoreService
) {}
ngOnInit(): void {
this.companyId = sessionStorage.getItem('companyId')
this.getAllCAD()
this.companyId = sessionStorage.getItem("companyId");
this.getAllCAD();
}
displayedColumns: string[] = ['checked', 'name', 'time', 'state','size'];
displayedColumns: string[] = ["checked", "name", "time", "state", "size"];
companyId:any; //单位编号
CADList:any=[]; //所有CAD图
selectCAD:any = []; //选中的CAD图
companyId: any; //单位编号
CADList: any = []; //所有CAD图
selectCAD: any = []; //选中的CAD图
//获取所有CAD图
getAllCAD () {
this.http.get('/api/CompanyAccount/CadData').subscribe(data=>{
this.CADList = data
this.selectCAD = []
this.CADList.forEach(element => {
element.loading = false
element.suffix = element.cadUrl.substring(element.cadUrl.lastIndexOf("."),element.cadUrl.length); //图名后缀
element.fileLength = (element.fileLength/1024/1024).toFixed(2)});
})
getAllCAD() {
this.http.get("/api/CompanyAccount/CadData").subscribe((data) => {
this.CADList = data;
this.selectCAD = [];
this.CADList.forEach((element) => {
element.loading = false;
element.suffix = element.cadUrl.substring(
element.cadUrl.lastIndexOf("."),
element.cadUrl.length
); //图名后缀
element.fileLength = (element.fileLength / 1024 / 1024).toFixed(2);
});
this.tabbarService.sendMessage("changeScore"); //通知服务改变分数
});
}
//change CAD图checked
checkedCAD (e,element) {
checkedCAD(e, element) {
if (e.checked) {
this.selectCAD.push(element)
this.selectCAD.push(element);
} else {
this.selectCAD.splice(this.selectCAD.findIndex(item => item.id === element.id), 1)}
this.selectCAD.splice(
this.selectCAD.findIndex((item) => item.id === element.id),
1
);
}
}
//打开上传文件窗口
openReadFile() {
let dialogRef = this.dialog.open(readFile);
dialogRef.afterClosed().subscribe(data=>{
dialogRef.afterClosed().subscribe((data) => {
if (data) {
this.file = data.file
this.fileName = data.name
this.startUploading()} //开始上传
});
this.file = data.file;
this.fileName = data.name;
this.startUploading();
} //开始上传
});
}
//打开编辑文件窗口
editFile () {
if (this.selectCAD.length===1) {
let data = this.selectCAD[0]
let dialogRef = this.dialog.open(editFile,{data});
dialogRef.afterClosed().subscribe(data=>{
if (data) {this.getAllCAD()}
});
} else if (this.selectCAD.length>1) {
editFile() {
if (this.selectCAD.length === 1) {
let data = this.selectCAD[0];
let dialogRef = this.dialog.open(editFile, { data });
dialogRef.afterClosed().subscribe((data) => {
if (data) {
this.getAllCAD();
}
});
} else if (this.selectCAD.length > 1) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('不支持批量编辑','确定',config);
}else if (!this.selectCAD.length) {
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("不支持批量编辑", "确定", config);
} else if (!this.selectCAD.length) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择CAD图纸','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("请选择CAD图纸", "确定", config);
}
}
//删除CAD图
deleteCAD () {
deleteCAD() {
if (this.selectCAD.length) {
let isDelete = confirm('您确定要删除吗')
let arr = []
let isDelete = confirm("您确定要删除吗");
let arr = [];
if (isDelete) {
this.selectCAD.forEach( async (element,index) => {
let result = await new Promise((result,reject)=>{
this.http.delete(`/api/CompanyAccount/CadData/${element.id}`).subscribe(data=>{result(index)})
this.http.delete(`/api/Objects/PlanPlatform/${element.cadUrl}`).subscribe(data=>{})
})
arr.push(result)
if (arr.length == this.selectCAD.length) {
this.getAllCAD()
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除CAD图纸成功','确定',config);}
this.selectCAD.forEach(async (element, index) => {
let result = await new Promise((result, reject) => {
this.http
.delete(`/api/CompanyAccount/CadData/${element.id}`)
.subscribe((data) => {
result(index);
});
this.http
.delete(`/api/Objects/PlanPlatform/${element.cadUrl}`)
.subscribe((data) => {});
});
arr.push(result);
if (arr.length == this.selectCAD.length) {
this.getAllCAD();
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("删除CAD图纸成功", "确定", config);
}
});
}
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择CAD图纸','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("请选择CAD图纸", "确定", config);
}
}
//上传文件↓
file:any; //上传的文件
fileName:any; //上传文件name
uploadisLoading:boolean = false; //进度条loading加载
uploadProgress:number=0; //进度条进度
objectName:any; //上传对象名
uploadId:any; //上传分块上传事件编号
file: any; //上传的文件
fileName: any; //上传文件name
uploadisLoading: boolean = false; //进度条loading加载
uploadProgress: number = 0; //进度条进度
objectName: any; //上传对象名
uploadId: any; //上传分块上传事件编号
//上传文件
startUploading () {
let file = this.file || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB一个分片
if (file && fileSize<=shardSize) { //上传文件<=5MB时
let formData = new FormData()
formData.append("file",file)
this.http.post(`/api/Objects/PlanPlatform/${this.companyId}/CAD`,formData).subscribe((data:any)=>{
this.objectName = data.objectName
this.addCADData()
})
} else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传
let data = {filename: file.name}
this.uploadisLoading = true
this.http.post(`/api/NewMultipartUpload/PlanPlatform/${this.companyId}/CAD`,{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
this.objectName = data.objectName
this.uploadId = data.uploadId
this.subsectionUploading()
})
startUploading() {
let file = this.file || null; //获取上传的文件
let fileSize = file.size || null; //上传文件的总大小
let shardSize = 5 * 1024 * 1024; //5MB一个分片
if (file && fileSize <= shardSize) {
//上传文件<=5MB时
let formData = new FormData();
formData.append("file", file);
this.http
.post(`/api/Objects/PlanPlatform/${this.companyId}/CAD`, formData)
.subscribe((data: any) => {
this.objectName = data.objectName;
this.addCADData();
});
} else if (file && fileSize > shardSize) {
//上传文件>5MB时,分块上传
let data = { filename: file.name };
this.uploadisLoading = true;
this.http
.post(
`/api/NewMultipartUpload/PlanPlatform/${this.companyId}/CAD`,
{},
{ params: data }
)
.subscribe((data: any) => {
//初始化分段上传
this.objectName = data.objectName;
this.uploadId = data.uploadId;
this.subsectionUploading();
});
}
}
PartNumberETag:any=[]; //每次返回需要保存的信息
PartNumberETag: any = []; //每次返回需要保存的信息
//开始分段上传
async subsectionUploading () {
let file = this.file || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB一个分片
let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段
for (let i = 0;i < allSlice;i++) { //循环分段上传
let start = i * shardSize //切割文件开始位置
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
let formData = new FormData()
formData.append("file",file.slice(start, end))
//同步写法实现异步调用
let result = await new Promise((resolve, reject) => {
// await 需要后面返回一个 promise 对象
this.http.post(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}&partNumber=${i+1}`,formData).subscribe((data:any)=>{
let msg = {
"partNumber":data.partNumber || null,
"eTag": data.eTag || null}
resolve(msg) // 调用 promise 内置方法处理成功
})
});
this.PartNumberETag.push(result)
this.uploadProgress = Number((i/allSlice).toFixed(2))*100
if (this.PartNumberETag.length === allSlice) {
this.uploadProgress = 100
this.endUploading()}
}//for循环
async subsectionUploading() {
let file = this.file || null; //获取上传的文件
let fileSize = file.size || null; //上传文件的总大小
let shardSize = 5 * 1024 * 1024; //5MB一个分片
let allSlice = Math.ceil(fileSize / shardSize); //总文件/5MB===共分多少段
for (let i = 0; i < allSlice; i++) {
//循环分段上传
let start = i * shardSize; //切割文件开始位置
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
let formData = new FormData();
formData.append("file", file.slice(start, end));
//同步写法实现异步调用
let result = await new Promise((resolve, reject) => {
// await 需要后面返回一个 promise 对象
this.http
.post(
`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${
this.uploadId
}&partNumber=${i + 1}`,
formData
)
.subscribe((data: any) => {
let msg = {
partNumber: data.partNumber || null,
eTag: data.eTag || null,
};
resolve(msg); // 调用 promise 内置方法处理成功
});
});
this.PartNumberETag.push(result);
this.uploadProgress = Number((i / allSlice).toFixed(2)) * 100;
if (this.PartNumberETag.length === allSlice) {
this.uploadProgress = 100;
this.endUploading();
}
} //for循环
}
//完成分块上传
endUploading () {
let data = this.PartNumberETag
let paramsData = {uploadId:this.uploadId}
this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${this.objectName}`,data,{params:paramsData}).subscribe(data=>{
this.addCADData()
this.uploadProgress = 0;
this.uploadisLoading = false
this.PartNumberETag =[] //清空保存返回的信息
})
endUploading() {
let data = this.PartNumberETag;
let paramsData = { uploadId: this.uploadId };
this.http
.post(
`/api/CompleteMultipartUpload/PlanPlatform/${this.objectName}`,
data,
{ params: paramsData }
)
.subscribe((data) => {
this.addCADData();
this.uploadProgress = 0;
this.uploadisLoading = false;
this.PartNumberETag = []; //清空保存返回的信息
});
}
//取消分块上传
cancel () {
this.http.delete(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}`).subscribe(data=>{
this.uploadProgress = 0;
this.uploadisLoading= false
this.PartNumberETag =[] //清空保存返回的信息
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('取消上传成功!','确定',config);
})
cancel() {
this.http
.delete(
`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}`
)
.subscribe((data) => {
this.uploadProgress = 0;
this.uploadisLoading = false;
this.PartNumberETag = []; //清空保存返回的信息
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("取消上传成功!", "确定", config);
});
}
//上传成功创建CAD
addCADData () {
addCADData() {
let data = {
name: this.fileName,
cadUrl: this.objectName,
fileLength: this.file.size,
creationTime: new Date(),
companyId: this.companyId
}
this.http.post('/api/CompanyAccount/CadData',data).subscribe(data=>{
this.getAllCAD()
})
companyId: this.companyId,
};
this.http.post("/api/CompanyAccount/CadData", data).subscribe((data) => {
this.getAllCAD();
});
}
//下载↓
selectDownloadFile:any; //选择下载的文件
download:any; //下载文件元数据
downloadisLoading:boolean = false; //进度条loading加载
downloadProgress:number=0; //进度条进度
selectDownloadFile: any; //选择下载的文件
download: any; //下载文件元数据
downloadisLoading: boolean = false; //进度条loading加载
downloadProgress: number = 0; //进度条进度
//读取下载文件信息
readFile () {
if (this.selectCAD.length===1) {
this.selectDownloadFile = this.selectCAD[0]
this.http.get('/api/ObjectMetadata/PlanPlatform/'+this.selectDownloadFile.cadUrl).subscribe(data=>{
this.download = data
this.downloadFile()
})
} else if (this.selectCAD.length>1) {
readFile() {
if (this.selectCAD.length === 1) {
this.selectDownloadFile = this.selectCAD[0];
this.http
.get(
"/api/ObjectMetadata/PlanPlatform/" + this.selectDownloadFile.cadUrl
)
.subscribe((data) => {
this.download = data;
this.downloadFile();
});
} else if (this.selectCAD.length > 1) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('暂时不支持批量下载','确定',config)
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("暂时不支持批量下载", "确定", config);
} else if (!this.selectCAD.length) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择CAD图纸','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("请选择CAD图纸", "确定", config);
}
}
//初始化下载
downloadFile () {
let file = this.download
let fileSize = file.fileLength//下载文件的总大小
let shardSize = 10 * 1024 * 1024 //文件大小是否大于10MB
if (file && fileSize<=shardSize) { //<=10MB时直接下载
this.downloadisLoading = true
this.setFileLoading()
this.http.get(`/api/Objects/PlanPlatform/${file.objectName}`,{responseType: 'blob'},).subscribe(data=>{
let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", this.selectDownloadFile.name+this.selectDownloadFile.suffix);
document.body.appendChild(link);
link.click();
this.downloadisLoading = false
this.setFileLoading()
})
} else if (file && fileSize>shardSize) { //>10MB时分块下载
this.blockingDownload() //分段下载
this.downloadisLoading = true
this.setFileLoading()
downloadFile() {
let file = this.download;
let fileSize = file.fileLength; //下载文件的总大小
let shardSize = 10 * 1024 * 1024; //文件大小是否大于10MB
if (file && fileSize <= shardSize) {
//<=10MB时直接下载
this.downloadisLoading = true;
this.setFileLoading();
this.http
.get(`/api/Objects/PlanPlatform/${file.objectName}`, {
responseType: "blob",
})
.subscribe((data) => {
let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute(
"download",
this.selectDownloadFile.name + this.selectDownloadFile.suffix
);
document.body.appendChild(link);
link.click();
this.downloadisLoading = false;
this.setFileLoading();
});
} else if (file && fileSize > shardSize) {
//>10MB时分块下载
this.blockingDownload(); //分段下载
this.downloadisLoading = true;
this.setFileLoading();
}
}
//分段下载并合并
async blockingDownload () {
let file = this.download
let fileSize = file.fileLength //下载文件的总大小
let shardSize = 3 * 1024 * 1024 //3MB一个分片
let allSlice = Math.ceil(fileSize / shardSize) //总文件/3MB===共分多少段
let allFile:any = [] //所有的file分段
for (let i=0;i<allSlice;i++) {
let start = i * shardSize //每次下载文件开始位置
let end = Math.min(fileSize, start + shardSize-1); //每次下载文件结束为止
let result = await new Promise ((result,reject)=>{
this.http.get(`/api/Objects/PlanPlatform/${file.objectName}`,{headers:{'range':`bytes= ${start}-${end}`},responseType:'blob'}).subscribe(data=>{
result(data) })
})
allFile.push(result)
this.downloadProgress = Number((i/allSlice).toFixed(2))*100
if (allFile.length === allSlice) { //合并文件输出给浏览器
async blockingDownload() {
let file = this.download;
let fileSize = file.fileLength; //下载文件的总大小
let shardSize = 3 * 1024 * 1024; //3MB一个分片
let allSlice = Math.ceil(fileSize / shardSize); //总文件/3MB===共分多少段
let allFile: any = []; //所有的file分段
for (let i = 0; i < allSlice; i++) {
let start = i * shardSize; //每次下载文件开始位置
let end = Math.min(fileSize, start + shardSize - 1); //每次下载文件结束为止
let result = await new Promise((result, reject) => {
this.http
.get(`/api/Objects/PlanPlatform/${file.objectName}`, {
headers: { range: `bytes= ${start}-${end}` },
responseType: "blob",
})
.subscribe((data) => {
result(data);
});
});
allFile.push(result);
this.downloadProgress = Number((i / allSlice).toFixed(2)) * 100;
if (allFile.length === allSlice) {
//合并文件输出给浏览器
let url = window.URL.createObjectURL(new Blob(allFile)); //createObjectURL创建一个下载Blob的url地址
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", this.selectDownloadFile.name+this.selectDownloadFile.suffix);
link.setAttribute(
"download",
this.selectDownloadFile.name + this.selectDownloadFile.suffix
);
document.body.appendChild(link);
link.click();
this.downloadProgress = 0
this.downloadisLoading = false
this.setFileLoading()
this.downloadProgress = 0;
this.downloadisLoading = false;
this.setFileLoading();
}
} //for循环
}
//取消分块下载
cancelDowload () {
}
cancelDowload() {}
//封装函数设置当前文件loading状态
setFileLoading () {
let id = this.selectDownloadFile.id
this.CADList.forEach(element => {
if (element.id === id) { element.loading = !element.loading }
setFileLoading() {
let id = this.selectDownloadFile.id;
this.CADList.forEach((element) => {
if (element.id === id) {
element.loading = !element.loading;
}
});
}
}
//创建文件弹窗组件
@Component({
selector: 'app-readFile',
templateUrl: './readFile.html',
styleUrls: ['./uploading-cad.component.scss']
selector: "app-readFile",
templateUrl: "./readFile.html",
styleUrls: ["./uploading-cad.component.scss"],
})
export class readFile {
constructor(
private http: HttpClient,
public dialog: MatDialog,
public dialogRef: MatDialogRef<readFile>,
@Inject(MAT_DIALOG_DATA) public data,
public snackBar: MatSnackBar
) {}
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<readFile>,
@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) { }
ngOnInit(): void {
}
ngOnInit(): void {}
file:any; //上传的文件
file: any; //上传的文件
//input file 选择文件
selectFile (e) {
this.file = e.target.files[0] || null //上传的文件
selectFile(e) {
this.file = e.target.files[0] || null; //上传的文件
}
//提交表单上传
onSubmit (e) {
onSubmit(e) {
if (this.file) {
let data = {
name:e.name,
file: this.file}
name: e.name,
file: this.file,
};
this.dialogRef.close(data);
} else {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择CAD图纸','确定',config);
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("请选择CAD图纸", "确定", config);
}
}
}
//编辑文件弹窗组件
@Component({
selector: 'app-editFile',
templateUrl: './editFile.html',
styleUrls: ['./uploading-cad.component.scss']
selector: "app-editFile",
templateUrl: "./editFile.html",
styleUrls: ["./uploading-cad.component.scss"],
})
export class editFile {
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<editFile>,
@Inject(MAT_DIALOG_DATA) public data) { }
constructor(
private http: HttpClient,
public dialog: MatDialog,
public dialogRef: MatDialogRef<editFile>,
@Inject(MAT_DIALOG_DATA) public data
) {}
ngOnInit(): void {
this.CADname = this.data.name
this.CADname = this.data.name;
}
CADname:any; //name
CADname: any; //name
//提交表单保存
onSubmit (e) {
let headers = new HttpHeaders({'Content-Type': 'text/json'});
let options = {headers};
this.http.put(`/api/CompanyAccount/CadData/${this.data.id}`,JSON.stringify(e.name),options).subscribe(data=>{
this.dialogRef.close('success');
})
onSubmit(e) {
let headers = new HttpHeaders({ "Content-Type": "text/json" });
let options = { headers };
this.http
.put(
`/api/CompanyAccount/CadData/${this.data.id}`,
JSON.stringify(e.name),
options
)
.subscribe((data) => {
this.dialogRef.close("success");
});
}
}

Loading…
Cancel
Save