hrms-mgt/src/modules/10_order/components/Detail.vue

128 lines
3.9 KiB
Vue
Raw Normal View History

2023-06-23 12:10:59 +07:00
<template>
<div class="toptitle text-dark col-12 row items-center">
2023-08-09 12:39:54 +07:00
<q-btn icon="mdi-arrow-left" unelevated round dense flat color="primary" class="q-mr-sm" @click="router.go(-1), destroyLocalStorage()" />
2023-06-28 12:10:47 +07:00
ออกคำส
2023-06-23 12:10:59 +07:00
</div>
<q-card flat bordered class="col-12 q-my-sm q-mt-sm">
2023-08-09 12:39:54 +07:00
<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" />
2023-06-23 12:10:59 +07:00
2023-08-09 12:39:54 +07:00
<q-step :name="2" title="เลือกรายชื่อ" prefix="2" :done="step > 2" :header-nav="step > 2" />
2023-06-23 12:10:59 +07:00
2023-08-09 12:39:54 +07:00
<q-step :name="3" title="เลือกรายชื่อส่งสำเนาคำสั่ง" prefix="3" :done="step > 3" :header-nav="step > 3" />
<q-step :name="4" title="รายละเอียดคำสั่งและแนบท้าย" prefix="4" :done="step > 4" :header-nav="step > 4" />
2023-06-23 12:10:59 +07:00
<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" />
<step04 v-if="step === 4" :next="nextStep" :previous="previousStep" />
</template>
</q-stepper>
</q-card>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
import { ref, defineAsyncComponent, onMounted, onUnmounted } from "vue";
2023-06-23 12:10:59 +07:00
import type { QStepper } from "quasar";
2023-08-08 11:25:44 +07:00
import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
const route = useRoute();
2023-08-09 12:39:54 +07:00
2023-08-08 11:25:44 +07:00
const orderId_params = route.params.orderid;
2023-06-23 12:10:59 +07:00
const step01 = defineAsyncComponent(
2023-06-23 12:29:10 +07:00
() =>
import("@/modules/10_order/components/step/step01.vue")
2023-06-23 12:10:59 +07:00
);
const step02 = defineAsyncComponent(
2023-06-23 12:29:10 +07:00
() =>
import("@/modules/10_order/components/step/step02.vue")
2023-06-23 12:10:59 +07:00
);
const step03 = defineAsyncComponent(
2023-06-23 12:29:10 +07:00
() =>
import("@/modules/10_order/components/step/step03.vue")
2023-06-23 12:10:59 +07:00
);
const step04 = defineAsyncComponent(
2023-06-23 12:29:10 +07:00
() =>
import("@/modules/10_order/components/step/step04.vue")
2023-06-23 12:10:59 +07:00
);
const router = useRouter();
2023-08-09 12:39:54 +07:00
const step = ref<number>(0);
2023-06-23 12:10:59 +07:00
const stepper = ref<QStepper>();
2023-08-08 11:25:44 +07:00
const orderId = ref<string>("");
2023-06-23 12:10:59 +07:00
onUnmounted(() => {
destroyLocalStorage();
});
2023-08-09 12:39:54 +07:00
2023-08-08 11:25:44 +07:00
const nextStep = async () => {
2023-06-23 12:10:59 +07:00
stepper.value!.next();
2023-08-04 12:07:24 +07:00
localStorage.setItem("currentStep", step.value.toString());
2023-08-08 11:25:44 +07:00
if (orderId.value) {
await http
.put(config.API.nextStep(orderId.value))
.then((res) => {
console.log(res);
})
.catch((e) => {
console.log(e);
});
}
2023-06-23 12:10:59 +07:00
};
2023-08-08 11:25:44 +07:00
const previousStep = async () => {
2023-06-23 12:10:59 +07:00
stepper.value!.previous();
localStorage.setItem("currentStep", step.value.toString());
2023-08-08 11:25:44 +07:00
if (orderId.value) {
await http
.put(config.API.prevStep(orderId.value))
.then((res) => {
console.log(res);
})
.catch((e) => {
console.log(e);
});
}
2023-06-23 12:10:59 +07:00
};
2023-08-04 12:07:24 +07:00
const destroyLocalStorage = () => {
localStorage.clear();
};
2023-08-09 12:39:54 +07:00
2023-08-04 12:07:24 +07:00
onMounted(() => {
2023-08-09 12:39:54 +07:00
// console.log("route query===>", route.query)
if (route.query.step) {
step.value = Number(route.query.step)
localStorage.setItem("currentStep", step.value.toString());
} else {
const currentStep = localStorage.getItem("currentStep");
if (currentStep) {
step.value = Number(currentStep);
} else {
step.value = 1;
}
2023-08-04 12:07:24 +07:00
}
2023-08-09 12:39:54 +07:00
2023-08-08 11:25:44 +07:00
if (orderId_params !== undefined) {
orderId.value = orderId_params.toString();
2023-08-09 12:39:54 +07:00
// console.log(orderId.value);
2023-08-08 11:25:44 +07:00
}
2023-08-04 12:07:24 +07:00
});
2023-06-23 12:10:59 +07:00
</script>
<style>
.q-stepper--horizontal .q-stepper__step-inner {
padding: 0px;
}
2023-08-09 12:39:54 +07:00
2023-07-03 00:16:08 +07:00
.step .q-stepper__tab--done .q-stepper__title,
.step .q-stepper__tab--active .q-stepper__title {
color: #35473c !important;
font-weight: 500;
2023-06-29 11:05:21 +07:00
}
2023-08-09 12:39:54 +07:00
2023-07-03 00:16:08 +07:00
.step .q-stepper__header--standard-labels .q-stepper__tab {
2023-06-29 11:05:21 +07:00
min-height: 60px;
}
2023-06-23 12:10:59 +07:00
</style>