<template>
  <div class="auto">
    <validator name='v'>
      <form class="form-horizontal">
        <p class="bg-info text-center" style="padding: 8px;">启用信息</p>
        <div class="row" style="margin-top:10px;">
          <span class="col-sm-2 col-sm-offset-1"><strong>已选中户数: {{model.discount}}</strong></span>
        </div>
        <div class="row" style="margin-top:10px;">
          <div  :class="[$v.f_reason.required ? 'has-error' : 'has-success']">
            <label for="f_reason" class=" font_normal_body">启用原因:</label>
            <input class="input_search" style="width:80%" v-model="model.f_reason" v-validate:f_reason='{required: true }' rows="3" placeholder="请填写原因">
          </div>
        </div>
      </form>
      <div style="text-align:right;height:auto;margin-top:30px;margin-right:50px;">
        <button class="button_search" @click="confirm()"  :disabled='!$v.valid'>确认</button>
        <button class="button_clear" @click="clean()">取消</button>
      </div>
    </validator>
  </div>
</template>
<script>
/**
*综合业务
表具停用组件
*/
export default {
  title: '批量启用',
  data () {
    return {
      model: {
        count: 0,
        discount: 0,
        f_reason: '',
        userinfo: {}
      }
    }
  },
  props: ['useraccount'],
  ready () {
    this.useraccount.forEach((item) => {
      if (item.f_user_state === '正常') {
        this.model.count = this.model.count + 1
      } else if (item.f_user_state = '销户') {
        this.model.discount = this.model.discount + 1
        this.model.userinfo = item
      }
    })
  },
  methods: {
    confirm () {
      this.model.f_reality_count = this.model.discount
      this.$FileService.batchOperate(this.model, '启用').then((res) => {
        this.$dispatch('success')
      }).catch((error) => {
        if (error.state === 603) {
          this.$error('重复提交')
          return
        }
        this.$dispatch('error', '批量启用', this.useraccount, error)
      })
    },
    clean () {
      this.$info('取消操作')
      this.$dispatch('clean', '批量启用', this.row)
    }
  }
}
</script>

<style>
</style>
