<template>
  <div class="auto">
    <validator name='v'>
      <form class="form-horizontal">
        <div class="row">
          <div class="col-sm-8 form-group" :class="[$v.cause.required || $v.cause.dctest? 'has-error' : 'has-success']">
            <label for="f_reason" class="font_normal_body">封堵原因</label>
            <input class="input_search"
                   style="width:80%"
                   v-model="model.cause"
                   v-validate:cause='{required: true }'
                   placeholder="封堵原因"/>
          </div>
        </div>
        <div class="row" style="margin-top:1px;">
          <div class="col-sm-8 form-group">
            <label for="f_reason" class="font_normal_body">备&emsp;&emsp;注</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>
  <upload :blodid="blodid" v-if="false" isremark="true" fusetype="表具停用"></upload>
</template>
<script>
import Vue from 'vue'

/**
 *综合业务
 表具停用组件
 */
export default {
  title: '用户封堵',
  props: ['row'],
  data () {
    return {
      blodid: '',
      showupload: true,
      model: {},
      reason: this.$appdata.getParam('封堵原因')
    }
  },
  ready () {
    this.blodid = this.row.f_userinfo_id
  },
  methods: {
    async confirm () {
      let params = {
        f_userfiles: {
          f_userfiles_id: this.row.f_userfiles_id,
          f_table_state: '封堵',
          version: this.row.version
        },
        f_userinfo: {
          f_userinfo_id: this.row.f_userinfo_id,
          f_user_state: '封堵',
          version: this.row.version
        },
        f_plugging: {
          f_userfiles_id: this.row.f_userfiles_id,
          f_user_id: this.row.f_user_id,
          f_userinfo_id: this.row.f_userinfo_id,
          f_user_name: this.row.f_user_name,
          f_user_phone: this.row.f_user_phone,
          f_comments: this.model.cause,
          f_othereason: this.model.f_othereason,
          f_operat_type: '封堵',
          f_describe: `${this.$login.f.name}对客户${this.row.f_user_name}进行封堵操作`,
          f_state: '有效',
          f_operator: this.$login.f.name,
          f_operatorid: this.$login.f.id,
          f_orgid: this.$login.f.orgid,
          f_orgname: this.$login.f.orgs,
          f_depid: this.$login.f.depids,
          f_depname: this.$login.f.deps,
          f_zoneid: this.$login.f.zoneid,
          f_zones: this.$login.f.zones,
          f_operate_date: this.$login.toStandardTimeString()
        }
      }
      this.$resetpost('rs/logic/sale_userPlugging', {data: params}, {
        resolveMsg: '用户封堵成功！！',
        rejectMsg: '用户封堵失败！！'
      })
      this.$dispatch('success')
    },
    clean () {
      this.$dispatch('refresh')
    }
  }
}
</script>

<style>
</style>
