chenjingyu 4 years ago
parent
commit
3e74a71722
  1. 1
      debug.log
  2. 1
      src/app/app.component.ts
  3. 10
      src/app/canvas-share-data.service.ts
  4. 3
      src/app/examiner/examiner.module.ts
  5. 99
      src/app/student/examination-details/examination-details.component.html
  6. 89
      src/app/student/examination-details/examination-details.component.scss
  7. 30
      src/app/student/examination-details/examination-details.component.ts
  8. 4
      src/app/student/student.module.ts
  9. 50
      src/app/ui/collection-tools-examinee/collection-tools.component.html
  10. 15
      src/app/ui/collection-tools-examinee/collection-tools.component.scss
  11. 648
      src/app/ui/collection-tools-examinee/collection-tools.component.ts
  12. 24
      src/app/ui/collection-tools-examinee/save.ts
  13. 17
      src/app/ui/collection-tools/collection-tools.component.ts
  14. 6
      src/app/ui/collection-tools/examinationQuestions.html
  15. 4
      src/app/ui/collection-tools/examinationQuestions.ts
  16. 6
      src/app/ui/collection-tools/save.ts
  17. 128
      src/app/working-area/model/axArrowConnector.ts
  18. 18
      src/app/working-area/model/axImageShape.ts
  19. 4
      src/app/working-area/model/axShape.ts
  20. 3
      src/app/working-area/model/gameMode.ts
  21. 105
      src/app/working-area/model/multipointIcon.ts
  22. 328
      src/app/working-area/model/pipeline.ts
  23. 119
      src/app/working-area/model/polygonIcon.ts
  24. 123
      src/app/working-area/working-area.component.ts

1
debug.log

@ -0,0 +1 @@
[1225/112746.821:ERROR:directory_reader_win.cc(43)] FindFirstFile: 系统找不到指定的路径。 (0x3)

1
src/app/app.component.ts

@ -33,6 +33,7 @@ export class AppComponent {
})
} else {
sessionStorage.clear()
localStorage.clear()
this.token.delete()
}

10
src/app/canvas-share-data.service.ts

@ -9,14 +9,24 @@ export class CanvasShareDataService {
constructor() { }
private _sendMessage: ReplaySubject<any> = new ReplaySubject<any>(1);
examDisposalNodesData//考生进入时获取当前试卷的处置节点
examFacilityAssetsData//考生进入时获取当前试卷要考察的消防设施
isChange = false; // 数据 是否改动
selectTemplateData: any; // 选择当前 模板数据
// 总平面图/建筑 楼层
selectStorey: any = {area: '', details: ''}; // 选择当前 楼层 数据
originalcompanyBuildingData: any; // 单位/建筑 数据
originaleveryStoreyData: any; // 总平面图/楼层/区域 楼层数据
examOriginaleveryStoreyData: any; // 考生答卷 总平面图/楼层/区域 楼层数据
hiddenBasicInfoFacilities: any; // 考生答卷 当前楼层需要隐藏的基本信息素材
// 总平面图/建筑 楼层
// 处置 节点

3
src/app/examiner/examiner.module.ts

@ -112,6 +112,7 @@ import { FinishDia }from './examiner-index/examiner-index.component'
NzTreeModule,
NzDatePickerModule,
],
providers: [ { provide: MatPaginatorIntl, useValue: myPaginator() } ]
providers: [ { provide: MatPaginatorIntl, useValue: myPaginator() } ],
exports:[PlanLevel]
})
export class ExaminerModule { }

99
src/app/student/examination-details/examination-details.component.html

@ -1,6 +1,6 @@
<div class="content">
<div><app-tabbar></app-tabbar></div>
<div class="cneter">
<div class="center">
<div class="left">
<div class="headerLeft">
@ -24,7 +24,8 @@
<div class="centerRight">
<div class="paperCenter" *ngIf="selectPaperType == '1'">
<mat-accordion>
<mat-accordion multi>
<!-- 基本信息 -->
<mat-expansion-panel>
<mat-expansion-panel-header class="panelHeader">
<label class="mariginRight">基本信息</label>
@ -32,10 +33,102 @@
</mat-expansion-panel-header>
</mat-expansion-panel>
<!-- 基本信息 -->
<!-- 四周毗邻 -->
<mat-expansion-panel *ngIf="selectPaper.adjoinData && selectPaper.adjoinData.length">
<mat-expansion-panel-header class="panelHeader">
<label class="mariginRight">四周毗邻</label>
<label>总分: <label class="mark"> {{selectPaper.adjoinScore}}</label>分, </label><label>单项<label class="mark"></label></label>
</mat-expansion-panel-header>
<div class="publicTest" *ngFor="let item of selectPaper.adjoinData">
<div class="publicTitle">{{item.name}}</div>
<div class="publicInput" *ngFor="let element of item.children"><label>{{element.name}}:</label><input type="text" [(ngModel)]="element.userAnswer" name="userAnswer"></div>
</div>
</mat-expansion-panel>
<!-- 四周毗邻 -->
<!-- 重点部位 -->
<mat-expansion-panel *ngIf="selectPaper.importLocationData && selectPaper.importLocationData.length">
<mat-expansion-panel-header class="panelHeader">
<label class="mariginRight">重点部位</label>
<label>总分: <label class="mark"> {{selectPaper.importLocationScore}}</label>分, </label><label>单项<label class="mark"></label></label>
</mat-expansion-panel-header>
<div class="publicTest" *ngFor="let item of selectPaper.importLocationData">
<div class="publicTitle">{{item.name}}</div>
<div class="publicTable">
<div class="tableRow" *ngFor="let element of item.tabledata; let key = index">
<div class="tabelHeader">{{element.propertyName}}</div>
<div class="tabelCenter" *ngFor="let elements of element.data">
<label *ngIf="key===0">{{elements.result}}</label>
<input type="text" [(ngModel)]="elements.userAnswer" name="userAnswer" *ngIf="key!=0">
</div>
</div>
</div>
</div>
</mat-expansion-panel>
<!-- 重点部位 -->
<!-- 功能分区 -->
<mat-expansion-panel *ngIf="selectPaper.functionalDivisionData && selectPaper.functionalDivisionData.length">
<mat-expansion-panel-header class="panelHeader">
<label class="mariginRight">功能分区</label>
<label>总分: <label class="mark"> {{selectPaper.functionalDivisionScore}}</label>分, </label><label>单项<label class="mark"></label></label>
</mat-expansion-panel-header>
<div class="publicTest" *ngFor="let item of selectPaper.functionalDivisionData">
<div class="publicTitle">{{item.name}}</div>
<div class="publicTable">
<div class="tableRow" *ngFor="let element of item.tabledata; let key = index">
<div class="tabelHeader">{{element.propertyName}}</div>
<div class="tabelCenter" *ngFor="let elements of element.data">
<label *ngIf="key===0">{{elements.result}}</label>
<input type="text" [(ngModel)]="elements.userAnswer" name="userAnswer" *ngIf="key!=0">
</div>
</div>
</div>
</div>
</mat-expansion-panel>
<!-- 功能分区 -->
<!-- 数据核验 -->
<mat-expansion-panel *ngIf="selectPaper.facilityData && selectPaper.facilityData.length">
<mat-expansion-panel-header class="panelHeader">
<label class="mariginRight">数据核验</label>
<label>总分: <label class="mark"> {{selectPaper.facilityScore}}</label>分, </label><label>单项<label class="mark"></label></label>
</mat-expansion-panel-header>
<div class="publicTest" *ngFor="let item of selectPaper.facilityData">
<div class="publicTitle">{{item.name}}</div>
<div class="publicInput" *ngFor="let element of item.children"><label>{{element.name}}:</label><input type="text" [(ngModel)]="element.userAnswer" name="userAnswer"></div>
</div>
</mat-expansion-panel>
<!-- 数据核验 -->
</mat-accordion>
</div>
<div class="paperCenter" *ngIf="selectPaperType == '2'">作战部署</div>
<!-- 作战部署 -->
<div class="paperCenter" *ngIf="selectPaperType == '2'">
<div class="planList">
<table>
<tr>
<td>预案名称</td>
<td>添加人</td>
<td>修改时间</td>
<td>是否公开</td>
<td>编制级别</td>
<td>设置分数</td>
<td>操作</td>
</tr>
<tr *ngFor="let item of selectPaper.planList">
<td>{{item.title}}</td>
<td>{{item.creatorName}}</td>
<td>{{item.modifiedTime | date:'yyyy-MM-dd'}}</td>
<td>{{item.isPublic ? '已公开' : '未公开'}}</td>
<td>{{item.planLevel | planlevel}}</td>
<td style="color: #FF8678;">{{item.score}}分</td>
<td>
<span style="color: #07CDCF;" (click)="enterExam(item)">进入</span>
</td>
</tr>
</table>
</div>
</div>
<!-- 作战部署 -->
</div>
</div>

89
src/app/student/examination-details/examination-details.component.scss

@ -1,3 +1,5 @@
table,table tr th, table tr td { border-bottom: 1px solid #EEF1F5; }
table { text-align: center; border-collapse: collapse; padding:2px;}
.content{
width: 100%;
height: 100%;
@ -5,7 +7,7 @@
display: flex;
flex-direction: column;
box-sizing: border-box;
.cneter {
.center {
flex: 1;
overflow: hidden;
background-color: #F2F5F6;
@ -111,4 +113,89 @@
background-color: #F5FDFE;
label { display: inline-block; }
}
}
input {
border-radius: 5px;
border: 1px solid rgb(212, 205, 205);
outline: none;
height: 30px;
padding-left: 10px;
}
//考生 具体考题 通用样式
.publicTest {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 0 10px;
.publicTitle {
margin-top: 10px;
width: 100%;
height: 30px;
line-height: 30px;
padding-left: 10px;
}
.publicInput {
margin: 10px;
width: 48%;
height: 36px;
line-height: 36px;
text-align: left;
overflow: hidden;
label {
display: inline-block;
width: 40%;
text-align: right;
margin-right: 10px;
}
input {
width: 50%;
}
}
.publicTable {
box-sizing: border-box;
width: 100%;
margin: 10px;
display: flex;
padding: 0 25px;
.tableRow {
flex: 1;
overflow: hidden;
.tabelHeader { background: #F5FDFE; }
>div {
width: 100%;
height: 36px;
line-height: 36px;
text-align: center;
margin: 5px;
input { width: 60%; }
}
}
}
}
//作战部署
.planList{
table{
width: 100%;
tr{
height: 42px;
font-size: 15px;
td{
input{
width: 62px;
height: 26px;
background: #F2F5F6;
border: none;
border-radius: 5px;
text-align: center;
}
span{
margin: 0 5px;
cursor: pointer;
}
}
}
tr:nth-child(1){ background: #F5FDFE; }
}
}

30
src/app/student/examination-details/examination-details.component.ts

@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { ActivatedRoute } from '@angular/router';
import { CanvasShareDataService } from 'src/app/canvas-share-data.service';
@Component({
selector: 'app-examination-details',
@ -11,23 +12,23 @@ import { ActivatedRoute } from '@angular/router';
})
export class ExaminationDetailsComponent implements OnInit {
constructor(public http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public route:ActivatedRoute) { }
constructor(public canvasData:CanvasShareDataService, public http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public route:ActivatedRoute) { }
async ngOnInit(): Promise<void> {
await this.getTestInfo()
this.getUnitPlans()//将试卷的预案考题放进数据中
}
paperId:any = this.route.snapshot.queryParams.paperId //试卷id
paperData:any //试卷信息
paperCompanyData:any = []; //考生具体考卷
selectPaper:any = {id:null}; //选择当前考卷
selectPaperType:string = '1'; //选择当前考卷内容
selectPaperType:string = '1'; //选择当前考卷内容 基本信息/作战部署
//获取考卷
async getTestInfo () {
let id = this.route.snapshot.queryParams.paperId
await new Promise((resolve, reject) => {
this.http.get(`/api/Papers/${id}`).subscribe((data:any)=>{
this.http.get(`/api/Papers/${this.paperId}`).subscribe((data:any)=>{
this.paperData = data
this.paperData.paperDataInfo.forEach(element => {
element.adjoinData? element.adjoinData = JSON.parse(element.adjoinData) : null
@ -39,7 +40,7 @@ export class ExaminationDetailsComponent implements OnInit {
this.paperCompanyData = JSON.parse( JSON.stringify(data.paperDataInfo) ) //具体考卷
this.selectPaper = this.paperCompanyData[0] || {id:null} //当前选择考卷
this.handlePaperData()
resolve()
resolve(1)
})
})
@ -77,12 +78,13 @@ export class ExaminationDetailsComponent implements OnInit {
this.http.get(`/api/PaperPlans`,{params:params}).subscribe(data => {
item.planList = []
item.planList = data
resolve()
resolve(1)
})
})
}
this.calculateScore()
}
examScore:any = 0//整个试卷的总分
//计算分数
calculateScore(){
@ -108,10 +110,22 @@ export class ExaminationDetailsComponent implements OnInit {
console.log(678,this.paperCompanyData)
}
//交卷
uploadPaper () {
console.log('交卷')
console.log(this.paperCompanyData)
}
//进入作战部署 考卷
enterExam(item){
console.log(item)
console.log(this.selectPaper)
sessionStorage.setItem('companyName',this.selectPaper.companyInfo.name)
sessionStorage.setItem('planId',item.planComponentId)
sessionStorage.setItem('buildingTypeId',this.selectPaper.companyInfo.buildingTypes[0].id)
sessionStorage.setItem('companyId',this.selectPaper.companyInfo.id)
let openType
item.examPlanType == 0 ? openType = 1 : openType = 2
window.open(`/canvasToolExaminee?planName=${item.title}&paperplanId=${item.id}&openType=${openType}&paperId=${this.paperId}&examId=${this.route.snapshot.queryParams.examId}&planComponentId=${item.planComponentId}`)
}
}

4
src/app/student/student.module.ts

@ -53,7 +53,8 @@ import { StudentRoutingModule } from './student-routing.module';
import { StudentIndexComponent } from './student-index/student-index.component';
import { StudentExamRecordComponent } from './student-exam-record/student-exam-record.component';
import { ExaminationDetailsComponent } from './examination-details/examination-details.component';
import { PlanLevel } from '../pipes/size.pipe';
import { ExaminerModule } from '../examiner/examiner.module';
@NgModule({
declarations: [StudentIndexComponent, StudentExamRecordComponent, ExaminationDetailsComponent],
@ -107,6 +108,7 @@ import { ExaminationDetailsComponent } from './examination-details/examination-d
NavigationModule,
NzTreeModule,
NzDatePickerModule,
ExaminerModule
],
providers: [ { provide: MatPaginatorIntl, useValue: myPaginator() } ]
})

50
src/app/ui/collection-tools-examinee/collection-tools.component.html

@ -2,10 +2,14 @@
<!-- header头部 -->
<div class="header">
<div class="headerTitle">{{examMsg.conpanyName}}</div>
<div class="headerCenter"> <input type="text" placeholder="请输入考试要点" [(ngModel)]="examMsg.keynote"> </div>
<div class="headerCenter">
<div *ngIf="planData" class="mainPointDiv">
<span [title]="planData.mainPoint">考试要点 : {{planData.mainPoint}}</span>
</div>
</div>
<div class="headerRight">
<button style="border: 1px solid #07CDCF; border-radius: 5px; margin: 0 15px;" (click)='openFireExamination()'><mat-icon>visibility</mat-icon>消防设施考题设定</button>
<button (click)="saveSite()" *ngIf="examType != 1"><mat-icon>description</mat-icon>保存</button>
<button (click)="saveSite()"><mat-icon>description</mat-icon>保存</button>
<button (click)="openUploadQuestions()"><mat-icon>open_in_browser</mat-icon>上传</button>
</div>
</div>
@ -43,31 +47,33 @@
<mat-icon *ngIf="toggleHandlePlans">keyboard_arrow_up</mat-icon>
<mat-icon *ngIf="!toggleHandlePlans">keyboard_arrow_down</mat-icon>
<label class="overflowText" style="font-weight: 550;">处置预案</label>
<label style="margin-left: 45px;">
<mat-icon title="选择考试节点" (click)='countValue($event)'>dashboard</mat-icon>
</label>
</div>
<div [hidden]="!toggleHandlePlans">
<nz-tree #nzTreeComponent [nzData]="treeData" nzBlockNode [nzTreeTemplate]="nzTreeTemplate" [nzExpandedKeys]="defaultExpandedKeys"></nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div id="terrNodePublic" (click)='selectanelPoint(node.origin)' [ngClass]="{'selectanelPoint': selectDisposalNode==node.origin.id}">
<label title="{{node.title}}" class="overflowText textNode">{{node.title}}</label>
<!-- <div class="planIconDiv" *ngIf="isEditPattern">
<mat-icon *ngIf="!node.origin.sitePlanId && !node.origin.buildingAreaId" (click)='editPanelPoint($event,node)'>edit</mat-icon>
<mat-icon *ngIf="node.level===0" (click)='addPanelPoint($event,node.origin,null)'>add</mat-icon>
<mat-icon *ngIf="!node.origin.sitePlanId && !node.origin.buildingAreaId" (click)='copyPanelPoint($event,node,treeData)'>library_books</mat-icon>
<mat-icon (click)='deletePanelPoint($event,node.origin)'>delete_forever</mat-icon>
</div> -->
</div>
</ng-template>
<div class="questionsBox">
<p>考试题目</p>
<nz-tree #nzTreeComponent [nzData]="questionstreeData" nzBlockNode [nzTreeTemplate]="nzTreeTemplate"></nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div id="terrNodePublic">
<label title="{{node.title}}" class="overflowText textNode">{{node.title}}</label>
</div>
</ng-template>
</div>
<div class="answerDiv">
<p>考生答案</p>
<nz-tree #nzTreeComponent2 [nzData]="treeData" nzBlockNode [nzTreeTemplate]="nzTreeTemplate2" [nzExpandedKeys]="defaultExpandedKeys"></nz-tree>
<ng-template #nzTreeTemplate2 let-node let-origin="origin">
<div id="terrNodePublic" (click)='selectanelPoint(node.origin)' [ngClass]="{'selectanelPoint': selectDisposalNode==node.origin.id}">
<label title="{{node.title}}" class="overflowText textNode">{{node.title}}</label>
</div>
</ng-template>
</div>
</div>
</div>
<!-- 处置预案 -->
<!-- 素材库 -->
<div id="materialBank" *ngIf="examType != 1">
<div id="materialBank">
<div class="planarGraphHeader" (click)='toggleMaterial()'>
<mat-icon *ngIf="toggleMaterialBank">keyboard_arrow_up</mat-icon>
<mat-icon *ngIf="!toggleMaterialBank">keyboard_arrow_down</mat-icon>
@ -225,7 +231,9 @@
<p style="width: 40%;display: inline-block;">{{item.PropertyName}}</p>
<span style="width: 26%;text-align:right;font-size: 13px;">{{imagesArr.length ? imagesArr.length : 0}} / {{item.PropertyValue}}</span>
<input [disabled]="!isEditPattern || (canvasAssetObj.GameMode == 0 && !pattern)" *ngIf="isImgNumCss" accept="image/*" (change)="selectFile($event)" type="file" style="width: 33%;position: absolute;right: 10px;top: 1px;opacity: 0;z-index: 100;cursor: pointer;height: 21px;">
<div style="width: 33%;height: 21px;line-height: 21px;text-align: center;position: absolute;right: 10px;top: 1px;z-index: 99;border: 1px solid rgb(208, 211, 214);border-radius: 2px;font-size: 13px;cursor: pointer;" (click)="imgNumBeyond()">添加</div>
<div [hidden]="!isEditPattern || (canvasAssetObj.GameMode == 0 && !pattern)" style="width: 33%;height: 21px;line-height: 21px;text-align: center;position: absolute;right: 10px;top: 1px;z-index: 99;border: 1px solid rgb(208, 211, 214);border-radius: 2px;font-size: 13px;cursor: pointer;" (click)="imgNumBeyond()">
添加
</div>
<div style="position: relative;;width: 89%;border:1px solid rgb(208, 211, 214);height: 100px;margin: 6px auto;" class="swiper-container">
@ -235,7 +243,7 @@
<!-- 如果需要导航按钮 -->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
<span style="position: absolute;right: 2px;top: 2px;cursor: pointer;z-index: 200;" *ngIf="isEditPattern">
<span style="position: absolute;right: 2px;top: 2px;cursor: pointer;z-index: 200;" [hidden]="!isEditPattern || (canvasAssetObj.GameMode == 0 && !pattern)">
<mat-icon class="hoverred" (click)="deleteImg()">delete</mat-icon>
</span>
</div>

15
src/app/ui/collection-tools-examinee/collection-tools.component.scss

@ -38,11 +38,16 @@
.headerCenter {
flex: 1;
overflow: hidden;
input {
width: 99%;
height: 30px;
background-color: #e7f0f0;
border-radius: 5px;
.mainPointDiv{
box-sizing: border-box;
padding-left: 8px;
cursor: default;
span{
font-family: Source Han Sans CN;
color: #FF8678;
font-size: 15px;
}
}
}
.headerRight {

648
src/app/ui/collection-tools-examinee/collection-tools.component.ts

@ -1,4 +1,4 @@
import { Component, OnInit, Inject, ViewChild,ElementRef,Renderer2, ViewContainerRef } from '@angular/core';
import { Component, OnInit, Inject, ViewChild,ElementRef,Renderer2, ViewContainerRef, ɵConsole } 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';
@ -18,7 +18,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { examinationQuestionsExaminee,uploadDisposalNodesExaminee,uploadQuestionsExaminee } from './examinationQuestions'
@Component({
selector: 'app-collection-tools',
templateUrl: './collection-tools.component.html',
@ -29,7 +28,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
@ViewChild('canvas',{static: true}) canvas:WorkingAreaComponent; //父组件中获得子组件的引用
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private element: ElementRef,public canvasData: CanvasShareDataService,private router:Router,private route:ActivatedRoute) { }
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
@ViewChild('nzTreeComponent2', { static: false }) nzTreeComponent!: NzTreeComponent;
// tree配置
private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数
return {
@ -151,191 +150,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
pattern:boolean = false//默认为基本信息编辑
//基本信息编辑模式
baseInfo(){
if (!this.pattern) {
this.basicInfo = true
this.canvas.setNameVisible(this.basicInfo,1)
this.pattern = true
this.canvasData.gameMode = GameMode.BasicInformation
this.canvasData.selectPanelPoint = new DisposalNodeData();
this.mateDeleteCustomize()
this.getAllLibrary()
this.checkedBuildingIndex = -1
this.getSitePlan() //总平面图一层
}
}
//想定作业编辑模式
wantWork(){
if (this.pattern) {
//让基本信息图标显示
this.basicInfo = false
this.canvas.setNameVisible(this.basicInfo,0)
this.pattern = false
this.canvasData.gameMode = GameMode.Assignment
this.getAllLibrary('plan')
this.getDisposalNode()
}
}
//ngzorro tree 拖拽
nzEvent(event: NzFormatEmitEvent): void {
if(this.isDrag){
let parentId
if(this.pos == 0){
parentId = event.node.key
}else{
if(event.node.level == 0){
parentId = null
}else{
parentId = event.node.origin.parentId
}
}
let orders = {}
let originalData = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] )) //tree原始数据
let targetNodeData = []//拖动移入节点的数据,用于遍历求出放在该数组的第几位
//找到需要重新排序的数组
if(this.pos == 0){
originalData.forEach(item => {
if(item.parentId == event.node.key){
targetNodeData.push(item)
}
})
}else{
if(event.node.origin.parentId){//如果拖动目标为非一级节点
originalData.forEach(item => {
if(item.parentId == event.node.origin.parentId){
targetNodeData.push(item)
}
})
}else{//如果拖动目标为一级节点
originalData.forEach(item => {
if(!item.parentId){
targetNodeData.push(item)
}
})
}
}
let idArr = []
targetNodeData.forEach(i => {
idArr.push(i.id)
})
console.log(6666666666666,event);
if(this.pos == 0 && event.node.origin.children.length == 1){
console.log("移入,没有兄弟")
let key = event.dragNode.key
orders[key] = 0
parentId = event.node.key
}else{
console.log("移入,多个兄弟")
let array = []
targetNodeData.forEach(item => {
if(item.id != event.dragNode.key){ //将拖动项先移除掉
array.push(item)
}
})
if(event.dragNode.isEnd[event.dragNode.isEnd.length - 1]){ //如果移入到最后一个
console.log("最后")
array.push(event.dragNode.origin)
}else if(event.dragNode.isStart[event.dragNode.isStart.length - 1]){//如果移入到第一个
console.log("第一")
array.unshift(event.dragNode.origin)
}else{//如果移入中间位置
console.log("中间")
array.splice(event.node.origin.order, 0, event.dragNode.origin)
}
array.forEach((item,key) => {
orders[item.id] = key
})
}
let obj ={
id : event.dragNode.origin.id,
parentId : parentId,
orders : orders
}
this.http.put("/api/DisposalNodes/Sort",obj).subscribe(data => {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('排序成功','确定',config)
this.refurbishTreeData()
})
}
}
isDrag //是否可以拖动
pos//放置位置
beforeDrop = (arg: NzFormatBeforeDropEvent) => {
if(arg.dragNode.origin.isDataNode && arg.node.level === 0){//如果为数据节点则不允许拖到一级节点
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('数据节点不允许拖拽到一级节点','确定',config)
this.isDrag = false
return of(false);
}else if(!arg.dragNode.origin.isDataNode && arg.node.level === 2){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('处置节点不允许拖拽到三级节点','确定',config)
this.isDrag = false
return of(false);
}else{
this.isDrag = true
this.pos = arg.pos
return of(true)
}
}
//ngzorro tree 拖拽
//天气栏目
weatherBtn = true
weatherBtnShow(){
this.weatherBtn = !this.weatherBtn
}
weatherBtnHidden(){
this.weatherBtn = !this.weatherBtn
}
//底部切换按钮div
detailsAndattentBtn = true
//节点详情
details(){
this.detailsAndattentBtn = true
}
//注意事项
attent(){
this.detailsAndattentBtn = false
}
//消防要素div边框高度调节
firecategoriesDivMouseDown(e){
document.onmousemove = (ev) => {
let bodyHeight = document.body.clientHeight //网页宽度
let maxHeight = this.element.nativeElement.querySelector('#rightDiv').clientHeight - 35 //最大宽度
if(bodyHeight - ev.clientY >= maxHeight){
this.element.nativeElement.querySelector('#firecategories').style.height = maxHeight+ 'px'
this.element.nativeElement.querySelector('#property').style.height = 35+ 'px'
}else{
this.element.nativeElement.querySelector('#firecategories').style.height = (bodyHeight - ev.clientY) + 'px' ;
this.element.nativeElement.querySelector('#property').style.height = (this.element.nativeElement.querySelector('#rightDiv').clientHeight - this.element.nativeElement.querySelector('#firecategories').clientHeight) + 'px'
}
}
document.onmouseup = () => {
document.onmousemove = null;
document.onmouseup = null;
}
}
//左侧div边框宽度调节
leftDivMouseDown(e){
@ -354,22 +169,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
//底部div高度调节
bottomDivMouseDown(e){
document.onmousemove = (ev) => {
let bodyHeight = document.body.clientHeight //网页高度
let maxHeight = this.element.nativeElement.querySelector('#rightDiv').clientHeight //最大高度
if(bodyHeight - ev.clientY >= maxHeight){
this.element.nativeElement.querySelector('#bottomDiv').style.height = maxHeight + 'px'
}else{
this.element.nativeElement.querySelector('#bottomDiv').style.height = (bodyHeight - ev.clientY) + 'px' ;
}
}
document.onmouseup = () => {
document.onmousemove = null;
document.onmouseup = null;
}
}
//右侧div边框宽度调节
rightDivMouseDown(e){
@ -625,15 +424,15 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
ngOnInit(): void {
this.getAllLibrary('plan') //获取素材库
this.getAllBuildings() //获取所有建筑
this.getAllFirePlan() //获取当前单位灾情
this.getPaperPlanData()//获得当前考题题目
let that = this
window.setTimeout(()=>{
document.getElementById("functionalDomainContent").oncontextmenu = function (event) {
// that.canvas.cancelPaint()
that.selectImageIndex = -1
event.preventDefault();
};
@ -646,15 +445,76 @@ export class CollectionToolsExamineeComponent implements OnInit {
})
}
paperId:any = this.route.snapshot.queryParams.paperId
planData:any //当前考题题目
Facilities:any //当前预案考题所有楼层要考的基本信息素材
//获得单位预案设定
getPaperPlanData(){
let params = {
paperId : this.paperId
}
this.http.get(`/api/PaperPlans`,{params:params}).subscribe((data:any) => {
console.log(456,data)
data.forEach(item => {
item.id == this.route.snapshot.queryParams.paperplanId ?
this.planData = item : null
})
let questions = JSON.parse(this.planData.examDisposalNodesData)
this.handleHybridTree(questions,'题目')
this.Facilities = JSON.parse(this.planData.examFacilityAssetsData)
})
}
//获得所有素材库
basicAssetLibraries:any = []//基本信息素材库
getAllAssetLibraries(Facilitiesitem){
this.canvasData.hiddenBasicInfoFacilities = Facilitiesitem.children
console.log(1314,this.canvasData.hiddenBasicInfoFacilities)
this.basicAssetLibraries = []
this.http.get('/api/AssetLibraries').subscribe(async(data:any) => {
console.log('素材库',data)
for (let index = 0; index < data.length; index++) {
const element = data[index];
let params = {
libraryId:element.id,
assetIds : Facilitiesitem.basicAssetsId
}
await new Promise ((resolve,reject)=>{
this.http.get('/api/Assets',{params:params})
.subscribe((data:any) => {
console.log(index,data)
if(data && data.length != 0){
data.forEach(item => {
item.tag = 1
})
element.images = data
this.basicAssetLibraries.push(
element
)
}
resolve()
})
})
}
// console.log(55555,this.basicAssetLibraries)
this.allLibrary = [...this.originalallLibrary,...this.basicAssetLibraries]
})
}
ngAfterViewInit(): void {
ngAfterViewInit(): void {
this.getSitePlan() //获取总平面图/楼层
// 监听canvas组件选中素材事件
this.canvas.on("select",obj=>{
//选中素材属性注入函数
this.setAssetsProperty(obj.assetData)
})
// 监听canvas组件取消选中素材事件
this.canvas.on("deselect",obj=>{
@ -662,27 +522,19 @@ export class CollectionToolsExamineeComponent implements OnInit {
})
// 监听canvas组件新增素材事件
this.canvas.on("createIcon",obj=>{
this.renovateTreeData(false)
console.log(obj.assetData)
// this.renovateTreeData(false)
})
// 监听canvas组件删除素材事件
this.canvas.on("deleteIcon",obj=>{
this.renovateTreeData(false)
// this.renovateTreeData(false)
})
}
copyAssetData:any //存储用于复制的素材
//复制素材
copyAsset(){
this.canvas.copy()
}
//粘贴素材
pasteAsset(){
let companyId = sessionStorage.getItem("companyId")
let buildingId = this.beforeOneCheckedBuilding.id
let floorId = this.selectingSitePlan.id
this.canvas.paste(companyId,buildingId,floorId)
}
basicInfo:boolean = true //基本信息名称显隐
wantToWork:boolean = true //想定作业名称显隐
@ -721,7 +573,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
saveNum :any = []
saveSite(){
if (this.selectingSitePlan && this.selectingSitePlan.id) {
this.saveNum = []
let SitePlanData = JSON.parse(JSON.stringify(this.canvasData.originaleveryStoreyData));
SitePlanData.data = JSON.stringify(SitePlanData.data)
let CompanyData = JSON.parse(JSON.stringify(this.canvasData.originalcompanyBuildingData));
@ -731,21 +582,114 @@ export class CollectionToolsExamineeComponent implements OnInit {
let adjoinArr = [] //毗邻数组
if(this.pattern){//如果是基本信息编辑模式
//如果是单位 总平面图
if(this.checkedBuildingIndex==-1){
//保存平面图数据
this.http.post("/api/SitePlanData",SitePlanData,{
params:{
companyId:this.params.companyId
}
}).subscribe(data => {
if(this.saveNum.length == 5){
this.canvasData.isChange = false
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('保存成功','确定',config);
}
},err=>{
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.canvasData.isChange = true
this.snackBar.open('平面图数据保存失败','确定',config);
})
//保存建筑数据
this.http.post("/api/CompanyData",CompanyData,{
params:{
companyId:this.params.companyId
}
}).subscribe(data => {
if(this.saveNum.length == 5){
this.canvasData.isChange = false
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('保存成功','确定',config);
}
},err=>{
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.canvasData.isChange = true
this.snackBar.open('单位数据保存失败','确定',config);
})
}else{ //如果是建筑
//建筑平面图数据
this.http.post("/api/BuildingAreaData",SitePlanData,{
params:{
companyId:this.params.companyId
}
}).subscribe(data => {
if(this.saveNum.length == 5){
this.canvasData.isChange = false
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('保存成功','确定',config);
}
},err=>{
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.canvasData.isChange = true
this.snackBar.open('平面图数据保存失败','确定',config);
})
//建筑数据
this.http.post("/api/BuildingData",CompanyData,{
params:{
companyId:this.params.companyId
}
}).subscribe(data => {
if(this.saveNum.length == 5){
this.canvasData.isChange = false
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('保存成功','确定',config);
}
},err=>{
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.canvasData.isChange = true
this.snackBar.open('单位数据保存失败','确定',config);
})
}
return true
}else{//如果是想定作业编辑模式
const dialogRef = this.dialog.open(saveOneDialogExaminee, {
data: {
allDisposalNode: this.canvasData.allDisposalNode,
selectedBuildingData:this.beforeOneCheckedBuilding,
selectedSiteData:this.selectingSitePlan,
siteOrbuilding:this.checkedBuildingIndex,
disasterId: this.allFirePlan[0].id || ''
}
});
console.log(SitePlanData)
// const dialogRef = this.dialog.open(saveOneDialogExaminee, {
// data: {
// allDisposalNode: this.canvasData.allDisposalNode,
// selectedBuildingData:this.beforeOneCheckedBuilding,
// selectedSiteData:this.selectingSitePlan,
// siteOrbuilding:this.checkedBuildingIndex,
// disasterId: this.allFirePlan[0].id || ''
// }
// });
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
});
// dialogRef.afterClosed().subscribe(result => {
// console.log('The dialog was closed');
// });
}
} else { //if
@ -771,79 +715,17 @@ export class CollectionToolsExamineeComponent implements OnInit {
//选择建筑
checkedBuilding(item,index){
if (this.checkedBuildingIndex!=index) {
if (this.canvasData.isChange) { //true 数据被改动
let isTrue = confirm('是否保存当前编辑数据')
if (isTrue) { //先保存数据 在切换
let isSuccess = this.saveSite()//true的时候 先保存数据
if (isSuccess != false) {
this.beforeOneCheckedBuilding = item
this.checkedBuildingIndex = index
if (index==-1) { //总平面图数据
this.getSitePlan()
} else { //建筑楼层/区域数据
this.getBuildingSitePlan(item)
}
}
} else {
this.beforeOneCheckedBuilding = item
this.checkedBuildingIndex = index
if (index==-1) { //总平面图数据
this.getSitePlan()
} else { //建筑楼层/区域数据
this.getBuildingSitePlan(item)
}
}
} else { //flase 数据未被改动
this.beforeOneCheckedBuilding = item
this.checkedBuildingIndex = index
if (index==-1) { //总平面图数据
this.getSitePlan()
} else { //建筑楼层/区域数据
this.getBuildingSitePlan(item)
}
} //if
this.beforeOneCheckedBuilding = item
this.checkedBuildingIndex = index
if (index==-1) { //总平面图数据
this.getSitePlan()
} else { //建筑楼层/区域数据
this.getBuildingSitePlan(item)
}
} //if
}
//删除建筑
deleteBuilding(e,item){
e.stopPropagation();
if(confirm("是否删除该建筑") == true){
let isHave = this.canvasData.allDisposalNode.find(items=>{ return items.buildingId === item.id })
if (isHave == undefined) {
this.http.delete(`/api/Buildings/${item.id}`).subscribe(data=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除成功','确定',config);
this.http.get("/api/Buildings",{
params:{
companyId :this.params.companyId
}
}).subscribe(data=>{
this.allBuildings = data
this.beforeOneCheckedBuilding = {name:"总平面图"}
this.checkedBuildingIndex = -1
this.getSitePlan()
})
},err=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除失败','确定',config);
this.getAllBuildings()
})
} else { //建筑 含有数据节点时
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('含有数据节点的建筑不允许删除','确定',config);
}
}
}
storeyData //将建筑素材和当前楼层素材合二为一
@ -852,9 +734,8 @@ export class CollectionToolsExamineeComponent implements OnInit {
//storeyData为当前楼层拥有的消防设施
this.storeyData = storeyData
let data = JSON.parse(JSON.stringify(this.allFireElements)) //所有消防要素模板
console.log(data)
let treeData = [] //tree型 处理完成后的数据
data.forEach(element => {
this.allFireElements.forEach(element => {
element.key = element.id
element.isTemplate = true //添加模板标识
element.isLook = true //添加是否可见标识
@ -881,9 +762,9 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
}
}
data.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} });
this.allFireElements.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} });
});
data.forEach(element => {
this.allFireElements.forEach(element => {
if (!element.parentId) { treeData.push(element) }
});
@ -913,8 +794,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
      return result;
  }
// console.log(filterEmpty(treeData))
this.dataSource.data = filterEmpty(treeData)
this.treeControl.expandAll()
@ -953,7 +832,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//点击树节点的显示隐藏icon
clickLookItem(node){
//修改真实素材islook属性
for(let key in this.storeyData.data){
if(key == node.id){
@ -976,8 +855,6 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
})
}
//子节点跟随父节点的islook变化
  if(node.children && node.children.length != 0){
      node.children.forEach(item=>{
@ -1024,10 +901,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
}else{
iconVisibleArr.push(node.id)
}
console.log(1,iconVisibleArr)
console.log(2,node.isLook)
this.canvas.setIconVisible(iconVisibleArr,!node.isLook)
}
//打开消防设施考题设定
@ -1070,13 +944,11 @@ export class CollectionToolsExamineeComponent implements OnInit {
let beforeOneId = this.selectingSitePlan.id || '' //当前 选中 平面图 楼层/区域 id
let companyBuildingData = JSON.parse(JSON.stringify( this.canvasData.originalcompanyBuildingData || {} )) // 当前 单位/建筑 数据
let storeyData = JSON.parse(JSON.stringify( this.canvasData.originaleveryStoreyData || {} )) //当前 楼层 数据
// for(let key in companyBuildingData.data){
// if (companyBuildingData.data[key].FloorId === beforeOneId) { //处理 单位/建筑 数据是否归于当前楼层下
// storeyData.data[key] = companyBuildingData.data[key]
// }
// }
console.log(566,storeyData.data)
this.Facilities.forEach(item => {
item.key == this.selectingSitePlan.id ?
this.getAllAssetLibraries(item) :
null
})
for(let key in storeyData.data){ //筛选数据
storeyData.data[key].key = storeyData.data[key].Id
let noMatch = this.allFireElements.find( every=> every.id===storeyData.data[key].FireElementId )
@ -1138,7 +1010,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
this.selectingSitePlan = this.sitePlanData[0] || {}
this.canvasData.selectStorey = this.sitePlanData[0] || {} //服务中 存一份数据
this.selectSitePlanIndex = 0
Promise.all([fireData,planData]).then((res)=>{
this.getSitePlanStorey(this.selectingSitePlan) //获取 平面图 楼层数据
})
@ -1207,10 +1079,44 @@ export class CollectionToolsExamineeComponent implements OnInit {
this.canvasData.originaleveryStoreyData.data? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {}
this.canvasData.originaleveryStoreyData.version? null : this.canvasData.originaleveryStoreyData.version = "2.0"
this.canvasData.originaleveryStoreyData.sitePlanId? null : this.canvasData.originaleveryStoreyData.sitePlanId = e.id || null
this.renovateTreeData()
let examParams = {
sitePlanId : e.id,
examinationId : this.route.snapshot.queryParams.examId,
planComponentId : this.route.snapshot.queryParams.planComponentId
}
this.http.get('/api/ExamSitePlanData',{params:examParams}).subscribe((data:any)=>{
this.canvasData.examOriginaleveryStoreyData = data || {} // 楼层原数据
this.canvasData.examOriginaleveryStoreyData.data? this.canvasData.examOriginaleveryStoreyData.data = JSON.parse(this.canvasData.examOriginaleveryStoreyData.data) : this.canvasData.examOriginaleveryStoreyData.data = {}
this.canvasData.examOriginaleveryStoreyData.version? null : this.canvasData.examOriginaleveryStoreyData.version = "2.0"
this.canvasData.examOriginaleveryStoreyData.buildingAreaId? null : this.canvasData.examOriginaleveryStoreyData.buildingAreaId = e.id || null
this.renovateTreeData()
})
})
}
//获取 建筑 楼层数据
getBuildingStorey (e) {
let params = {buildingAreaId: e.id}
this.http.get(`/api/BuildingAreaData`,{params}).subscribe((data:any)=>{
this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据
this.canvasData.originaleveryStoreyData.data? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {}
this.canvasData.originaleveryStoreyData.version? null : this.canvasData.originaleveryStoreyData.version = "2.0"
this.canvasData.originaleveryStoreyData.buildingAreaId? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null
let examParams = {
buildingAreaId : e.id,
examinationId : this.route.snapshot.queryParams.examId,
planComponentId : this.route.snapshot.queryParams.planComponentId
}
this.http.get('/api/ExamBuildingAreaData',{params:examParams}).subscribe((data:any)=>{
this.canvasData.examOriginaleveryStoreyData = data || {} // 楼层原数据
this.canvasData.examOriginaleveryStoreyData.data? this.canvasData.examOriginaleveryStoreyData.data = JSON.parse(this.canvasData.examOriginaleveryStoreyData.data) : this.canvasData.examOriginaleveryStoreyData.data = {}
this.canvasData.examOriginaleveryStoreyData.version? null : this.canvasData.examOriginaleveryStoreyData.version = "2.0"
this.canvasData.examOriginaleveryStoreyData.buildingAreaId? null : this.canvasData.examOriginaleveryStoreyData.buildingAreaId = e.id || null
this.renovateTreeData()
})
})
}
//获取 建筑 数据
getBuildingData (e) {
return new Promise ((resolve,reject)=>{
@ -1224,62 +1130,21 @@ export class CollectionToolsExamineeComponent implements OnInit {
})
}
//获取 建筑 楼层数据
getBuildingStorey (e) {
let params = {buildingAreaId: e.id}
this.http.get(`/api/BuildingAreaData`,{params}).subscribe((data:any)=>{
this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据
this.canvasData.originaleveryStoreyData.data? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {}
this.canvasData.originaleveryStoreyData.version? null : this.canvasData.originaleveryStoreyData.version = "2.0"
this.canvasData.originaleveryStoreyData.buildingAreaId? null : this.canvasData.originaleveryStoreyData.buildingAreaId = e.id || null
this.renovateTreeData()
})
}
//点击选中 平面图 楼层/区域 时
selectSitePlan (item,index) {
if (this.selectSitePlanIndex != index) {
this.canvasData.selectPanelPoint = new DisposalNodeData();
if (this.canvasData.isChange) { //true 数据被改动
let isTrue = confirm('是否保存当前编辑数据')
if (isTrue) { //先保存数据 在切换
let isSuccess = this.saveSite()//true的时候 先保存数据
if (isSuccess != false) {
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
}
}
} else { //不保存数据 直接切换
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
this.getSitePlanCompanyData()
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
let params = { buildingId: this.beforeOneCheckedBuilding.id }
this.getBuildingData(params)
}
}
} else { //false 数据没被改动
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
}
} //if
this.selectingSitePlan = item
this.selectSitePlanIndex = index
this.canvasData.selectStorey = item //服务中 存一份数据
if (this.checkedBuildingIndex==-1) { //总平面图时
this.getSitePlanStorey(item) //获取 平面图 楼层数据
} else { //楼层/区域时
this.getBuildingStorey(item) //获取 建筑 楼层数据
}
}
}
@ -1542,6 +1407,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
}
allLibrary:any = []; //所有素材库 + 素材
originalallLibrary = []; //原始所有素材库 + 素材 备份
selectLibrary:any; //选中的素材库
selectImage:any; //选中的素材库图片
selectImageIndex:number; //选中的素材库图片index
@ -1552,8 +1418,10 @@ export class CollectionToolsExamineeComponent implements OnInit {
data.forEach(element => {
element.images = []
});
this.originalallLibrary = data
this.allLibrary = data
this.selectImageIndex = -1
console.log(654,this.allLibrary)
// this.canvas.cancelPaint()
})
}
@ -1569,6 +1437,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//点击选中素材库图片时
selectImg (item,items,index) {
console.log(66666666,items)
this.selectLibrary = item.name
this.selectImage = items
this.selectImageIndex = index
@ -1579,7 +1448,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//处置预案
examType = this.route.snapshot.queryParams.openType // 预案类型 1=已存在/2=自定义
examType = Number(this.route.snapshot.queryParams.openType) // 预案类型 1=已存在/2=自定义
allFirePlan:any = []; //所有灾情
selectDisposalNode:string = ''; //当前点击tree节点 css选中样式
@ -1587,7 +1456,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
getAllFirePlan () {
let api
this.examType == 1? api='/api/Disasters' : api='/api/ExamDisasters'
let params = {componentId: sessionStorage.getItem('planId')}
let params = {componentId: this.route.snapshot.queryParams.planComponentId}
this.http.get(api,{params:params}).subscribe((data:any)=>{
if (!data.length) { //该 单位没有灾情时
let msg = {
@ -1609,25 +1478,27 @@ export class CollectionToolsExamineeComponent implements OnInit {
//获取所有处置节点
getDisposalNode () {
let api
this.examType == 1? api='/api/DisposalNodes' : api='/api/ExamDisposalNodes'
console.log(4444,this.examType)
api='/api/ExamDisposalNodes'
this.selectDisposalNode = ''
let params
this.examType == 1? params = {disasterId: this.allFirePlan[0].id || ''} : params = {examDisasterId: this.allFirePlan[0].id || ''}
params = {examDisasterId: this.allFirePlan[0].id || '',disposalNodeType:1,examinationId:this.route.snapshot.queryParams.examId}
this.http.get(api,{params:params}).subscribe(data=>{ //处置节点
this.canvasData.allDisposalNode = data
this.handleHybridTree()
this.handleHybridTree(this.canvasData.allDisposalNode,'答案')
})
}
treeData:any = []; //渲染tree处理完成数据
questionstreeData:any = [];//渲染tree处理完成数据(题目)
defaultExpandedKeys:any = []; //首次渲染 tree展开状态
//处理 节点 Tree数据
handleHybridTree () {
this.defaultExpandedKeys = []
handleHybridTree (disposalNodedata,type) {
// this.defaultExpandedKeys = []
let treeData = []
let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] ))
let data = JSON.parse(JSON.stringify( disposalNodedata || [] ))
data.forEach(element => {
this.defaultExpandedKeys.push(element.id)
element.title = element.name //name
element.key = element.id //id
element.children = [] //children
@ -1645,23 +1516,25 @@ export class CollectionToolsExamineeComponent implements OnInit {
data.forEach(element=>{
!element.parentId? treeData.push(element) : null
})
this.treeData = [...treeData]
this.defaultExpandedKeys = [...this.defaultExpandedKeys]
type == '题目' ? this.questionstreeData = [...treeData] : this.treeData = [...treeData]
}
//刷新 treeData 保存已展开节点
refurbishTreeData () {
let api
this.examType == 1? api='/api/DisposalNodes' : api='/api/ExamDisposalNodes'
api='/api/ExamDisposalNodes'
this.defaultExpandedKeys = []
let params
this.examType == 1? params = {disasterId: this.allFirePlan[0].id || ''} : params = {examDisasterId: this.allFirePlan[0].id || ''}
params = {examDisasterId: this.allFirePlan[0].id,disposalNodeType:1,examinationId:this.route.snapshot.queryParams.examId}
this.http.get(api,{params:params}).subscribe(nodeData=>{ //处置节点
this.canvasData.allDisposalNode = nodeData
let oldTreeData = this.nzTreeComponent.getExpandedNodeList()
oldTreeData.forEach(item=>{
this.defaultExpandedKeys.push(item.key)
})
console.log(1,oldTreeData)
console.log(2,this.defaultExpandedKeys)
let treeData = []
let data = JSON.parse(JSON.stringify( this.canvasData.allDisposalNode || [] ))
data.forEach(element => {
@ -1812,6 +1685,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
//点击 处置Tree节点
selectanelPoint (e) {
console.log(12111,e)
if (!e.buildingAreaId && !e.sitePlanId) { //当前节点 不是 数据节点 时
let msg = this.canvasData.findDisposalNode(e.id)
this.canvasData.selectPanelPointBaseData = msg
@ -1824,7 +1698,7 @@ export class CollectionToolsExamineeComponent implements OnInit {
if (this.canvasData.selectPanelPoint.DisposalNodeId != e.id) { //选择节点 不是当前节点时
let api
this.examType == 1? api='/api/DisposalNodeData' : api='/api/ExamDisposalNodeData'
api='/api/ExamDisposalNodeData'
let params = {nodeId: e.id}
let parameter = { //查询 节点 对应 建筑/楼层 index,id
buildingIndex: e.sitePlanId? -1 : this.allBuildings.findIndex(item=>{ return item.id===e.buildingId }), //总平面图/建筑 index

24
src/app/ui/collection-tools-examinee/save.ts

@ -3,6 +3,7 @@ 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 {CanvasShareDataService,DisposalNodeData} from '../../canvas-share-data.service' //引入服务
import { ActivatedRoute } from '@angular/router';
// 保存想定作业第一个弹窗
@Component({
selector: 'dialog-overview-example-dialog',
@ -52,7 +53,8 @@ export class saveOneDialogExaminee {
public dialogRef: MatDialogRef<saveTwoDialogExaminee>,
public canvasData: CanvasShareDataService,
public snackBar: MatSnackBar,
@Inject(MAT_DIALOG_DATA) public data) {}
@Inject(MAT_DIALOG_DATA) public data,
public route:ActivatedRoute) {}
type = this.data.type
allDisposalNode = this.data.allDisposalNode
@ -120,11 +122,13 @@ export class saveOneDialogExaminee {
imageUrls: null,
parentId: this.nodeItem ? this.nodeItem.id : null,
examDisasterId: this.data.disasterId,
ExamPlanComponentId: sessionStorage.getItem('planId') || '',
ExamPlanComponentId: this.route.snapshot.queryParams.planComponentId || '',
companyId: this.data.siteOrbuilding == -1 ? sessionStorage.getItem('companyId') : null,
sitePlanId: this.data.siteOrbuilding==-1 ? this.selectedSiteData.id : null,
buildingId: this.selectedBuildingData.id || null,
buildingAreaId: this.data.siteOrbuilding!=-1 ? this.selectedSiteData.id : null
buildingAreaId: this.data.siteOrbuilding!=-1 ? this.selectedSiteData.id : null,
examinationId:this.route.snapshot.queryParams.examId,
disposalNodeType:1
}
if(type == 'old'){
let istrue = this.canvasData.findDisposalNode(this.nodeItem.id,name)
@ -181,7 +185,7 @@ export class saveOneDialogExaminee {
data: JSON.stringify(this.canvasData.selectPanelPoint.Data) || null,
version: this.canvasData.selectPanelPoint.Version || "2.0",
ExamDisposalNodeId: data.id,
ExamPlanComponentId: sessionStorage.getItem("planId"),
ExamPlanComponentId: this.route.snapshot.queryParams.planComponentId,
}
this.http.post(`/api/ExamDisposalNodeData`,objData).subscribe(data => {
const config = new MatSnackBarConfig();
@ -240,11 +244,13 @@ export class saveOneDialogExaminee {
imageUrls: null,
parentId: this.nodeItem ? this.nodeItem.id : null,
examDisasterId: this.data.disasterId,
ExamPlanComponentId: sessionStorage.getItem('planId') || '',
ExamPlanComponentId: this.route.snapshot.queryParams.planComponentId || '',
companyId: null,
sitePlanId: null,
buildingId: null,
buildingAreaId: null
buildingAreaId: null,
examinationId:this.route.snapshot.queryParams.examId,
disposalNodeType:1
}
dispositionNodeData.weather = this.canvasData.selectPanelPointBaseData.weather
@ -255,6 +261,7 @@ export class saveOneDialogExaminee {
dispositionNodeData.notes = this.canvasData.selectPanelPointBaseData.notes
//1.先创建一个处置节点 然后 .then 2.创建数据节点到刚创建的处置节点 3.然后拿着创建好的数据节点的id 将平面图data保存
new Promise((resolve,reject) => {
console.log(1,dispositionNodeData)
this.http.post("/api/ExamDisposalNodes",dispositionNodeData).subscribe((data:any) => {
resolve(data.id)
})
@ -269,15 +276,12 @@ export class saveOneDialogExaminee {
})
}).then((data:any) => {
// 保存平面图数据到当前节点
// console.log(6666,data)
// let postdata =JSON.parse(JSON.stringify(this.canvasData.selectPanelPoint))
// postdata.Data = JSON.stringify(postdata.Data)
let objData = {
id: null,
data: JSON.stringify(this.canvasData.selectPanelPoint.Data) || null,
version: this.canvasData.selectPanelPoint.Version || "2.0",
ExamDisposalNodeId: data.id,
ExamPlanComponentId: sessionStorage.getItem("planId"),
ExamPlanComponentId: this.route.snapshot.queryParams.planComponentId,
}
this.http.post(`/api/ExamDisposalNodeData`,objData).subscribe(data => {

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

@ -901,9 +901,10 @@ export class CollectionToolsComponent implements OnInit {
//storeyData为当前楼层拥有的消防设施
this.storeyData = storeyData
let data = JSON.parse(JSON.stringify(this.allFireElements)) //所有消防要素模板
console.log(data)
console.log(889,this.storeyData)
let treeData = [] //tree型 处理完成后的数据
data.forEach(element => {
this.allFireElements.forEach(element => {
element.key = element.id
element.isTemplate = true //添加模板标识
element.isLook = true //添加是否可见标识
@ -920,7 +921,7 @@ export class CollectionToolsComponent implements OnInit {
//定义查看模式下能看到的元素
element.isLookPattern = true
if(element.parentId){
data.forEach(i => {
this.allFireElements.forEach(i => {
if(i.id == element.parentId){
i.isLookPattern = true
}
@ -930,9 +931,9 @@ export class CollectionToolsComponent implements OnInit {
}
}
}
data.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} });
this.allFireElements.forEach(item => { if (item.parentId == element.id) {element.children.push(item)} });
});
data.forEach(element => {
this.allFireElements.forEach(element => {
if (!element.parentId) { treeData.push(element) }
});
@ -955,15 +956,13 @@ export class CollectionToolsComponent implements OnInit {
          }
      }
  }
  
 
  function filterEmpty(listData) {
      const result = [];
      recursionFilterEmpty(listData, result);
      return result;
  }
// console.log(filterEmpty(treeData))
this.dataSource.data = filterEmpty(treeData)
this.treeControl.expandAll()
@ -1239,6 +1238,7 @@ export class CollectionToolsComponent implements OnInit {
getSitePlanCompanyData () {
return new Promise ((resolve,reject)=>{
this.http.get('/api/CompanyData',{params:this.params}).subscribe((data:any)=>{
this.canvasData.originalcompanyBuildingData = data || {} // 单位原数据
this.canvasData.originalcompanyBuildingData.data? this.canvasData.originalcompanyBuildingData.data = JSON.parse(this.canvasData.originalcompanyBuildingData.data) : this.canvasData.originalcompanyBuildingData.data = {}
this.canvasData.originalcompanyBuildingData.version? null : this.canvasData.originalcompanyBuildingData.version = "2.0"
@ -1252,6 +1252,7 @@ export class CollectionToolsComponent implements OnInit {
getSitePlanStorey (e) {
let params = {sitePlanId: e.id}
this.http.get(`/api/SitePlanData`,{params}).subscribe((data:any)=>{
console.log(12345,data)
this.canvasData.originaleveryStoreyData = data || {} // 楼层原数据
this.canvasData.originaleveryStoreyData.data? this.canvasData.originaleveryStoreyData.data = JSON.parse(this.canvasData.originaleveryStoreyData.data) : this.canvasData.originaleveryStoreyData.data = {}
this.canvasData.originaleveryStoreyData.version? null : this.canvasData.originaleveryStoreyData.version = "2.0"

6
src/app/ui/collection-tools/examinationQuestions.html

@ -3,7 +3,7 @@
<div id="nodeTree" style="max-height: 300px;overflow-y: auto; margin: 25px 0;">
<!-- 消防列表树 -->
<nz-tree
#nzTreeComponent
#nzTreeComponent3
[nzData]="renderData"
nzCheckable
nzMultiple
@ -13,10 +13,10 @@
(nzClick)="nzEvent($event)"
(nzExpandChange)="nzEvent($event)"
(nzCheckBoxChange)="nzEvent($event)"
[nzTreeTemplate]="nzTreeTemplate"
[nzTreeTemplate]="nzTreeTemplate3"
>
</nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<ng-template #nzTreeTemplate3 let-node let-origin="origin">
<div class="treeNodeTemplate">
<label class="overflowText textNode">{{node.origin.name || node.origin.Name}}</label>
</div>

4
src/app/ui/collection-tools/examinationQuestions.ts

@ -18,7 +18,7 @@ export class examinationQuestions {
constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data) {}
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
@ViewChild('nzTreeComponent3', { static: false }) nzTreeComponent!: NzTreeComponent;
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
defaultExpandedKeys = []; //展开指定的树节点 key值
@ -68,6 +68,8 @@ export class examinationQuestions {
let oldTreeData = this.nzTreeComponent.getCheckedNodeList()
// console.log(oldTreeData)
let alltreedata = JSON.parse(sessionStorage.getItem("tree型数据"))
let keyArr = []
oldTreeData.forEach(element => {

6
src/app/ui/collection-tools/save.ts

@ -124,7 +124,8 @@ export class saveOneDialog {
companyId: this.data.siteOrbuilding == -1 ? sessionStorage.getItem('companyId') : null,
sitePlanId: this.data.siteOrbuilding==-1 ? this.selectedSiteData.id : null,
buildingId: this.selectedBuildingData.id || null,
buildingAreaId: this.data.siteOrbuilding!=-1 ? this.selectedSiteData.id : null
buildingAreaId: this.data.siteOrbuilding!=-1 ? this.selectedSiteData.id : null,
disposalNodeType:0
}
if(type == 'old'){
let istrue = this.canvasData.findDisposalNode(this.nodeItem.id,name)
@ -244,7 +245,8 @@ export class saveOneDialog {
companyId: null,
sitePlanId: null,
buildingId: null,
buildingAreaId: null
buildingAreaId: null,
disposalNodeType:0
}
dispositionNodeData.weather = this.canvasData.selectPanelPointBaseData.weather

128
src/app/working-area/model/axArrowConnector.ts

@ -1,12 +1,15 @@
import { WorkingAreaComponent } from '../working-area.component';
import * as PIXI from 'pixi.js';
import { AxShape } from './axShape';
import { Sprite } from 'pixi.js';
/**
*
*
*/
export class AxArrowConnector extends AxShape {
pointTexture: PIXI.Texture = PIXI.Texture.from('assets/images/handle-main.png')
pointSprites: Array<Sprite> = new Array<Sprite>();
line: PIXI.Graphics;
text: PIXI.Text;
style = new PIXI.TextStyle({
@ -27,8 +30,14 @@ export class AxArrowConnector extends AxShape {
});
pts: PIXI.Point[];
constructor(assetData: any, workingArea: WorkingAreaComponent) {
markerStart = true;// 是否绘制起始箭头
markerEnd = true;// 是否绘制结束箭头
constructor(assetData: any, workingArea: WorkingAreaComponent,markerStart: boolean,markerEnd:boolean) {
super(assetData, workingArea);
this.markerStart = markerStart;
this.markerEnd = markerEnd;
this.name = assetData.Id;
this.text = new PIXI.Text(this.assetData.Name
+ '\r\n'
@ -38,25 +47,91 @@ export class AxArrowConnector extends AxShape {
this.addChild(this.text);
this.addChild(this.line);
this.workingArea.backgroundImage.addChild(this);
this.refresh(this.line, this.assetData.MultiPoint);
this.refresh();
this.drawPoints();
this.sortableChildren = true;
this.text.zIndex = this.children.length;
}
public drawPoints() {
this.assetData.MultiPoint.forEach(element => {
var point = new Sprite(this.pointTexture);
point.position = element;
point.anchor.set(0.5);
this.pointSprites.push(point);
this.addChild(point);
});
this.pointSprites.forEach((value, index, array) => {
value.interactive = true;
value.on('mousedown', event => {
event.stopPropagation();
if (this.workingArea.allowEdit && this.assetData.GameMode === this.workingArea.canvasData.gameMode) {
event.currentTarget.data = event.data;
event.currentTarget.alpha = 0.5;
event.currentTarget.dragging = true;
}
})
.on('mouseup', event => {
if (event.currentTarget.dragging) {
event.currentTarget.alpha = 1;
event.currentTarget.dragging = false;
event.currentTarget.data = null;
}
})
.on('mouseupoutside', event => {
if (event.currentTarget.dragging) {
event.currentTarget.alpha = 1;
event.currentTarget.dragging = false;
event.currentTarget.data = null;
}
})
.on('mousemove', event => {
if (event.currentTarget.dragging) {
const newPosition = event.currentTarget.data.getLocalPosition(event.currentTarget.parent);
event.currentTarget.x = newPosition.x;
event.currentTarget.y = newPosition.y;
this.assetData.MultiPoint[index].x = newPosition.x;
this.assetData.MultiPoint[index].y = newPosition.y;
this.workingArea.canvasData.isChange = true;
this.refresh();
}
})
.on('rightclick', event => {
});
})
this.setPointsVisible(false);
}
/**
*
* @param b true/false
*/
public setPointsVisible(b:boolean) {
this.pointSprites.forEach(item => {
item.visible = b;
})
}
/**
*
*/
public refresh(c: PIXI.Graphics, pts: PIXI.Point[]): void {
public refresh(): void {
const c = this.line;
const pts = this.assetData.MultiPoint;
if (pts.length < 2) {
return;
}
this.text.position = pts[0];
this.text.anchor.set(0.5, 1);
this.text.text = this.assetData.Name
+ '\r\n'
+ this.assetData.PropertyInfos?.find(item => item.PropertyName === '名称/编号')?.PropertyValue;
const strokeWidth = 1;
const startWidth = 30 + strokeWidth;
const endWidth = 30 + strokeWidth;
const edgeWidth = this.assetData.Thickness === 0?10:this.assetData.Thickness; // 宽度
const edgeWidth = this.assetData.Thickness === 0 ? 10 : this.assetData.Thickness; // 宽度
const openEnded = false;
const markerStart = false;// 起始箭头
const markerEnd = false;// 结束箭头
const spacing = (openEnded) ? 0 : 0 + strokeWidth / 2;
const startSize = 30 + strokeWidth;
const endSize = 30 + strokeWidth;
@ -101,11 +176,13 @@ export class AxArrowConnector extends AxShape {
// c.lineStyle(1, 0x000000, 1);
c.clear();
c.lineTextureStyle({ width: 1, color: lineColor, join: PIXI.LINE_JOIN.ROUND });
c.beginFill(fillColor);
const startNx = nx;
const startNy = ny;
if (markerStart && !openEnded) {
if (!openEnded) {
c.beginFill(fillColor);
}
if (this.markerStart && !openEnded) {
this.paintMarker(c, pts[0].x, pts[0].y, nx, ny, startSize, startWidth, edgeWidth, spacing, true);
} else {
const outStartX = pts[0].x + orthx / 2 + spacing * nx;
@ -213,7 +290,7 @@ export class AxArrowConnector extends AxShape {
orthx = edgeWidth * ny1;
orthy = - edgeWidth * nx1;
if (markerEnd && !openEnded) {
if (this.markerEnd && !openEnded) {
this.paintMarker(c, pe.x, pe.y, -nx, -ny, endSize, endWidth, edgeWidth, spacing, false);
} else {
c.lineTo(pe.x - spacing * nx1 + orthx / 2, pe.y - spacing * ny1 + orthy / 2);
@ -235,18 +312,16 @@ export class AxArrowConnector extends AxShape {
for (let i = fns.length - 1; i >= 0; i--) {
fns[i]();
}
c.closePath();
c.endFill();
// if (openEnded)
// {
// c.end();
// c.stroke();
// }
// else
// {
// c.close();
// c.fillAndStroke();
// }
if (openEnded)
{
c.closePath();
}
else
{
c.closePath();
c.endFill();
}
// c.setShadow(false);
@ -320,6 +395,11 @@ export class AxArrowConnector extends AxShape {
}
redraw(): void{
this.refresh(this.line, this.assetData.MultiPoint);
this.pointSprites.forEach(item => {
item.destroy();
})
this.pointSprites.splice(0, this.pointSprites.length);
this.refresh();
this.drawPoints();
}
}

18
src/app/working-area/model/axImageShape.ts

@ -1,12 +1,12 @@
import { WorkingAreaComponent } from '../working-area.component';
import * as ObjectID from 'bson-objectid';
import { GameMode } from './gameMode';
import { Pipeline } from './pipeline';
import { PaintMode } from './paintModel';
import * as PIXI from 'pixi.js';
import { PropertyInfo } from './PropertyInfo';
import { AxShape } from './axShape';
import { Sprite } from 'pixi.js';
import { AxArrowConnector } from './axArrowConnector';
/**
*
@ -370,7 +370,7 @@ export class AxImageShape extends AxShape {
paintingPipeline(x: number, y: number) {
if (this.assetData.CanConnect) {
if (this.workingArea.getPaintMode() === PaintMode.Pipeline) {
if (this.workingArea.paintingPipeline === null) {
if (this.workingArea.paintingShape === null) {
this.workingArea.previewLineSegment.visible = true;
this.workingArea.currentClickPoint.position =
new PIXI.Point(this.workingArea.circleShadow.x, this.workingArea.circleShadow.y);
@ -408,19 +408,19 @@ export class AxImageShape extends AxShape {
GameMode: this.workingArea.canvasData.gameMode,
LinkedObjects: new Array(this.assetData.Id),
};
this.workingArea.paintingPipeline = new Pipeline(tempData, this.workingArea);
this.assetData.Pipelines.push(this.workingArea.paintingPipeline.assetData.Id);
this.workingArea.emit('createIcon', this.workingArea.paintingPipeline);
this.workingArea.paintingShape = new AxArrowConnector(tempData, this.workingArea,false,true);
this.assetData.Pipelines.push(this.workingArea.paintingShape.assetData.Id);
this.workingArea.emit('createIcon', this.workingArea.paintingShape);
} else {
this.workingArea.previewLineSegment.visible = false;
this.workingArea.currentClickPoint.position =
new PIXI.Point(this.workingArea.circleShadow.x, this.workingArea.circleShadow.y);
this.workingArea.paintPoints.push(new PIXI.Point(x, y));
this.workingArea.paintingPipeline.assetData.MultiPoint =
this.workingArea.paintingShape.assetData.MultiPoint =
JSON.parse(JSON.stringify(this.workingArea.paintPoints));
this.workingArea.paintingPipeline.assetData.LinkedObjects.push(this.assetData.Id);
this.assetData.Pipelines.push(this.workingArea.paintingPipeline.assetData.Id);
this.workingArea.paintingPipeline.refresh();
this.workingArea.paintingShape.assetData.LinkedObjects.push(this.assetData.Id);
this.assetData.Pipelines.push(this.workingArea.paintingShape.assetData.Id);
this.workingArea.paintingShape.redraw();
this.workingArea.initPipelineData();
}
}

4
src/app/working-area/model/axShape.ts

@ -73,4 +73,8 @@ export class AxShape extends Container {
redraw(): void {
}
refresh(): void{
}
}

3
src/app/working-area/model/gameMode.ts

@ -3,5 +3,6 @@
*/
export enum GameMode {
BasicInformation,
Assignment
Assignment,
Examinee
}

105
src/app/working-area/model/multipointIcon.ts

@ -1,11 +1,12 @@
import { WorkingAreaComponent } from '../working-area.component';
import { GameMode } from './gameMode';
import * as PIXI from 'pixi.js';
import { AxShape } from './axShape';
/**
* 线
*/
export class MultipointIcon extends PIXI.Container {
export class MultipointIcon extends AxShape {
public pointsData: PIXI.Point[];
public pointsGraphics: PIXI.Graphics[] = [];
public iconsTilingSprite: PIXI.TilingSprite[] = [];
@ -34,8 +35,8 @@ export class MultipointIcon extends PIXI.Container {
* @param texture
* @param points
*/
constructor(public assetData: any, private workingArea: WorkingAreaComponent) {
super();
constructor(assetData: any,workingArea: WorkingAreaComponent) {
super(assetData,workingArea);
this.name = this.assetData.Id;
this.pointsData = this.assetData.MultiPoint;
this.x = this.assetData.Point.x;
@ -56,7 +57,7 @@ export class MultipointIcon extends PIXI.Container {
icon.x = pointA.x;
icon.y = pointA.y;
icon.angle = angle;
icon.height = this.assetData.Thickness === 0 ? 32 : this.assetData.Thickness;
// icon.height = this.assetData.Thickness === 0 ? 32 : this.assetData.Thickness;
this.iconsTilingSprite.push(icon);
this.addChild(icon);
if (i === 0) {
@ -173,50 +174,50 @@ export class MultipointIcon extends PIXI.Container {
// this.text.scale.set(scale);
// });
// 添加选中事件
this.iconsTilingSprite.forEach((item, index, array) => {
item.interactive = true;
item.buttonMode = true;
item.on('mousedown', event => {
event.stopPropagation();
this.workingArea.selection.selectOne(this);
if (this.workingArea.allowEdit && this.assetData.GameMode === this.workingArea.canvasData.gameMode) {
event.currentTarget.parent.data = event.data;
event.currentTarget.parent.alpha = 0.5;
event.currentTarget.parent.dragging = true;
event.currentTarget.parent.dragPoint = event.data.getLocalPosition(event.currentTarget.parent.parent);
event.currentTarget.parent.dragPoint.x -= event.currentTarget.parent.x;
event.currentTarget.parent.dragPoint.y -= event.currentTarget.parent.y;
}
})
.on('mouseup', event => {
if (event.currentTarget.parent.dragging) {
event.currentTarget.parent.alpha = 1;
event.currentTarget.parent.dragging = false;
event.currentTarget.parent.data = null;
}
})
.on('mouseupoutside', event => {
if (event.currentTarget.parent.dragging) {
event.currentTarget.parent.alpha = 1;
event.currentTarget.parent.dragging = false;
event.currentTarget.parent.data = null;
}
})
.on('mousemove', event => {
if (event.currentTarget.parent.dragging) {
const newPosition = event.currentTarget.parent.data.getLocalPosition(event.currentTarget.parent.parent);
event.currentTarget.parent.x = newPosition.x - event.currentTarget.parent.dragPoint.x;
event.currentTarget.parent.y = newPosition.y - event.currentTarget.parent.dragPoint.y;
this.assetData.Point = new PIXI.Point(this.x, this.y);
this.workingArea.canvasData.isChange = true;
}
})
.on('rightclick', event => {
});
});
// this.iconsTilingSprite.forEach((item, index, array) => {
// item.interactive = true;
// item.buttonMode = true;
// item.on('mousedown', event => {
// event.stopPropagation();
// this.workingArea.selection.selectOne(this);
// if (this.workingArea.allowEdit && this.assetData.GameMode === this.workingArea.canvasData.gameMode) {
// event.currentTarget.parent.data = event.data;
// event.currentTarget.parent.alpha = 0.5;
// event.currentTarget.parent.dragging = true;
// event.currentTarget.parent.dragPoint = event.data.getLocalPosition(event.currentTarget.parent.parent);
// event.currentTarget.parent.dragPoint.x -= event.currentTarget.parent.x;
// event.currentTarget.parent.dragPoint.y -= event.currentTarget.parent.y;
// }
// })
// .on('mouseup', event => {
// if (event.currentTarget.parent.dragging) {
// event.currentTarget.parent.alpha = 1;
// event.currentTarget.parent.dragging = false;
// event.currentTarget.parent.data = null;
// }
// })
// .on('mouseupoutside', event => {
// if (event.currentTarget.parent.dragging) {
// event.currentTarget.parent.alpha = 1;
// event.currentTarget.parent.dragging = false;
// event.currentTarget.parent.data = null;
// }
// })
// .on('mousemove', event => {
// if (event.currentTarget.parent.dragging) {
// const newPosition = event.currentTarget.parent.data.getLocalPosition(event.currentTarget.parent.parent);
// event.currentTarget.parent.x = newPosition.x - event.currentTarget.parent.dragPoint.x;
// event.currentTarget.parent.y = newPosition.y - event.currentTarget.parent.dragPoint.y;
// this.assetData.Point = new PIXI.Point(this.x, this.y);
// this.workingArea.canvasData.isChange = true;
// }
// })
// .on('rightclick', event => {
// });
// });
}
/**
*
@ -235,10 +236,10 @@ export class MultipointIcon extends PIXI.Container {
}
// 刷新数据
public refresh() {
console.log(this.assetData);
this.iconsTilingSprite.forEach(element => {
element.height = this.assetData.Thickness === 0 ? 32 : this.assetData.Thickness;
});
// console.log(this.assetData);
// this.iconsTilingSprite.forEach(element => {
// element.height = this.assetData.Thickness === 0 ? 32 : this.assetData.Thickness;
// });
this.text.text = this.assetData.Name
+ '\r\n'
+ this.assetData.PropertyInfos.find(item => item.PropertyName === '名称/编号')?.PropertyValue;

328
src/app/working-area/model/pipeline.ts

@ -1,328 +0,0 @@
import { WorkingAreaComponent } from '../working-area.component';
import * as PIXI from 'pixi.js';
import { AxShape } from './axShape';
/**
* 线
*/
export class Pipeline extends AxShape {
public line: PIXI.Graphics = new PIXI.Graphics();
constructor(assetData: any, workingArea: WorkingAreaComponent) {
super(assetData, workingArea);
this.name = this.assetData.Id;
this.moveable = false;
this.x = this.assetData.Point.x;
this.y = this.assetData.Point.y;
this.workingArea.backgroundImage.addChild(this);
this.addChild(this.line);
// 画线图标
this.refresh();
this.interactive = true;
this.on('mousedown', event => {
event.stopPropagation();
this.workingArea.selection.selectOne(this);
});
}
/**
*
*/
public refresh() {
const strokeWidth = 1;
const startWidth = 30 + strokeWidth;
const endWidth = 30 + strokeWidth;
const edgeWidth = 10;
const openEnded = false;
const markerStart = false;
const markerEnd = true;
const spacing = (openEnded) ? 0 : 0 + strokeWidth / 2;
const startSize = 30 + strokeWidth;
const endSize = 30 + strokeWidth;
const isRounded = true;
const pts = this.assetData.MultiPoint;
const c = this.line;
if (pts.length < 2) { return; }
// Base vector (between first points)
const pe = pts[pts.length - 1];
// Finds first non-overlapping point
let i0 = 1;
while (i0 < pts.length - 1 && pts[i0].x === pts[0].x && pts[i0].y === pts[0].y) {
i0++;
}
const dx = pts[i0].x - pts[0].x;
const dy = pts[i0].y - pts[0].y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist === 0) {
return;
}
// Computes the norm and the inverse norm
let nx = dx / dist;
let nx1 = nx;
let nx2 = nx;
let ny = dy / dist;
let ny2 = ny;
let ny1 = ny;
let orthx = edgeWidth * ny;
let orthy = -edgeWidth * nx;
// Stores the inbound function calls in reverse order in fns
const fns = [];
// if (isRounded) {
// // c.setLineJoin('round');
// c.lineTextureStyle({ join: PIXI.LINE_JOIN.ROUND });
// } else if (pts.length > 2) {
// // Only mitre if there are waypoints
// // c.setMiterLimit(1.42);
// c.lineTextureStyle({ miterLimit: 1.42 });
// }
// c.lineStyle(1, 0x000000, 1);
c.clear();
c.lineTextureStyle({ width: 1, color: 0x00000, join: PIXI.LINE_JOIN.ROUND });
// c.begin();
c.beginFill(0xffffff);
const startNx = nx;
const startNy = ny;
if (markerStart && !openEnded) {
this.paintMarker(c, pts[0].x, pts[0].y, nx, ny, startSize, startWidth, edgeWidth, spacing, true);
} else {
const outStartX = pts[0].x + orthx / 2 + spacing * nx;
const outStartY = pts[0].y + orthy / 2 + spacing * ny;
const inEndX = pts[0].x - orthx / 2 + spacing * nx;
const inEndY = pts[0].y - orthy / 2 + spacing * ny;
if (openEnded) {
c.moveTo(outStartX, outStartY);
fns.push( () => {
c.lineTo(inEndX, inEndY);
});
} else {
c.moveTo(inEndX, inEndY);
c.lineTo(outStartX, outStartY);
}
}
let dx1 = 0;
let dy1 = 0;
let dist1 = 0;
for (let i = 0; i < pts.length - 2; i++) {
// Work out in which direction the line is bending
const pos = this.relativeCcw(pts[i].x, pts[i].y, pts[i + 1].x, pts[i + 1].y, pts[i + 2].x, pts[i + 2].y);
dx1 = pts[i + 2].x - pts[i + 1].x;
dy1 = pts[i + 2].y - pts[i + 1].y;
dist1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
if (dist1 !== 0) {
nx1 = dx1 / dist1;
ny1 = dy1 / dist1;
const tmp1 = nx * nx1 + ny * ny1;
const tmp = Math.max(Math.sqrt((tmp1 + 1) / 2), 0.04);
// Work out the normal orthogonal to the line through the control point and the edge sides intersection
nx2 = (nx + nx1);
ny2 = (ny + ny1);
const dist2 = Math.sqrt(nx2 * nx2 + ny2 * ny2);
if (dist2 !== 0) {
nx2 = nx2 / dist2;
ny2 = ny2 / dist2;
// Higher strokewidths require a larger minimum bend, 0.35 covers all but the most extreme cases
const strokeWidthFactor = Math.max(tmp, Math.min(1 / 200 + 0.04, 0.35));
const angleFactor = (pos !== 0 && isRounded) ? Math.max(0.1, strokeWidthFactor) : Math.max(tmp, 0.06);
const outX = pts[i + 1].x + ny2 * edgeWidth / 2 / angleFactor;
const outY = pts[i + 1].y - nx2 * edgeWidth / 2 / angleFactor;
const inX = pts[i + 1].x - ny2 * edgeWidth / 2 / angleFactor;
const inY = pts[i + 1].y + nx2 * edgeWidth / 2 / angleFactor;
if (pos === 0 || !isRounded) {
// If the two segments are aligned, or if we're not drawing curved sections between segments
// just draw straight to the intersection point
c.lineTo(outX, outY);
((x, y) => {
fns.push(() => {
c.lineTo(x, y);
});
})(inX, inY);
} else if (pos === -1) {
const c1x = inX + ny * edgeWidth;
const c1y = inY - nx * edgeWidth;
const c2x = inX + ny1 * edgeWidth;
const c2y = inY - nx1 * edgeWidth;
c.lineTo(c1x, c1y);
if (isRounded) {
c.quadraticCurveTo(outX, outY, c2x, c2y); // 圆角
} else {
c.lineTo(outX, outY);
}
((x, y) => {
fns.push(() => {
c.lineTo(x, y);
});
})(inX, inY);
} else {
c.lineTo(outX, outY);
((x, y) => {
const c1x = outX - ny * edgeWidth;
const c1y = outY + nx * edgeWidth;
const c2x = outX - ny1 * edgeWidth;
const c2y = outY + nx1 * edgeWidth;
fns.push(() => {
if (isRounded) {
c.quadraticCurveTo(x, y, c1x, c1y);
} else {
c.lineTo(x, y);
}
});
fns.push(() => {
c.lineTo(c2x, c2y);
});
})(inX, inY);
}
nx = nx1;
ny = ny1;
}
}
}
orthx = edgeWidth * ny1;
orthy = - edgeWidth * nx1;
if (markerEnd && !openEnded) {
this.paintMarker(c, pe.x, pe.y, -nx, -ny, endSize, endWidth, edgeWidth, spacing, false);
} else {
c.lineTo(pe.x - spacing * nx1 + orthx / 2, pe.y - spacing * ny1 + orthy / 2);
const inStartX = pe.x - spacing * nx1 - orthx / 2;
const inStartY = pe.y - spacing * ny1 - orthy / 2;
if (!openEnded) {
c.lineTo(inStartX, inStartY);
} else {
c.moveTo(inStartX, inStartY);
fns.splice(0, 0, () => {
c.moveTo(inStartX, inStartY);
});
}
}
for (let i = fns.length - 1; i >= 0; i--) {
fns[i]();
}
c.closePath();
c.endFill();
// if (openEnded)
// {
// c.end();
// c.stroke();
// }
// else
// {
// c.close();
// c.fillAndStroke();
// }
// Workaround for shadow on top of base arrow
// c.setShadow(false);
// Need to redraw the markers without the low miter limit
// c.setMiterLimit(4);
// if (isRounded)
// {
// c.setLineJoin('flat');
// }
// if (pts.length > 2) {
// // Only to repaint markers if no waypoints
// // Need to redraw the markers without the low miter limit
// // c.setMiterLimit(4);
// c.lineTextureStyle({ width: 1, color: 0x00000, miterLimit: 4 });
// if (markerStart && !openEnded) {
// // c.begin();
// this.paintMarker(c, pts[0].x, pts[0].y, startNx, startNy, startSize, startWidth, edgeWidth, spacing, true);
// // c.stroke();
// // c.end();
// // c.closePath();
// }
// if (markerEnd && !openEnded) {
// // c.begin();
// this.paintMarker(c, pe.x, pe.y, -nx, -ny, endSize, endWidth, edgeWidth, spacing, true);
// // c.stroke();
// // c.end();
// // c.closePath();
// }
// }
}
/**
*
* @param c
* @param ptX
* @param ptY
* @param nx
* @param ny
* @param size
* @param arrowWidth
* @param edgeWidth
* @param spacing
* @param initialMove
*/
paintMarker(c: PIXI.Graphics, ptX: number, ptY: number, nx: number, ny: number,
size: number, arrowWidth: number, edgeWidth: number, spacing: number, initialMove: boolean) {
const widthArrowRatio = edgeWidth / arrowWidth;
const orthx = edgeWidth * ny / 2;
const orthy = -edgeWidth * nx / 2;
const spaceX = (spacing + size) * nx;
const spaceY = (spacing + size) * ny;
if (initialMove) {
c.moveTo(ptX - orthx + spaceX, ptY - orthy + spaceY);
} else {
c.lineTo(ptX - orthx + spaceX, ptY - orthy + spaceY);
}
c.lineTo(ptX - orthx / widthArrowRatio + spaceX, ptY - orthy / widthArrowRatio + spaceY);
c.lineTo(ptX + spacing * nx, ptY + spacing * ny);
c.lineTo(ptX + orthx / widthArrowRatio + spaceX, ptY + orthy / widthArrowRatio + spaceY);
c.lineTo(ptX + orthx + spaceX, ptY + orthy + spaceY);
}
relativeCcw(x1: number, y1: number, x2: number, y2: number, px: number, py: number) {
x2 -= x1;
y2 -= y1;
px -= x1;
py -= y1;
let ccw = px * y2 - py * x2;
if (ccw === 0.0) {
ccw = px * x2 + py * y2;
if (ccw > 0.0) {
px -= x2;
py -= y2;
ccw = px * x2 + py * y2;
if (ccw < 0.0) {
ccw = 0.0;
}
}
}
return (ccw < 0.0) ? -1 : ((ccw > 0.0) ? 1 : 0);
}
}

119
src/app/working-area/model/polygonIcon.ts

@ -2,11 +2,12 @@ import { WorkingAreaComponent } from '../working-area.component';
import { GameMode } from './gameMode';
import * as PIXI from 'pixi.js';
import { PaintMode } from './paintModel';
import { AxShape } from './axShape';
/**
*
*/
export class PolygonIcon extends PIXI.Container {
export class PolygonIcon extends AxShape {
public pointsData: PIXI.Point[];
public pointsGraphics: PIXI.Graphics[] = [];
public polygonGraphics: PIXI.Graphics = new PIXI.Graphics();
@ -35,8 +36,8 @@ export class PolygonIcon extends PIXI.Container {
*
* @param points
*/
constructor(public assetData: any, private workingArea: WorkingAreaComponent) {
super();
constructor(assetData: any,workingArea: WorkingAreaComponent) {
super(assetData,workingArea);
this.name = this.assetData.Id;
this.x = this.assetData.Point.x;
this.y = this.assetData.Point.y;
@ -140,64 +141,64 @@ export class PolygonIcon extends PIXI.Container {
}
});
});
// 添加选中事件
this.polygonGraphics.interactive = true;
this.polygonGraphics.buttonMode = true;
this.polygonGraphics
.on('mousedown', event => {
event.stopPropagation();
this.workingArea.selection.selectOne(this);
if (this.workingArea.allowEdit && this.assetData.GameMode === this.workingArea.canvasData.gameMode) {
event.currentTarget.parent.data = event.data;
event.currentTarget.parent.alpha = 0.5;
event.currentTarget.parent.dragging = true;
// // 添加选中事件
// this.polygonGraphics.interactive = true;
// this.polygonGraphics.buttonMode = true;
// this.polygonGraphics
// .on('mousedown', event => {
// event.stopPropagation();
// this.workingArea.selection.selectOne(this);
// if (this.workingArea.allowEdit && this.assetData.GameMode === this.workingArea.canvasData.gameMode) {
// event.currentTarget.parent.data = event.data;
// event.currentTarget.parent.alpha = 0.5;
// event.currentTarget.parent.dragging = true;
event.currentTarget.parent.dragPoint = event.data.getLocalPosition(event.currentTarget.parent.parent);
event.currentTarget.parent.dragPoint.x -= event.currentTarget.parent.x;
event.currentTarget.parent.dragPoint.y -= event.currentTarget.parent.y;
}
})
.on('mouseup', event => {
if (event.currentTarget.parent.dragging) {
event.currentTarget.parent.alpha = 1;
event.currentTarget.parent.dragging = false;
event.currentTarget.parent.data = null;
}
})
.on('mouseupoutside', event => {
if (event.currentTarget.parent.dragging) {
event.currentTarget.parent.alpha = 1;
event.currentTarget.parent.dragging = false;
event.currentTarget.parent.data = null;
}
})
.on('mousemove', event => {
if (event.currentTarget.parent.dragging) {
const newPosition = event.currentTarget.parent.data.getLocalPosition(event.currentTarget.parent.parent);
event.currentTarget.parent.x = newPosition.x - event.currentTarget.parent.dragPoint.x;
event.currentTarget.parent.y = newPosition.y - event.currentTarget.parent.dragPoint.y;
// event.currentTarget.parent.dragPoint = event.data.getLocalPosition(event.currentTarget.parent.parent);
// event.currentTarget.parent.dragPoint.x -= event.currentTarget.parent.x;
// event.currentTarget.parent.dragPoint.y -= event.currentTarget.parent.y;
// }
// })
// .on('mouseup', event => {
// if (event.currentTarget.parent.dragging) {
// event.currentTarget.parent.alpha = 1;
// event.currentTarget.parent.dragging = false;
// event.currentTarget.parent.data = null;
// }
// })
// .on('mouseupoutside', event => {
// if (event.currentTarget.parent.dragging) {
// event.currentTarget.parent.alpha = 1;
// event.currentTarget.parent.dragging = false;
// event.currentTarget.parent.data = null;
// }
// })
// .on('mousemove', event => {
// if (event.currentTarget.parent.dragging) {
// const newPosition = event.currentTarget.parent.data.getLocalPosition(event.currentTarget.parent.parent);
// event.currentTarget.parent.x = newPosition.x - event.currentTarget.parent.dragPoint.x;
// event.currentTarget.parent.y = newPosition.y - event.currentTarget.parent.dragPoint.y;
this.assetData.Point = new PIXI.Point(this.x, this.y);
this.workingArea.canvasData.isChange = true;
}
})
.on('rightclick', event => {
// this.workingArea.selection.deselectAll();
})
.on('mouseover', event => {
event.stopPropagation();
if (this.workingArea.previewImage !== null
&& this.workingArea.getPaintMode() === PaintMode.singlePointIcon) {
this.workingArea.previewImage.visible = false;
}
})
.on('mouseout', event => {
event.stopPropagation();
if (this.workingArea.previewImage !== null
&& this.workingArea.getPaintMode() === PaintMode.singlePointIcon) {
this.workingArea.previewImage.visible = true;
}
});
// this.assetData.Point = new PIXI.Point(this.x, this.y);
// this.workingArea.canvasData.isChange = true;
// }
// })
// .on('rightclick', event => {
// // this.workingArea.selection.deselectAll();
// })
// .on('mouseover', event => {
// event.stopPropagation();
// if (this.workingArea.previewImage !== null
// && this.workingArea.getPaintMode() === PaintMode.singlePointIcon) {
// this.workingArea.previewImage.visible = false;
// }
// })
// .on('mouseout', event => {
// event.stopPropagation();
// if (this.workingArea.previewImage !== null
// && this.workingArea.getPaintMode() === PaintMode.singlePointIcon) {
// this.workingArea.previewImage.visible = true;
// }
// });
}
/**
*

123
src/app/working-area/working-area.component.ts

@ -10,7 +10,6 @@ import { AxImageShape } from './model/axImageShape';
import { GameMode } from './model/gameMode';
import { MultipointIcon } from './model/multipointIcon';
import { PolygonIcon } from './model/polygonIcon';
import { Pipeline } from './model/pipeline';
import { PaintMode } from './model/paintModel';
import { AxShape } from './model/axShape';
import { PropertyInfo } from './model/PropertyInfo';
@ -82,10 +81,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*
*/
public paintPoints: PIXI.Point[] = [];
/**
* 线
*/
public paintingPipeline: Pipeline = null;
/**
*
*/
@ -278,7 +273,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.animator.update();
this.mousePosition = this.app.renderer.plugins.interaction.mouse.global;
// 预览图片
if (this.previewImage !== null) {
if (this.previewImage !== null && this.backgroundImage !== null) {
this.previewImage.position = this.backgroundImage.toLocal(this.mousePosition);
}
@ -314,7 +309,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*/
this.on('select', obj => {
if (this.allowEdit) {
if (obj instanceof MultipointIcon) {
if (obj instanceof AxArrowConnector) {
obj.setPointsVisible(true);
}
else if (obj instanceof MultipointIcon) {
if (obj.assetData.GameMode === this.canvasData.gameMode) {
obj.setPointVisiable(true);
} else {
@ -338,7 +336,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*/
this.on('deselect', obj => {
if (this.allowEdit) {
if (obj instanceof MultipointIcon) {
if (obj instanceof AxArrowConnector) {
obj.setPointsVisible(false);
}
else if (obj instanceof MultipointIcon) {
obj.setPointVisiable(false);
} else if (obj instanceof PolygonIcon) {
obj.filters = [];
@ -375,6 +376,12 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
} else if (item instanceof AxPreviewImageShape) {
const data = 1 / scale;
item.scale.set(data);
}else if (item instanceof AxArrowConnector) {
const data = 1 / scale;
item.text.scale.set(data);
item.pointSprites.forEach(point => {
point.scale.set(data);
});
}
});
@ -383,17 +390,19 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*
*/
this.on('createIcon', obj => {
if (obj.assetData.GameMode === GameMode.BasicInformation) {
if (obj.assetData.GameMode === GameMode.BasicInformation) { // 基本信息
// 添加楼层数据
this.canvasData.originaleveryStoreyData.data[obj.assetData.Id] = obj.assetData;
// 添加建筑数据
this.canvasData.originalcompanyBuildingData.data[obj.assetData.Id] = obj.assetData;
} else {
} else if(obj.assetData.GameMode === GameMode.Assignment){ // 处置预案
if (this.canvasData.selectPanelPoint.Data === undefined
|| this.canvasData.selectPanelPoint.Data === null) {
this.canvasData.selectPanelPoint.Data = new FloorNodeData();
}
this.canvasData.selectPanelPoint.Data.Stock[obj.assetData.Id] = obj.assetData;
} else if (obj.assetData.GameMode === GameMode.Examinee) { // 考生考试
// this.canvasData.examOriginaleveryStoreyData.data[obj.assetData.Id] = obj.assetData;
}
this.canvasData.isChange = true;
});
@ -466,29 +475,39 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.selection.select(obj);
});
}
/**
*
*/
// /**
// * 刷新工作区
// */
public async refresh() {
this.setPaintMode(PaintMode.endPaint);
this.resetCanvas();
this.destroyBackgroundImage();
if (!this.canvasData.selectStorey.imageUrl) {
return;
}
await this.createBackgroundImage(this.canvasData.selectStorey.imageUrl);
this.createFloorShape();
this.createFloorShape(this.canvasData.originaleveryStoreyData.data);
if (this.canvasData.gameMode === GameMode.Assignment) {
this.createWorkNode();
this.createNodeShape(this.canvasData.selectPanelPoint.Data);
}
this.emit('backgroundScale', this.backgroundImage.scale.x);
// await this.createBackground(this.canvasData.selectStorey.imageUrl);
}
/**
*
*/
public async createBackground(imageUrl:string) {
if (this.backgroundImage !== null) {
this.destroyBackgroundImage();
}
await this.createBackgroundImage(imageUrl)
}
/**
*
*/
private createFloorShape() {
const floorData = this.canvasData.originaleveryStoreyData.data;
public createFloorShape(floorData: any) {
Object.keys(floorData).forEach((key) => {
switch (floorData[key].InteractiveMode) {
case 0:
@ -503,18 +522,21 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
break;
case 3:
if (floorData[key].Name === '水带') {
const pipeline = new Pipeline(floorData[key], this);
} else {
const wall = new AxArrowConnector(floorData[key], this);
const distance = new AxArrowConnector(floorData[key], this,false,true);
} else if(floorData[key].Name === '距离'){
const distance = new AxArrowConnector(floorData[key], this,true,true);
}else if(floorData[key].Name === '普通墙' || floorData[key].Name === '承重墙'){
const wall = new AxArrowConnector(floorData[key], this,false,false);
}
break;
}
});
this.emit('backgroundScale', this.backgroundImage.scale.x);
}
private createWorkNode() {
// 加载处置节点数据
const nodeData = this.canvasData.selectPanelPoint.Data;
/**
*
*/
public createNodeShape(nodeData: any) {
if (nodeData !== undefined && nodeData !== null) {
Object.keys(nodeData).forEach((key) => {
Object.keys(nodeData[key]).forEach((tempKey) => {
@ -530,12 +552,13 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
const polygonIcon = new PolygonIcon(nodeData[key][tempKey], this);
break;
case 3:
const pipeline = new Pipeline(nodeData[key][tempKey], this);
const pipeline = new AxArrowConnector(nodeData[key][tempKey], this,false,true);
break;
}
});
});
}
this.emit('backgroundScale', this.backgroundImage.scale.x);
}
/**
*
@ -607,7 +630,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
/**
*
*/
private async createBackgroundImage(imageUrl: string): Promise<void> {
public async createBackgroundImage(imageUrl: string): Promise<void> {
const image = await PIXI.Texture.fromURL(imageUrl);
this.backgroundImage = new PIXI.Sprite(image);
this.backgroundImage.anchor.set(0.5);
@ -763,20 +786,20 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
break;
case PaintMode.Pipeline:
if (this.canvasData.selectTemplateData.name === '水带') {
if (this.paintingPipeline !== null) {
if (this.paintingShape !== null) {
this.currentClickPoint.position = new PIXI.Point(this.circleShadow.x, this.circleShadow.y);
this.paintPoints.push(new PIXI.Point(this.circleShadow.x, this.circleShadow.y));
this.paintingPipeline.assetData.MultiPoint = JSON.parse(JSON.stringify(this.paintPoints));
this.paintingPipeline.refresh();
this.paintingShape.assetData.MultiPoint = JSON.parse(JSON.stringify(this.paintPoints));
this.paintingShape.refresh();
}
} else {
this.previewLineSegment.visible = true;
this.enterPaintEndButton.position = this.circleShadow.position;
this.enterPaintEndButton.visible = true;
this.currentClickPoint.position = new PIXI.Point(this.circleShadow.x, this.circleShadow.y);
this.paintPoints.push(new PIXI.Point(this.circleShadow.x, this.circleShadow.y));
if (this.paintPoints.length >= 2) {
this.enterPaintEndButton.position = this.circleShadow.position;
this.enterPaintEndButton.visible = true;
if (this.paintPoints.length < 2) {
return;
}
if (this.paintingShape === null) {
const jsonObject = JSON.parse(JSON.stringify(this.canvasData.selectTemplateData.propertyInfos));
@ -809,7 +832,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
IsFromBuilding: this.canvasData.selectTemplateData.isFromBuilding,
GameMode: this.canvasData.gameMode
};
this.paintingShape = new AxArrowConnector(assetData2, this);
if (this.canvasData.selectTemplateData.name === '距离') {
this.paintingShape = new AxArrowConnector(assetData2, this,true,true);
} else if (this.canvasData.selectTemplateData.name === '普通墙' || this.canvasData.selectTemplateData.name === '承重墙') {
this.paintingShape = new AxArrowConnector(assetData2, this,false,false);
}
} else {
this.paintingShape.assetData.MultiPoint = JSON.parse(JSON.stringify(this.paintPoints));
this.paintingShape.redraw();
@ -911,10 +938,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
if (!this.canvasData.selectStorey.imageUrl) {
this.backgroundImage.visible = false;
} else {
// this.backgroundImage.texture = PIXI.Texture.from(this.canvasData.selectStorey.imageUrl);
// this.backgroundImage.angle = this.canvasData.selectStorey.imageAngle;
// this.backgroundImage.visible = true;
this.refresh();
this.backgroundImage.texture = PIXI.Texture.from(this.canvasData.selectStorey.imageUrl);
this.backgroundImage.angle = this.canvasData.selectStorey.imageAngle;
this.backgroundImage.visible = true;
// this.refresh();
}
}
/**
@ -922,6 +949,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*/
public destroyBackgroundImage(): void {
this.app.stage.removeChild(this.backgroundImage);
this.backgroundImage = null;
}
/**
*
@ -1000,6 +1028,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*
*/
public beginPaint() {
console.log(this.canvasData.selectTemplateData);
this.selection.deselectAll();
this.setPaintMode(PaintMode.endPaint);
this.setPaintMode(this.canvasData.selectTemplateData.interactiveMode);
@ -1009,7 +1038,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
*/
public initPipelineData(): void {
this.paintPoints = [];
this.paintingPipeline = null;
this.paintingShape = null;
}
public beginPaintingArrows(): void {
this.paintMode = PaintMode.Arrows;
@ -1064,10 +1093,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.backgroundImage.removeChild(this.paintingIcon);
}
if (this.paintingPipeline !== undefined
&& this.paintingPipeline !== null) {
this.backgroundImage.removeChild(this.paintingPipeline);
}
// if (this.paintingShape !== undefined
// && this.paintingShape !== null) {
// this.backgroundImage.removeChild(this.paintingShape);
// }
if (this.paintingShape !== null) {
this.backgroundImage.removeChild(this.paintingShape);
this.paintingShape = null;
@ -1196,8 +1225,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
const polygonIcon = new PolygonIcon(newData, this);
break;
case PaintMode.Pipeline:
if (item.Name !== '水带') {
const wall = new AxArrowConnector(newData, this);
if (item.Name === '距离') {
const wall = new AxArrowConnector(newData, this,true,true);
} else if (item.Name === '普通墙' || item.Name === '承重墙') {
const wall = new AxArrowConnector(newData, this,false,false);
}
break;
}

Loading…
Cancel
Save