import { Component, OnInit,EventEmitter,Input,Output,ViewContainerRef, ViewChild,OnDestroy} from '@angular/core';
import { Subject } from 'rxjs';
import { Http } from '@global/service/Http';
import { AppNotification } from '@global/service/Notification';
import { NavController, ModalController } from '@ionic/angular';
import { App } from '@global/service/App';
import * as moment from 'moment';
import { ComUtil } from '@global/util/ComUtil';
import { AppEnvironment } from 'src/environments/AppEnvironment';


@Component({
  selector: 'ctrl-mob-panel',
  templateUrl: './mob-panel.html',
  styleUrls: ['./mob-panel.scss']
})
export class Mdctrl_itempanel implements OnInit,OnDestroy{

    /**
     * 名称
     *
     * @type {string}
     * @memberof Mdctrl_itempanel
     */
    @Input() public name: string;

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
     * @memberof Mdctrl_itempanel
     */
    @Input() public viewState: Subject<ViewState>;


    /**
     * 是否为内嵌视图
     *
     * @type {boolean}
     * @memberof Mdctrl_itempanel
     */
    @Input() public isembeddedView: boolean;

    /**
     * 是否为模态模式
     *
     * @type {boolean}
     * @memberof Mdctrl_itempanel
     */
    @Input() public isModalMode: boolean;

    /**
     * 当前部件激活数据
     *
     * @public
     * @type {void}
     * @memberof Mdctrl_itempanel
     */
    public $activeData: Array<any> = [];

    constructor(private $http: Http, private $notification: AppNotification,private $navCtrl:NavController,private $app:App,private $modalCtrl: ModalController) {

    }


    /**
     * 返回
     *
     * @memberof Mdctrl_itempanel
     */
    public backView() {
        if (this.isModalMode) {
            let res: any;
            if (this.$activeData && this.$activeData.length > 0) {
                res = { ret: 'OK', result: this.$activeData };
            } else {
                res = { ret: 'NO', result: [] };
            }
            this.$modalCtrl.dismiss(res, 'close');
        } else {
            this.$navCtrl.back();
        }
    }

  ngOnInit(): void {}

  ngOnDestroy(): void {}

  /**
    * 单条数据
    *
    * @type {any}
    * @memberof Mdctrl_itempanel
    */
  @Input() public item:any;

  
  getDatas() {
      if (!this.item) {
          return [];
      }
      return [this.item];
  }

  getData() {
      return this.item;
  }



    


}


