<template>
    <div class="auto select-overspread" >
        <validator name='v'>
            <form class="form-horizontal" novalidate>
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#">详细信息</a></li>
                </ul>
                <div class="row">
                    <div  class="col-sm-6">
                        <label class="font_normal_body" >客户编号</label>
                        <input  class="input_search" style="width:60%" type="text" v-model="data.f_userinfo_code" :readonly="editValue" v-show="true">
                    </div>
                    <div  class="col-sm-6">
                      <label class="font_normal_body" >客户状态</label>
                      <input  class="input_search" style="width:60%" type="text" v-model="data.f_user_state" :readonly="editValue" v-show="true">
                    </div>
                    <div  class="col-sm-6">
                        <label class="font_normal_body">客户名称</label>
                        <input  class="input_search" style="width:60%" type="text" v-model="data.f_user_name" :readonly="editValue" v-show="true">
                    </div>
                    <div class="col-sm-6">
                      <label class="font_normal_body" >客户电话</label>
                      <input  class="input_search" style="width:60%" type="text" v-model="data.f_user_phone" :readonly="editValue" v-show="true">
                    </div>
                </div>
                <div class="row">

                    <div  class="col-sm-6">
                        <label class="font_normal_body" >地址信息</label>
                        <input  class="input_search" style="width:60%" type="text" v-model="data.f_address" :readonly="editValue" v-show="true">
                    </div>
                    <div  class="col-sm-6">
                      <label class="font_normal_body" >打印状态</label>
                      <v-select id="idCardType" :value.sync="data.f_print_state"
                                v-model="data.f_print_state"
                                :value-single="true"
                                :options='printstates' placeholder='打印状态'
                                style="width: 65%"
                                @change="showconfirm(data.f_print_state)"
                                close-on-select></v-select>
                    </div>
                </div>
                <div class="row">
                  <div  class="col-sm-6">
                    <label class="font_normal_body" >打印类型</label>
                    <input  class="input_search" style="width:60%" type="text" v-model="data.f_print_dh" :readonly="editValue" v-show="true">
                  </div>
                  <div  class="col-sm-6">
                    <label class="font_normal_body" >打印时间</label>
                    <datepicker :disabled='false'
                                :format="'yyyy-MM-dd HH:mm:ss'" :readonly="true"
                                :value.sync="data.f_printdate"
                                placeholder="打印时间"
                                v-model="data.f_printdate" style="width: 60%">
                    </datepicker>
                  </div>
                </div>
            </form>

            <div style="text-align:right;height:auto;margin:6px 15px 0 0;">
                  <button @click="resetPprintOrder()" v-if="this.$login.r.includes('重置打印单') && resetshow " class="button_clear">作废</button>
                <button v-show="confirmshow" @click="confirm()" class="button_clear">确定</button>
                <button @click="close()" class="button_clear">取消</button>
            </div>
            <!--</div>-->
        </validator>
    </div>
</template>
<script>
    import {HttpResetClass} from 'vue-client'

    export default {
      data () {
        return {
          model: {},
          editValue: true,
                // 编辑控制
          isEdit: false,
                // 扣费方式的改变 如果涉及日运算，则阶梯开始时间和生效时间不做显示
          stairStartShow: true,
                // 公司树状图信息
          curorgid: [],
          f_filialeid: '',  // 所属公司
          f_filialename: '',  // 所属公司名称
                // 限购配置
          printstates: [{label: '已打印', value: '是'}, {label: '未打印', value: '否'}],
          confirmshow: false,
          resetshow: true
        }
      },
      props: ['data', 'config', 'f_filialeid'],
      watch: {
        'data' (val) {
          if (val) {
                    //  initGen(this, val)
          } else {
            this.initModel()
          }
        }

      },
      ready () {
        this.checkdata()
    },
      methods: {
        checkdata () {
          if (this.data.f_print_state != null) {
            if (this.data.f_print_state == '未打印') {
              this.confirmshow = false
              this.printstates = [{label: '未打印', value: '未打印'}]
              this.resetshow = true
            } else if (this.data.f_print_state == '') {
              this.printstates = []
              this.resetshow = false
              this.confirmshow = false
            } else {
              this.printstates = [{label: '已打印', value: '是'}, {label: '未打印', value: '否'}]
              this.data.f_print_state = '是'
              this.confirmshow = this.$login.r.includes('打印单置未打印')
              this.resetshow = false
            }
          } else {
            this.printstates = []
            this.resetshow = false
            this.confirmshow = false
          }
        },
        showconfirm (val) {
          if (val != null && val != '') {
            switch (val) {
              case '否': this.confirmshow = this.$login.r.includes('打印单置未打印'); break
              case '是': this.confirmshow = false; break
            }
          } else {

          }
        },
        getorg (id, name) {
          this.f_filialeid = id[0]
          this.f_filialename = name[0]
        },
        initModel () {
          this.model = {
            f_user_type: '',
            f_gasproperties: '',
            f_price_type: '',
            f_stairmonths: 1,
            f_perform_date: '',
            detailprice: [],
            f_stair_start_date: '',
            f_population_increment: 0,
            f_population_base: 4,
            f_comments: '',
            f_deduction_way: this.config.deductionWay
          }
        },
        close () {
          this.$dispatch('close')
        },
        showChangeView () {
          this.$parent.changeView = true
        },
        confirm () {
          this.$dispatch('revoke', this.data)
        },
    resetPprintOrder () {
      this.data.f_print_state = '重置'
      this.$dispatch('revoke', this.data)
    }
      },
      watch: {
        'data.f_userinfo_code' () {
          this.checkdata()
        }
      }
    }
</script>
<style lang="less">
    #gas-price-form {
        .form-group {
            margin-left: 0px;
            margin-right: 0px;
        }
    }

</style>
