<!-- 开票信息 -->
<template>
  <list-item :item-height="44">
    <item v-for="(ele, i) of formdata" :key="ele.title">
      <div slot="name" class="font-color">{{ ele.title }}</div>
      <span v-if="ele.type === 'currency'" slot="content">{{ billingInfo[ele.prop] || currency }}</span>
      <span v-else-if="ele.type === 'bool'" slot="content">{{ billingInfo[ele.prop] === 'Y' ? '是' : '否' }}</span>
      <span v-else="ele.type === 'text'" slot="content">{{ billingInfo[ele.prop] }}</span>
    </item>
  </list-item>
</template>

<script>
export default {
  props: ['billingInfo'],
  data () {
    return {
    }
  },
  computed: {
    formdata () {
      return this.createForm()
    },
  },
  methods: {
    factory (arr) {
      let outArr = []
      if (arr.length) {
        arr.forEach(ele => {
          let [title, prop, type] = ele
          outArr.push({
            title: title || '',
            prop: prop || 'fdf',
            type: type || 'text',
          })
        })
      }
      return outArr
    },
    createForm () {
      let billingInfo_A = [// 自然人
        ['纳税人类型', 'taxpayer_type_n', 'text'],
        ['发票类型', 'invoice_kind_n', 'text'],
        ['发票抬头', 'invoice_title', 'text'],
        ['发票地址', 'invoice_adds', 'text'],
        ['开户电话', 'invoice_tel', 'text'],
        ['开户银行', 'open_bank', 'text'],
        ['开户行账号', 'open_account', 'text'],
      ]
      let billingInfo_B = [// 法人
        ['纳税人类型', 'taxpayer_type_n', 'text'],
        ['发票类型', 'invoice_kind_n', 'text'],
        ['发票抬头', 'invoice_title', 'text'],
        ['发票地址', 'invoice_adds', 'text'],
        ['开户电话', 'invoice_tel', 'text'],
        ['开户银行', 'open_bank', 'text'],
        ['开户行账号', 'open_account', 'text'],
        ['纳税人识别号', 'organization_code', 'text'],
      ]
      let newForm = this.billingInfo.bp_class === 'NP' ? billingInfo_A : billingInfo_B
      return this.factory(newForm)
    },
  },
}
</script>

<style lang="less" scoped></style>
