<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <div class="row" style="margin-top:10px;">
          <div class="col-sm-4 form-group" :class="[$v.f_book_no.required ? 'has-error' : '']">
            <label class=" font_normal_body">折&emsp;&emsp;号</label>
            <input style="width:60%" v-validate:f_book_no='{required: true }' type="text" v-model="model.f_book_no">
          </div>
        </div>
      </form>
      <book-bill :show="print" :url="'rs/report/book_bill'" :data='bookData' @toggle="close" @printok="printok"  v-ref:bookbill></book-bill>
      <div style="text-align:right;height:auto;margin-top:30px;margin-right:50px;">
        <button class="button_search btn-gn" @click="confirm()"  :disabled='!$v.valid'>确认</button>
        <button class="button_clear btn-gn" @click="clean()" >取消</button>
      </div>
    </validator>
  </div>
  <upload :blodid="row.f_userinfo_id" isremark="true" fusetype="发折"></upload>
</template>
<script>
  /**
   *综合业务
   *发折组件
   */

  export default {
    title: '补卡管理',
    data () {
      return {
        model: {
          f_book_no: ''
        },
        print: false,
        bookData: {}
      }
    },
    props: ['row', 'cardData'],
    methods: {
      confirm () {
        this.$dispatch('no-button')
        this.bookData = {
          f_userinfo_id: this.row.f_userinfo_id,
          f_book_no: this.model.f_book_no,
          f_zzhh: -1,
          content: {
            f_userinfo_code: `'${this.row.f_userinfo_code}'`,
            f_user_name: `'${this.row.f_user_type == '民用' ? this.row.f_user_name : ''}'`,
            f_unit_name: `'${this.row.f_user_type == '非民用' ? this.row.f_user_name : ''}'`,
            f_address: `'${this.row.f_address}'`,
            f_meter_style: `'${this.row.f_meter_style}'`,
            f_meter_brand: `'${this.row.f_meter_brand}'`,
            f_meternumber: `'${this.row.f_meternumber}'`,
            f_idnumber: `'${this.row.f_idnumber}'`,
            f_aroundmeter: `'${this.row.f_aroundmeter}'`,
            f_user_phone: `'${this.row.f_user_phone}'`,
            f_meter_base: `'${this.row.f_meter_base}'`,
            f_operate_date: `'${this.$login.toStandardDateString()}'`
          }
        }
        this.print = true
      },
      clean () {
        this.$dispatch('refresh')
      },
      close () {
        this.print = false
        this.clean()
      },
      async printok () {
        let data = {
          f_userinfo_id: this.row.f_userinfo_id,
          f_book_no: this.model.f_book_no,
          f_send_date: this.$login.toStandardTimeString(),
          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
        }
        await this.$resetpost('rs/entity/t_send_book', data, {resolveMsg: null, rejectMsg: null})
        this.$dispatch('success')
      }
    }
  }
</script>
