<template>
  <div class="container-fluid">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <caption><h1 align="center">功能信息</h1></caption>
        <div class="form-group">
          <label for="f_username" class="col-sm-1 control-label col-sm-offset-1 ">上一级：</label>
          <div class="col-sm-2">
            <div class="form-group">
              <input type="text"  v-model="parent.name" class="form-control" id="f_username" placeholder="上一级" disabled>
            </div>
          </div>

          <label for="f_userid" class="col-sm-1 control-label">功能名称：</label>
          <div class="col-sm-2">
            <div class="form-group">
              <input type="text" v-model="model.id" class="form-control" id="f_userid" placeholder="编号">
            </div>
          </div>
        </div>
        <div class="form-group">
          <label for="f_userid" class="col-sm-1 col-sm-offset-1 control-label">选择类型：</label>
          <input type="radio" name="type" value="" >功能
          <input type="radio" name="type" value="">流程
          <input type="radio" name="type" value="">自定义
        </div>
        <div class="form-group">
          <label for="f_username" class="col-sm-1 control-label col-sm-offset-1">描述：</label>
          <div class="col-sm-7">
            <div class="form-group">
              <textarea class="form-control" rows="3" style="width: 100%;" ></textarea>
            </div>
          </div>
        </div>
      </form>
      <!-- <button v-if='$v.valid' @click="confirm()" class="btn btn-success col-sm-1 col-sm-offset-2">保&nbsp;&nbsp;&nbsp;存</button> -->
      <button @click="confirm()" class="btn btn-success col-sm-1 col-sm-offset-2">
        <span class="glyphicon glyphicon-floppy-disk"></span>保存
      </button>
      <button @click='$back()' class="btn btn-default col-sm-1 col-sm-offset-1">
        <span class=" glyphicon glyphicon-log-out"></span>返回
      </button>
    </validator>
  </div>
</template>

<script>
import co from 'co'

let saveGen = function * (self) {
  let msg = yield self.$http.post('rs/data/save',{data:self.model})
  //yield self.$showMessage(msg.data)
  console.log(msg)
  yield self.$showMessage(msg.bodyText)
  self.$back('refresh')
}

export default {
  title: '功能信息',
  props: ['parent'],
  data () {
    return {
      model: ''
    }
  },
  methods: {
    confirm () {
      let gen = saveGen(this)
      return co(gen)
    }
  }
}

</script>
