|
|
|
@ -1,17 +1,17 @@
|
|
|
|
|
import { Component, Input, Renderer2, OnDestroy, AfterViewInit, ElementRef, OnInit, ViewChild } from '@angular/core'; |
|
|
|
|
import { CustomReuseStrategy } from 'src/app/CustomReuseStrategy'; |
|
|
|
|
import { Component, Input, Renderer2, OnDestroy, AfterViewInit, ElementRef, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; |
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
import { NzUploadFile } from 'ng-zorro-antd/upload'; |
|
|
|
|
import { Observable, Observer } from 'rxjs'; |
|
|
|
|
import { NzUploadChangeParam } from 'ng-zorro-antd/upload'; |
|
|
|
|
import { TreeService } from 'src/app/service/tree.service'; |
|
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
|
import { asBlob } from 'html-docx-js-typescript' |
|
|
|
|
// 要保存这个docx文件推荐引入file-saver哦,你可以用npm i -D file-saver来安装
|
|
|
|
|
import { saveAs } from 'file-saver' |
|
|
|
|
import { ObjectsSimpleService } from 'src/app/service/objectsSimple.service'; |
|
|
|
|
declare var AMap: any; |
|
|
|
|
import Viewer from 'viewerjs'; |
|
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal'; |
|
|
|
|
import { OperationLogComponent } from './operation-log/operation-log.component'; |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-unit-details', |
|
|
|
|
templateUrl: './unit-details.component.html', |
|
|
|
@ -22,7 +22,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
@ViewChild('box') box: ElementRef; |
|
|
|
|
loading = false; |
|
|
|
|
avatarUrl?: string; |
|
|
|
|
constructor(private message: NzMessageService, private router: Router, private toTree: TreeService, private fb: FormBuilder, private http: HttpClient, private renderer: Renderer2, private el: ElementRef, public renderer2: Renderer2, private elementRef: ElementRef) { |
|
|
|
|
constructor(private message: NzMessageService, private router: Router, private toTree: TreeService, private fb: FormBuilder, private http: HttpClient, private renderer: Renderer2, private el: ElementRef, public renderer2: Renderer2, private elementRef: ElementRef, private objectsSrv: ObjectsSimpleService, private modal: NzModalService, private viewContainerRef: ViewContainerRef) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
disableds = false |
|
|
|
@ -96,6 +96,8 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
validateForm!: FormGroup; |
|
|
|
|
id = "" |
|
|
|
|
integrity = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.id = this.router['browserUrlTree'].queryParams.id |
|
|
|
|
if (this.router['browserUrlTree'].queryParams.pattern != "edit") { |
|
|
|
@ -119,6 +121,73 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imageUrl = ''//单位照片
|
|
|
|
|
isLoadingSave: boolean = false |
|
|
|
|
uploadIndex: string |
|
|
|
|
filechange(e) { |
|
|
|
|
this.isLoadingSave = true |
|
|
|
|
let file = e.target.files[0] || null //获取上传的文件
|
|
|
|
|
this.openFileSelect(file, `unitPhoto/${this.id}/`) |
|
|
|
|
} |
|
|
|
|
//设置文件路径并上传
|
|
|
|
|
postFilePath |
|
|
|
|
openFileSelect(file: File, extensionPath: string) { |
|
|
|
|
this.postFilePath = extensionPath; |
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB 超过5MB要分块上传
|
|
|
|
|
if (fileSize >= shardSize) // 超过5MB要分块上传
|
|
|
|
|
{ |
|
|
|
|
this.postFileByMul(file); |
|
|
|
|
} |
|
|
|
|
else //普通上传
|
|
|
|
|
{ |
|
|
|
|
this.postFile(file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//小文件直接上传
|
|
|
|
|
async postFile(file: File) { |
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
|
this.objectsSrv.postFile(this.postFilePath, file).subscribe(data => { |
|
|
|
|
let dataObj = data as any; |
|
|
|
|
let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName; |
|
|
|
|
this.imageUrl = filePath |
|
|
|
|
this.isLoadingSave = false |
|
|
|
|
resolve('success') |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
//大文件分块上传
|
|
|
|
|
postFileByMul(file: File) { |
|
|
|
|
this.objectsSrv.postFile_MultipartUpload(this.postFilePath, file).then((value) => { |
|
|
|
|
let dataObj = value as any; |
|
|
|
|
let filePath = dataObj.filePath |
|
|
|
|
this.imageUrl = filePath |
|
|
|
|
this.isLoadingSave = false |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查看图片
|
|
|
|
|
viewImg(url) { |
|
|
|
|
let dom = document.getElementById(`viewerjs`) |
|
|
|
|
let pObjs = dom.childNodes; |
|
|
|
|
let node = document.createElement("img") |
|
|
|
|
node.style.display = "none"; |
|
|
|
|
node.src = url; |
|
|
|
|
node.id = 'img' |
|
|
|
|
dom.appendChild(node) |
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
let viewer = new Viewer(document.getElementById(`viewerjs`), { |
|
|
|
|
hidden: () => { |
|
|
|
|
dom.removeChild(pObjs[0]); |
|
|
|
|
viewer.destroy(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
node.click(); |
|
|
|
|
}, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isMapLabel: boolean |
|
|
|
|
//地图标注位置
|
|
|
|
@ -1049,7 +1118,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
let num4 = (num + num2 + num3 - 1) / 63 |
|
|
|
|
let num4 = (num + num2 + num3 - 1) / 64 |
|
|
|
|
this.integrity = Math.floor(num4 * 100) / 100 |
|
|
|
|
console.log(num, num2, num3, num4); |
|
|
|
|
this.datas.basicInfo.positionCoordinates = { |
|
|
|
@ -1071,6 +1140,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
address: this.datas.basicInfo.addr, |
|
|
|
|
useNature: this.datas.basicInfo.nature, |
|
|
|
|
integrity: this.integrity, |
|
|
|
|
imageFile: this.imageUrl, |
|
|
|
|
data: JSON.stringify(this.datas) |
|
|
|
|
} |
|
|
|
|
this.http.patch('/api/Companies/' + this.id, body).subscribe(data => { |
|
|
|
@ -1097,6 +1167,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
// this.datas.basicInfo.phone = data.directorPhone
|
|
|
|
|
this.datas.basicInfo.nature = data.useNature |
|
|
|
|
this.integrity = data.integrity |
|
|
|
|
this.imageUrl = data.imageFile |
|
|
|
|
this.validateForm.patchValue({ |
|
|
|
|
code: data.usci, |
|
|
|
|
organizationId: data.organizationId, |
|
|
|
@ -1107,7 +1178,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
principalName: data.directorName, |
|
|
|
|
principalPhone: data.directorPhone, |
|
|
|
|
adminName: data.securityAdministratorName, |
|
|
|
|
adminPhone: data.securityAdministratorPhone |
|
|
|
|
adminPhone: data.securityAdministratorPhone, |
|
|
|
|
}) |
|
|
|
|
if (this.datas.basicInfo.positionCoordinates && (this.datas.basicInfo.positionCoordinates.x != 0 && this.datas.basicInfo.positionCoordinates.y != 0)) {//已标注
|
|
|
|
|
this.isMapLabel = true |
|
|
|
@ -1122,7 +1193,7 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
getAllOrganization() { |
|
|
|
|
let organizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId |
|
|
|
|
let params = { |
|
|
|
|
OrganizationId: organizationId || '', |
|
|
|
|
// OrganizationId: organizationId || '',
|
|
|
|
|
ContainsChildren: "true", |
|
|
|
|
PageNumber: 1, |
|
|
|
|
PageSize: 9999 |
|
|
|
@ -1141,4 +1212,19 @@ export class UnitDetailsComponent implements OnInit {
|
|
|
|
|
this.nodes = [...this.toTree.toTree(data.items)] |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
looklog() { |
|
|
|
|
const modal = this.modal.create({ |
|
|
|
|
nzTitle: '操作日志', |
|
|
|
|
nzContent: OperationLogComponent, |
|
|
|
|
nzViewContainerRef: this.viewContainerRef, |
|
|
|
|
nzWidth: 660, |
|
|
|
|
nzMaskClosable: false, |
|
|
|
|
nzComponentParams: { |
|
|
|
|
id: this.id, |
|
|
|
|
}, |
|
|
|
|
nzFooter: null |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|