background-upload.component.ts 1.06 KB
Newer Older
李维's avatar
李维 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
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 {

  @Input() items = {"leftTop": '', "middleTop": '', "rightTop": '', "leftMiddle": '', "rightMiddle": '', "leftBottom": '', "middleBottom": '', "rightBottom": ''};
  @Output() change = new EventEmitter();
  constructor( ) { }

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

  cleanAll() {
    if(confirm("确定清空所有背景吗?")) {
      this.items["leftTop"] = "";
      this.items["middleTop"] = "";
      this.items["rightTop"] = "";

      this.items["leftMiddle"] = "";
      this.items["rightMiddle"] = "";

      this.items["leftBottom"] = "";
      this.items["middleBottom"] = "";
      this.items["rightBottom"] = "";
      this.change.emit(this.items)
    }
  }

  deletePic(key) {
    this.items[key] = ""
    this.change.emit(this.items)
  }
}