<template>
<div v-if="record">
  <div class="columns is-multiline mx-0 mt-1" id="printable">
    <div class="column is-5">
      <div class="field">
        <label class="label">{{ $lang('code') }}:</label>
        <div class="control">
          {{ `${record.code}` }}
        </div>
      </div>
    </div>
    <div class="column is-7">
      <div class="field">
        <label class="label">{{ $lang('account-type') }}:</label>
        <div class="control">
          {{ `${record.type__code} / ${record.type__name}` }}
        </div>
      </div>
    </div>
    <div class="column is-5">
      <div class="field">
        <label class="label">{{ $lang('currency') }}:</label>
        <div class="control">
          {{ `${record.currency__code} / ${record.currency__name}` }}
        </div>
      </div>
    </div>
    <div class="column is-7">
      <div class="field">
        <label class="label">{{ $lang('balance') }}:</label>
        <div class="control">
          {{ $numtoString(record.balance) }}
        </div>
        <!--<p class="help is-findata">{{$vnmoney($formatNumber(record.balance))}}</p>-->
      </div>
    </div>
    <div class="column is-5">
      <div class="field">
        <label class="label">{{ $lang('open-date') }}:</label>
        <div class="control">
          {{ `${$dayjs(record.create_time).format('DD/MM/YYYY')}` }}
        </div>
      </div>
    </div>
    <!--<div class="column is-7">
      <div class="field">
        <label class="label">Chi nhánh:</label>
        <div class="control">
          {{ `${record.branch__code} / ${record.branch__name}` }}
        </div>
      </div>
    </div> -->
  </div>
  <div class="border-bottom"></div>
  <div class="mt-5" id="ignore">
    <button class="button is-primary has-text-white" @click="$exportpdf('printable', record.code)">{{$lang('print')}}</button>
  </div>
</div>
</template>
<script>
  export default {
    props: ['row'],
    data() {
      return {
        errors: {},
        record: undefined
      }
    },
    async created() {
      this.record = await this.$getdata('internalaccount', {id: this.row.account || this.row.id}, undefined, true)
    },
    methods: {
      selected(attr, obj) {
        this.record[attr] = obj
        if(attr==='_type') this.category = obj.category__code
      }
    }
  }
</script>