Skip to content
set.ts 2.12 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {AppService} from "../../../../../service/http.service";

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

    id;    // 问卷ID;

    isans = null; //匿名
    isopen; //公开
    temp = {
        id: '',
        isopen: null,
        isans: null,
        title: '',
        explai: '',
        usergroup: '',
        state: ''
    };

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

    ionViewDidLoad() {
        this.id = this.navParams.get('id');
        this.appService.ObserverHttpPostAdd('/wisdomgroup/modules/question/edit/', this.id).subscribe((res) => {
            this.temp = res.json().data;
            if (this.temp.isans == 1) {
                this.isans = true;
            } else {
                this.isans = false;
            }
            if (this.temp.isopen == 1) {
                this.isopen = true;
            } else {
                this.isopen = false;
            }
        });

    }

    save() {
        //是否匿名
        if (this.isans == true || this.isans == 1) {
            this.temp.isans = 1;
        } else {
            this.temp.isans = 2;
        }
        //是否公开问卷结果
        if (this.isopen == true || this.isopen == 1) {
            this.temp.isopen = 1;
        } else {
            this.temp.isopen = 0;
        }
        const data = {
            id: this.temp.id,
            title: this.temp.title,   //问卷标题
            explai: this.temp.explai,   //问卷说明
            usergroup: this.temp.usergroup,  //用户组id
            isopen: this.temp.isopen,  //是否公开
            isans: this.temp.isans,   //是否匿名
            state: this.temp.state   //状态
        };
        this.appService.ObserverHttpPost('/wisdomgroup/modules/question/updateOnApp', data)
            .subscribe((res) => {
                if (res) {
                    this.navCtrl.pop();
                }
            })
    }

}