2024-09-24 11:55:31 +07:00
|
|
|
<script setup lang="ts">
|
2024-09-24 18:04:34 +07:00
|
|
|
import { onBeforeMount, onMounted, ref } from "vue";
|
2024-09-24 11:55:31 +07:00
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
|
2024-09-24 18:04:34 +07:00
|
|
|
import { useRoute } from "vue-router";
|
2024-09-24 11:55:31 +07:00
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2024-09-24 18:04:34 +07:00
|
|
|
import { useCommandDetail } from "@/modules/18_command/store/DetailStore";
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2024-09-24 11:55:31 +07:00
|
|
|
|
|
|
|
|
const $q = useQuasar();
|
2024-09-24 18:04:34 +07:00
|
|
|
const route = useRoute();
|
|
|
|
|
const store = useCommandDetail();
|
|
|
|
|
const {
|
|
|
|
|
showLoader,
|
|
|
|
|
hideLoader,
|
|
|
|
|
dialogConfirm,
|
|
|
|
|
dialogMessageNotify,
|
|
|
|
|
messageError,
|
|
|
|
|
} = useCounterMixin();
|
2024-09-24 11:55:31 +07:00
|
|
|
|
2024-09-24 18:04:34 +07:00
|
|
|
const step = defineModel<number>("step", { required: true }); //ขั้นตอนการลงนาม
|
|
|
|
|
const { fetchData } = defineProps({
|
|
|
|
|
fetchData: { type: Function, require: true },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const commandId = ref<string>(route.params.id.toString()); //ID คำสั่ง
|
2024-09-24 11:55:31 +07:00
|
|
|
|
|
|
|
|
//แบบร่าง
|
2024-09-24 18:04:34 +07:00
|
|
|
const isDraft = defineModel<boolean>("isDraft", { required: true });
|
2024-09-24 11:55:31 +07:00
|
|
|
const isCheckDraft = ref<boolean>(false); //เช็คทำแบบร่างเสร็จสิ้น
|
|
|
|
|
|
|
|
|
|
// รอผู้มีอำนาจลงนามอนุมัติ
|
2024-09-24 18:04:34 +07:00
|
|
|
const isAuthority = defineModel<boolean>("isAuthority", { required: true }); //ผู้มีอำนาจลงนามอนุมัติแล้ว
|
|
|
|
|
|
2024-09-24 11:55:31 +07:00
|
|
|
const isCheckAuthority = ref<boolean>(false); //เช็ครอผู้มีอำนาจลงนามอนุมัติ
|
2024-09-24 18:04:34 +07:00
|
|
|
const isAttachment = defineModel<boolean>("isAttachment", { required: true }); //เช็คบัญชีแนบท้าย
|
2024-09-24 11:55:31 +07:00
|
|
|
const fileUploadOrder = ref<any>(null); //ไฟล์คำสั่ง
|
|
|
|
|
const fileUploadTailer = ref<any>(null); //ไฟล์เอกสารแนบท้าย
|
|
|
|
|
const fileOrder = ref<any>(null); //ไฟล์คำสั่ง
|
|
|
|
|
const fileTailer = ref<any>(null); //ไฟล์เอกสารแนบท้าย
|
|
|
|
|
|
|
|
|
|
//รอออกคำสั่ง
|
|
|
|
|
const isCheckOrder = ref<boolean>(false); //เช็ครอออกคำสั่ง
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันยืนยันการส่งให้ผู้มีอำนาจลงนามอนุมัติ
|
|
|
|
|
*/
|
|
|
|
|
function onConfirmDraft() {
|
|
|
|
|
dialogConfirm(
|
|
|
|
|
$q,
|
2024-09-24 18:04:34 +07:00
|
|
|
async () => {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.put(config.API.command + `/draft/${commandId.value}`, {
|
|
|
|
|
sign: isDraft.value,
|
|
|
|
|
})
|
|
|
|
|
.then(async () => {
|
|
|
|
|
fetchData?.();
|
|
|
|
|
isCheckDraft.value = true;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-09-24 11:55:31 +07:00
|
|
|
},
|
|
|
|
|
"ยืนยันการส่งให้ผู้มีอำนาจลงนามอนุมัติ",
|
|
|
|
|
"คุณต้องการยืนยันการส่งให้ผู้มีอำนาจลงนามอนุมัติใช่หรือไม่?"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-24 18:04:34 +07:00
|
|
|
async function updateCheckboxAuthority(val: boolean) {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.put(config.API.command + `/pending-check/${commandId.value}`, {
|
|
|
|
|
sign: val,
|
|
|
|
|
})
|
|
|
|
|
.then(() => {})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-24 11:55:31 +07:00
|
|
|
/**
|
|
|
|
|
* ฟังก์ชันยืนยันการส่งออกคำสั่ง
|
|
|
|
|
*/
|
|
|
|
|
function onConfirmOrder() {
|
|
|
|
|
if (
|
2024-09-24 18:04:34 +07:00
|
|
|
store?.dataCommand?.commandNo !== "" &&
|
|
|
|
|
store?.dataCommand?.commandAffectDate !== null &&
|
|
|
|
|
store?.dataCommand?.commandExcecuteDate !== null
|
2024-09-24 11:55:31 +07:00
|
|
|
) {
|
|
|
|
|
dialogConfirm(
|
|
|
|
|
$q,
|
2024-09-24 18:04:34 +07:00
|
|
|
async () => {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.put(config.API.command + `/pending/${commandId.value}`, {
|
|
|
|
|
sign: isAuthority.value,
|
|
|
|
|
})
|
|
|
|
|
.then(async () => {
|
|
|
|
|
fetchData?.();
|
|
|
|
|
isCheckAuthority.value = true;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-09-24 11:55:31 +07:00
|
|
|
},
|
|
|
|
|
"ยืนยันการส่งออกคำสั่ง",
|
|
|
|
|
"คุณต้องการยืนยันการส่งออกคำสั่งใช่หรือไม่?"
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
dialogMessageNotify(
|
|
|
|
|
$q,
|
|
|
|
|
"ไม่สามารถดำเนินการต่อได้ กรุณากรอกเลขที่คำสั่ง วันที่ลงนาม และวันที่คำสั่งมีผลให้ครบ"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-24 18:04:34 +07:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
isCheckDraft.value = isDraft.value;
|
|
|
|
|
isCheckAuthority.value = isAuthority.value;
|
|
|
|
|
});
|
2024-09-24 11:55:31 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="q-px-lg q-py-md">
|
2024-09-24 18:04:34 +07:00
|
|
|
<q-timeline :color="store.status === 'CANCEL' ? 'grey-4' : 'blue-5'">
|
2024-09-24 11:55:31 +07:00
|
|
|
<!-- แบบร่าง -->
|
|
|
|
|
<q-timeline-entry
|
|
|
|
|
title="แบบร่าง"
|
2024-09-24 18:04:34 +07:00
|
|
|
:icon="step === 1 ? 'mdi-pencil' : step > 1 ? 'done' : 'mdi-numeric-1'"
|
2024-09-24 11:55:31 +07:00
|
|
|
>
|
|
|
|
|
<div class="row q-col-gutter-sm">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<q-checkbox
|
|
|
|
|
v-model="isDraft"
|
|
|
|
|
label="ทำแบบร่างเสร็จสิ้น: Print เอกสารเพื่อส่งเสนอผู้มีอำนาจลงนาม"
|
2024-09-24 18:04:34 +07:00
|
|
|
:disable="isCheckDraft || store.readonly"
|
2024-09-24 11:55:31 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-12" v-if="!isCheckDraft">
|
|
|
|
|
<q-btn
|
2024-09-24 18:04:34 +07:00
|
|
|
v-if="!store.readonly"
|
2024-09-24 11:55:31 +07:00
|
|
|
@click.prevent="onConfirmDraft"
|
|
|
|
|
label="ส่งให้ผู้มีอำนาจลงนามอนุมัติ"
|
2024-09-24 18:04:34 +07:00
|
|
|
:color="!isDraft ? 'grey-5' : 'public'"
|
2024-09-24 11:55:31 +07:00
|
|
|
:disable="!isDraft"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-timeline-entry>
|
|
|
|
|
|
|
|
|
|
<!-- รอผู้มีอำนาจลงนามอนุมัติ -->
|
|
|
|
|
<q-timeline-entry
|
|
|
|
|
title="รอผู้มีอำนาจลงนามอนุมัติ"
|
2024-09-24 18:04:34 +07:00
|
|
|
:icon="step === 2 ? 'mdi-pencil' : step > 2 ? 'done' : 'mdi-numeric-2'"
|
2024-09-24 11:55:31 +07:00
|
|
|
:color="step < 2 ? 'grey-4' : ''"
|
|
|
|
|
>
|
|
|
|
|
<div class="row q-col-gutter-sm" v-if="isCheckDraft">
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<q-checkbox
|
2024-09-24 18:04:34 +07:00
|
|
|
@update:model-value="updateCheckboxAuthority"
|
2024-09-24 11:55:31 +07:00
|
|
|
v-model="isAuthority"
|
|
|
|
|
label="ผู้มีอำนาจลงนามอนุมัติแล้ว"
|
2024-09-24 18:04:34 +07:00
|
|
|
:disable="step > 2 || isAuthority || store.readonly"
|
2024-09-24 11:55:31 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
:class="isAttachment ? 'col-12' : 'col-6'"
|
|
|
|
|
style="padding-left: 50px"
|
|
|
|
|
v-if="isAuthority"
|
|
|
|
|
>
|
|
|
|
|
<fieldset class="border q-px-lg q-py-sm">
|
|
|
|
|
<legend class="text-header q-px-sm">
|
|
|
|
|
อัปโหลดเอกสารสแกนกลับเข้าสู่ระบบ
|
|
|
|
|
</legend>
|
|
|
|
|
<div class="row q-col-gutter-md q-mb-md">
|
|
|
|
|
<!-- คำสั่ง -->
|
|
|
|
|
<div :class="isAttachment ? 'col-6' : 'col-12'">
|
|
|
|
|
<label class="text-file">คำสั่ง</label>
|
|
|
|
|
<div class="text-right" v-if="fileOrder">
|
|
|
|
|
<q-btn flat dense color="primary" icon="mdi-eye" rounded>
|
|
|
|
|
<q-tooltip>ดูไฟล์คำสั่ง</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
<!-- :href="OrderPDFUpload" -->
|
|
|
|
|
<q-btn
|
|
|
|
|
rounded
|
|
|
|
|
type="a"
|
|
|
|
|
flat
|
|
|
|
|
dense
|
|
|
|
|
color="red"
|
|
|
|
|
icon="mdi-download"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<q-tooltip>ดาวน์โหลดไฟล์คำสั่ง</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
<q-file
|
2024-09-24 18:04:34 +07:00
|
|
|
v-if="step === 2"
|
2024-09-24 11:55:31 +07:00
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
v-model="fileUploadOrder"
|
|
|
|
|
label="เลือกไฟล์คำสั่ง"
|
|
|
|
|
hide-bottom-space
|
2024-09-24 18:04:34 +07:00
|
|
|
:rules="[(val:string) => val || 'กรุณาเลือกไฟล์ไฟล์คำสั่ง']"
|
2024-09-24 11:55:31 +07:00
|
|
|
accept=".pdf"
|
2024-09-24 18:04:34 +07:00
|
|
|
:readonly="store.readonly"
|
2024-09-24 11:55:31 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="attach_file" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-file>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- เอกสารแนบท้าย -->
|
|
|
|
|
<div v-if="isAttachment" class="col-6">
|
|
|
|
|
<label class="text-file">เอกสารแนบท้าย</label>
|
|
|
|
|
<div class="text-right" v-if="fileTailer">
|
|
|
|
|
<q-btn flat dense color="primary" icon="mdi-eye" rounded>
|
|
|
|
|
<q-tooltip>ดูเอกสารแนบท้าย</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
<!-- :href="TailerPDFUpload" -->
|
|
|
|
|
<q-btn
|
|
|
|
|
type="a"
|
|
|
|
|
rounded
|
|
|
|
|
flat
|
|
|
|
|
dense
|
|
|
|
|
color="red"
|
|
|
|
|
icon="mdi-download"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<q-tooltip>ดาวน์โหลดเอกสารแนบท้าย</q-tooltip>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-file
|
2024-09-24 18:04:34 +07:00
|
|
|
v-if="step === 2"
|
2024-09-24 11:55:31 +07:00
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
v-model="fileUploadTailer"
|
|
|
|
|
label="เลือกไฟล์เอกสารแนบท้าย"
|
|
|
|
|
hide-bottom-space
|
2024-09-24 18:04:34 +07:00
|
|
|
:rules="[(val:string) => val || 'กรุณาเลือกไฟล์เอกสารแนบท้าย']"
|
2024-09-24 11:55:31 +07:00
|
|
|
accept=".pdf"
|
2024-09-24 18:04:34 +07:00
|
|
|
:readonly="store.readonly"
|
2024-09-24 11:55:31 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon name="attach_file" />
|
|
|
|
|
</template>
|
|
|
|
|
</q-file>
|
|
|
|
|
</div>
|
2024-09-24 18:04:34 +07:00
|
|
|
|
|
|
|
|
<div class="row col-12" v-if="!store.readonly">
|
|
|
|
|
<q-space />
|
|
|
|
|
<q-btn
|
|
|
|
|
icon="mdi-upload"
|
|
|
|
|
label="อัปโหลดเอกสารส"
|
|
|
|
|
:color="
|
|
|
|
|
fileUploadOrder == null ||
|
|
|
|
|
(isAttachment && fileUploadTailer === null)
|
|
|
|
|
? 'grey-5'
|
|
|
|
|
: 'blue-5'
|
|
|
|
|
"
|
|
|
|
|
:disable="
|
|
|
|
|
fileUploadOrder == null ||
|
|
|
|
|
(isAttachment && fileUploadTailer === null)
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
</q-btn>
|
|
|
|
|
</div>
|
2024-09-24 11:55:31 +07:00
|
|
|
</div>
|
|
|
|
|
</fieldset>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-09-24 18:04:34 +07:00
|
|
|
<div
|
|
|
|
|
class="col-12"
|
|
|
|
|
v-if="
|
|
|
|
|
step === 2 &&
|
|
|
|
|
isAuthority &&
|
|
|
|
|
fileOrder &&
|
|
|
|
|
(isAttachment || fileTailer)
|
|
|
|
|
"
|
|
|
|
|
>
|
2024-09-24 11:55:31 +07:00
|
|
|
<q-btn
|
2024-09-24 18:04:34 +07:00
|
|
|
v-if="!store.readonly"
|
2024-09-24 11:55:31 +07:00
|
|
|
@click.prevent="onConfirmOrder"
|
|
|
|
|
label="ยืนยันออกคำสั่ง"
|
2024-09-24 18:04:34 +07:00
|
|
|
:color="
|
|
|
|
|
!isAuthority ||
|
|
|
|
|
fileOrder === null ||
|
|
|
|
|
(fileTailer === null && isAttachment)
|
|
|
|
|
? 'grey-5'
|
|
|
|
|
: 'public'
|
|
|
|
|
"
|
2024-09-24 11:55:31 +07:00
|
|
|
:disable="
|
2024-09-24 18:04:34 +07:00
|
|
|
!isAuthority ||
|
|
|
|
|
fileOrder === null ||
|
|
|
|
|
(fileTailer === null && isAttachment)
|
2024-09-24 11:55:31 +07:00
|
|
|
"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-timeline-entry>
|
|
|
|
|
|
|
|
|
|
<!-- รอออกคำสั่ง -->
|
|
|
|
|
<q-timeline-entry
|
|
|
|
|
title="รอออกคำสั่ง"
|
2024-09-24 18:04:34 +07:00
|
|
|
:icon="step === 3 ? 'mdi-pencil' : step > 3 ? 'done' : 'mdi-numeric-3'"
|
2024-09-24 11:55:31 +07:00
|
|
|
:color="step < 3 ? 'grey-4' : ''"
|
|
|
|
|
>
|
|
|
|
|
<div class="row q-col-gutter-sm" v-if="isCheckAuthority">
|
2024-09-24 18:04:34 +07:00
|
|
|
<!-- <div class="col-12">รอออกคำสั่ง</div> -->
|
2024-09-24 11:55:31 +07:00
|
|
|
</div>
|
|
|
|
|
</q-timeline-entry>
|
|
|
|
|
|
|
|
|
|
<!-- รอออกคำสั่ง -->
|
|
|
|
|
<q-timeline-entry
|
|
|
|
|
title="ออกคำสั่งเสร็จสิ้น"
|
2024-09-24 18:04:34 +07:00
|
|
|
:icon="step === 4 ? 'mdi-pencil' : step > 4 ? 'done' : 'mdi-numeric-4'"
|
2024-09-24 11:55:31 +07:00
|
|
|
:color="step < 4 ? 'grey-4' : ''"
|
|
|
|
|
>
|
2024-09-24 18:04:34 +07:00
|
|
|
<div class="row q-col-gutter-sm">
|
|
|
|
|
<!-- <div class="col-12">รอออกคำสั่ง</div> -->
|
2024-09-24 11:55:31 +07:00
|
|
|
</div>
|
|
|
|
|
</q-timeline-entry>
|
|
|
|
|
</q-timeline>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.border {
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
border: 1px solid #e9eaec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.text-header {
|
|
|
|
|
color: #34373c;
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
font-weight: 300;
|
|
|
|
|
}
|
|
|
|
|
</style>
|