<template>
  <el-select v-model="_value" placeholder="请选择">
    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
  </el-select>
</template>

<script>
  import { mapGetters } from 'vuex';

  export default {
    name: 'AmountSelect',
    computed: {
      ...mapGetters(['financialAccounts']),
      _value: {
        get() {
          return this.value;
        },
        set(value) {
          this.$emit('input', value);
        }
      }
    },
    props: {
      value: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        options: [],
      }
    },
    mounted() {
      this.getFinancialAccounts();
    },
    methods: {
      getFinancialAccounts() {
        this.options = this.financialAccounts.map(item => ({
          label: item.accountName,
          value: item.accountId
        }));
      },
    }
  }
</script>