<template>
  <div class="register-new-recruit">
    <r-btn :label="label" icon="pgs-save" @click="open" no-wrap />
    <operation-dialog :title="title" v-model="opened">
      <div class="row q-col-gutter-md"></div>
      <template #right-actions>
        <r-btn action label="Извлечь" @click="submit" />
      </template>
    </operation-dialog>
  </div>
</template>

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

<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator';
import DataBlock from '@components/cards/statements/components/dataBlock.vue';
import TaskButton from '@/mixins/TaskButton';
import { RecruitV4 } from '@/recruits/openapi/person-registry';

@Component({
  components: {
    DataBlock,
  },
})
export default class ExtractPersonalFile extends Mixins(TaskButton) {
  @Prop({ default: () => ({}) })
  declare readonly model: RecruitV4;

  @Prop({ default: () => '' })
  readonly title: string;

  opened = false;

  submit(recruit: RecruitV4): void {
    this.$emit('submit', {
      buttonId: this.buttonSettings.id,
      data: recruit,
    });
    this.close();
  }

  open(): void {
    if (this.disable) return;
    this.opened = true;
    this.$emit('open');
  }

  close(): void {
    this.opened = false;
    this.$emit('close');
  }
}
</script>
