<!-- 商业伙伴 -->
<template>
  <Collapse v-model="activeNames" v-if="bplist.length">
    <CollapseItem v-for="(p, pi) of bplist" :title="p.bp_name" :key="p.bp_name" :name="pi">
      <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 slot="content">{{ bplist[pi][ele.prop] }}</span>
        </item>
      </list-item>
    </CollapseItem>
  </Collapse>
</template>

<script>
import { Collapse, CollapseItem } from 'vant';
import 'vant/lib/collapse/style';
import 'vant/lib/collapse-item/style';

export default {
  props: ['bplist'],
  components: {
    Collapse, CollapseItem
  },
  data() {
    return {
      activeNames: [0],
      formdata: [],
    }
  },
  created() {
    this.createForm()
  },
  methods: {
    factory(arr) {
      // 接收二维数组,产生 formdata
      if (arr.length) {
        arr.forEach(ele => {
          let [title, prop, type] = ele
          this.formdata.push({
            title: title || '',
            prop: prop || '',
            type: type || 'text'
          })
        });
      }
    },
    createForm() {
      let formArr = [
        ['商业伙伴编码', 'bp_id_n', 'text'],
        ['商业伙伴名称', 'bp_name', 'text'],
        ['证件号码', 'id_card_no', 'text'],
        ['联系电话', 'cell_phone', 'text'],
        ['资产', 'capital', 'text'],
        ['商业伙伴角色', 'bp_category_n', 'text'],
        ['征信授权签约状态', 'confirm_status', 'text'],
        ['征信签约顺序', 'sign_position', 'text'],
        ['合同签约状态', 'car_confirm_status', 'text'],
        ['合同签约顺序', 'contract_sign_position', 'text'],
      ]
      this.factory(formArr)
    }
  }
}
</script>

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