background-upload.component.ts 954 Bytes
Newer Older
李维's avatar
李维 committed
1 2 3 4 5 6 7 8 9
import {Component, EventEmitter, Input, Output } from '@angular/core';  

@Component({
  selector: 'app-background-upload',
  templateUrl: './background-upload.component.html',
  styleUrls: ['./background-upload.component.scss']
}) 
export class BackgroundUploadComponent {

李维's avatar
李维 committed
10
  @Input() items = {"leftTop": '', "middleTop": '', "rightTop": '', "leftMiddle": '', "rightMiddle": '', "leftBottom": '', "middleBottom": '', "rightBottom": ''};
李维's avatar
李维 committed
11 12 13 14 15 16 17 18
  @Output() change = new EventEmitter();
  constructor( ) { }

  onImageUploadSuccess(e, items, key) {
    items[key] = e.url;
    this.change.emit(items)
  }

李维's avatar
李维 committed
19 20 21 22 23 24 25
  cleanAll() {
    if(confirm("确定清空所有背景吗?")) {
      this.items = {"leftTop": '', "middleTop": '', "rightTop": '', "leftMiddle": '', "rightMiddle": '', "leftBottom": '', "middleBottom": '', "rightBottom": ''}
      this.change.emit(this.items)
    }
  }

李维's avatar
李维 committed
26 27 28 29
  deletePic(key) {
    this.items[key] = ""
    this.change.emit(this.items)
  }
李维's avatar
李维 committed
30
}