Browse Source

新增查看图片视频word文档

zhuzhou
陈鹏飞 3 years ago
parent
commit
3ac88e8a1a
  1. 8
      src/app/plan-audit/plan-record/plan-record.component.html
  2. 84
      src/app/plan-audit/plan-record/plan-record.component.ts
  3. 5
      src/app/plan-audit/wait-examineer/wait-examineer.component.html
  4. 233
      src/app/plan-audit/wait-examineer/wait-examineer.component.ts

8
src/app/plan-audit/plan-record/plan-record.component.html

@ -176,6 +176,11 @@
<button mat-raised-button color="primary" style="float: right;margin-top: 10px;margin-right: 15px;" (click)='lookNew()'>查看详情</button>
<iframe [src]='iframeSrc'></iframe>
</div>
<!-- 视频 -->
<div class="video" *ngIf="showtype == 1080" style="text-align: center;">
<video [src]="src" controls="controls" width="auto" height="auto"></video>
</div>
<!-- 视频 -->
<div id="viewer" *ngIf="showtype==1"></div>
<div class="twoD" *ngIf="showtype==2">
<div class="planBox">
@ -212,3 +217,6 @@
</div>
</div>
</div>
<div id="viewerjs">
</div>

84
src/app/plan-audit/plan-record/plan-record.component.ts

@ -12,7 +12,8 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import { HttpClient } from '@angular/common/http'
import { DomSanitizer } from '@angular/platform-browser';
import { Viewer } from 'photo-sphere-viewer';
import { Viewer as photoViewer } from 'photo-sphere-viewer';
import Viewer from 'viewerjs';
declare var CryptoJS
@Component({
@ -187,7 +188,7 @@ export class PlanRecordComponent implements OnInit {
obj.innerHTML=''
}
window.setTimeout(()=>{
this.viewer = new Viewer({
this.viewer = new photoViewer({
container: document.querySelector('#viewer'),
panorama:'/api/Objects/PlanPlatform/'+ this.fetchUrl,
@ -231,43 +232,54 @@ export class PlanRecordComponent implements OnInit {
//毕升
lookWord(){
this.showtype=0
let docIdWordArray = CryptoJS.enc.Utf8.parse(`PlanPlatform/` + this.fetchUrl);
let docId = CryptoJS.enc.Base64.stringify(docIdWordArray);
let jwt = sessionStorage.getItem("token");
let rawJwt = CryptoJS.enc.Base64.parse(jwt.split('.')[1]);
let identityJson = CryptoJS.enc.Utf8.stringify(rawJwt);
let identityJsonparse=JSON.parse(identityJson)
let filename:string
this.http.get(`/api/ObjectMetadata/PlanPlatform/${this.fetchUrl}`).subscribe((data:any)=>{
filename=data.fileName
let json={
doc: {
docId: docId,
title: filename,
//title: filename,
fetchUrl: `http://39.106.78.171:8000/api/Objects/PlanPlatform/`+this.fetchUrl
},
user: {
uid: identityJsonparse.sub,
nickName: identityJsonparse.name,
avatar: "",
privilege: [
'FILE_READ','FILE_DOWNLOAD', 'FILE_PRINT'
],
},
}
var stringjson=JSON.stringify(json)
var wordArray = CryptoJS.enc.Utf8.parse(stringjson);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
this.src=`http://121.5.10.84:80/apps/editor/openPreview?data=${base64}`
this.iframeSrc=this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
//window.open(`http://121.5.10.84:80/apps/editor/openPreview?data=${base64}`)
})
console.log('lookWord')
this.showtype = 0
//let src
let suffix = this.fetchUrl.split('.')[this.fetchUrl.split('.').length - 1].toLowerCase()
if (suffix == 'docx' || suffix == 'doc') {
let arr = this.fetchUrl.split('.')
arr[arr.length - 1] = 'pdf'
this.src = `/api/Objects/PlanPlatform/` + arr.join('.')
} else if (suffix == 'pdf') {
this.src = `/api/Objects/PlanPlatform/` + this.fetchUrl
} else if (suffix == 'jpeg' || suffix == 'jpg' || suffix == 'png') {
this.src = ""
this.lookImg(this.fetchUrl)
} else if (suffix == 'mp4' || suffix == 'MP4') {
this.showtype = 1080 //视频
this.src = `/api/Objects/PlanPlatform/` + this.fetchUrl
}
this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
}
//查看按钮跳转
lookNew(){
window.open(this.src)
if (this.src) {
window.open(this.src)
}
}
lookImg(imgUrl,type?:boolean) {
// console.log(imgUrl)
let dom = document.getElementById(`viewerjs`)
let pObjs = dom.childNodes;
let node = document.createElement("img")
node.style.display = "none";
if(type){
let src = imgUrl.split("?")[0]
node.src = src
}else{
node.src = "/api/Objects/PlanPlatform/" + imgUrl;
}
node.id = 'imgxxx'
dom.appendChild(node)
setTimeout(() => {
let viewer = new Viewer(document.getElementById(`viewerjs`), {
hidden: () => {
dom.removeChild(pObjs[0]);
viewer.destroy();
}
});
node.click();
}, 0);
}
//查看二维三维预案

5
src/app/plan-audit/wait-examineer/wait-examineer.component.html

@ -282,6 +282,11 @@
<div class="word" *ngIf="showtype == 0">
<iframe [src]='iframeSrc'></iframe>
</div>
<!-- 视频 -->
<div class="video" *ngIf="showtype == 1080" style="text-align: center;">
<video [src]="src" controls="controls" width="auto" height="auto"></video>
</div>
<!-- 视频 -->
<!-- 全景图 -->
<div id="viewer" *ngIf="showtype == 1"></div>
<div class="twoD" *ngIf="showtype == 2">

233
src/app/plan-audit/wait-examineer/wait-examineer.component.ts

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2020-12-25 16:13:50
* @LastEditors: sueRimn
* @LastEditTime: 2021-06-04 10:14:51
* @LastEditTime: 2021-08-16 11:12:52
*/
import { Component, Inject, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
@ -14,7 +14,7 @@ import { HttpClient } from '@angular/common/http'
declare var CryptoJS
import { DomSanitizer } from '@angular/platform-browser';
import { Viewer as photoViewer } from 'photo-sphere-viewer';
import Viewer from 'viewerjs';
import Viewer from 'viewerjs';
declare var echarts: any;
@ -61,7 +61,10 @@ export class WaitExamineerComponent implements OnInit {
]
}
this.getAlltabledate()
this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
}
planTypeIndex //平面图类型 选择是总平面图还是层平面图
@ -106,6 +109,8 @@ export class WaitExamineerComponent implements OnInit {
companyId
fetchUrl
companyName
plantypes
IsNewData=[true,false]
//获取表格数据
getAlltabledate() {
@ -113,7 +118,9 @@ export class WaitExamineerComponent implements OnInit {
Operation: this.level || [],
ContentType: Number(this.projectlevel) || [],
Level: this.PlanLevel || [],
verifyState: [0, 3]
verifyState: [0, 3],
PlanType:this.plantypes||[],
IsNewData:this.IsNewData
}
this.http.get("/api/ContentVerifies", { params: paramsdata }).subscribe((data: any) => {
this.tableDate = data.items
@ -129,22 +136,28 @@ export class WaitExamineerComponent implements OnInit {
this.level = ''
this.projectlevel = ''
this.PlanLevel = ''
this.plantypes=[]
let level = sessionStorage.getItem("level");
this.getAlltabledate()
}
lookImg(imgUrl){
console.log(imgUrl)
let dom = document.getElementById(`viewerjs`)
lookImg(imgUrl,type?:boolean) {
// console.log(imgUrl)
let dom = document.getElementById(`viewerjs`)
let pObjs = dom.childNodes;
let node = document.createElement("img")
node.style.display = "none";
node.src = "/api/Objects/PlanPlatform/" + imgUrl;
if(type){
let src = imgUrl.split("?")[0]
node.src = src
}else{
node.src = "/api/Objects/PlanPlatform/" + imgUrl;
}
node.id = 'imgxxx'
dom.appendChild(node)
setTimeout(() => {
let viewer = new Viewer(document.getElementById(`viewerjs`), {
hidden:()=>{
hidden: () => {
dom.removeChild(pObjs[0]);
viewer.destroy();
}
@ -165,38 +178,67 @@ export class WaitExamineerComponent implements OnInit {
differentContentOfBuildingsInfo: any//当前单位变更数据 之 建筑信息
differentContentOfFunction: any = []//当前单位变更数据 之 功能分区
differentContentOfPicture: any//当前单位变更数据 之 实景图
bianzhi = false
radioClick(e, item) {
this.selectedItem = item
console.log(item)
//console.log(item)
// console.log('当前选择的信息',JSON.parse(this.selectedItem.differentContent) )
if(item.contentType == 11 && this.selectedItem.differentContent){
if (item.contentType == 11 && this.selectedItem.differentContent) {
let differentContent = JSON.parse(this.selectedItem.differentContent)
//console.log('差异信息', differentContent)
// 单位信息
this.differentContentOfUnitInfo = differentContent.filter(item => item.propertyName == 'basicInfo')
// 实景图
this.differentContentOfPicture = differentContent.filter(item => item.propertyName == 'realityImageGroups')
//建筑信息
this.differentContentOfBuildingsInfo = JSON.parse(JSON.stringify(differentContent.filter(item => item.propertyName == 'buildings')[0]))
this.differentContentOfBuildingsInfo.childrens.forEach(element => {
element.childrens = element.childrens.filter(item => item.isObj == false)
});
//功能分区
let differentContentOfFunction = JSON.parse(JSON.stringify(differentContent.filter(item => item.propertyName == 'buildings')[0]))
this.differentContentOfFunction = []
differentContentOfFunction.childrens.forEach(item => {
item.childrens.forEach(i => {
if (i.propertyName == "buildingFunctionalDivisions") {
i.propertyName = item.propertyName
this.differentContentOfFunction.push(i)
if (differentContent.filter(item => item.propertyName == 'buildings').length != 0) {
//建筑信息
this.differentContentOfBuildingsInfo = JSON.parse(JSON.stringify(differentContent.filter(item => item.propertyName == 'buildings')[0]))
function resolveDiff(list: Array<DiffItem>, path?: Array<string>): Array<Result> {
let resultList: Array<Result> = [];
for (let i = 0; i < list.length; i++) {
if (path == null) path = [];
let item = list[i];
//递归最底层
if (!item.childrens.length) {
let res = new Result();
res.path = path.concat([item.displayName]);
res.oldValue = item.oldValue;
res.newValue = item.newValue;
resultList.push(res);
} else {
!!item.displayName && path.push(item.displayName);
let deepList = resolveDiff(item.childrens, path)
resultList = resultList.concat(deepList);
}
}
return resultList;
}
this.differentContentOfBuildingsInfo.childrens.forEach(element => {
element.difData = resolveDiff(element.childrens)
});
});
//console.log('建筑信息', this.differentContentOfBuildingsInfo)
//功能分区
let differentContentOfFunction = JSON.parse(JSON.stringify(differentContent.filter(item => item.propertyName == 'buildings')[0]))
this.differentContentOfFunction = []
differentContentOfFunction.childrens.forEach(item => {
item.childrens.forEach(i => {
if (i.propertyName == "buildingFunctionalDivisions") {
i.propertyName = item.propertyName
this.differentContentOfFunction.push(i)
}
});
});
}
}
// console.log('功能分区', this.differentContentOfFunction)
@ -209,18 +251,22 @@ export class WaitExamineerComponent implements OnInit {
this.id = item.id
this.fetchUrl = ''
this.viewer = {}
if (item.contentType == 11) {
this.bianzhi = false
window.setTimeout(() => {
this.showtype = 3
sessionStorage.setItem('companyId', item.itemId)
}, 0)
} else if (item.contentType == 12) {
this.bianzhi = false
//水源
this.http.get(`/api/WaterSources/${item.itemId}`).subscribe((data) => {
this.waterData = data
this.showtype = 12
})
} else if (item.contentType == 13) {
this.bianzhi = false
//消防力量
this.http.get(`/api/CustomFireForce/${item.itemId}`).subscribe((data: any) => {
if (data.forceType != 0) {//如果是其他消防力量
@ -242,6 +288,7 @@ export class WaitExamineerComponent implements OnInit {
})
} else if (item.contentType == 14) {
this.bianzhi = false
//联动力量
this.http.get(`/api/LinkageForces/${item.itemId}`).subscribe((data: any) => {
@ -251,37 +298,45 @@ export class WaitExamineerComponent implements OnInit {
})
} else {
this.http.get(`/api/PlanComponents/${item.itemId}`).subscribe((data: any) => {
//console.log('预案信息',data)
this.companyId = data.companyId
this.companyName = data.companyName
if (data.planType != 2 && data.planType != 1) {
this.fetchUrl = data.attachmentUrls[0]
var index = this.fetchUrl.indexOf("\/")
if (this.fetchUrl.substr(0, index) == 'psw') {
this.showtype = 1
var obj = document.getElementById('viewer')
if (obj != null) {
obj.innerHTML = ''
}
window.setTimeout(() => {
this.viewer = new photoViewer({
container: document.querySelector('#viewer'),
panorama: '/api/Objects/PlanPlatform/' + this.fetchUrl,
});
})
if (data.planMode == 2 ||data.planMode==4) {
this.showtype = 0
this.bianzhi = true
this.src = `/CreatePlanOnlineFive?navIsOpen=false&companyId=${data.companyId}&planName=${data.name}&unitName=${data.companyName}&planCategory=${data.planCategory}&planId=${data.id}&unitTypeId=${data.company.buildingTypes[0].id}&orName=${data.company.organizationName}&orId=${data.company.organizationId}&pattern=false`
this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
//this.src=`/keyUnit/viewunitinfoplan?id=${data.companyId}&orName=${data.company.organizationId}&orId=${data.company.organizationName}`
} else {
this.lookWord()
this.bianzhi = false
this.fetchUrl = data.attachmentUrls[0]
var index = this.fetchUrl.indexOf("\/")
if (this.fetchUrl.substr(0, index) == 'psw') {
this.showtype = 1
var obj = document.getElementById('viewer')
if (obj != null) {
obj.innerHTML = ''
}
window.setTimeout(() => {
this.viewer = new photoViewer({
container: document.querySelector('#viewer'),
panorama: '/api/Objects/PlanPlatform/' + this.fetchUrl,
});
})
} else {
this.lookWord()
}
}
} else {
this.bianzhi = false
this.organizationName = item.organizationName
this.planData = data
this.handleData()
return
//this.src=`/planAudit/planpass?id=${data.companyId}&companyName=${data.companyName}&auditPlanId=${data.id}&auditStatus=${data.auditStatus}&planType=1`
//this.iframeSrc=this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
//window.open(`/planAudit/planpass?id=${data.companyId}&companyName=${data.companyName}&auditPlanId=${data.id}&auditStatus=${data.auditStatus}&planType=1`)
}
@ -302,43 +357,30 @@ export class WaitExamineerComponent implements OnInit {
//毕升
lookWord() {
console.log('lookWord')
this.showtype = 0
let docIdWordArray = CryptoJS.enc.Utf8.parse(`PlanPlatform/` + this.fetchUrl);
let docId = CryptoJS.enc.Base64.stringify(docIdWordArray);
let jwt = sessionStorage.getItem("token");
let rawJwt = CryptoJS.enc.Base64.parse(jwt.split('.')[1]);
let identityJson = CryptoJS.enc.Utf8.stringify(rawJwt);
let identityJsonparse=JSON.parse(identityJson)
let filename:string
this.http.get(`/api/ObjectMetadata/PlanPlatform/${this.fetchUrl}`).subscribe((data:any)=>{
filename=data.fileName
let json={
doc: {
docId: docId,
title: filename,
//title: filename,
fetchUrl: `http://39.106.78.171:8000/api/Objects/PlanPlatform/`+this.fetchUrl
},
user: {
uid: identityJsonparse.sub,
nickName: identityJsonparse.name,
avatar: "",
privilege: [
'FILE_READ','FILE_DOWNLOAD', 'FILE_PRINT'
],
},
}
var stringjson=JSON.stringify(json)
var wordArray = CryptoJS.enc.Utf8.parse(stringjson);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
this.src=`http://121.5.10.84:80/apps/editor/openPreview?data=${base64}`
this.iframeSrc=this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
//window.open(`http://121.5.10.84:80/apps/editor/openPreview?data=${base64}`)
})
//let src
let suffix = this.fetchUrl.split('.')[this.fetchUrl.split('.').length - 1].toLowerCase()
if (suffix == 'docx' || suffix == 'doc') {
let arr = this.fetchUrl.split('.')
arr[arr.length - 1] = 'pdf'
this.src = `/api/Objects/PlanPlatform/` + arr.join('.')
} else if (suffix == 'pdf') {
this.src = `/api/Objects/PlanPlatform/` + this.fetchUrl
} else if (suffix == 'jpeg' || suffix == 'jpg' || suffix == 'png') {
this.src = ""
this.lookImg(this.fetchUrl)
} else if (suffix == 'mp4' || suffix == 'MP4') {
this.showtype = 1080 //视频
this.src = `/api/Objects/PlanPlatform/` + this.fetchUrl
}
this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
}
//查看按钮跳转
lookNew() {
window.open(this.src)
if (this.src) {
window.open(this.src)
}
}
//查看二维三维预案
@ -573,6 +615,14 @@ export class WaitExamineerComponent implements OnInit {
}, 0)
}
}
//判断iframe是否加载完成
iftrue=true
ifranmeLoad(){
var iframe = document.getElementById("myiframe");
iframe.onload = function(){
}
this.iftrue=!this.iftrue
}
}
@ -803,4 +853,19 @@ export class remark {
}
}
}
}
class DiffItem {
newValue: any
oldValue: any
childrens: Array<DiffItem>
operation: number
displayName: string
propertyName: string
}
class Result {
path: string[]
oldValue: any
newValue: any
}
Loading…
Cancel
Save