<template>
  <BasicModal
    :showCancelBtn="false"
    :showOkBtn="false"
    width="800px"
    v-bind="$attrs"
    @register="register"
    :title="title"
  >
    <AccountRecord v-if="title === '账户记录'" @select="select" :data="data" />
  </BasicModal>
</template>
<script lang="ts">
  import AccountRecord from './accountrecord/index.vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { defineComponent, reactive, toRefs } from 'vue';

  export default defineComponent({
    components: { BasicModal, AccountRecord },
    emits: ['select'],
    setup(_, { emit }) {
      const state = reactive({
        title: '',
        data: '',
      });
      const [register, { closeModal }] = useModalInner((data) => {
        state.title = data;
        state.data = data;
      });

      function select(data) {
        emit('select', data);
        closeModal();
      }
      return {
        register,
        select,
        ...toRefs(state),
      };
    },
  });
</script>
