<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <div class="row">
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">&nbsp;操作&nbsp;</label>
            <input v-show="false" v-model="model.f_operat_type" v-validate:f_operat_type='{required: true}'>
            <v-select :value.sync="model.f_operat_type"
                      :options='operator_type' placeholder='请选择'
                      selected="补费" value-single
                      style="width:60%"
                      close-on-select></v-select>
            <!--<v-select v-if="this.data.f_collection_type==='按气量'" :value.sync="model.f_operat_type"-->
            <!--:options='operator_type2' placeholder='请选择'-->
            <!--selected="补气"-->
            <!--style="width:60%"-->
            <!--close-on-select></v-select>-->
          </div>
          <div class="col-sm-4 form-group"></div>

          <div class="col-sm-4 form-group"
               :class="[$v.f_preamount.required || $v.f_preamount.dctest ? 'has-error' : 'has-success']">
            <label class="font_normal_body">&nbsp;金额&nbsp;</label>
            <input class="input_search" type="number" v-model="model.f_preamount" style="width:60%"
                   v-validate:f_preamount='{required: true,  dctest: [0, ">" ]}' placeholder="金额">
          </div>
          <!--<div v-if="this.data.f_collection_type==='按气量'" class="col-sm-4 form-group"-->
          <!--:class="[$v.f_pregas.required || $v.f_pregas.dctest ? 'has-error' : 'has-success']">-->
          <!--<label class="font_normal_body">&nbsp;气量&nbsp;</label>-->
          <!--<input class="input_search" type="number" v-model="model.f_pregas" style="width:60%"-->
          <!--v-validate:f_pregas='{required: true,  dctest: [0, ">" ]}' placeholder="气量">-->
          <!--</div>-->

        </div>

        <div class="row">
          <div class="col-sm-12">
            <label for="f_paper_account" class="font_normal_body ">&nbsp;备注&nbsp;</label>
            <input class="input_search" style="width:87%" rows="1" v-model="model.f_comments"></input>
          </div>
        </div>
      </form>
      <div style="text-align:right;">
        <button class="btn button_search btn-gn" @click="confirm()" :disabled='!$v.valid'>确认</button>
        <button class="btn button_clear btn-gn" @click="clean()">取消</button>
      </div>
    </validator>
    <!--<validate-bill v-if="hasValidateBill" :data="model" @validate-bill="validateBill"></validate-bill>-->
    <!--<print-bill :show="print" :bill-manager='config.hasBillManage' v-ref:printbill :bill-url='billUrl' v-on:toggle="clean" @printok="printok" :data='printModel'></print-bill>-->
    <!--<print-bill :show="print" :bill-config='config' :bill-data='billData' v-on:toggle="clean" @printok="printok" :data='printModel'  v-ref:printbill></print-bill>-->
  </div>
  <upload :blodid="data.f_userinfo_id" v-if="showupload" isremark="true" fusetype="补费扣费"></upload>
</template>


<script>
import Vue from 'vue'

export default {
  title: '团体补费扣费',
  data () {
    return {
      blodid: '',
      showupload: false,
      operator_type: [{label: '补费', value: '团体补费'}, {label: '扣费', value: '团体扣费'}],
      model: {
        f_operat_type: '',
        f_pregas: 0,
        f_preamount: 0,
        f_comments: ''
      }

    }
  },
  props: ['row'],
  ready () {
    this.model.f_operat_type = '团体补费'
  },
  methods: {
    async confirm () {
      let param = {
        version: this.row.version,
        id: this.row.id,
        f_customer: this.row.f_customer,
        f_preamount: this.model.f_preamount,
        f_comments: this.model.f_comments,
        f_operat_type: this.model.f_operat_type,
        operInfo: {
          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
        }
      }
      this.$resetpost('rs/logic/groupFeeDeduction', {data: param}, {
        warnMsg: `确定要对用户${this.row.f_user_name}进行${this.model.f_operat_type}吗？`,
        resolveMsg: `${this.model.f_operat_type}成功！！`,
        rejectMsg: `${this.model.f_operat_type}失败！！请重试！！`
      }).then((res) => {
        this.clean()
      })
    },
    clean () {
      this.$dispatch('refresh')
    }
    // printok () {
    //   this.$dispatch('success')
    // },
    // validateBill (val) {
    //   this.validateOk = !val.isOk
    //   this.billData.bill = val.bill
    // }
  }
}
</script>
