/**
* @Author Sean
* @Date 2019/4/19
*/
<template>
  <div>
    <list-item :item-height="45">
      <item>
        <div slot="name">主承租人</div>
        <div slot="content">\{{ contract.bp_id_tenant_n }}</div>
      </item>
      <item>
        <div slot="name">项目编号</div>
        <div slot="content">\{{ contract.project_number }}</div>
      </item>
      <item>
        <div slot="name">合同编号</div>
        <div slot="content">\{{ contract.contract_number }}</div>
      </item>
      <item>
        <div slot="name">公司名称</div>
        <div slot="content">\{{ contract.company_id_n }}</div>
      </item>
      <item>
        <div slot="name">业务类型</div>
        <div slot="content">\{{ contract.business_type_n }}</div>
      </item>
      <item>
        <div slot="name">产品线</div>
        <div slot="content">\{{ contract.division_n }}</div>
      </item>
    </list-item>
    <!--银行信息-->
    <list-item v-if="readOnly === 'mainten'">
      <item>
        <div slot="name">自动扣款银行</div>
        <input
          slot="content" v-model="contract.direct_debit_bank_id_n" readonly type="text"
          placeholder="请输入"
          @click="selectDebitBank">
        <img slot="right-icon" src="../../assets/image/arrow-down@2x.png" class="right-icon">
      </item>
      <item>
        <div slot="name">账户名</div>
        <input slot="content" v-model="contract.dd_bank_account_name" type="text" placeholder="请输入">
      </item>
      <item>
        <div slot="name">账户号</div>
        <input slot="content" v-model="contract.dd_bank_account_num" type="text" placeholder="请输入">
      </item>
      <item>
        <div slot="name">账户类型</div>
        <input
          slot="content" v-model="contract.ebank_account_prop_n" readonly type="text"
          placeholder="请输入"
          @click="selectEbankAccount">
        <img slot="right-icon" src="../../assets/image/arrow-down@2x.png" class="right-icon">
      </item>
    </list-item>
    <list-item v-if="readOnly === 'sign'">
      <item>
        <div slot="name">自动扣款银行</div>
        <div slot="content">\{{ contract.direct_debit_bank_id_n }}</div>
      </item>
      <item>
        <div slot="name">账户名</div>
        <div slot="content">\{{ contract.dd_bank_account_name }}</div>
      </item>
      <item>
        <div slot="name">账户号</div>
        <div slot="content">\{{ contract.dd_bank_account_num }}</div>
      </item>
      <item>
        <div slot="name">账户类型</div>
        <div slot="content">\{{ contract.ebank_account_prop_n }}</div>
      </item>
    </list-item>
  </div>
</template>

<script>
export default {
  props: {
    contract: Object,
    readOnly: {
      type: String,
      default: function () {
        return 'mainten'
      }
    }
  },
  data () {
    return {
      bank_list: [],
      bank_account_list: [],
    }
  },
  created: function () {
    this.selectListLoad()
  },
  mounted: function () {
  },
  updated: function () {
  },
  methods: {
    // 查询下拉框
    selectListLoad () {
      let vm = this
      let url = process.env.basePath + 'account_bank_lov_list'
      let param = {}
      vm.$post(url, param).then(function (res) {
        if (res.result === 'S') {
          // 银行
          vm.bank_list = res.bank_list
          // 账户类型
          vm.bank_account_list = res.bank_account_list
        } else if (res.result === 'E') {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    selectDebitBank () {
      let vm = this
      hlsPopup.selectList({
        list: vm.bank_list,
        code: 'direct_debit_bank_id',
        object: {},
        returnItem: function (index, obj, child) {
          vm.$set(vm.contract, 'direct_debit_bank_id', vm.bank_list[index].code)
          vm.$set(vm.contract, 'direct_debit_bank_id_n', vm.bank_list[index].code_name)
        },
      })
    },
    selectEbankAccount () {
      let vm = this
      hlsPopup.selectList({
        list: vm.bank_account_list,
        code: 'ebank_account_prop',
        object: {},
        returnItem: function (index, obj, child) {
          vm.$set(vm.contract, 'ebank_account_prop', vm.bank_account_list[index].code)
          vm.$set(vm.contract, 'ebank_account_prop_n', vm.bank_account_list[index].code_name)
        /* vm.contract['ebank_account_prop'] = vm.bank_account_list[index].code
          vm.contract['ebank_account_prop_n'] = vm.bank_account_list[index].code_name */
        },
      })
    },
  },
}
</script>

<style scoped lang="less" rel="stylesheet">
.right-icon{
  width: 12px;
}
</style>
