<template>
  <list-item :item-height="44">
    <item :showArrow="true">
      <div slot="name">纳税人类型</div>
      <input
        slot="content"
        v-model="taxpayer_type_n"
        type="text"
        readonly
        placeholder="请选择"
        onfocus="this.blur()"
        @click="selectTaxpayer"
      >
    </item>
    <item :showArrow="true">
      <div slot="name">发票类型</div>
      <input
        slot="content"
        v-model="invoice_kind_n"
        type="text"
        readonly
        placeholder="请选择"
        onfocus="this.blur()"
        @click="selectInvoiceType"
      >
    </item>
    <item>
      <div slot="name">发票抬头</div>
      <input slot="content" v-model="invoiceInfo.invoice_title" type="text" placeholder="请输入发票抬头" >
    </item>
    <item>
      <div slot="name">发票地址及电话</div>
      <input slot="content" v-model="invoiceInfo.invoice_bp_address_phone_num" type="text" placeholder="请输入发票地址及电话" >
    </item>
    <item>
      <div slot="name">发票开户行及账号</div>
      <input
        slot="content"
        v-model="invoiceInfo.invoice_bp_bank_account"
        type="text"
        placeholder="请输入发票开户行及账号"
      >
    </item>
    <item>
      <div slot="name">纳税人识别号</div>
      <input
        slot="content"
        v-model="invoiceInfo.organization_code" type="text" placeholder="请输入纳税人识别号" >
    </item>
  </list-item>
</template>
<script>
export default {
  data () {
    return {
      taxpayer_type_n: '',
      invoice_kind_n: '',
      invoicList: [],
      taxpayerList: [],
      invoiceInfo: {
        taxpayer_type: '',
        invoice_kind: '',
        invoice_title: '',
        invoice_bp_address_phone_num: '',
        invoice_bp_bank_account: '',
      },
    }
  },
  created () {
    this.getInvoiceType()
    this.getTaxpayer()
  },
  updated () {
    this.sendList()
  },
  methods: {
    getInvoiceType () {
      let vm = this
      let url = process.env.basePath + 'bp_invoice_kind_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.invoicList = res.lists.map(item => {
            return {
              code: item.invoice_kind,
              code_name: item.invoice_kind_n,
            }
          })
        }
      })
    },
    getTaxpayer () {
      let vm = this
      let url = process.env.basePath + 'bp_taxpayer_type_query'
      let param = {}
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.taxpayerList = res.lists.map(item => {
            return {
              code: item.taxpayer_type,
              code_name: item.taxpayer_type_n,
            }
          })
        }
      })
    },
    selectInvoiceType (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.invoicList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.invoiceInfo.invoice_kind = obj.bp_type
          vm.invoice_kind_n = obj.bp_type_n
        },
      })
    },
    selectTaxpayer (e) {
      let vm = this
      vm.hlsPopup.selectList({
        list: vm.taxpayerList,
        code: 'bp_type',
        object: {},
        returnItem: function (index, obj) {
          vm.invoiceInfo.taxpayer_type = obj.bp_type
          vm.taxpayer_type_n = obj.bp_type_n
        },
      })
    },
    sendList () {
      this.$emit('getinvoiceList', this.invoiceInfo)
    },
  },
}
</script>
<style scoped>
input::placeholder{
    color: #B4B4B5;
}
</style>
