|
|
|
@ -4,9 +4,13 @@
|
|
|
|
|
* @Author: sueRimn |
|
|
|
|
* @Date: 2020-11-06 14:39:10 |
|
|
|
|
* @LastEditors: sueRimn |
|
|
|
|
* @LastEditTime: 2020-11-06 19:09:32 |
|
|
|
|
* @LastEditTime: 2020-11-07 19:41:29 |
|
|
|
|
*/ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http'; |
|
|
|
|
import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar'; |
|
|
|
|
import { FileUploader, FileItem } from 'ng2-file-upload' |
|
|
|
|
import Swiper from 'swiper'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-find-problem', |
|
|
|
@ -15,11 +19,54 @@ import { Component, OnInit } from '@angular/core';
|
|
|
|
|
}) |
|
|
|
|
export class FindProblemComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor() { } |
|
|
|
|
constructor(public snackBar: MatSnackBar,private http: HttpClient) { } |
|
|
|
|
testSwiper: Swiper; |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.testSwiper = new Swiper('.swiper-container', { |
|
|
|
|
direction: 'horizontal', |
|
|
|
|
loop: true, |
|
|
|
|
observer:true,//修改swiper自己或子元素时,自动初始化swiper
|
|
|
|
|
observeParents:true,//修改swiper的父元素时,自动初始化swiper
|
|
|
|
|
//lazy: true,
|
|
|
|
|
// 如果需要前进后退按钮
|
|
|
|
|
navigation: { |
|
|
|
|
nextEl: '.swiper-button-next', |
|
|
|
|
prevEl: '.swiper-button-prev', |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, 0); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
ngAfterViewInit() {
|
|
|
|
|
console.log("d") |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.testSwiper = new Swiper('.swiper-container', { |
|
|
|
|
direction: 'horizontal', |
|
|
|
|
loop: true, |
|
|
|
|
observer:true,//修改swiper自己或子元素时,自动初始化swiper
|
|
|
|
|
observeParents:true,//修改swiper的父元素时,自动初始化swiper
|
|
|
|
|
//lazy: true,
|
|
|
|
|
// 如果需要前进后退按钮
|
|
|
|
|
navigation: { |
|
|
|
|
nextEl: '.swiper-button-next', |
|
|
|
|
prevEl: '.swiper-button-prev', |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, 0); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
ceshiimg=["../../../assets/images/upload.jpg","../../../assets/images/upload2.jpg"] |
|
|
|
|
inputShow=true//控制input显隐
|
|
|
|
|
chooseid//key值
|
|
|
|
|
textareazhi="" //备注框初始化
|
|
|
|
|
imgsrc = "../../../assets/images/upload.jpg" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数
|
|
|
|
|
imgUrl = ""//返回来的图片地址后缀
|
|
|
|
|
file: any; //上传的文件
|
|
|
|
|
isspinner:boolean=false //控制进度圈的显示隐藏
|
|
|
|
|
//问题对象
|
|
|
|
|
knowRoute=[{name:`问题1`,idnum:""}] |
|
|
|
|
num=1 |
|
|
|
@ -27,7 +74,81 @@ export class FindProblemComponent implements OnInit {
|
|
|
|
|
addPermission(){ |
|
|
|
|
this.num++; |
|
|
|
|
var nums=this.num.toString() |
|
|
|
|
this.knowRoute.push({name:"问题"+nums,idnum:""}) |
|
|
|
|
//this.knowRoute.push({name:"问题"+nums,idnum:""})
|
|
|
|
|
this.uploadSucced.push({name:"问题"+nums,src:[],text:""}) |
|
|
|
|
console.log(this.uploadSucced) |
|
|
|
|
} |
|
|
|
|
//删除一行
|
|
|
|
|
deletePermission(key){ |
|
|
|
|
this.uploadSucced.splice(key,1) |
|
|
|
|
console.log(this.uploadSucced) |
|
|
|
|
} |
|
|
|
|
uploadSucced:any = JSON.parse(localStorage.getItem(sessionStorage.getItem("companyId")+"findproblem")) || [{name:"问题1",src:[],text:""}]//上传成功暂存对象
|
|
|
|
|
//保存点击事件
|
|
|
|
|
savaClick(){ |
|
|
|
|
// this.uploadSucced[this.chooseid].text=this.textareazhi
|
|
|
|
|
localStorage.setItem(sessionStorage.getItem("companyId")+"findproblem",JSON.stringify(this.uploadSucced)) |
|
|
|
|
alert("保存成功") |
|
|
|
|
console.log(JSON.parse(localStorage.getItem(sessionStorage.getItem("companyId")+"xxx")) ) |
|
|
|
|
//this.snackBar.open('上传成功','确定',config);
|
|
|
|
|
}
|
|
|
|
|
//change选择文件
|
|
|
|
|
filechange(e,key) { |
|
|
|
|
this.chooseid=key |
|
|
|
|
this.file = e.target.files[0] || null //上传的文件
|
|
|
|
|
var reader = new FileReader(); |
|
|
|
|
reader.readAsDataURL(this.file); |
|
|
|
|
var image:any = new Image(); |
|
|
|
|
reader.onload = function(){ |
|
|
|
|
image.src = reader.result |
|
|
|
|
} |
|
|
|
|
setTimeout(() => { |
|
|
|
|
if(image.width>=4096 || image.height>=5000 ){
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择分辨率小于4096*5000的图片','确定',config); |
|
|
|
|
}else{ |
|
|
|
|
if(this.file){ |
|
|
|
|
this.startUploading(key) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, 500); |
|
|
|
|
}
|
|
|
|
|
//上传文件
|
|
|
|
|
startUploading(key) { |
|
|
|
|
this.isspinner = true |
|
|
|
|
let file = this.file || null //获取上传的文件
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
|
|
|
|
|
if (file && fileSize <= shardSize) { //上传文件<=5MB时
|
|
|
|
|
// this.upload()
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file",file) |
|
|
|
|
this.http.post(`/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{ |
|
|
|
|
this.isspinner = false |
|
|
|
|
this.imgUrl = data.objectName |
|
|
|
|
this.imgsrc = `/api/Objects/PlanPlatform/${this.imgUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` |
|
|
|
|
console.log(this.imgsrc) |
|
|
|
|
console.log(this.uploadSucced) |
|
|
|
|
this.uploadSucced[key].src.push(this.imgsrc) |
|
|
|
|
//this.inputShow=false
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('上传成功','确定',config); |
|
|
|
|
}) |
|
|
|
|
} else if (file && fileSize >= shardSize) { //上传文件>5MB时,分块上传
|
|
|
|
|
|
|
|
|
|
/* let data = { filename: file.name } |
|
|
|
|
this.http.post(`/api/NewMultipartUpload/PlanPlatform/${this.unitinfo.id}`, {}, { params: data }).subscribe((data: any) => { //初始化分段上传
|
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
this.uploadId = data.uploadId |
|
|
|
|
this.subsectionUploading() |
|
|
|
|
}) */ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|