<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <p class="bg-info text-center" style="padding: 8px;">启用信息</p>

        <div class="row">
          <div class="col-sm-4">
            <label for="f_reason" class="font_normal_body">启用原因</label>
            <v-select v-model="model.f_comments"
                      placeholder='启用原因'
                      :value.sync="model.f_comments"
                      :options='reason'
                      v-ref:reason
                      close-on-select ></v-select>
          </div>
        </div>
        <div class="row" style="margin-top:1px;" v-if= "model.f_comments[0] === '其他'">
          <div class="col-sm-8">
            <label for="f_reason" class="font_normal_body">其他原因</label>
            <input class="input_search" style="width:80%" v-model="model.f_othereason"  placeholder="请填写原因"/>
          </div>
        </div>
      </form>
      <div style="text-align:right;">
        <button class="button_search button_spacing" @click="confirm()"  :disabled='!$v.valid'>确认</button>
        <button class="button_clear" @click="clean()" >取消</button>
      </div>
    </validator>
  </div>
</template>
<script>
/**
*综合业务
*表具启用组件
*/

let meterEnable = async function (self, model, row) {
  let data = {
    f_userfiles_id: {
      f_userfiles_id: row.f_userfiles_id,
      f_table_state: '正常',
      version: row.version
    },
    f_user_id: row.f_user_id,
    record_userinfo: row.f_userinfo_id,
    f_userinfo_id: row.f_userinfo_id,
    f_user_name: row.f_user_name,
    f_state: '有效',
    f_comments: model.f_comments[0],
    f_othereason: model.f_othereason,
    f_operat_type: '启用',
    f_describe: `${self.$login.f.name}对客户${row.f_user_name}进行表具启用操作`,
    f_operator: self.$login.f.name,
    f_operatorid: self.$login.f.id,
    f_orgid: self.$login.f.orgid,
    f_orgname: self.$login.f.orgs,
    f_depid: self.$login.f.depids,
    f_depname: self.$login.f.deps
  }
  await self.$resetpost('rs/entity/t_enable', data, {resolveMsg: '表具启用成功', rejectMsg: '表具启用失败'})
  self.$dispatch('success')
}

export default {
  title: '启用管理',
  props: ['row'],
  data () {
    return {
      model: {
      },
      select: {
        f_date: '',
        f_reason: ''
      },
      reason: this.$appdata.getParam('启用原因')
    }
  },
  methods: {
    confirm () {
      meterEnable (this, this.model, this.row)
      // this.$LogicService.meterEnable(this.model, this.row)
      // .then(
      //   (res) => this.$dispatch('success', '表具启用', this.row, res)
      // ).catch(
      //   (error) => {
      //     if (error.state === 603) {
      //       this.$error('重复提交')
      //       return
      //     }
      //     this.$dispatch('error', '表具启用', this.row, error)
      //   }
      // )
    },
    clean () {
      this.$dispatch('refresh')
    }
  }
}
</script>

<style>
</style>
