Browse Source

上传副本完善

beijing
陈鹏飞 3 years ago
parent
commit
a166a88ec7
  1. 9
      src/app/pages/license/file-category/edit-file-category/edit-file-category.component.html
  2. 5
      src/app/pages/license/file-category/edit-file-category/edit-file-category.component.ts
  3. 40
      src/app/pages/license/update-category/edit-update-category/edit-update-category.component.html
  4. 34
      src/app/pages/license/update-category/edit-update-category/edit-update-category.component.ts

9
src/app/pages/license/file-category/edit-file-category/edit-file-category.component.html

@ -31,12 +31,11 @@
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'pdf'" src="../../../../assets/images/license/pdf.png" (click)="lookFile(data2)"> <img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'pdf'" src="../../../../assets/images/license/pdf.png" (click)="lookFile(data2)">
<input *ngIf="!data2.imageUrl" (change)="filechange($event)" class="fileinput" type="file" name="" id=""> <input *ngIf="!data2.imageUrl" (change)="filechange($event)" class="fileinput" type="file" name="" id="">
<button *ngIf="!data2.imageUrl" nz-button [nzLoading]=""><i nz-icon nzType="upload" <button *ngIf="!data2.imageUrl" nz-button [nzLoading]="isLoadingSave"><i nz-icon nzType="upload" nzTheme="outline"></i>上传附件</button>
nzTheme="outline"></i>上传附件</button>
</div> </div>
<div class="uploadDiv" *ngIf="data2.imageUrl"> <div class="uploadDiv" *ngIf="data2.imageUrl">
<input (change)="filechange($event)" class="fileinput" type="file" name="" id=""> <input (change)="filechange($event)" class="fileinput" type="file" name="" id="">
<button nz-button [nzLoading]=""><i nz-icon nzType="upload" nzTheme="outline"></i>重新上传</button> <button nz-button [nzLoading]="isLoadingSave"><i nz-icon nzType="upload" nzTheme="outline"></i>重新上传</button>
</div> </div>
</div> </div>
@ -44,8 +43,8 @@
<textarea style="background: #173350;height: 100px;width: 100%;border-radius: 0;border: 0;color: white;" cols="30" rows="10" [(ngModel)]="data2.remark" formControlName="remark"></textarea> <textarea style="background: #173350;height: 100px;width: 100%;border-radius: 0;border: 0;color: white;" cols="30" rows="10" [(ngModel)]="data2.remark" formControlName="remark"></textarea>
<div class="btnbox"> <div class="btnbox">
<button nz-button type="submit" class="ok" (click)="submitReview()">提交审核</button> <button nz-button type="submit" class="ok" (click)="submitReview()" [nzLoading]="isLoadingSave">提交审核</button>
<button nz-button type="submit" class="ok" (click)="ok()">保存</button> <button nz-button type="submit" class="ok" (click)="ok()" [nzLoading]="isLoadingSave">保存</button>
<button nz-button type="button" class="cancel" (click)="destroyModal()">取消</button> <button nz-button type="button" class="cancel" (click)="destroyModal()">取消</button>
</div> </div>
</form> </form>

5
src/app/pages/license/file-category/edit-file-category/edit-file-category.component.ts

@ -57,6 +57,7 @@ export class EditFileCategoryComponent implements OnInit {
isLoadingSave: boolean = false isLoadingSave: boolean = false
uploadIndex: string uploadIndex: string
filechange(e) { filechange(e) {
this.isLoadingSave = true
let oilStationId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id let oilStationId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id
let file = e.target.files[0] || null //获取上传的文件 let file = e.target.files[0] || null //获取上传的文件
this.openFileSelect(file, `stationPhotos/${oilStationId}/`) this.openFileSelect(file, `stationPhotos/${oilStationId}/`)
@ -84,7 +85,7 @@ export class EditFileCategoryComponent implements OnInit {
let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName; let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName;
this.imageUrl = filePath this.imageUrl = filePath
this.data2.imageUrl = filePath this.data2.imageUrl = filePath
console.log('上传成功', filePath) this.isLoadingSave = false
resolve('success') resolve('success')
}); });
}) })
@ -100,7 +101,7 @@ export class EditFileCategoryComponent implements OnInit {
let filePath = dataObj.filePath let filePath = dataObj.filePath
this.imageUrl = filePath this.imageUrl = filePath
this.data2.imageUrl = filePath this.data2.imageUrl = filePath
console.log('上传成功', filePath) this.isLoadingSave = false
}); });
} }

40
src/app/pages/license/update-category/edit-update-category/edit-update-category.component.html

@ -47,38 +47,36 @@
<p>附件上传(图片格式、pdf格式、word格式)</p> <p>附件上传(图片格式、pdf格式、word格式)</p>
<div class="uploadDivbox"> <div class="uploadDivbox">
<div class="uploadDiv" style="margin-right: 12px;"> <div class="uploadDiv">
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'img'" style="width: 100%;height: 100%;cursor: pointer;" [src]="data2.imageUrl" (click)="viewImg(data2.imageUrl)"> <img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'img'" style="width: 100%;height: 100%;cursor: pointer;" [src]="data2.imageUrl" (click)="viewImg(data2.imageUrl)">
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'word'" src="../../../../assets/images/license/word.png" (click)="lookFile(data2)"> <img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'word'" src="../../../../assets/images/license/word.png" (click)="lookFile(data2.imageUrl)">
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'pdf'" src="../../../../assets/images/license/pdf.png" (click)="lookFile(data2)"> <img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'pdf'" src="../../../../assets/images/license/pdf.png" (click)="lookFile(data2.imageUrl)">
<input *ngIf="!data2.imageUrl" (change)="filechange($event)" class="fileinput" type="file" name="" id=""> <input *ngIf="!data2.imageUrl" (change)="filechange($event,true)" class="fileinput" type="file" name="" id="">
<button *ngIf="!data2.imageUrl" nz-button><i nz-icon nzType="upload" <button *ngIf="!data2.imageUrl" nz-button [nzLoading]="isLoadingSave"><i nz-icon nzType="upload" nzTheme="outline"></i>上传附件</button>
nzTheme="outline"></i>上传附件</button>
</div> </div>
<div class="uploadDiv" *ngIf="data2.imageUrl"> <div class="uploadDiv" *ngIf="data2.imageUrl" style="margin: 0 10px;">
<input (change)="filechange($event)" class="fileinput" type="file" name="" id=""> <input (change)="filechange($event,true)" class="fileinput" type="file" name="" id="">
<button nz-button><i nz-icon nzType="upload" nzTheme="outline"></i>重新上传</button> <button nz-button [nzLoading]="isLoadingSave"><i nz-icon nzType="upload" nzTheme="outline"></i>重新上传</button>
</div> </div>
<div class="uploadDiv"> <div class="uploadDiv" *ngIf="data2.hasAttachmentDefault" style="margin: 0 10px;">
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'img'" style="width: 100%;height: 100%;cursor: pointer;" [src]="data2.imageUrl" (click)="viewImg(data2.imageUrl)"> <img *ngIf="data2.attachment && getFileType(data2.attachment) == 'img'" style="width: 100%;height: 100%;cursor: pointer;" [src]="data2.attachment" (click)="viewImg(data2.attachment)">
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'word'" src="../../../../assets/images/license/word.png" (click)="lookFile(data2)"> <img *ngIf="data2.attachment && getFileType(data2.attachment) == 'word'" src="../../../../assets/images/license/word.png" (click)="lookFile(data2.attachment)">
<img *ngIf="data2.imageUrl && getFileType(data2.imageUrl) == 'pdf'" src="../../../../assets/images/license/pdf.png" (click)="lookFile(data2)"> <img *ngIf="data2.attachment && getFileType(data2.attachment) == 'pdf'" src="../../../../assets/images/license/pdf.png" (click)="lookFile(data2.attachment)">
<input *ngIf="!data2.imageUrl" (change)="filechange($event)" class="fileinput" type="file" name="" id=""> <input *ngIf="!data2.attachment" (change)="filechange($event,false)" class="fileinput" type="file" name="" id="">
<button *ngIf="!data2.imageUrl" nz-button><i nz-icon nzType="upload" <button *ngIf="!data2.attachment" nz-button [nzLoading]="isLoadingSave"><i nz-icon nzType="upload" nzTheme="outline"></i>上传副本</button>
nzTheme="outline"></i>上传副本</button>
</div> </div>
<div class="uploadDiv" *ngIf="data2.imageUrl"> <div class="uploadDiv" *ngIf="data2.attachment && data2.hasAttachmentDefault">
<input (change)="filechange($event)" class="fileinput" type="file" name="" id=""> <input (change)="filechange($event,false)" class="fileinput" type="file" name="" id="">
<button nz-button><i nz-icon nzType="upload" nzTheme="outline"></i>重新上传副本</button> <button nz-button [nzLoading]="isLoadingSave">重新上传副本</button>
</div> </div>
</div> </div>
<div class="btnbox"> <div class="btnbox">
<button nz-button type="submit" class="ok" (click)="submitReview()">提交审核</button> <button nz-button type="submit" class="ok" (click)="submitReview()" [nzLoading]="isLoadingSave">提交审核</button>
<button nz-button type="submit" class="ok" (click)="ok()">保存</button> <button nz-button type="submit" class="ok" (click)="ok()" [nzLoading]="isLoadingSave">保存</button>
<button nz-button type="button" class="cancel" (click)="destroyModal()">取消</button> <button nz-button type="button" class="cancel" (click)="destroyModal()">取消</button>
</div> </div>
</form> </form>

34
src/app/pages/license/update-category/edit-update-category/edit-update-category.component.ts

@ -119,25 +119,27 @@ export class EditUpdateCategoryComponent implements OnInit {
//查看文件 //查看文件
lookFile(item) { lookFile(item) {
if (!item.imageUrl) { if (!item) {
return return
} }
if (this.getFileType(item.imageUrl) == 'word') { if (this.getFileType(item) == 'word') {
let arr = item.imageUrl.split('.') let arr = item.split('.')
arr[arr.length - 1] = 'pdf' arr[arr.length - 1] = 'pdf'
window.open(arr.join('.')) window.open(arr.join('.'))
} else if (this.getFileType(item.imageUrl) == 'pdf') { } else if (this.getFileType(item) == 'pdf') {
window.open(item.imageUrl) window.open(item)
} else { } else {
this.message.create('warning', '暂不支持查看!'); this.message.create('warning', '暂不支持查看!');
} }
} }
uploadType: boolean; //是否是上传副本
isLoadingSave: boolean = false isLoadingSave: boolean = false
uploadIndex: string uploadIndex: string
filechange(e) { filechange(e, type: boolean) {
this.uploadType = type
this.isLoadingSave = true
let oilStationId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id let oilStationId = JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id
let file = e.target.files[0] || null //获取上传的文件 let file = e.target.files[0] || null //获取上传的文件
this.openFileSelect(file, `stationPhotos/${oilStationId}/`) this.openFileSelect(file, `stationPhotos/${oilStationId}/`)
@ -163,9 +165,12 @@ export class EditUpdateCategoryComponent implements OnInit {
this.objectsSrv.postFile(this.postFilePath, file).subscribe(data => { this.objectsSrv.postFile(this.postFilePath, file).subscribe(data => {
let dataObj = data as any; let dataObj = data as any;
let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName; let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName;
this.imageUrl = filePath if (this.uploadType){
this.data2.imageUrl = filePath this.data2.imageUrl = filePath
console.log('上传成功', filePath) } else {
this.data2.attachment = filePath
}
this.isLoadingSave = false
resolve('success') resolve('success')
}); });
}) })
@ -179,9 +184,12 @@ export class EditUpdateCategoryComponent implements OnInit {
this.objectsSrv.postFile_MultipartUpload(this.postFilePath, file).then((value) => { this.objectsSrv.postFile_MultipartUpload(this.postFilePath, file).then((value) => {
let dataObj = value as any; let dataObj = value as any;
let filePath = dataObj.filePath let filePath = dataObj.filePath
this.imageUrl = filePath if (this.uploadType){
this.data2.imageUrl = filePath this.data2.imageUrl = filePath
console.log('上传成功', filePath) } else {
this.data2.attachment = filePath
}
this.isLoadingSave = false
}); });
} }

Loading…
Cancel
Save