import { Component } from '@angular/core';
import {IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {EditPage} from "../edit/edit";
import {PersonPage} from "../../modal/person/person";
import { AppService } from "../../../../service/appHttpService";


@IonicPage()
@Component({
  selector: 'page-desicr',
  templateUrl: 'desicr.html',
})
export class DesicrPage {

  desrc = {
      title:'',   //问卷标题
      explai:'',   //问卷说明
      usergroup:'',  //用户组id
      isopen:0,  //是否公开
      isans:1,   //是否匿名
      state:1   //状态

  };
    groupName = '选择用户组';

  constructor(public navCtrl: NavController, public navParams: NavParams,
              public modalCtrl: ModalController,public appService: AppService) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad DesicrPage');
  }

    submitOrder(){
      // this.navCtrl.push('EditPage');
        const data = {}
        this.appService.ObserverHttpPost('/wisdomgroup/modules/question/create',this.desrc)
            .subscribe(
                (res)=>{
                   this.navCtrl.pop();
                }
            )
    }

    selectPerson(){
        let modal = this.modalCtrl.create(PersonPage);
        modal.onDidDismiss(data=>{
            console.log(data);
            this.desrc.usergroup = data.id;
            this.groupName = data.groupName;
        })
        modal.present();
    }

}
