<template>
  <div class="toptitle text-dark col-12 row items-center">
    <q-btn
      icon="mdi-arrow-left"
      unelevated
      round
      dense
      flat
      color="primary"
      class="q-mr-sm"
      @click="router.go(-1)"
    />
    เพิ่ม คำสั่งให้ออก ปลดออก ไล่ออก
  </div>
  <q-card flat bordered class="col-12 q-my-sm q-mt-sm">
    <q-stepper
      v-model="step"
      ref="stepper"
      color="primary"
      animated
      class="step"
      header-class="bg-grey-1"
    >
      <q-step
        :name="1"
        title="รายละเอียดการออกคำสั่ง"
        prefix="1"
        :done="step > 1"
        :header-nav="step > 1"
      />
      <q-step
        :name="2"
        title="เลือกรายชื่อส่งสำเนาคำสั่ง"
        prefix="2"
        :done="step > 2"
        :header-nav="step > 2"
      />
      <q-step
        :name="3"
        title="รายละเอียดคำสั่งและแนบท้าย"
        prefix="3"
        :header-nav="step > 3"
      />
      <template v-slot:message>
        <step01 v-if="step === 1" :next="nextStep" :previous="previousStep" />
        <step02 v-if="step === 2" :next="nextStep" :previous="previousStep" />
        <step03 v-if="step === 3" :next="nextStep" :previous="previousStep" />
      </template>
    </q-stepper>
  </q-card>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
import { ref, defineAsyncComponent } from "vue";
import type { QStepper } from "quasar";

const step01 = defineAsyncComponent(
  () => import("@/modules/06_retirement/components/DismissOrder/step01.vue")
);
const step02 = defineAsyncComponent(
  () => import("@/modules/06_retirement/components/DismissOrder/step02.vue")
);
const step03 = defineAsyncComponent(
  () => import("@/modules/06_retirement/components/DismissOrder/step03.vue")
);

const router = useRouter();
const step = ref<number>(1);
const stepper = ref<QStepper>();

const nextStep = () => {
  stepper.value!.next();
};

const previousStep = () => {
  stepper.value!.previous();
};
</script>
<style>
.q-stepper--horizontal .q-stepper__step-inner {
  padding: 0px;
}
.step .q-stepper__tab--done .q-stepper__title,
.step .q-stepper__tab--active .q-stepper__title {
  color: #35473c !important;
  font-weight: 500;
}
.step .q-stepper__header--standard-labels .q-stepper__tab {
  min-height: 60px;
}
</style>
