เพิ่มคำสั่งรักษาการแทนและยกเลิกลาออก

This commit is contained in:
Warunee Tamkoo 2024-07-18 16:42:43 +07:00
parent 30562f176e
commit abdbb586c5
2 changed files with 188 additions and 41 deletions

View file

@ -127,6 +127,10 @@ const result = ref<string>("");
const refRaw = ref<string>(""); const refRaw = ref<string>("");
const complaintId = ref<string>(""); const complaintId = ref<string>("");
// C-PM-40
const actStartDate = ref<Date | null>(null);
const actEndDate = ref<Date | null>(null);
const typeOrderFilter = ref<any>({ const typeOrderFilter = ref<any>({
typeOrderOption: [], typeOrderOption: [],
}); });
@ -155,6 +159,34 @@ watch(nameCommand, async () => {
positionCommand.value = nameCommand.value.positionName; positionCommand.value = nameCommand.value.positionName;
} }
}); });
const mainCommandCodes = ref<string[]>([
"C-PM-01",
"C-PM-02",
"C-PM-03",
"C-PM-04",
"C-PM-05",
"C-PM-06",
"C-PM-07",
"C-PM-08",
"C-PM-09",
"C-PM-10",
"C-PM-11",
"C-PM-12",
"C-PM-13",
"C-PM-14",
"C-PM-15",
"C-PM-16",
"C-PM-17",
"C-PM-18",
"C-PM-21",
"C-PM-22",
"C-PM-23",
"C-PM-24",
"C-PM-38",
"C-PM-39",
"C-PM-40",
"C-PM-41",
]);
const commandCodes = ref<string[]>([ const commandCodes = ref<string[]>([
"C-PM-19", "C-PM-19",
@ -180,11 +212,14 @@ const fecthTypeOption = async (actions: string) => {
const filterRes = response.filter((e: any) => const filterRes = response.filter((e: any) =>
commandCodes.value.includes(e.commandCode) commandCodes.value.includes(e.commandCode)
); );
const mainFilterRes = response.filter((e: any) =>
mainCommandCodes.value.includes(e.commandCode)
);
const data = const data =
orderId_paramsName === "OrderDetail" || orderId_paramsName === "OrderDetail" ||
orderId_paramsName === "OrderAdd" orderId_paramsName === "OrderAdd"
? response ? mainFilterRes
: filterRes; : filterRes;
typeOrderOption.value = data.map((e: OrederResult) => ({ typeOrderOption.value = data.map((e: OrederResult) => ({
@ -254,6 +289,7 @@ const fetchdetailOrder = async () => {
book.value = data.militaryCommandNo; book.value = data.militaryCommandNo;
bookDate.value = data.militaryCommanDate; bookDate.value = data.militaryCommanDate;
//10 //10
if (data.orderTypeCode === "c-pm-10") { if (data.orderTypeCode === "c-pm-10") {
nodeTree(); nodeTree();
} }
@ -296,6 +332,9 @@ const fetchdetailOrder = async () => {
result.value = data.result; result.value = data.result;
refRaw.value = data.refRaw; refRaw.value = data.refRaw;
complaintId.value = data.complaintId; complaintId.value = data.complaintId;
actStartDate.value = data.actStartDate;
actEndDate.value = data.actEndDate;
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -443,6 +482,10 @@ const selectCMP = async (selectOrder: OrederResult) => {
refRaw.value = ""; refRaw.value = "";
complaintId.value = ""; complaintId.value = "";
// 40
actStartDate.value = null;
actEndDate.value = null;
}; };
// //
@ -622,6 +665,11 @@ const onSubmit = async () => {
result: result.value, result: result.value,
refRaw: refRaw.value, refRaw: refRaw.value,
}); });
} else if (typeOrder.value.commandCode == "C-PM-40") {
Object.assign(formdata, {
actStartDate: actStartDate.value,
actEndDate: actEndDate.value,
});
} }
// //
@ -2374,6 +2422,100 @@ const getClass = (val: boolean) => {
/> />
</div> </div>
</div> </div>
<!-- C-PM-40 -->
<div
class="row col-12 q-col-gutter-x-lg q-col-gutter-y-md"
v-if="typeOrder != null && typeOrder.commandCode === 'C-PM-40'"
>
<div class="col-xs-12 col-md-3">
<datepicker
menu-class-name="modalfix"
v-model="actStartDate"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
:max-date="actEndDate"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
:class="getClass(true)"
outlined
dense
class="full-width datepicker"
:model-value="
actStartDate != null ? date2Thai(actStartDate) : null
"
:label="`${'วันที่เริ่มรักษาการ'}`"
:rules="[
(val) => !!val || `${'กรุณาเลือกวันที่เริ่มรักษาการ'}`,
]"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-12 col-md-3">
<datepicker
menu-class-name="modalfix"
v-model="actEndDate"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
:min-date="actStartDate"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
:class="getClass(true)"
outlined
dense
class="full-width datepicker"
:model-value="
actEndDate != null ? date2Thai(actEndDate) : null
"
:label="`${'วันที่สิ้นสุดรักษาการ'}`"
:rules="[
(val) => !!val || `${'กรุณาเลือกวันที่สิ้นสุดรักษาการ'}`,
]"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
</div>
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
<q-card-actions align="right"> <q-card-actions align="right">

View file

@ -77,23 +77,8 @@ const attachmentStatus = computed(() => {
code.value != "c-pm-30" && code.value != "c-pm-30" &&
code.value != "c-pm-31" && code.value != "c-pm-31" &&
code.value != "c-pm-32" && code.value != "c-pm-32" &&
code.value != "c-pm-38" code.value != "c-pm-38" &&
? true code.value != "c-pm-41"
: false;
});
// gen report server code gen report
const genReportStatus = computed(() => {
return code.value == "c-pm-19" ||
code.value == "c-pm-20" ||
code.value == "c-pm-25" ||
code.value == "c-pm-26" ||
code.value == "c-pm-27" ||
code.value == "c-pm-28" ||
code.value == "c-pm-29" ||
code.value == "c-pm-30" ||
code.value == "c-pm-31" ||
code.value == "c-pm-32"
? true ? true
: false; : false;
}); });
@ -127,20 +112,20 @@ const downloadCover = async (type: string) => {
}; };
// //
const downloadAttachment = async (type: string) => { const downloadAttachment = async (type: string, sub: string = "docx") => {
// if (type === "xlsx") { if (sub === "xlsx") {
// genReportXLSX( genReportXLSX(
// dataAttachmentxlxs.value, dataAttachment.value,
// ` ${orderName.value}`, `เอกสารแนบท้าย คำสั่ง ${orderName.value}`,
// type type
// ); );
// } else { } else {
genReport( genReport(
dataAttachment.value, dataAttachment.value,
`เอกสารแนบท้าย คำสั่ง ${orderName.value}`, `เอกสารแนบท้าย คำสั่ง ${orderName.value}`,
type type
); );
// } }
}; };
const dataCover = ref<any>(); const dataCover = ref<any>();
@ -167,7 +152,7 @@ const fetchReportAttachment = async (type: string, orderId: string) => {
await http await http
.get(config.API.reportOrderAttachment(type, orderId, code.value)) .get(config.API.reportOrderAttachment(type, orderId, code.value))
.then(async (res) => { .then(async (res) => {
genPDf(res.data.result); genPDf(res.data.result, code.value == "c-pm-40" ? "xlsx" : "docx");
dataAttachment.value = res.data.result; dataAttachment.value = res.data.result;
}) })
.catch(async (e) => { .catch(async (e) => {
@ -187,9 +172,9 @@ const fetchReportAttachment = async (type: string, orderId: string) => {
// }); // });
}; };
function genPDf(data: any) { function genPDf(data: any, type: string = "docx") {
axios axios
.post(config.API.reportTemplate + `/docx`, data, { .post(config.API.reportTemplate + `/${type}`, data, {
headers: { headers: {
accept: "application/pdf", accept: "application/pdf",
"content-Type": "application/json", "content-Type": "application/json",
@ -539,7 +524,12 @@ const viewFileUpload = async (url: string) => {
<q-item <q-item
clickable clickable
v-close-popup v-close-popup
@click="downloadAttachment('pdf')" @click="
downloadAttachment(
'pdf',
code == 'c-pm-40' ? 'xlsx' : 'docx'
)
"
> >
<!-- type="a" <!-- type="a"
:href="orderAttachmentPdf" :href="orderAttachmentPdf"
@ -552,15 +542,30 @@ const viewFileUpload = async (url: string) => {
<q-item <q-item
clickable clickable
v-close-popup v-close-popup
@click="downloadAttachment('docx')" @click="
downloadAttachment(
code == 'c-pm-40' ? 'xlsx' : 'docx',
code == 'c-pm-40' ? 'xlsx' : 'docx'
)
"
> >
<!-- type="a" <!-- type="a"
:href="orderAttachmentXlsx" :href="orderAttachmentXlsx"
target="_blank" --> target="_blank" -->
<q-item-section avatar <q-item-section avatar>
><q-icon color="blue" name="mdi-file-word" <q-icon
/></q-item-section> v-if="code == 'c-pm-40'"
<q-item-section>ไฟล .docx</q-item-section> color="green"
name="mdi-file-excel-outline"
/>
<q-icon v-else color="blue" name="mdi-file-word" />
</q-item-section>
<q-item-section
>ไฟล
{{
code == "c-pm-40" ? ".xlsx" : ".docx"
}}</q-item-section
>
</q-item> </q-item>
</q-list> </q-list>
</q-menu> </q-menu>