<template>
  <div class="flex-row">
    <div class="span" style="overflow-y: auto;">
      <validator name='v'>
        <form novalidate class="form-horizontal">
          <div class="row" style="margin-top:5px;">
              <div class="col-sm-12">
                <label for="f_curbalance" class="font_normal_body">备注:</label>
                <input class="input_search" style="width:60%" style="width:60%" rows="1" v-model="model.f_comments"></textarea>
              </div>
          </div>
        </form>
        <div style="text-align:right;margin-top: 2%">
          <button class="button_search btn-gn" @click="confirm()">确认</button>
          <button class="button_clear btn-gn" @click="clean()">取消</button>
        </div>
      </validator>
    </div>
  </div>
</template>

<script>
  let callbackUserFiles = async function (self) {
    console.log(self.row.f_user_id, self.row.version)

    let param = {
      f_user_id: self.row.f_user_id,
      f_userinfo_id: self.row.f_userinfo_id,
      version: self.row.version,
      f_table_state: '正常',
      f_open_date: self.$login.toStandardTimeString(),
      f_open_person: self.$login.f.name,
      f_comments: self.model.f_comments,

      f_operat_type: '开通',
      f_describe: `${self.$login.f.name}对客户${self.row.f_user_name}进行开通操作`,
      f_state: '有效',

      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,

      f_user_id: {
        f_user_id: self.row.f_user_id,
        version: self.row.version,
        f_table_state: '正常',
        f_open_date: self.$login.toStandardTimeString()
      }
    }
    await self.$resetpost('rs/entity/t_open_meter', param, {rejectMsg: '开通失败', resolveMsg: '开通成功'})
    self.$dispatch('success')
  }

  export default {
    title: '物联网表开通',
    data () {
      return {
        model: {
          f_comments: ''
        }
      }
    },
    props: ['row'],
    ready () {
    },
    methods: {
      confirm () {
        callbackUserFiles(this)
      },
      clean () {
        this.$dispatch('refresh', this.row)
      }
    }
  }
</script>
