Refactoring code module 07_insignia

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-25 16:44:07 +07:00
parent 208d867dfd
commit 6fb6024f53
31 changed files with 1158 additions and 2444 deletions

View file

@ -1,395 +0,0 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar, QForm } from "quasar";
import { useRouter, useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
/** import Store*/
import { useCounterMixin } from "@/stores/mixin";
/** useStore*/
const mixin = useCounterMixin();
const {
date2Thai,
dateToISO,
messageError,
showLoader,
hideLoader,
dialogConfirm,
success,
dialogMessageNotify,
} = mixin;
/** use */
const router = useRouter();
const route = useRoute();
const $q = useQuasar();
const id = ref<string>(route.params.id as string);
const myForm = ref<QForm | null>(null); //form data input
const edit = ref<boolean>(false);
const dateStart = ref<Date>(new Date());
const dateEnd = ref<Date>(new Date());
const yearly = ref<number>(new Date().getFullYear());
const files = ref<any>();
const fileDocDataUpload = ref<File[]>([]);
const roundInsig = ref<any>();
const datelast = ref<number>(1);
const options = ref([
{ label: "รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ 1", value: 1 },
{ label: "รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ 2", value: 2 },
]);
/** Function เรียกข้อมูลของรอบการเสนอขอ */
async function fetchData() {
edit.value = true;
showLoader();
await http
.get(config.API.getRoundInsignia(id.value))
.then((res) => {
const data = res.data.result;
id.value = data.period_id;
roundInsig.value =
options.value.filter((r: any) => r.value == data.period_round).length >
0
? options.value.filter((r: any) => r.value == data.period_round)[0]
: null;
yearly.value = data.period_year;
datelast.value = data.period_amount;
dateStart.value = new Date(data.period_start);
dateEnd.value = new Date(data.period_end);
// files.value = data.period_doc;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* Function พโหลดไฟล
* @param files ไฟล
*/
function fileUploadDoc(files: any) {
files.forEach((file: any) => {
fileDocDataUpload.value.push(file);
});
}
/**
* Function พเดทป
* @param year บคาป คศ
*/
async function updateYear(year: number) {
yearly.value = year;
await updateDateRange();
}
/** Function ตรวจสอบค่าว่างของ Input */
function checkSave() {
if (myForm.value !== null) {
myForm.value.validate().then(async (success) => {
if (success) {
dialogConfirm($q, () => SaveData());
} else if (Number(datelast.value) !== 0) {
dialogMessageNotify($q, "กรุณาเลือกรอบการเสนอขอพระราชทานเครื่องราชฯ");
}
});
}
}
/** Function บันทึกข้อมูล */
async function SaveData() {
if (edit.value) {
await editData(id.value);
} else {
await addData();
clickBack();
}
}
/** Function อัพเดทวันที่เริ่มต้น และ สิ้นสุด */
function updateDateRange() {
if (roundInsig.value.value == 1) {
dateStart.value = new Date(yearly.value, 9, 1);
dateEnd.value = new Date(yearly.value + 1, 3, 29);
} else if (roundInsig.value.value == 2) {
dateStart.value = new Date(yearly.value + 1, 3, 29);
dateEnd.value = new Date(yearly.value + 1, 4, 29);
}
}
/** Function เพิ่มข้อมูลรอบการเสนอขอพระราชทานเครื่องราชฯ */
async function addData() {
const formData = new FormData();
const name = `รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ ${
roundInsig.value.value
} ${yearly.value + 543} `;
formData.append("name", name);
formData.append("year", yearly.value.toString());
formData.append("amount", datelast.value.toString());
formData.append("round", roundInsig.value.value);
if (dateStart.value !== null) {
formData.append("startDate", dateToISO(dateStart.value));
}
if (dateEnd.value !== null) {
formData.append("endDate", dateToISO(dateEnd.value));
}
formData.append("file", files.value);
showLoader();
await http
.post(config.API.listRoundInsignia(), formData)
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
}
/** Function แก้ไขข้อมูลรอบการเสนอขอพระราชทานเครื่องราชฯ */
async function editData(id: string) {
const formData = new FormData();
const name = `รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ ${
roundInsig.value.value
} ${yearly.value + 543}`;
formData.append("name", name);
formData.append("year", yearly.value.toString());
formData.append("amount", datelast.value.toString());
formData.append("round", roundInsig.value.value);
if (dateStart.value !== null) {
formData.append("startDate", dateToISO(dateStart.value));
}
if (dateEnd.value !== null) {
formData.append("endDate", dateToISO(dateEnd.value));
}
formData.append("file", files.value);
showLoader();
await http
.put(config.API.editRoundInsignia(id), formData)
.then(() => {
success($q, "แก้ไขข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
clickBack();
});
}
/** Function ย้อนกลับหน้า รอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์ */
function clickBack() {
router.push({ name: "insigniaProposals" });
}
/** Hook */
onMounted(async () => {
// params id
(await route.params?.id) && fetchData();
});
</script>
<template>
<div class="col-xs-12 col-sm-12 col-md-11">
<div class="toptitle col-12 row items-center">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="clickBack"
/>
{{
edit
? "รอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
: "เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
}}
</div>
<q-form ref="myForm">
<div class="col-12">
<q-card bordered>
<div class="col-12 row q-col-gutter-md q-pa-md">
<div class="col-xs-12 col-sm-12 row">
<q-separator />
<div class="col-12 row q-pa-sm q-col-gutter-sm">
<q-select
class="col-10 inputgreen"
dense
outlined
v-model="roundInsig"
:options="options"
option-value="value"
option-label="label"
label="รอบการเสนอขอพระราชทานเครื่องราชฯ"
@update:model-value="updateDateRange"
:rules="[(val) => !!val || `${'กรุณาเลือกรอบที่'}`]"
/>
<datepicker
menu-class-name="modalfix"
v-model="yearly"
class="col-2 inputgreen"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:modelValue="updateYear"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
:model-value="yearly + 543"
:rules="[(val) => !!val || `${'กรุณาเลือกปีที่เสนอ'}`]"
:label="`${'ปีที่เสนอ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
<datepicker
menu-class-name="modalfix"
v-model="dateStart"
:locale="'th'"
autoApply
class="col-xs-12 col-sm-5 inputgreen"
borderless
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="full-width datepicker"
:model-value="
dateStart != null ? date2Thai(dateStart) : 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>
<datepicker
menu-class-name="modalfix"
v-model="dateEnd"
class="col-xs-12 col-sm-5 inputgreen"
:locale="'th'"
autoApply
borderless
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
outlined
dense
class="col-xs-12 col-sm-4"
:model-value="dateEnd != null ? date2Thai(dateEnd) : 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>
<q-input
class="col-xs-12 col-sm-2 inputgreen"
dense
outlined
v-model="datelast"
label="จำนวนวันแจ้งเตือนก่อนวันสิ้นสุด"
mask="###"
:rules="[
(val) =>
!!val || `${'กรุณากรอกจำนวนวันแจ้งเตือนก่อนวันสิ้นสุด'}`,
]"
lazy-rules
/>
<q-file
class="col-xs-12 col-sm-10 inputgreen"
outlined
dense
v-model="files"
@added="fileUploadDoc"
label="อัปโหลดเอกสารประกอบ"
hide-bottom-space
lazy-rules
accept=".pdf,.xlsx,.doc"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
</q-file>
</div>
</div>
</div>
<q-separator />
<q-separator />
<div class="row col-12 q-pa-sm">
<q-space />
<q-btn
unelevated
dense
class="q-px-md items-center"
color="light-blue-10"
label="บันทึก"
@click="checkSave"
/>
</div>
</q-card>
</div>
</q-form>
</div>
</template>

View file

@ -1,440 +0,0 @@
<script setup lang="ts">
import { ref, useAttrs, onMounted } from "vue";
import { checkPermission } from "@/utils/permissions";
import router from "@/router";
import { useQuasar } from "quasar";
import config from "@/app.config";
import http from "@/plugins/http";
/** import Type*/
import type { QTableProps } from "quasar";
import type {
FormProprsalsRound2,
ColId,
} from "@/modules/07_insignia/interface/request/Main";
import DialogDetail from "@/modules/07_insignia/components/1_Proposals/DialogDetail.vue";
/** import Store*/
import { useCounterMixin } from "@/stores/mixin";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
/** use */
const storeInsignia = useInsigniaDataStore();
const mixin = useCounterMixin();
const {
date2Thai,
success,
messageError,
showLoader,
hideLoader,
dialogConfirm,
dialogRemove,
} = mixin;
/** use */
const $q = useQuasar(); // noti quasar
/** คอลัมน์ที่แสดง */
const visibleColumns = ref<string[]>([
"period_name",
"period_year",
"period_start",
"period_end",
"statusRoyal",
]);
/** คอลัมน์ */
const columns = ref<QTableProps["columns"]>([
{
name: "period_name",
align: "left",
label: "รอบการเสนอขอพระราชทานเครื่องราชฯ",
sortable: true,
field: "period_name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "period_year",
align: "left",
label: "ปีที่เสนอ",
sortable: true,
field: "period_year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "period_start",
align: "left",
label: "วันที่เริ่มต้น",
sortable: true,
field: "period_start",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "period_end",
align: "left",
label: "วันที่สิ้นสุด",
sortable: true,
field: "period_end",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "statusRoyal",
align: "left",
label: "สถานะ",
sortable: false,
field: "statusRoyal",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
/** ข้อมูลตาราง (จำลอง)*/
const rows = ref<FormProprsalsRound2[]>([]);
/** Function เรียกรายการรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์ */
async function fetchData() {
showLoader();
await http
.get(config.API.listRoundInsignia())
.then((res) => {
const data = res.data.result;
rows.value = data.map((e: FormProprsalsRound2) => ({
period_id: e.period_id,
period_name: e.period_name,
period_year: e.period_year + 543,
period_amount: e.period_amount,
period_start:
e.period_start == null ? null : date2Thai(new Date(e.period_start)),
period_end:
e.period_end == null ? null : date2Thai(new Date(e.period_end)),
period_isActive: e.period_isActive,
period_doc: e.period_doc,
period_status: e.period_status,
statusRoyal: storeInsignia.convertStatus(e.period_status),
}));
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* Function นยนการลบรอบการเสนอขอ
* @param id รอบการเสนขอ
*/
function clickDelete(id: string) {
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.RoundInsignia(id))
.then(async () => {
await fetchData();
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
}
/** Fnction คำนวณรายชื่อผู้ได้รับเครื่องราช */
// async function clickListInsignia(propsId: string) {
// dialogConfirm(
// $q,
// async () => {
// await getRequest(propsId);
// },
// "",
// "?"
// );
// }
/** Fnction เรียกจาก API ข้อมูลผู้ได้รับเครื่องราชฯ */
// async function getRequest(id: string) {
// showLoader();
// await http
// .get(config.API.requestInsignia(id))
// .then(() => {
// success($q, "");
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(async () => {
// await fetchData();
// });
// }
/** ค้นหาในตาราง */
const filterKeyword = ref<string>("");
const filterRef = ref<HTMLInputElement | null>(null);
const resetFilter = () => {
filterKeyword.value = "";
if (filterRef.value) {
filterRef.value.focus();
}
};
const attrs = ref<any>(useAttrs());
const pagination = ref({
descending: false,
page: 1,
rowsPerPage: 10,
});
/** Hook */
onMounted(async () => {
await fetchData();
});
const modalForm = ref<boolean>(false);
const actionType = ref<string>("");
const roundId = ref<string>("");
function onOpenFormDetail(action: string = "", id: string = "") {
modalForm.value = true;
actionType.value = action;
roundId.value = id;
}
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายการรอบการเสนอขอพระราชทานเครองราชอสรยาภรณ
</div>
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
<div class="row q-col-gutter-sm">
<div class="row col-12 q-col-gutter-sm">
<div>
<q-btn
v-if="checkPermission($route)?.attrIsCreate"
@click="onOpenFormDetail()"
flat
round
color="add"
icon="mdi-plus"
>
<q-tooltip>เพมรายการรอบการเสนอขอ</q-tooltip>
</q-btn>
</div>
<q-space />
<q-input
class="col-xs-12 col-sm-3 col-md-2"
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filterKeyword == ''" name="search" />
<q-icon
v-if="filterKeyword !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
class="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<div class="col-12">
<d-table
ref="table"
:columns="columns"
:rows="rows"
:filter="filterKeyword"
row-key="Order"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td auto-width>
<!-- <q-btn
dense
flat
round
color="primary"
@click="clickListInsignia(props.row.period_id)"
icon="mdi-account-check"
>
<q-tooltip>ไดบเครองราชฯ</q-tooltip>
</q-btn> -->
<q-btn
v-if="checkPermission($route)?.attrIsGet"
dense
flat
round
color="info"
@click="onOpenFormDetail('view', props.row.period_id)"
icon="mdi-eye"
>
<q-tooltip>รายละเอยด</q-tooltip>
</q-btn>
<q-btn
v-if="
checkPermission($route)?.attrIsGet &&
checkPermission($route)?.attrIsUpdate &&
props.row.period_status !== 'DONE'
"
dense
flat
round
color="edit"
@click="onOpenFormDetail('edit', props.row.period_id)"
icon="edit"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
v-if="
checkPermission($route)?.attrIsDelete &&
props.row.period_status !== 'DONE'
"
dense
flat
round
color="red"
@click="clickDelete(props.row.period_id)"
icon="mdi-delete"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.id">
<div>
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
v-if="
props.row.period_doc !== null &&
checkPermission($route)?.attrIsGet
"
dense
type="a"
flat
target="_blank"
round
color="light-blue-8"
icon="mdi-file-download"
:href="props.row.period_doc"
>
<q-tooltip>ดาวนโหลดเอกสารประกอบ </q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</div>
</q-card>
<DialogDetail
v-model:modal="modalForm"
:actionType="actionType"
:roundId="roundId"
:fetchList="fetchData"
/>
</template>
<style lang="scss" scope>
.filter-card {
background-color: #f1f1f1b0;
}
.toggle-expired-account {
font-size: 12px;
font-weight: 400;
font-size: 15px;
line-height: 150%;
color: #35373c;
}
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -1,13 +1,14 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import DialogHeader from "@/components/DialogHeader.vue";
import type { OptionPeriod } from "@/modules/07_insignia/interface/index/Main";
/** import Store*/
import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/components/DialogHeader.vue";
/** use*/
const $q = useQuasar();
@ -31,6 +32,7 @@ const props = defineProps({
fetchList: { type: Function, required: true },
});
// popup
const title = computed(() => {
return actionType.value === "view"
? "รายละเอียดรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์"
@ -38,24 +40,25 @@ const title = computed(() => {
? "แก้ไขข้อมูล"
: "เพิ่มรอบการเสนอขอพระราชทานเครื่องราชอิสริยาภรณ์";
});
//
const readonly = computed(() => {
return actionType.value === "view" ? true : false;
});
const options = ref([
const roundInsig = ref<any>(); //
const yearly = ref<number>(new Date().getFullYear()); //
const dateStart = ref<Date | null>(null); //
const dateEnd = ref<Date | null>(null); //
const datelast = ref<number | null>(null); //
const files = ref<any>(); //
const fileDocDataUpload = ref<File[]>([]); //
//
const options = ref<OptionPeriod[]>([
{ label: "รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ 1", value: 1 },
{ label: "รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ 2", value: 2 },
]);
const roundInsig = ref<any>();
const yearly = ref<number>(new Date().getFullYear());
const dateStart = ref<Date | null>(null);
const dateEnd = ref<Date | null>(null);
const datelast = ref<number | null>(null);
const files = ref<any>();
const fileDocDataUpload = ref<File[]>([]);
/**
* Function เรยกขอมลของรอบการเสนอขอ
*/
@ -63,12 +66,14 @@ function fetchData() {
showLoader();
http
.get(config.API.getRoundInsignia(roundId.value))
.then((res) => {
const data = res.data.result;
.then(async (res) => {
const data = await res.data.result;
roundInsig.value =
options.value.filter((r: any) => r.value == data.period_round).length >
0
? options.value.filter((r: any) => r.value == data.period_round)[0]
options.value.filter((r: OptionPeriod) => r.value == data.period_round)
.length > 0
? options.value.filter(
(r: OptionPeriod) => r.value == data.period_round
)[0]
: null;
yearly.value = data.period_year;
datelast.value = data.period_amount;
@ -83,7 +88,9 @@ function fetchData() {
});
}
/** Function อัพเดทวันที่เริ่มต้น และ สิ้นสุด */
/**
* Function พเดทวนทเรมต และ นส
*/
function updateDateRange() {
if (roundInsig.value.value == 1) {
dateStart.value = new Date(yearly.value, 9, 1);
@ -117,7 +124,7 @@ function fileUploadDoc(files: any) {
* Function นทกขอม
*/
function onSubmit() {
dialogConfirm($q, () => {
dialogConfirm($q, async () => {
showLoader();
const formData = new FormData();
const name = `รอบการเสนอขอพระราชทานเครื่องราชฯ รอบที่ ${
@ -156,6 +163,11 @@ function onSubmit() {
});
}
/**
* function popup รอบการเสนอขอพระราชทานเครองราชอสรยาภรณ
*
* และกำหนดตวแปรเปนค Defult
*/
function onCloseDialog() {
modal.value = false;
roundInsig.value = "";
@ -167,6 +179,23 @@ function onCloseDialog() {
fileDocDataUpload.value = [];
}
/**
* function นคาชอคลาสตามคาทกำหนด
* @param val ากำหนดวาจะแสดงคลาสไหน
* @returns อคลาส
*/
function classInput(val: boolean) {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
}
/**
* ทำงานเม modal เป true actionType เป view
*
*
*/
watch(
() => modal.value,
() => {
@ -177,13 +206,6 @@ watch(
}
}
);
const classInput = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script>
<template>

View file

@ -1,13 +1,18 @@
<script setup lang="ts">
import { onMounted, ref, computed, reactive, watch } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useQuasar, QForm } from "quasar";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRouter } from "vue-router";
/** import Type*/
import type { QTableProps } from "quasar";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
import type { CheckboxData } from "@/modules/07_insignia/interface/request/Main";
/** import components*/
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue";
@ -16,11 +21,9 @@ import DialogHeader from "@/components/DialogHeader.vue";
import btnDownloadFile from "@/modules/07_insignia/components/2_Manage/downloadFile.vue";
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
/** import Stores*/
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
import { useCounterMixin } from "@/stores/mixin";
/**user stores*/
/**use*/
const myForm = ref<QForm>();
const $q = useQuasar();
const DataStore = useInsigniaDataStore();
const roleDataStore = useroleUserDataStore();
const mixin = useCounterMixin();
@ -33,31 +36,54 @@ const {
dialogMessageNotify,
} = mixin;
const myForm = ref<QForm>();
const router = useRouter();
const $q = useQuasar();
/**
* props
*/
const props = defineProps({
tab: {
type: String,
},
roundId: {
type: String,
},
fecthInsigniaAll: {
type: Function,
},
fecthInsigniaByOc: {
type: Function,
},
roundName: {
type: String,
},
requestStatus: {
type: String,
},
fecthStat: {
type: Function,
},
});
const modelPopupReject = ref<boolean>(false);
const modelPopupDelete = ref<boolean>(false);
const modalAdd = ref<boolean>(false);
const modalEdit = ref<boolean>(false);
const rowid = ref<string>("");
const organization = ref<string>("");
const modelPopupReject = ref<boolean>(false); //popup
const modelPopupDelete = ref<boolean>(false); // popup
const modalAdd = ref<boolean>(false); //popup
const modalEdit = ref<boolean>(false); //popup
const modalPersonal = ref<boolean>(false); //popup
const rowid = ref<string>(""); // id
const organization = ref<string>(""); //
/** หมายเหตุ*/
const dialogNote = ref<boolean>(false);
const dialogTitle = ref<string>("");
const dialogDesc = ref<string>("");
const typeinsigniaOptions = ref<any>(DataStore.typeinsigniaOptions);
const employeeClassOps = ref<any>(DataStore.employeeClassOps);
const modalPersonal = ref<boolean>(false);
const dialogNote = ref<boolean>(false); //
const dialogTitle = ref<string>(""); // popup
const dialogDesc = ref<string>(""); //
const typeinsigniaOptions = ref<OptionData[]>(DataStore.typeinsigniaOptions); //
const employeeClassOps = ref<OptionData[]>(DataStore.employeeClassOps); //
/**แจ้งเตือน*/
const dialogWarn = ref<boolean>(false);
const checkboxData = ref<any>([]);
const checkboxData = ref<CheckboxData[]>([]);
const organizationOptions = ref<any>([{ id: "1", name: "ทั้งหมด" }]);
const filterOrganizationOP = ref<any>([]);
const organizationOptions = ref<OptionData[]>([{ id: "1", name: "ทั้งหมด" }]);
const filterOrganizationOP = ref<OptionData[]>([]);
/** หัวตาราง*/
const visibleColumns = ref<string[]>([
@ -224,33 +250,9 @@ const columns2 = ref<QTableProps["columns"]>([
},
]);
const rows2 = ref<any[]>([]);
const rows2 = ref<any[]>([]); //
const person = ref<any>([]);
const props = defineProps({
tab: {
type: String,
},
roundId: {
type: String,
},
fecthInsigniaAll: {
type: Function,
},
fecthInsigniaByOc: {
type: Function,
},
roundName: {
type: String,
},
requestStatus: {
type: String,
},
fecthStat: {
type: Function,
},
});
/** เช็คสถานนะแสดงปุ่มเพิ่ม*/
const checkStatus = computed(() => {
if (
@ -328,6 +330,7 @@ async function fecthlistperson(id: string = "") {
organizationOrganization: e.root,
}));
modalAdd.value = true;
rows2.value = data;
})
.catch((err) => {
@ -419,7 +422,7 @@ async function clickmodalEdit(props: any) {
* @param response response
* @param filename อไฟล
*/
function downloadFile(response: any, filename: string) {
async function downloadFile(response: any, filename: string) {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
@ -476,27 +479,27 @@ async function clickSave() {
* @param profileId
*/
async function listEdit(profileId: string) {
showLoader();
let data: any = {
insigniaId: insignia.value,
};
await http
.put(config.API.insigniaEdit(profileId), data)
.then(() => {
.then(async () => {
await props?.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ");
modalEdit.value = false;
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
modalEdit.value = false;
if (props.fecthInsigniaByOc) {
await props.fecthInsigniaByOc(
props.roundId,
organization.value,
"officer",
props.tab
);
}
.finally(() => {
hideLoader();
});
}
@ -528,24 +531,25 @@ async function savaReasonReject(reason: string) {
* @param reason หมายเหต
*/
async function listreject(profileId: string, reason: string) {
showLoader();
await http
.put(config.API.insigniaReject(profileId), { reason: reason })
.then(() => {
.then(async () => {
await props?.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
success($q, "ย้ายข้อมูลสำเร็จ");
modelPopupReject.value = false;
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
if (props.fecthInsigniaByOc) {
await props.fecthInsigniaByOc(
props.roundId,
organization.value,
"officer",
props.tab
);
}
modelPopupReject.value = await false;
.finally(() => {
hideLoader();
});
}
@ -584,24 +588,24 @@ async function savaReasonDelete(reason: string) {
* @param reason หมายเหต
*/
async function listdelete(id: string, reason: string) {
showLoader();
await http
.put(config.API.insigniaDelete(id), { reason: reason })
.then(() => {
.then(async () => {
await props?.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
success($q, "ลบข้อมูลสำเร็จ");
closemodelPopupDelete();
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
if (props.fecthInsigniaByOc) {
await props.fecthInsigniaByOc(
props.roundId,
organization.value,
"officer",
props.tab
);
}
await closemodelPopupDelete();
hideLoader();
});
}
const dataPerson = reactive({
@ -640,7 +644,7 @@ function clearForm() {
}
const insignia = ref<string>("");
const insigniaOptions = ref<any[]>([]);
const insigniaOptions = ref<OptionData[]>([]);
const insigniaType = ref<string>("");
/** function เรียกประเภทเครื่องราช*/
@ -660,8 +664,6 @@ async function fecthInsignia() {
});
}
function onclickViewinfo(id: string) {}
const personId = ref<string>("");
/**
* function redirect to ทะเบยนประว
@ -670,7 +672,6 @@ const personId = ref<string>("");
function nextPage(id: string) {
modalPersonal.value = true;
personId.value = id;
// router.push(`/registry-officer/${id}`);
}
function updatemodalPersonal(modal: boolean) {
@ -753,22 +754,22 @@ function clickShowWarn(
* @param update function
* @param name selec
*/
function filterSelector(val: any, update: Function, name: any) {
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "typeinsigniaOptions") {
DataStore.typeinsignia = "";
typeinsigniaOptions.value = DataStore.typeinsigniaOptions.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "employeeClassOps") {
DataStore.employeeClass = "";
employeeClassOps.value = DataStore.employeeClassOps.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterOrganizationOP") {
filterOrganizationOP.value = organizationOptions.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
@ -831,7 +832,7 @@ onMounted(async () => {
:hide-dropdown-icon="false"
style="width: 400px"
@update:model-value="changtypeOc"
@filter="(inputValue: any,
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'filterOrganizationOP'
)"
/>
@ -900,7 +901,7 @@ onMounted(async () => {
DataStore.employeeClass
)
"
@filter="(inputValue: any,
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'typeinsigniaOptions'
)"
>
@ -945,7 +946,7 @@ onMounted(async () => {
DataStore.employeeClass
)
"
@filter="(inputValue: any,
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'employeeClassOps'
)"
>

View file

@ -1,24 +1,21 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { checkPermission } from "@/utils/permissions";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
/** import Type*/
import type { QTableProps } from "quasar";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
/** import components*/
import DialogInformation from "@/components/Dialogs/Information.vue";
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
/** import Stores */
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
/** useStore*/
const roleDataStore = useroleUserDataStore();
const DataStore = useInsigniaDataStore();
const router = useRouter();
const props = defineProps({
tab: {
type: String,
@ -35,10 +32,10 @@ const props = defineProps({
});
const organization = ref<string>("1");
const organizationOptions = ref<any>([{ id: "1", name: "ทั้งหมด" }]);
const filterOrganizationOP = ref<any>([]);
const typeinsigniaOptions = ref<any>(DataStore.typeinsigniaOptions);
const employeeClassOps = ref<any>(DataStore.employeeClassOps);
const organizationOptions = ref<OptionData[]>([{ id: "1", name: "ทั้งหมด" }]);
const filterOrganizationOP = ref<OptionData[]>([]); //
const typeinsigniaOptions = ref<OptionData[]>(DataStore.typeinsigniaOptions); //
const employeeClassOps = ref<OptionData[]>(DataStore.employeeClassOps); //
/** หัวตาราง*/
const columns = ref<QTableProps["columns"]>([
@ -179,7 +176,6 @@ const personId = ref<string>("");
function nextPage(id: string) {
modalPersonal.value = true;
personId.value = id;
// router.push(`/registry-officer/${id}`);
}
function updatemodalPersonal(modal: boolean) {
@ -226,22 +222,22 @@ function closeReson() {
* @param update funtion
* @param name selec
*/
function filterSelector(val: any, update: Function, name: any) {
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "typeinsigniaOptions") {
DataStore.typeinsignia = "";
typeinsigniaOptions.value = DataStore.typeinsigniaOptions.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "employeeClassOps") {
DataStore.employeeClass = "";
employeeClassOps.value = DataStore.employeeClassOps.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterOrganizationOP") {
filterOrganizationOP.value = organizationOptions.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
@ -302,7 +298,7 @@ onMounted(async () => {
:hide-dropdown-icon="false"
style="width: 400px"
@update:model-value="changtypeOc"
@filter="(inputValue:any,
@filter="(inputValue: string,
doneFn:Function) => filterSelector(inputValue, doneFn,'filterOrganizationOP'
) "
/>
@ -370,7 +366,7 @@ onMounted(async () => {
DataStore.employeeClass
)
"
@filter="(inputValue:any,
@filter="(inputValue: string,
doneFn:Function) => filterSelector(inputValue, doneFn,'typeinsigniaOptions'
) "
>
@ -415,7 +411,7 @@ onMounted(async () => {
DataStore.employeeClass
)
"
@filter="(inputValue:any,
@filter="(inputValue: string,
doneFn:Function) => filterSelector(inputValue, doneFn,'employeeClassOps'
) "
>

View file

@ -1,25 +1,21 @@
<script setup lang="ts">
import { onMounted, ref, watch, reactive } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { onMounted, ref } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
/** import Type*/
import type { QTableProps } from "quasar";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
/** import components*/
import DialogInformation from "@/components/Dialogs/Information.vue";
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
/** import Stores */
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
/** useStore*/
const DataStore = useInsigniaDataStore();
const roleDataStore = useroleUserDataStore();
const { adminRole } = roleDataStore;
const router = useRouter();
const props = defineProps({
tab: {
@ -35,11 +31,12 @@ const props = defineProps({
type: Function,
},
});
const typeinsigniaOptions = ref<any>(DataStore.typeinsigniaOptions);
const employeeClassOps = ref<any>(DataStore.employeeClassOps);
const filterOrganizationOP = ref<any>([]);
const typeinsigniaOptions = ref<OptionData[]>(DataStore.typeinsigniaOptions); //
const employeeClassOps = ref<OptionData[]>(DataStore.employeeClassOps); //
const filterOrganizationOP = ref<OptionData[]>([]); // //
const organization = ref<string>("1");
const organizationOptions = ref<any>([{ id: "1", name: "ทั้งหมด" }]);
const organizationOptions = ref<OptionData[]>([{ id: "1", name: "ทั้งหมด" }]);
/** หัวตาราง*/
const columns = ref<QTableProps["columns"]>([
@ -179,7 +176,6 @@ const personId = ref<string>("");
function nextPage(id: string) {
modalPersonal.value = true;
personId.value = id;
// router.push(`/registry-officer/${id}`);
}
function updatemodalPersonal(modal: boolean) {
@ -204,6 +200,7 @@ const pagination = ref({
const dialogNote = ref<boolean>(false);
const note = ref<string>("");
const noteTitle = ref<string>("");
/**
* function openPopup แสดง หมายเหต
* @param row รายละเอยดขอม
@ -225,22 +222,22 @@ function closeReson() {
* @param update funtion
* @param name selec
*/
function filterSelector(val: any, update: Function, name: any) {
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "typeinsigniaOptions") {
DataStore.typeinsignia = "";
typeinsigniaOptions.value = DataStore.typeinsigniaOptions.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "employeeClassOps") {
DataStore.employeeClass = "";
employeeClassOps.value = DataStore.employeeClassOps.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterOrganizationOP") {
filterOrganizationOP.value = organizationOptions.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
@ -301,7 +298,7 @@ onMounted(async () => {
:hide-dropdown-icon="false"
style="width: 400px"
@update:model-value="changtypeOc"
@filter="(inputValue:any,
@filter="(inputValue: string,
doneFn:Function) => filterSelector(inputValue, doneFn,'filterOrganizationOP'
) "
/>
@ -369,7 +366,7 @@ onMounted(async () => {
DataStore.employeeClass
)
"
@filter="(inputValue:any,
@filter="(inputValue: string,
doneFn:Function) => filterSelector(inputValue, doneFn,'typeinsigniaOptions'
) "
>
@ -414,7 +411,7 @@ onMounted(async () => {
DataStore.employeeClass
)
"
@filter="(inputValue:any,
@filter="(inputValue: string,
doneFn:Function) => filterSelector(inputValue, doneFn,'employeeClassOps'
) "
>

View file

@ -1,22 +1,25 @@
<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
/** import Type*/
import type { QTableProps } from "quasar";
import type { ResponseNoSend } from "@/modules/07_insignia/interface/response/Main";
/** import Stores */
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useCounterMixin } from "@/stores/mixin";
/** useStore*/
/** use*/
const $q = useQuasar();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError } = mixin;
const DataStore = useInsigniaDataStore();
const $q = useQuasar();
/**
* props
*/
const props = defineProps({
roundId: {
type: String,
@ -27,7 +30,7 @@ const props = defineProps({
});
/** ข้อมูลตาราง*/
const rows = ref<any[]>([]);
const rows = ref<ResponseNoSend[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -63,7 +66,7 @@ async function fecthOrg() {
.get(config.API.insigniaNosend(props.roundId))
.then((res) => {
let data = res.data.result;
rows.value = data.map((e: any) => ({
rows.value = data.map((e: ResponseNoSend) => ({
orgId: e.orgId,
orgName: e.orgName,
}));

View file

@ -1,19 +1,18 @@
<script setup lang="ts">
import { ref } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
import type { Optionround } from "@/modules/07_insignia/interface/index/Main";
/**import Stores */
import { useCounterMixin } from "@/stores/mixin";
/** use Store*/
/** use*/
const $q = useQuasar();
const mixin = useCounterMixin();
const { messageError, showLoader, hideLoader } = mixin;
const $q = useQuasar();
/** props*/
const props = defineProps({
profileId: {
@ -27,7 +26,7 @@ const props = defineProps({
},
});
const titleReport = ref<string>("");
const titleReport = ref<string>(""); //
/**
* function ดาวนโหลดไฟล
@ -63,6 +62,11 @@ async function downloadDocument(type: string) {
}
}
/**
* function โหลดเอกสาร
* @param response อม
* @param filename อไฟล
*/
function downloadFile(response: any, filename: string) {
const link = document.createElement("a");
var fileName = filename;

View file

@ -1,765 +0,0 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
import http from "@/plugins/http";
import config from "@/app.config";
/**import Componrnts*/
import cardTop from "@/modules/07_insignia/components/2_Manage/StatCard.vue"; // stat
import tab1 from "@/modules/07_insignia/components/2_Manage/Tab1.vue"; //
import tab2 from "@/modules/07_insignia/components/2_Manage/Tab2.vue"; //
import tab3 from "@/modules/07_insignia/components/2_Manage/Tab3.vue"; //
import tab4 from "@/modules/07_insignia/components/2_Manage/Tab4.vue"; //
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue"; //
/**import stoer */
import { useCounterMixin } from "@/stores/mixin";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useroleUserDataStore } from "@/stores/roleUser";
import { useRoute } from "vue-router";
/**use */
const $q = useQuasar(); // noti quasar
const roleDataStore = useroleUserDataStore();
const DataStore = useInsigniaDataStore();
const mixin = useCounterMixin();
const { messageError, dialogConfirm, showLoader, hideLoader, success } = mixin;
const route = useRoute();
/**
* วแปร
*/
const loading = ref<boolean>(false);
const loadview = ref<boolean>(false);
const hideBottom = ref<boolean>(false);
const round = ref<string>("");
const roundName = ref<string>("");
const optionRound = ref<any>([]);
const optiontypeOc = ref<any>([]);
const tab = ref<any>("");
const stat = ref<any>({
allUserUser: 0,
orgAllCount: 0,
orgNoSendCount: 0,
orgSendCount: 0,
});
const requestNote = ref<string>("");
const requestStatus = ref<string>("");
const requestId = ref<string>("");
const document = ref<string>("");
const fileUpload = ref<any>(null);
const modalPopupBackToEdit = ref<boolean>(false); //model
const modalbackInsignia2Role = ref<boolean>(false);
/**
* function เรยกรอบการเสนอขอพระราชทานเครอง
*/
function fecthlistRound() {
http
.get(config.API.listRoundInsignia())
.then(async (res: any) => {
optionRound.value = res.data.result.map((e: any) => ({
id: e.period_id,
year: e.period_year,
name: e.period_name,
}));
// UI
if (optionRound.value.length !== 0) {
DataStore.optionRound = optionRound.value;
const lastValue = optionRound.value[0];
if (DataStore.roundId) {
round.value = DataStore.roundId; //
} else {
round.value = lastValue.id.toString(); //
}
DataStore.roundId = round.value;
roundName.value = lastValue.name;
await fecthStat(round.value);
} else {
loadview.value = false;
loading.value = false;
}
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function เรยกด Stat ของรอบการเสนอขอพระราชทานเครอง
*/
function fecthStat(id: string) {
http
.get(config.API.insigniaDashboard(id))
.then((res) => {
stat.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
}
/**
* funcion เชคหนวยงาน
*/
function fecthAgency() {
http
.get(config.API.keycloakPosition())
.then((res) => {
loadview.value = true;
DataStore.agency = res.data.result.rootId;
DataStore.typeOc = DataStore.agency;
loading.value = true;
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function fetch โครองสรางปจจ
*/
function fetchActiveId() {
http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
fetchListOrg(data.activeId);
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function fetch อมลโครองสรางปจจ
* @param id โครงสรางปจจ
*/
function fetchListOrg(id: string) {
showLoader();
http
.get(config.API.orgByIdSystem(id, route.meta.Key as string))
.then(async (res) => {
const data = await res.data.result.map((item: any) => ({
id: item.orgTreeId,
name: item.orgName,
}));
optiontypeOc.value = data;
DataStore.fetchOption(optiontypeOc.value); // DataStore
await fecthAgency();
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/**
* function เรยกประเภทเครองราช
*/
function fecthInsignia() {
http
.get(config.API.insigniaOrg)
.then((res) => {
const data = res.data.result;
DataStore.fetchInsigniaType(data);
})
.catch((err) => {
messageError($q, err);
});
}
/**
* function เปลยนรอบการแสดง
*/
async function changround() {
DataStore.roundId = round.value;
fecthStat(round.value); // Stat
var organization = await (DataStore.agency != null // agency agency Oc
? DataStore.agency
: DataStore.typeOc);
fecthInsigniaByOc(round.value, organization, "officer", tab.value); //
// get round name
const roundFilter = await optionRound.value.find(
(x: any) => round.value === x.id
);
roundName.value = `รอบการเสนอขอพระราชทานเครื่องราชฯ ปี ${
roundFilter.year + 543
}`;
}
/**
* function เรยกขอมลรายชอขาราชการสามญฯ ทธนขอพระราชทานเครองราชอสรยาภรณ ตามรอบการเสนอขอ
* @param roundId id รอบการเสนอขอ
* @param ocId id หนวยงาน
* @param role ประเภท officer,employee
* @param status สถานะ
*/
function fecthInsigniaByOc(
roundId: string,
ocId: string,
role: string,
status: string
) {
if (roundId && ocId && role && status) {
showLoader();
http
.get(config.API.insigniaList(roundId, ocId, role, status))
.then(async (res) => {
requestNote.value = res.data.result.requestNote;
requestStatus.value = res.data.result.requestStatus;
requestId.value = res.data.result.requestId;
document.value = res.data.result.document;
await DataStore.fetchData(res.data.result.items); //
await DataStore.fetchDataInsignia(res.data.result); //
loading.value = true;
//
if (res.data.result.items !== null) {
if (res.data.result.items.length !== 0) {
hideBottom.value = true;
} else hideBottom.value = false;
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
}
/**
* function นยนการสงรอบการเสนอขอต เฉพาะ รอบท requestStatus st1 และ st4
*/
function sendToDirector() {
dialogConfirm($q, () => {
showLoader();
http
.get(config.API.insigniaSendToDirector(round.value, DataStore.agency))
.then(async () => {
await fecthStat(round.value);
await fecthInsigniaByOc(
round.value,
DataStore.agency,
"officer",
tab.value
);
await success($q, "บันทึกสำเร็จ");
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
});
}
/**
* function open popup แกไข*
*/
function popupBackToEdit() {
modalPopupBackToEdit.value = true;
}
/**
* function open popup กล admin
*/
function popupBackToInsignia2Role() {
modalbackInsignia2Role.value = true;
}
/**
* funtion นยนการ กลบรอบการเสนอขอ เฉพาะ รอบท requestStatus st3 และ insignia2Role
* @param reason หมายเหตการตกล
*/
function backToEdit(reason: string) {
dialogConfirm(
$q,
() => {
showLoader();
http
.put(
config.API.insigniaDirectorBackToEdit(round.value, DataStore.agency),
{
reason: reason,
}
)
.then(async () => {
await fecthInsigniaByOc(
round.value,
DataStore.agency,
"officer",
tab.value
);
modalPopupBackToEdit.value = await false;
await success($q, "บันทึกสำเร็จ");
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
},
"ยืนยันการตีกลับ",
"ต้องการยืนยันการตีกลับใช่หรือไม่?"
);
}
/**
* function นยนการอนรอบการเสนอขอ เฉพาะ รอบท requestStatus st3 และ insignia2Role
*/
function directorApproved() {
dialogConfirm(
$q,
() => {
showLoader();
http
.get(config.API.insigniaDirectorApproved(round.value, DataStore.agency))
.then(async () => {
await fecthInsigniaByOc(
round.value,
DataStore.agency,
"officer",
tab.value
);
await fecthStat(round.value);
await success($q, "บันทึกสำเร็จ");
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
},
"ยืนยันการอนุมัติ",
"ต้องการยืนยันการอนุมัติใช่หรือไม่?"
);
}
/**
* function นยนการตกลบรอบการเสนอขอ เฉพาะ รอบท requestStatus st5 และ adminRole
* @param reason หมายเหตการตกล
*/
function backToEditinsignia2Role(reason: string) {
dialogConfirm($q, () => {
http
.put(config.API.rejectRequest(round.value, DataStore.typeOc), {
reason: reason,
})
.then(async () => {
await fecthInsigniaByOc(
round.value,
DataStore.typeOc,
"officer",
tab.value
);
modalbackInsignia2Role.value = await false;
await success($q, "การตีกลับสำเร็จ");
})
.catch((err) => {
messageError($q, err);
});
});
}
/**
* function นยนการลอกขอม
*/
function requestSendNote() {
dialogConfirm($q, () => {
showLoader();
http
.post(config.API.insigniaRequestSendNote(round.value), {
name: roundName.value,
})
.then(async () => {
await fecthInsigniaByOc(
round.value,
DataStore.typeOc,
"officer",
tab.value
);
await fecthStat(round.value);
await success($q, "บันทึกสำเร็จ");
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
});
}
/**
* function ปโหลดไฟลเจาหนาท
* @param event file
*/
async function uploadFile(event: any) {
dialogConfirm($q, async () => {
const selectedFile = event;
const formdata = new FormData();
formdata.append("Document", selectedFile);
await http
.put(config.API.uploadfileOnlyInsignia(requestId.value), formdata)
.then(async () => {
await fecthInsigniaByOc(
round.value,
DataStore.agency,
"officer",
tab.value
);
success($q, "อัปโหลดไฟล์สำเร็จ");
fileUpload.value = null;
})
.catch((err) => {
messageError($q, err);
}),
"ยืนยันการอัปโหลดไฟล์",
"ต้องการยืนยันการอัปโหลดไฟล์นี้หรือไม่ ?";
});
}
/**
* hook
*/
onMounted(async () => {
tab.value = DataStore.mainTab;
DataStore.dataInsigniaType.length === 0 && (await fecthInsignia());
fecthlistRound();
fetchActiveId();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายชอขาราชการสามญฯ ทธนขอพระราชทานเครองราชอสรยาภรณ
</div>
<q-card bordered class="row col-12 q-mt-sm" v-if="loadview">
<div class="row col-12 items-center bg-grey-1">
<div class="q-pl-md q-pr-sm text-weight-medium text-grey-7">รอบ</div>
<q-select
borderless
dense
v-model="round"
:options="optionRound"
map-options
emit-value
option-value="id"
option-label="name"
@update:model-value="changround"
/>
<q-space />
<!-- สกจ. Freez อม -->
<q-btn
v-if="
roleDataStore.adminRole &&
DataStore.isLock !== true &&
hideBottom &&
checkPermission($route)?.attrIsUpdate
"
dense
unelevated
label="ล็อกข้อมูล"
color="public"
class="q-px-md q-ml-md"
@click="requestSendNote"
>
<q-tooltip>อกขอม</q-tooltip>
</q-btn>
</div>
<div class="col-12"><q-separator /></div>
<div v-if="roleDataStore.adminRole" class="col-12 row bg-white">
<div class="fit q-px-md q-py-sm">
<div class="row col-12 q-col-gutter-sm fit">
<!-- stat -->
<cardTop
:amount="stat.orgAllCount"
label="หน่วยงานทั้งหมด"
color="#016987"
/>
<cardTop
:amount="stat.orgSendCount"
label="หน่วยงานที่ส่งรายชื่อเเล้ว"
color="#02A998"
/>
<cardTop
:amount="stat.orgNoSendCount"
label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ"
color="#2EA0FF"
/>
<cardTop
:amount="stat.allUserUser"
label="จำนวนคนที่ยื่นขอ"
color="#4154B3"
/>
</div>
</div>
</div>
</q-card>
<q-card v-else>
<div class="q-pa-md q-gutter-sm">
<q-banner inline-actions rounded class="bg-grey-1 text-center">
ไมอมลรอบการเสนอขอพระราชทานเครองราชอสรยาภรณ
</q-banner>
</div>
</q-card>
<q-card flat bordered class="col-12 q-mt-sm" v-if="loading">
<div
v-if="
(roleDataStore.insignia1Role && requestStatus == 'st4') ||
(roleDataStore.insignia2Role && requestStatus == 'st5')
"
class="q-pa-md q-gutter-sm"
>
<q-banner
inline-actions
bordered
class="bg-orange-1 text-orange border-orange"
>
<q-icon name="mdi-information-outline" size="20px" /> หมายเหต กล
{{ requestNote }}
</q-banner>
</div>
<div class="row col-12">
<q-tabs
v-model="tab"
dense
class="text-grey"
active-color="primary"
active-class="bg-teal-1"
indicator-color="primary"
align="left"
>
<q-tab name="pending" label="คนที่ยื่นขอ" />
<q-tab name="reject" label="คนที่ไม่ยื่นขอ" />
<q-tab name="delete" label="คนที่ถูกลบออก" />
<q-tab
v-if="roleDataStore.adminRole"
name="organization"
label="หน่วยงานที่ยังไม่ได้ส่งรายชื่อ"
/>
</q-tabs>
</div>
<q-separator />
<q-tab-panels v-model="tab" animated>
<!-- แทบคนทนขอ -->
<q-tab-panel name="pending" class="q-pa-none">
<tab1
:tab="tab"
:roundId="round"
:roundName="roundName"
:fecthInsigniaByOc="fecthInsigniaByOc"
:request-status="requestStatus"
:fecthStat="fecthStat"
/>
</q-tab-panel>
<!-- แทบคนทไมนขอ -->
<q-tab-panel name="reject" class="q-pa-none">
<tab2
:tab="tab"
:roundId="round"
:fecthInsigniaByOc="fecthInsigniaByOc"
/>
</q-tab-panel>
<!-- แทบคนทกลบออก -->
<q-tab-panel name="delete" class="q-pa-none">
<tab3
:tab="tab"
:roundId="round"
:fecthInsigniaByOc="fecthInsigniaByOc"
/>
</q-tab-panel>
<!-- แทบหนวยงานทงไมไดงรายช -->
<q-tab-panel
v-if="roleDataStore.adminRole"
name="organization"
class="q-pa-none"
>
<tab4 :tab="tab" :roundId="round" />
</q-tab-panel>
</q-tab-panels>
<q-toolbar class="q-py-md text-right">
<q-file
v-if="
roleDataStore.insignia1Role && checkPermission($route)?.attrIsUpdate
"
bg-color="white"
clearable
outlined
dense
v-model="fileUpload"
accept=".pdf"
:style="fileUpload === null ? 'width: 150px' : 'width: auto'"
label="อัปโหลดไฟล์"
>
<template v-slot:prepend>
<q-icon color="light-blue" name="attach_file" />
<q-tooltip>ปโหลดไฟล</q-tooltip>
</template>
</q-file>
<q-btn
flat
round
color="light-blue"
icon="upload"
@click="uploadFile(fileUpload)"
v-if="fileUpload !== null"
/>
<div v-if="document">
<q-btn
size="md"
icon="mdi-download"
flat
round
color="primary"
v-if="
roleDataStore.insignia1Role && checkPermission($route)?.attrIsGet
"
:href="document"
target="_blank"
>
<q-tooltip>ดาวนโหลด</q-tooltip>
</q-btn>
<q-btn
v-else-if="checkPermission($route)?.attrIsGet"
color="primary"
icon-right="mdi-download"
label="ดาวน์โหลดไฟล์"
outline
:href="document"
target="_blank"
>
<q-tooltip>ดาวนโหลด</q-tooltip></q-btn
>
</div>
<q-space />
<q-btn
v-if="
roleDataStore.insignia1Role &&
(requestStatus == 'st1' || requestStatus == 'st4') &&
checkPermission($route)?.attrIsUpdate
"
dense
unelevated
label="บันทึกข้อมูล"
color="public"
class="q-px-md"
@click="sendToDirector"
/>
<q-btn
v-if="
roleDataStore.insignia2Role &&
(requestStatus == 'st3' || requestStatus == 'st5') &&
checkPermission($route)?.attrIsUpdate
"
dense
unelevated
label="ตีกลับ"
color="orange"
class="q-px-md"
@click="popupBackToEdit"
/>
<q-btn
v-if="
roleDataStore.insignia2Role &&
requestStatus == 'st3' &&
checkPermission($route)?.attrIsUpdate
"
dense
unelevated
label="อนุมัติ"
color="positive"
class="q-px-md q-ml-md"
@click="directorApproved"
/>
<q-btn
v-if="
requestStatus == 'st6' &&
roleDataStore.adminRole &&
!DataStore.isLock &&
checkPermission($route)?.attrIsUpdate
"
dense
unelevated
label="ตีกลับ"
color="orange"
class="q-px-md"
@click="popupBackToInsignia2Role"
/>
</q-toolbar>
<!-- popup หมายเหต -->
<DialogPopupReason
v-model:modal="modalPopupBackToEdit"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEdit"
/>
<DialogPopupReason
v-model:modal="modalbackInsignia2Role"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEditinsignia2Role"
/>
</q-card>
</template>
<style lang="scss" scope>
.border-orange {
border: 1px solid #ffa800;
border-radius: 5px;
}
.filter-card {
background-color: #f1f1f1b0;
}
.toggle-expired-account {
font-size: 12px;
font-weight: 400;
font-size: 15px;
line-height: 150%;
color: #35373c;
}
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -1,22 +1,25 @@
<script setup lang="ts">
import { onMounted, ref, watch } from "vue";
import { QForm, useQuasar } from "quasar";
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
/** import Type*/
import type { DataOption } from "@/modules/04_registry/components/profileType";
import type { DataStructureTree } from "@/interface/main";
/**
* import Components
*/
import DialogHeader from "../DialogHeader.vue";
import DialogHeader from "@/components/DialogHeader.vue";
/** import Stores */
import { useCounterMixin } from "@/stores/mixin";
import { useRoute } from "vue-router";
/** useStore*/
/** use*/
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const {
date2Thai,
@ -28,23 +31,9 @@ const {
dateToISO,
} = mixin;
const route = useRoute();
const $q = useQuasar();
const myForm = ref<any>();
const files = ref<any>();
const filesReturn = ref<any>();
const OrganazationId = ref<string>("");
const OrganazationId2 = ref<string>("");
const OrgList = ref<DataOption[]>([]);
const OrgList2 = ref<DataOption[]>([]);
const Datereceive = ref<Date | null>();
const Datereturn = ref<Date | null>();
const remark = ref<string>("");
const nullii = ref<any>(null);
const filesCheck = ref<string>("");
const filesReturnCheck = ref<string>("");
/**
* props
*/
const props = defineProps({
modal: Boolean,
personId: String,
@ -52,16 +41,31 @@ const props = defineProps({
fecthlistInsignia: Function,
dateCheckReceive: String,
dateCheckReturn: String,
dataModal: Object,
});
/** function clearDate */
const files = ref<any>(); //
const filesReturn = ref<any>(); //
const OrganazationId = ref<string>(""); //id
const OrganazationId2 = ref<string>(""); //id
const OrgList = ref<DataOption[]>([]); //
const OrgList2 = ref<DataOption[]>([]); ////
const Datereceive = ref<Date | null>(); //
const Datereturn = ref<Date | null>(); //
const nullii = ref<any>(null);
const filesCheck = ref<string>("");
const filesReturnCheck = ref<string>("");
/**
* function clearDate
*/
function clearReturnDate() {
Datereturn.value = null;
}
/** function Colsepopup*/
/**
* function Colsepopup
*/
function close() {
props.close?.();
Datereceive.value = null;
@ -83,11 +87,9 @@ function onSubmit(type: string, id: string) {
if (props.dateCheckReceive === null) {
formData.append("Date", dateToISO((Datereceive.value as Date) ?? nullii));
formData.append("File", files.value);
// formData.append("OrgId", OrganazationId.value);
} else {
formData.append("Date", dateToISO((Datereturn.value as Date) ?? nullii));
formData.append("File", filesReturn.value);
// formData.append("OrgId", OrganazationId2.value);
}
showLoader();
http
@ -110,32 +112,26 @@ function onSubmit(type: string, id: string) {
});
}
watch(
() => props.modal,
() => {
if (props.modal == true) {
fetchOrgList();
}
}
);
/** function เรียกหน่วยงาน*/
function fetchOrgList() {
/**
* function เรยกหนวยงาน
*/
async function fetchOrgList() {
showLoader();
http
await http
.get(config.API.activeOrganization)
.then((res) => {
.then(async (res) => {
const data = res.data.result;
http
await http
.get(config.API.orgByIdSystem(data.activeId, route.meta.Key as string))
.then(async (res) => {
const data = await res.data.result.map((item: any) => ({
id: item.orgTreeId,
name: item.orgName,
}));
OrgList.value = data;
OrgList2.value = data;
const dataSystem = await res.data.result.map(
(item: DataStructureTree) => ({
id: item.orgTreeId,
name: item.orgName,
})
);
OrgList.value = dataSystem;
OrgList2.value = dataSystem;
})
.catch((err) => {
messageError($q, err);
@ -149,7 +145,21 @@ function fetchOrgList() {
});
}
/** callback function จำทำงานเมื่อ props มีการเปลี่ยนแปลง*/
/**
* callback function จะทำงานเม modal การเปลยนแปลง
*/
watch(
() => props.modal,
() => {
if (props.modal == true) {
fetchOrgList();
}
}
);
/**
* callback function จะทำงานเม props การเปลยนแปลง
*/
watch(props, () => {
if (props.dataModal) {
Datereceive.value = props.dataModal.dateReceiveInsignia;
@ -172,7 +182,6 @@ watch(props, () => {
<q-dialog v-model="props.modal" persistent>
<q-card style="min-width: 900px">
<q-form
ref="myForm"
greedy
@submit.prevent
@validation-success="
@ -212,7 +221,7 @@ watch(props, () => {
dense
borderless
outlined
:rules="[(val) => !!val || 'กรุณาเลือกวันที่ได้รับ']"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่ได้รับ']"
hide-bottom-space
class="inputgreen"
:model-value="
@ -256,7 +265,7 @@ watch(props, () => {
v-model="files"
label="ไฟล์หลักฐานการรับ"
lazy-rules
:rules="[(val) => val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
:rules="[(val:string) => val || 'กรุณาเลือกไฟล์หลักฐานการรับ']"
hide-bottom-space
:disable="dateCheckReceive !== null"
>
@ -279,7 +288,7 @@ watch(props, () => {
v-model="OrganazationId"
lazy-rules
:label="`หน่วยงานที่รับ`"
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่รับ']"
:rules="[(val:string) => !!val || 'กรุณาเลือกหน่วยงานที่รับ']"
:disable="dateCheckReceive !== null"
class="inputgreen"
/>
@ -317,7 +326,7 @@ watch(props, () => {
borderless
outlined
class="inputgreen"
:rules="[(val) => !!val || 'กรุณาเลือกวันที่คืน']"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่คืน']"
hide-bottom-space
:model-value="
Datereturn != null ? date2Thai(Datereturn) : undefined
@ -362,7 +371,7 @@ watch(props, () => {
v-model="filesReturn"
label="ไฟล์หลักฐานการคืน"
lazy-rules
:rules="[(val) => val || 'กรุณาเลือกไฟล์หลักฐานการคืน']"
:rules="[(val:string) => val || 'กรุณาเลือกไฟล์หลักฐานการคืน']"
hide-bottom-space
:disable="dateCheckReturn !== null"
>
@ -385,7 +394,7 @@ watch(props, () => {
v-model="OrganazationId2"
lazy-rules
:label="`หน่วยงานที่คืน`"
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่คืน']"
:rules="[(val:string) => !!val || 'กรุณาเลือกหน่วยงานที่คืน']"
:disable="dateCheckReturn !== null"
class="inputgreen"
/>

View file

@ -1,6 +1,9 @@
<script setup lang="ts">
import { ref, watch, computed, reactive } from "vue";
import { QForm, useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useResultDataStore } from "@/modules/07_insignia/storeResult";
import http from "@/plugins/http";
import config from "@/app.config";
@ -8,13 +11,8 @@ import config from "@/app.config";
* import Type
*/
import type { DataOption } from "@/modules/04_registry/components/profileType";
import DialogHeader from "@/components/DialogHeader.vue";
/**
* import Stores
*/
import { useCounterMixin } from "@/stores/mixin";
import { useResultDataStore } from "@/modules/07_insignia/storeResult";
import DialogHeader from "@/components/DialogHeader.vue";
/**
* use
@ -38,9 +36,7 @@ const {
*/
const props = defineProps({
modal: Boolean,
save: {
type: Function,
},
close: {
type: Function,
},
@ -63,29 +59,31 @@ const props = defineProps({
* วแปร
*/
const status = ref<string>("");
const Advertise = ref<string>("");
const issue = ref<string>("");
const brand = ref<string>("");
const cardid = ref<string>("");
const fullName = ref<string>("");
const volume = ref<string>("");
const episode = ref<string>("");
const duty = ref<string>("");
const announced = ref<string>("");
const position = ref<string>("");
const payment = ref<string>("");
const addressPayment = ref<string | null>(null);
const affiliationRequest = ref<string>("");
const affiliationReceived = ref<string>("");
const receivedate = ref<Date | null>();
const announceDate = ref<Date | null>();
const invoiceDate = ref<Date | null>(null);
const filterinsigniaOp2 = ref<any[]>([]);
const employeeClass = ref<string>("");
const Advertise = ref<string>(""); //
const issue = ref<string>(""); //
const brand = ref<string>(""); //
const cardid = ref<string>(""); //
const fullName = ref<string>(""); //-
const volume = ref<string>(""); //
const episode = ref<string>(""); //
const duty = ref<string>(""); //
const announced = ref<string>(""); //
const position = ref<string>(""); //
const payment = ref<string>(""); //
const addressPayment = ref<string | null>(null); //
const affiliationRequest = ref<string>(""); //
const affiliationReceived = ref<string>(""); //
const receivedate = ref<Date | null>(); //
const announceDate = ref<Date | null>(); //
const invoiceDate = ref<Date | null>(null); //
const filterinsigniaOp2 = ref<DataOption[]>([]); //
const employeeClass = ref<string>(""); //./
// ./
const employeeClassOps = ref<DataOption[]>([
{ id: "officer", name: "ข้าราชการ กทม.สามัญ" },
{ id: "employee", name: "ลูกจ้างประจำ" },
]);
//
const paymentOp = [
{ label: "จัดส่งทางไปรษณีย์", value: "จัดส่งทางไปรษณีย์" },
{ label: "มารับด้วยตัวเอง", value: "มารับด้วยตัวเอง" },
@ -97,45 +95,13 @@ const formFilter = reactive({
searchKeyword: "",
});
/** function reset วันที่จ่ายใบกำกับ*/
/**
* function reset นทายใบกำก
*/
function clearDateInvoiceDate() {
invoiceDate.value = null;
}
/**
* callback function จำทำงานเม props.modal = true เป popup เพมรายชอบนทกผล
*/
watch(props, () => {
if (props.modal === true) {
filterinsigniaOp2.value = DataStore.insigniaOp2;
employeeClass.value = "";
cardid.value = "";
fullName.value = "";
position.value = "";
Advertise.value = "";
brand.value = "";
receivedate.value = null;
issue.value = "";
affiliationRequest.value = "";
affiliationReceived.value = "";
announceDate.value = null;
volume.value = "";
episode.value = "";
duty.value = "";
announced.value = "";
invoiceDate.value = null;
payment.value = "";
if (props.personId !== undefined) {
if (props.action === "editData") {
fectDataByid(props.personId); //
}
}
} else {
status.value = "";
selectType();
}
});
/**
* disbleStatus
*/
@ -241,7 +207,9 @@ function fectDataByid(id: string) {
});
}
/** function บักทึกผล*/
/**
* function กทกผล
*/
function onSubmit() {
dialogConfirm($q, () => {
if (props.roundId !== undefined) {
@ -293,17 +261,51 @@ function searchcardid() {
* @param update function
* @param name selec
*/
const filterSelector = (val: any, update: Function, name: any) => {
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "insigniaOp2") {
brand.value = "";
brand.value = val ? "" : brand.value;
filterinsigniaOp2.value = DataStore.insigniaOp2.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: DataOption) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
};
}
/**
* callback function จำทำงานเม props.modal = true เป popup เพมรายชอบนทกผล
*/
watch(props, () => {
if (props.modal === true) {
filterinsigniaOp2.value = DataStore.insigniaOp2;
employeeClass.value = "";
cardid.value = "";
fullName.value = "";
position.value = "";
Advertise.value = "";
brand.value = "";
receivedate.value = null;
issue.value = "";
affiliationRequest.value = "";
affiliationReceived.value = "";
announceDate.value = null;
volume.value = "";
episode.value = "";
duty.value = "";
announced.value = "";
invoiceDate.value = null;
payment.value = "";
if (props.personId !== undefined) {
if (props.action === "editData") {
fectDataByid(props.personId); //
}
}
} else {
status.value = "";
selectType();
}
});
</script>
<template>
@ -322,7 +324,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
<div class="col-4">
<q-select
:rules="[
(val) => !!val || 'กรุณาเลือก ขรก.สามัญ/ลูกจ้างประจำ',
(val:string) => !!val || 'กรุณาเลือก ขรก.สามัญ/ลูกจ้างประจำ',
]"
hide-bottom-space
:options="employeeClassOps"
@ -406,7 +408,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
<q-input
:disable="disbleStatus || status == 'DONE'"
:rules="[
(val) =>
(val:string) =>
!!val ||
'กรุณากรอกหมายเลขประกาศนีย์บัตรกำกับเครื่องราชอิสริยาภรณ์',
]"
@ -440,9 +442,9 @@ const filterSelector = (val: any, update: Function, name: any) => {
class="inputgreen"
style="min-width: 150px"
:rules="[
(val) => !!val || 'กรุณากรอกชื่อชั้นตราเครื่องราชอิสริยาภรณ์',
(val:string) => !!val || 'กรุณากรอกชื่อชั้นตราเครื่องราชอิสริยาภรณ์',
]"
@filter="(inputValue:any,doneFn:Function) =>
@filter="(inputValue:string,doneFn:Function) =>
filterSelector(inputValue, doneFn,'insigniaOp2') "
/>
</div>
@ -469,7 +471,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
dense
borderless
outlined
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่']"
class="inputgreen"
hide-bottom-space
:model-value="
@ -491,7 +493,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
<div class="col-xs-12 col-sm-6">
<q-input
:disable="disbleStatus || status == 'DONE'"
:rules="[(val) => !!val || 'กรุณากรอกทะเบียนฐานันดร']"
:rules="[(val:string) => !!val || 'กรุณากรอกทะเบียนฐานันดร']"
class="inputgreen"
hide-bottom-space
dense
@ -507,7 +509,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
:disable="
disbleStatus || status == 'DONE' || status == 'PENDING'
"
:rules="[(val) => !!val || 'กรุณากรอกสังกัด']"
:rules="[(val:string) => !!val || 'กรุณากรอกสังกัด']"
class="inputgreen"
hide-bottom-space
dense
@ -523,7 +525,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
:disable="
disbleStatus || status == 'DONE' || status == 'PENDING'
"
:rules="[(val) => !!val || 'กรุณากรอกสังกัด']"
:rules="[(val:string) => !!val || 'กรุณากรอกสังกัด']"
class="inputgreen"
hide-bottom-space
dense
@ -561,7 +563,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
dense
borderless
outlined
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่']"
class="inputgreen"
hide-bottom-space
:model-value="
@ -591,7 +593,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
borderless
v-model="volume"
:label="`เล่มที่`"
:rules="[(val) => !!val || 'กรุณากรอกเล่มที่']"
:rules="[(val:string) => !!val || 'กรุณากรอกเล่มที่']"
/>
</div>
<div class="col-xs-12 col-sm-4">
@ -605,7 +607,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
borderless
v-model="episode"
:label="`ตอนที่`"
:rules="[(val) => !!val || 'กรุณากรอกตอนที่']"
:rules="[(val:string) => !!val || 'กรุณากรอกตอนที่']"
/>
</div>
<div class="col-xs-12 col-sm-6">
@ -619,7 +621,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
borderless
v-model="duty"
:label="`หน้าที่`"
:rules="[(val) => !!val || 'กรุณากรอกหน้าที่']"
:rules="[(val:string) => !!val || 'กรุณากรอกหน้าที่']"
/>
</div>
<div class="col-xs-12 col-sm-6">
@ -633,7 +635,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
borderless
v-model="announced"
:label="`ลำดับที่`"
:rules="[(val) => !!val || 'กรุณากรอกลำดับที่']"
:rules="[(val:string) => !!val || 'กรุณากรอกลำดับที่']"
/>
</div>
<div class="col-12 q-my-xs"><q-separator size="2px" /></div>

View file

@ -1,30 +1,41 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
/** import Type*/
import type { QTableProps, QForm } from "quasar";
import type { TypeData } from "@/modules/07_insignia/interface/index/Main";
import type {
TypeData,
DataDocuments,
} from "@/modules/07_insignia/interface/index/Main";
/** import Stores */
import { useCounterMixin } from "@/stores/mixin";
/** useStore*/
/** use*/
const $q = useQuasar();
const mixin = useCounterMixin();
const { success, messageError, hideLoader, dialogConfirm, showLoader } = mixin;
const $q = useQuasar();
const myForm = ref<any>();
/**
* props
*/
const props = defineProps({
roundId: {
type: String,
},
});
const fileUpload = ref<any>(null);
const reason = ref<string>("");
const documentTitle = ref<string>("");
const filterKeyword = ref<string>("");
const filterDoc = ref<any>(null);
const myForm = ref<any>();
const fileUpload = ref<any>(null); //
const documentTitle = ref<string>(""); //
const reason = ref<string>(""); //
const filterKeyword = ref<string>(""); //
/** คอลัมน์ตาราง*/
const rows2 = ref<DataDocuments[]>([]);
const colums2 = ref<QTableProps["columns"]>([
{
name: "no",
@ -61,15 +72,10 @@ const visibleColumnsReference = ref<String[]>([
"annotation",
"file",
]);
const rows2 = ref<any>([]);
const props = defineProps({
roundId: {
type: String,
},
});
/** function ดึงข้อมูลรายการเอกสารอ้างอิง */
/**
* function งขอมลรายการเอกสารอางอ
*/
async function getRequest() {
showLoader();
await http
@ -93,46 +99,46 @@ async function getRequest() {
});
}
/** function เช็คฟอร์มก่อนบันทึก และยืนยันการบันทึกข้อมูล */
/**
* function เชคฟอรมกอนบนท และยนยนการบนทกขอม
*/
function save() {
myForm.value.validate().then((result: boolean) => {
if (result) {
dialogConfirm($q, () => putRequest());
dialogConfirm($q, async () => {
showLoader();
const dataAppend = new FormData();
dataAppend.append("Name", documentTitle.value);
dataAppend.append("Reason", reason.value);
dataAppend.append("File", fileUpload.value);
await http
.put(config.API.requestDocNote(props.roundId as string), dataAppend)
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
documentTitle.value = "";
reason.value = "";
fileUpload.value = null;
// reset validate
myForm.value.reset();
getRequest();
hideLoader();
});
});
}
});
}
/** function บันทึกเอกสาร */
async function putRequest() {
showLoader();
const dataAppend = new FormData();
dataAppend.append("Name", documentTitle.value);
dataAppend.append("Reason", reason.value);
dataAppend.append("File", fileUpload.value);
await http
.put(config.API.requestDocNote(props.roundId as string), dataAppend)
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
documentTitle.value = "";
reason.value = "";
fileUpload.value = null;
// reset validate
myForm.value.reset();
getRequest();
hideLoader();
});
}
/** function resetFilter */
/**
* function resetFilter
*/
function resetFilterRef() {
filterKeyword.value = "";
filterDoc.value.focus();
}
const pagination = ref({
@ -169,7 +175,7 @@ onMounted(async () => {
hide-bottom-space
lazy-rules
accept=".pdf"
:rules="[(val) => !!val || `กรุณาเลือกไฟล์เอกสาร`]"
:rules="[(val:string) => !!val || `กรุณาเลือกไฟล์เอกสาร`]"
>
<template v-slot:prepend>
<q-icon name="attach_file" color="primary" />
@ -185,7 +191,7 @@ onMounted(async () => {
v-model="documentTitle"
:label="`${'ชื่อเอกสาร'}`"
hide-bottom-space
:rules="[(val) => !!val || `กรุณากรอกชื่อเอกสาร`]"
:rules="[(val:string) => !!val || `กรุณากรอกชื่อเอกสาร`]"
/>
</div>
<div class="col-6 row no-wrap">
@ -217,7 +223,6 @@ onMounted(async () => {
standout
dense
v-model="filterKeyword"
ref="filterDoc"
outlined
debounce="300"
placeholder="ค้นหา"

View file

@ -1,4 +1,3 @@
div
<script setup lang="ts">
import { ref, watch } from "vue";
import { QForm, useQuasar } from "quasar";
@ -9,14 +8,13 @@ import DialogHeader from "@/components/DialogHeader.vue";
/** impotrStores */
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm } = mixin;
const $q = useQuasar();
const title = ref<string>("");
const amount = ref<number>();
/**
* props
*/
const props = defineProps({
modal: Boolean,
save: {
@ -36,13 +34,20 @@ const props = defineProps({
},
});
/** function closePopup*/
const title = ref<string>(""); //
const amount = ref<number>(); //
/**
* function closePopup
*/
function closeModal() {
props.close();
}
/** function ยืนยันการบันทึก*/
const onSubmit = () => {
/**
* function นยนการบนท
*/
function onSubmit() {
dialogConfirm($q, () => {
if (props.actionType === "insignia") {
props.save(
@ -55,7 +60,7 @@ const onSubmit = () => {
props.save(props.insigniadata.id, amount.value);
}
});
};
}
watch(props, () => {
if (props.modal === true) {
@ -66,6 +71,7 @@ watch(props, () => {
}
});
</script>
<template>
<q-dialog v-model="props.modal" persistent>
<q-card style="width: 800px">
@ -104,7 +110,7 @@ watch(props, () => {
lazy-rules
type="number"
label="จำนวน"
:rules="[(val) => !!val || `${'กรุณากรอกจำนวน'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกจำนวน'}`]"
/>
</div></div
></q-card-section>

View file

@ -1,27 +1,22 @@
div
<script setup lang="ts">
import { ref, watch } from "vue";
import { QForm, useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
/** impotrComponents */
import DialogHeader from "@/components/DialogHeader.vue";
/** impotrStores */
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { dialogConfirm, dialogMessageNotify } = mixin;
const $q = useQuasar();
const router = useRouter();
const mixin = useCounterMixin();
const { dialogConfirm } = mixin;
const myForm = ref<QForm | null>(null); //form data input
const routeName = router.currentRoute.value.name;
const amount = ref<number | null>();
const Org = ref<string | null>("");
const grandCross = ref<string | null>("");
const filterInsigniaOp = ref<any>();
/**
* props
*/
const props = defineProps({
modal: Boolean,
save: {
@ -38,7 +33,14 @@ const props = defineProps({
},
});
/** function closePopup*/
const routeName = router.currentRoute.value.name;
const amount = ref<number | null>(); //
const grandCross = ref<string | null>(""); //
const filterInsigniaOp = ref<any[]>([]); //
/**
* function closePopup
*/
function closeModal() {
props.close();
}
@ -49,14 +51,16 @@ function closeModal() {
* @param update function
* @param name Selec
*/
function filterSelector(val: any, update: Function, name: any) {
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "filterInsigniaOp") {
grandCross.value = null;
const newList = props.insigniaList.filter(
(e: any) => e.name !== "ทั้งหมด"
);
filterInsigniaOp.value = newList.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
@ -65,22 +69,14 @@ function filterSelector(val: any, update: Function, name: any) {
}
/** function ยืนยันการบันทึก*/
const onSubmit = () => {
// if (myForm.value !== null) {
// myForm.value.validate().then(async (success) => {
// if (success) {
function onSubmit() {
dialogConfirm($q, () => props.save(grandCross.value, amount.value));
// } else {
// dialogMessageNotify($q, "");
// }
// });
// }
};
}
watch(props, () => {
if (props.modal === false) {
grandCross.value = "";
Org.value = "";
amount.value = null;
}
});
@ -122,14 +118,14 @@ watch(
map-options
outlined
options-cover
:rules="[(val) => !!val || `${'กรุณาเลือกเครื่องราชฯ'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือกเครื่องราชฯ'}`]"
v-model="grandCross"
:label="
routeName == 'insigniaAllocate'
? `เครื่องราชฯ`
: `เลือกหน่วยงาน`
"
@filter="(inputValue:any,doneFn:Function) =>
@filter="(inputValue:string,doneFn:Function) =>
filterSelector(inputValue, doneFn,'filterInsigniaOp') "
/>
</div>
@ -143,7 +139,7 @@ watch(
lazy-rules
type="number"
label="จำนวน"
:rules="[(val) => !!val || `${'กรุณากรอกจำนวน'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกจำนวน'}`]"
/>
</div>
</div>

View file

@ -1,639 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, watch, useAttrs } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import router from "@/router";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
/** impotrType */
import type { OptionDataYear } from "@/modules/07_insignia/interface/index/Main";
import type { QTableProps, QInput } from "quasar";
/** impotrComponents */
import DialogForm from "@/modules/07_insignia/components/4_Allocate/DialogForm.vue";
import DialogEdit from "@/modules/07_insignia/components/4_Allocate/DialogEdit.vue";
/** impotrStores */
import { useCounterMixin } from "@/stores/mixin";
import { useAllocateDataStore } from "@/modules/07_insignia/storeAllocate";
const DataStore = useAllocateDataStore();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, dialogRemove, success } = mixin;
const $q = useQuasar();
const attrs = ref<any>(useAttrs());
const tab = ref<string>("");
const selectRound = ref<string>();
const selectRoundOption = ref<OptionDataYear[]>([]);
const modal = ref<boolean>(false);
const action = ref<string>("");
const roundYear = ref<number>();
const insigniaOp = ref<any>([]);
const filterInsigniaOp = ref<any>({ insigniaOp: [] });
const loadView = ref<boolean>(false);
const pagination = ref({
sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
});
/** ข้อมูล Table*/
const visibleColumns = ref<string[]>([
"no",
"insignia",
"total",
"allocate",
"remain",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "insignia",
align: "left",
label: "เครื่องราชอิสริยาภรณ์",
sortable: true,
field: "insignia",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "total",
align: "left",
label: "จำนวนทั้งหมด",
sortable: true,
field: "total",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "allocate",
align: "left",
label: "จัดสรรแล้ว",
sortable: true,
field: "allocate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "remain",
align: "left",
label: "คงเหลือ",
sortable: true,
field: "remain",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const filterRef = ref<QInput>();
const filter = ref<string>("");
const rowData = ref<any>([]);
/** function เรียกรอบการเสนอขอ*/
async function fecthRound() {
await http
.get(config.API.noteround())
.then(async (res) => {
let data = res.data.result;
if (data.length !== 0) {
selectRoundOption.value = data.map((e: any) => ({
id: e.id,
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
year: e.year,
}));
if (DataStore.roundId && DataStore.roundYear) {
selectRound.value = DataStore.roundId;
roundYear.value = DataStore.roundYear;
} else {
selectRound.value = data[0].id;
roundYear.value = data[0].year;
}
if (selectRound.value) {
DataStore.roundId = selectRound.value;
}
if (roundYear.value) {
await fecthInsignia();
await fecthInsigniaType();
} else {
hideLoader();
}
}
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/** function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insigniaOrg)
.then(async (res) => {
let data = res.data.result;
await DataStore.fetchDatainsignia(data);
insigniaOp.value = await DataStore.insigniaOp.filter(
(x: any) => x.type == tab.value || x.type === ""
);
})
.catch((err) => {
messageError($q, err);
});
}
/** function เรียก Tab*/
const fecthInsigniaType = async () => {
await http(config.API.insigniaTypeOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);
if (DataStore.mainTab) {
tab.value = DataStore.mainTab;
} else tab.value = DataStore.insigniaType[0].name;
loadView.value = true;
})
.catch((err) => {
messageError($q, err);
});
};
/** function เลือกรอบการเสนขอ*/
async function selectorRound(round: string | undefined) {
selectRound.value = round;
if (selectRound.value) {
DataStore.roundId = selectRound.value;
}
const yearFilter = selectRoundOption.value.find((x: any) => x.id == round); //
roundYear.value = yearFilter?.year;
DataStore.roundYear = roundYear.value;
await fecthlistInsignia();
}
/** function เรียกรายการเครืองราชฯ */
async function fecthlistInsignia() {
DataStore.mainTab = tab.value;
showLoader();
await http
.get(config.API.insigniaManageType(tab.value, Number(roundYear.value)))
.then((res) => {
let data = res.data.result;
DataStore.listinsignia(data);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* function reDirectToPage หนวยงานจดสรรเครองราชอสรยาภรณ
* @param id ดสรรเครองราชอสรยาภรณ
* @param name อเครองราช
*/
function redirectToPage(id: string, name: string) {
DataStore.insigniaName = name;
router.push(`/insignia/allocate/org/${id}`);
}
/** ตัวแปร popup*/
const modalEdit = ref<boolean>(false);
const actionType = ref<string>("");
/** function closePopup*/
function close() {
modal.value = false;
modalEdit.value = false;
}
/** function openPopup การเพิ่มการจัดสรรเครื่องราชฯ*/
const addData = () => {
modal.value = true;
action.value = "addData";
};
/** function openPopup การแกไขการจัดสรรเครื่องราชฯ*/
const clickEditrow = (data: any) => {
rowData.value = data;
modalEdit.value = true;
actionType.value = "insignia";
};
//
const save = async (insigniaId: string, total: string) => {
showLoader();
await http
.post(config.API.insigniaManageAdd(), {
insignia: insigniaId,
year: `${roundYear.value}`,
total: total,
})
.then(async () => {
success($q, "บันทึกข้อมูลสำเร็จ");
await fecthlistInsignia();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
close();
});
};
//
/**
* function ททกการแกไขการจดสรรเครองราชฯ
* @param id รอบการเสนอ
* @param insigniaId การจดสรรเครองราชฯ
* @param total จำนวน
* @param year
*/
async function saveEdit(
id: string,
insigniaId: string,
total: Number,
year: Number
) {
showLoader();
let body = {
insignia: insigniaId,
year: year,
total: Number(total),
};
await http
.put(config.API.insigniaManageById(id), body)
.then(async () => {
await fecthlistInsignia();
await success($q, "แก้ไขข้อมูลสำเร็จ");
close();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* function ลบการจดสรรเครองราชฯ
* @param insigniaId การจดสรรเครองราชฯ
*/
async function clickDelete(insigniaId: string) {
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.insigniaManageById(insigniaId))
.then(async () => {
await fecthlistInsignia();
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
function resetFilter() {
// reset X
filter.value = "";
filterRef.value!.focus();
}
/**
* function นหาขอมลใน option
* @param val คำคนหา
* @param update function
* @param name Selec
*/
function filterSelector(val: any, update: Function, name: any) {
update(() => {
const needle = val.toLowerCase();
if (name === "filterInsigniaOp") {
DataStore.insignia = undefined as any;
filterInsigniaOp.value = insigniaOp.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
}
/**
* function เคลยร filter
* @param name filter
*/
const clearInsigniaFilters = (name: string) => {
console.log(insigniaOp.value);
if (name === "filterInsigniaOp") {
DataStore.insignia = "";
filterInsigniaOp.value = insigniaOp.value;
}
};
/** function callback ทำงานเมื่อ Tab มีการเปลี่ยน*/
watch(tab, () => {
insigniaOp.value = DataStore.insigniaOp.filter(
(x: any) => x.type == tab.value || x.type === ""
);
let a = insigniaOp.value.find((e: any) => e.id == DataStore.insignia);
if (!a) {
DataStore.insignia = "";
}
filterInsigniaOp.value = insigniaOp.value;
fecthlistInsignia();
});
/** Hook*/
onMounted(async () => {
await fecthRound();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
ดสรรเครองราชอสรยาภรณ
</div>
<q-card
flat
bordered
class="col-12 q-my-md q-mt-sm rounded-borders"
v-if="loadView"
>
<div class="bg-grey-1 col-12 row items-center">
<div class="q-pl-md q-pr-sm text-weight-medium text-grey-7">รอบ</div>
<q-select
hide-bottom-space
borderless
dense
lazy-rules
emit-value
map-options
options-dense
option-label="name"
option-value="id"
v-model="selectRound"
:options="selectRoundOption"
use-input
input-debounce="0"
input-class="text-bold text-grey"
@update:model-value="selectorRound(selectRound)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
</q-select>
</div>
<q-separator />
<q-tabs
dense
v-model="tab"
align="left"
class="bg-white text-grey"
active-color="primary"
indicator-color="primary"
>
<div v-for="item in DataStore.insigniaType">
<q-tab :name="item.name" :label="item.label" />
</div>
</q-tabs>
<q-separator />
<q-tab-panels v-model="tab" animated>
<q-tab-panel
v-for="item in DataStore.insigniaType"
:key="item.name"
:name="item.name"
class="q-pa-none"
>
<div class="q-pa-md">
<div class="row col-12 q-pb-sm q-col-gutter-x-xs">
<div>
<q-select
v-model="DataStore.insignia"
dense
outlined
lazy-rules
hide-bottom-space
:label="`${'เครื่องราชฯ'}`"
emit-value
map-options
option-label="name"
:options="filterInsigniaOp"
option-value="id"
:readonly="false"
use-input
:borderless="false"
style="min-width: 350px"
@update:model-value="
DataStore.selectInsignia(DataStore.insignia)
"
@filter="(inputValue:any,
doneFn:Function) => filterSelector(inputValue, doneFn,'filterInsigniaOp'
) "
>
<template
v-if="
DataStore.insignia !== undefined &&
DataStore.insignia !== ''
"
v-slot:append
>
<q-icon
name="cancel"
@click.stop.prevent="
clearInsigniaFilters('filterInsigniaOp'),
DataStore.selectInsignia(DataStore.insignia)
"
class="cursor-pointer"
/>
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div>
<q-btn
v-if="checkPermission($route)?.attrIsCreate"
@click="addData()"
flat
round
color="add"
icon="mdi-plus"
>
<q-tooltip>เพ</q-tooltip>
</q-btn>
</div>
<q-space />
<div class="items-center" style="display: flex">
<!-- นหาขอความใน table -->
<q-input
standout
dense
v-model="filter"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
class="q-ml-sm"
>
<template v-slot:append>
<q-icon v-if="filter == ''" name="search" />
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<!-- แสดงคอลมนใน table -->
<q-select
v-model="visibleColumns"
:display-value="$q.lang.table.columns"
multiple
outlined
dense
:options="columns"
options-dense
option-value="name"
map-options
emit-value
style="min-width: 150px"
class="gt-xs q-ml-sm"
/>
</div>
</div>
<d-table
ref="table"
:columns="columns"
:rows="DataStore.rows"
:filter="filter"
row-key="id"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td auto-width>
<q-btn
v-if="checkPermission($route)?.attrIsGet"
flat
round
dense
icon="mdi-eye"
color="info"
@click.stop="
redirectToPage(props.row.id, props.row.insignia)
"
>
<q-tooltip> รายละเอยด</q-tooltip>
</q-btn>
<q-btn
v-if="checkPermission($route)?.attrIsUpdate"
flat
round
dense
icon="edit"
color="edit"
@click.stop="clickEditrow(props.row)"
>
<q-tooltip> แกไขขอม</q-tooltip>
</q-btn>
<q-btn
v-if="checkPermission($route)?.attrIsDelete"
flat
round
dense
icon="delete"
color="red"
@click.stop="clickDelete(props.row.id)"
>
<q-tooltip> ลบขอม</q-tooltip>
</q-btn>
</q-td>
<q-td key="no" :props="props">
{{ props.rowIndex + 1 }}
</q-td>
<q-td key="year" :props="props">
{{ props.row.year }}
</q-td>
<q-td key="insignia" :props="props">
{{ props.row.insignia }}
</q-td>
<q-td key="total" :props="props">
{{ props.row.total }}
</q-td>
<q-td key="allocate" :props="props">
{{ props.row.allocate }}
</q-td>
<q-td key="remain" :props="props">
{{ props.row.remain }}
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-tab-panel>
</q-tab-panels>
</q-card>
<q-card v-else>
<div class="q-pa-md q-gutter-sm">
<q-banner inline-actions rounded class="bg-grey-1 text-center">
ไมอมลรอบการเสนอขอพระราชทานเครองราชอสรยาภรณ
</q-banner>
</div>
</q-card>
<DialogForm
:modal="modal"
:save="save"
:close="close"
:insignia-list="insigniaOp"
/>
<DialogEdit
:modal="modalEdit"
:save="saveEdit"
:close="close"
:insigniadata="rowData"
:actionType="actionType"
/>
</template>
<style lang="scss" scoped></style>

View file

@ -1,551 +0,0 @@
<script setup lang="ts">
import { ref, useAttrs } from "vue";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
/** impotrComponents */
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue";
import DialogHeader from "@/modules/07_insignia/components/DialogHeader.vue";
import cardTop from "@/modules/07_insignia/components/2_Manage/StatCard.vue";
/** impotrStores */
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { dialogMessage } = mixin;
const $q = useQuasar(); // noti quasar
const attrs = ref<any>(useAttrs());
const modal = ref<boolean>(false);
const saveWriteNote = ref<any[]>([]);
const addNote = ref<boolean>(false);
const name = ref<string>("");
const clickNote = () => {
addNote.value = true;
};
const pagination = ref({
sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
});
const stat = ref<any>({
total: 3,
sendInsig: 2,
remainInsig: 1,
});
/** ข้อมูล Table1*/
const visibleColumns = ref<string[]>([
"no",
"citizenId",
"name",
"organization",
"positionType",
"positionAdmin",
"positionLine",
"positionNum",
"status",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "citizenId",
align: "left",
label: "เลขประจำตัวประชาชน",
sortable: true,
field: "citizenId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "name",
align: "left",
label: "ชื่อ - นามสกุล",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "organization",
align: "left",
label: "สังกัด",
sortable: true,
field: "organization",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionType",
align: "left",
label: "ประเภทตำแหน่ง",
sortable: true,
field: "positionType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionAdmin",
align: "left",
label: "ตำแหน่งทางการบริหาร",
sortable: true,
field: "positionAdmin",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionLine",
align: "left",
label: "ตำแหน่งในสายงาน/ระดับ",
sortable: true,
field: "positionLine",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionNum",
align: "left",
label: "ตำแหน่ง เลขที่",
sortable: true,
field: "positionNum",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "status",
align: "left",
label: "สถานะ",
sortable: true,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const rows = ref<any[]>([]);
/** ข้อมูล Table2*/
const visibleColumns2 = ref<string[]>([
"no",
"name",
"position",
"level",
"institution",
]);
const columns2 = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "name",
align: "left",
label: "ชื่อ-นามสกุล",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "position",
align: "left",
label: "ตำแหน่งในสายงาน",
sortable: true,
field: "position",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "level",
align: "left",
label: "ระดับ",
sortable: true,
field: "level",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "institution",
align: "left",
label: "สังกัด",
sortable: true,
field: "institution",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const rows2 = ref<any[]>([]);
// const clickDelete = (id: string) => {
// $q.dialog({
// title: "",
// message: "?",
// cancel: {
// flat: true,
// color: "negative",
// },
// persistent: true,
// })
// .onOk(async () => {})
// .onCancel(() => {})
// .onDismiss(() => {});
// };
/** function closePopup*/
function clickClose() {
modal.value = false;
}
/** function openPopupAdd*/
function clickAdd() {
modal.value = true;
}
/** function บันทึกข้อมูล note*/
async function saveNote() {
if (saveWriteNote.value.length == 0) {
dialogMessage(
$q,
"ไม่สามารถบันทึกข้อมูลได้",
"กรุณาเพิ่มหมายเหตุ",
"warning",
undefined,
"orange",
undefined,
undefined,
true
);
return;
}
}
/** ค้นหาในตาราง*/
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
const resetFilter = () => {
filterKeyword.value = "";
filterRef.value.focus();
};
const filterKeyword2 = ref<string>("");
const filterRef2 = ref<any>(null);
const resetFilter2 = () => {
filterKeyword2.value = "";
filterRef2.value.focus();
};
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายชอทดสรรเครองราชอสรยาภรณ {{ name }}
</div>
<q-card bordered class="q-py-sm row col-12">
<div class="col-12 row bg-white">
<div class="fit q-px-md q-py-sm">
<div class="row col-12 q-col-gutter-md fit">
<cardTop
:amount="stat.total"
label="จำนวนเครื่องราช ฯ ทั้งหมด"
color="#016987"
/>
<cardTop
:amount="stat.sendInsig"
label="จำนวนเครื่องราช ฯ ที่จัดสรรให้หน่วยงานแล้ว"
color="#02A998"
/>
<cardTop
:amount="stat.remainInsig"
label="จำนวนเครื่องราช ฯ คงเหลือ"
color="#2EA0FF"
/>
</div>
</div>
</div>
</q-card>
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
<div class="row q-col-gutter-sm">
<div class="row col-12 q-col-gutter-sm">
<div>
<q-btn
@click="clickAdd()"
size="12px"
flat
round
color="add"
icon="mdi-plus"
>
<q-tooltip>เพมรายการจดสรรเครองราชอสรยาภรณ</q-tooltip>
</q-btn>
</div>
<q-space />
<q-input
class="col-xs-12 col-sm-3 col-md-2"
standout
dense
v-model="filterKeyword"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filterKeyword == ''" name="search" />
<q-icon
v-if="filterKeyword !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
class="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<div class="col-12">
<d-table
ref="table"
:columns="columns"
:rows="rows"
:filter="filterKeyword"
row-key="id"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td key="no" :props="props">
{{ props.rowIndex + 1 }}
</q-td>
<q-td key="citizenId" :props="props">
{{ props.row.citizenId }}
</q-td>
<q-td key="name" :props="props">
{{ props.row.name }}
</q-td>
<q-td key="organization" :props="props">
{{ props.row.organization }}
</q-td>
<q-td key="positionType" :props="props">
{{ props.row.positionType }}
</q-td>
<q-td key="positionAdmin" :props="props">
{{ props.row.positionAdmin }}
</q-td>
<q-td key="positionLine" :props="props">
{{ props.row.positionLine }}
</q-td>
<q-td key="positionNum" :props="props">
{{ props.row.positionNum }}
</q-td>
<q-td key="status" :props="props">
{{ props.row.status }}
</q-td>
<q-td auto-width>
<q-btn
dense
size="12px"
flat
round
color="blue"
icon="mdi-alert-circle-outline"
>
<q-tooltip>หมายเหต</q-tooltip>
</q-btn>
</q-td>
<q-td>
<q-btn label="คืนแล้ว" @click="clickNote()" color="blue" />
</q-td>
</q-tr>
</template>
</d-table>
</div>
</div>
</q-card>
<q-dialog v-model="modal" persistent>
<q-card style="width: 900px; max-width: 80vw">
<q-form ref="myForm">
<DialogHeader tittle="เพิ่มรายชื่อ " :close="clickClose" />
<q-separator />
<q-card-section class="q-pa-md q-col-gutter-sm">
<q-input
class="col-12"
standout
dense
v-model="filterKeyword2"
ref="filterRef2"
outlined
debounce="300"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filterKeyword2 == ''" name="search" />
<q-icon
v-if="filterKeyword2 !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter2"
/>
</template>
</q-input>
<div class="col-12">
<d-table
ref="table2"
:columns="columns2"
:rows="rows2"
:filter="filterKeyword2"
row-key="Order"
flat
bordered
:paging="true"
dense
class="custom-header-table"
v-bind="attrs"
:visible-columns="visibleColumns2"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
<q-td auto-width>
<q-btn
dense
class="q-px-md"
outline
color="primary"
v-close-popup
label="เพิ่ม"
>
</q-btn>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card-section>
</q-form>
</q-card>
</q-dialog>
<DialogPopupReason
v-model:modal="addNote"
title="คืนเครื่องราชฯ"
label="กรอกเหตุผลที่ต้องการคืนเครื่องราชฯ"
:savaForm="saveNote"
/>
</template>
<style lang="scss" scope>
.filter-card {
background-color: #f1f1f1b0;
}
.toggle-expired-account {
font-size: 12px;
font-weight: 400;
font-size: 15px;
line-height: 150%;
color: #35373c;
}
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -1,14 +1,19 @@
<script setup lang="ts">
import { onMounted, ref, useAttrs } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import router from "@/router";
import { useRoute, useRouter } from "vue-router";
import { checkPermission } from "@/utils/permissions";
import { useCounterMixin } from "@/stores/mixin";
import { useAllocateDataStore } from "@/modules/07_insignia/storeAllocate";
import http from "@/plugins/http";
import config from "@/app.config";
import { checkPermission } from "@/utils/permissions";
/** impotrType */
import type { QTableProps } from "quasar";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
import type { ResponseAllocate } from "@/modules/07_insignia/interface/response/Main";
import type { DataStructureTree } from "@/interface/main";
/** impotrComponents */
import cardTop from "@/modules/07_insignia/components/2_Manage/StatCard.vue";
@ -16,8 +21,7 @@ import DialogForm from "@/modules/07_insignia/components/4_Allocate/DialogForm.v
import DialogEdit from "@/modules/07_insignia/components/4_Allocate/DialogEdit.vue";
/** impotrStores */
import { useCounterMixin } from "@/stores/mixin";
import { useAllocateDataStore } from "@/modules/07_insignia/storeAllocate";
const router = useRouter();
const DataStore = useAllocateDataStore();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, success, dialogRemove } = mixin;
@ -27,13 +31,7 @@ const $q = useQuasar(); //ใช้ noti quasar
const route = useRoute();
/** ข้อมูล Table*/
const visibleColumns = ref<string[]>([
"no",
"organization",
"total",
"allocate",
"remain",
]); //
const rows = ref<ResponseAllocate[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -81,27 +79,35 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const rows = ref<any[]>([]);
const visibleColumns = ref<string[]>([
"no",
"organization",
"total",
"allocate",
"remain",
]);
const name = ref<string>("");
const id = ref<string>(route.params.id.toString());
const modal = ref<boolean>(false);
const orgList = ref<any>([]);
const orgList = ref<OptionData[]>([]); //
const pagination = ref({
sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
});
const stat = ref<any>({
total: 0,
allocate: 0,
remain: 0,
const stat = ref({
total: 0, //
allocate: 0, //
remain: 0, //
});
/** funcion เรียกข้อมูล stat*/
/**
* funcion เรยกขอม stat
*/
async function fecthDashboard() {
// showLoader();
await http
.get(config.API.insigniaManageOrgDashboard(id.value))
.then((res) => {
@ -114,16 +120,17 @@ async function fecthDashboard() {
.catch((err) => {
messageError($q, err);
});
// .finally(() => hideLoader());
}
/** funcion เรียกข้อมูลรายชื่อ หน่วยงานจัดสรรเครื่องราชอิสริยาภรณ์ ตริตาภรณ์มงกุฎไทย ()*/
/**
* funcion เรยกขอมลรายช หนวยงานจดสรรเครองราชอสรยาภรณ ตรตาภรณมงกฎไทย ()
*/
async function fecthListData() {
showLoader();
await http
.get(config.API.insigniaManageOrg(id.value))
.then((res) => {
rows.value = res.data.result.map((e: any) => ({
rows.value = res.data.result.map((e: ResponseAllocate) => ({
id: e.id,
organization: e.organizationOrganization,
total: e.total,
@ -139,7 +146,9 @@ async function fecthListData() {
});
}
/** funcion เรียกข้อมูลหน่วยงานจัดสรรเครื่องราชอิสริยาภรณ์ */
/**
* funcion เรยกขอมลหนวยงานจดสรรเครองราชอสรยาภรณ
*/
async function fetchOrgList() {
http
.get(config.API.activeOrganization)
@ -149,7 +158,7 @@ async function fetchOrgList() {
http
.get(config.API.orgByIdSystem(data.activeId, route.meta.Key as string))
.then(async (res) => {
const data = await res.data.result.map((item: any) => ({
const data = await res.data.result.map((item: DataStructureTree) => ({
id: item.orgTreeId,
name: item.orgName,
}));
@ -164,12 +173,16 @@ async function fetchOrgList() {
});
}
/** funcion ย้อนกลับหน้าจัดสรรเครื่องราชอิสริยาภรณ์*/
/**
* funcion อนกลบหนาจดสรรเครองราชอสรยาภรณ
*/
function backHistory() {
router.push(`/insignia/allocate`);
}
/** funcion closePopup */
/**
* funcion closePopup
*/
function close() {
modal.value = false;
modalEdit.value = false;
@ -225,13 +238,13 @@ async function saveEdit(organizationId: string, amount: number) {
});
}
const rowData = ref<any>([]);
const modalEdit = ref<boolean>(false);
const rowData = ref<ResponseAllocate>(); //
const modalEdit = ref<boolean>(false); // popup
/**
* function openPopup แกไข
* @param data อมลทจะแกไข
*/
function clickEditrow(data: any) {
function clickEditrow(data: ResponseAllocate) {
rowData.value = data;
modalEdit.value = true;
}
@ -259,9 +272,9 @@ async function clickDelete(insigniaId: string) {
});
}
const clickAdd = () => {
function clickAdd() {
modal.value = true;
};
}
/** ค้นหาในตาราง*/
const filterKeyword = ref<string>("");

View file

@ -1,6 +1,9 @@
<script setup lang="ts">
import { ref, watch, onMounted } from "vue";
import { QForm, useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useBrrowDataStore } from "@/modules/07_insignia/storeBrrow";
import http from "@/plugins/http";
import config from "@/app.config";
@ -10,15 +13,7 @@ import type { DataOption } from "@/modules/04_registry/components/profileType";
/** impotrComponents */
import DialogHeader from "@/components/DialogHeader.vue";
/** impotrStores */
import { useCounterMixin } from "@/stores/mixin";
import { useBrrowDataStore } from "@/modules/07_insignia/storeBrrow";
import { useRoute } from "vue-router";
const $q = useQuasar();
const myForm = ref<QForm>();
const route = useRoute();
const DataStore = useBrrowDataStore();
const mixin = useCounterMixin();
const {
@ -31,22 +26,9 @@ const {
notifyError,
} = mixin;
const brand = ref<string>("");
const roundNo = ref<string | undefined>("");
const cardid = ref<string>("");
const OrganazationId = ref<string>("");
const fullName = ref<string>("");
const receivedate = ref<Date | null>();
const returndate = ref<Date | null>();
const reason = ref<string>("");
const listPerson = ref<any>([]);
const OrgList = ref<DataOption[]>([]);
const filterOrgList = ref<DataOption[]>([]);
const insigniaNoteProfileId = ref<string>("");
const filterSelectRound = ref<any>();
const selectRound = ref<any>();
const type = ref<any>(DataStore.type);
/**
* props
*/
const props = defineProps({
modal: Boolean,
save: {
@ -85,7 +67,25 @@ const props = defineProps({
},
});
/** function เคลียร์ข้อมูลในฟอร์ม*/
const brand = ref<string>(""); //
const roundNo = ref<string | undefined>(""); //
const cardid = ref<string>(""); //
const OrganazationId = ref<string>(""); //
const receivedate = ref<Date | null>(); //
const returndate = ref<Date | null>(); //
const fullName = ref<string>(""); //-
const reason = ref<string>("");
const listPerson = ref<any>([]);
const OrgList = ref<DataOption[]>([]);
const filterOrgList = ref<DataOption[]>([]);
const insigniaNoteProfileId = ref<string>("");
const filterSelectRound = ref<any>();
const selectRound = ref<any>();
const type = ref<any>(DataStore.type);
/**
* function เคลยรอมลในฟอร
*/
function clearData() {
receivedate.value = null;
returndate.value = null;
@ -97,7 +97,9 @@ function clearData() {
reason.value = "";
}
/** function เรียกข้อมูลรายการเครื่องราช */
/**
* function เรยกขอมลรายการเครองราช
*/
async function fecthlistInsignia() {
if (roundNo.value !== "" && roundNo.value !== null) {
showLoader();
@ -125,48 +127,9 @@ async function fecthlistInsignia() {
}
}
/** funcion เรียกข้อมูลหน่วยงานจัดสรรเครื่องราชอิสริยาภรณ์ */
async function fetchOrgList() {
http
.get(config.API.activeOrganization)
.then((res) => {
const data = res.data.result;
http
.get(config.API.orgByIdSystem(data.activeId, route.meta.Key as string))
.then(async (res) => {
const data = await res.data.result.map((item: any) => ({
id: item.orgTreeId,
name: item.orgName,
}));
OrgList.value = data;
filterOrgList.value = data;
})
.catch((err) => {
messageError($q, err);
});
})
.catch((err) => {
messageError($q, err);
});
}
// -
// const fetchData = async () => {
// showLoader();
// await http
// .get(config.API.insigniaManageBorrowById(props.profileId))
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// hideLoader();
// });
// };
// -
/** function บันทึกการเพิ่มข้อมูล*/
/**
* function นทกการเพมขอม
*/
async function onSubmit() {
dialogConfirm($q, async () => {
showLoader();
@ -205,7 +168,9 @@ async function onSubmit() {
});
}
/** function ค้นหาคนจากเลขประจำตัวประชาชน*/
/**
* function นหาคนจากเลขประจำตวประชาชน
*/
async function searchcardid() {
if (cardid.value.length === 13) {
showLoader();
@ -236,13 +201,17 @@ async function searchcardid() {
}
}
/** function closePopup*/
/**
* function closePopup
*/
function closeDialog() {
clearData();
props.close();
}
/** function reset วันที่คืน*/
/**
* function reset นท
*/
function clearReturnDate() {
returndate.value = null;
}
@ -253,17 +222,17 @@ function clearReturnDate() {
* @param update function
* @param name Selec
*/
function filterSelector(val: any, update: Function, name: any) {
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "filterOrgList") {
OrganazationId.value = "";
OrganazationId.value = val ? "" : OrganazationId.value;
filterOrgList.value = OrgList.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
}
if (name === "filterSelectRoundOption") {
roundNo.value = "";
roundNo.value = val ? "" : roundNo.value;
filterSelectRound.value = selectRound.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
@ -271,29 +240,32 @@ function filterSelector(val: any, update: Function, name: any) {
});
}
/** function setValue*/
const setValue = () => {
/**
* function setValue
*/
function setValue() {
filterSelectRound.value = props.filterSelectRoundOption;
selectRound.value = props.selectRoundOption;
};
}
/** Hook*/
onMounted(() => {
setValue();
});
/** function callback เช็ค props ถ้าเปิด dialog ให้ดึงรายการข้อมูล */
/**
* function callback เช props าเป dialog ใหงรายการขอม
*/
watch(props, () => {
if (props.modal == true && props.roundId != "all") {
roundNo.value = props.roundId;
if (props.action === "editData") {
// fetchOrgList();
} else {
fecthlistInsignia();
setValue();
}
}
});
/** Hook*/
onMounted(() => {
setValue();
});
</script>
<template>
@ -333,9 +305,9 @@ watch(props, () => {
:readonly="false"
:borderless="false"
style="min-width: 150px"
:rules="[(val) => !!val || 'กรุณาเลือกรอบการขอเครื่องราชฯ']"
:rules="[(val:string) => !!val || 'กรุณาเลือกรอบการขอเครื่องราชฯ']"
@update:model-value="fecthlistInsignia()"
@filter="(inputValue:any,
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'filterSelectRoundOption'
) "
/>
@ -376,7 +348,7 @@ watch(props, () => {
v-model="fullName"
:label="`${'ชื่อ-นามสกุล'}`"
:rules="[
(val) =>
(val:string) =>
!!val ||
'ชื่อ-นามสกุลต้องไม่ว่าง กรุณากรอกเลขประจำตัวประชาชนให้ถูกต้อง',
]"
@ -388,7 +360,7 @@ watch(props, () => {
</div>
<div class="col-xs-12 col-sm-6">
<q-input
:rules="[(val) => !!val || 'กรุณาเลือกเครื่องราชฯ']"
:rules="[(val:string) => !!val || 'กรุณาเลือกเครื่องราชฯ']"
v-model="brand"
disable
dense
@ -420,7 +392,7 @@ watch(props, () => {
dense
borderless
outlined
:rules="[(val) => !!val || 'กรุณาเลือกวันที่']"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่']"
hide-bottom-space
:model-value="
receivedate != null ? date2Thai(receivedate) : undefined
@ -468,7 +440,7 @@ watch(props, () => {
dense
borderless
outlined
:rules="[(val) => !!val || 'กรุณาเลือกวันที่คืน']"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่คืน']"
hide-bottom-space
:model-value="
returndate != null ? date2Thai(returndate) : undefined
@ -491,28 +463,6 @@ watch(props, () => {
</datepicker>
</div>
<!-- <div class="col-xs-12 col-sm-6">
<q-select
hide-bottom-space
:options="filterOrgList"
dense
lazy-rules
borderless
option-label="name"
option-value="id"
emit-value
map-options
outlined
use-input
v-model="OrganazationId"
:label="`เลือกหน่วยงานที่ส่งคืน`"
:rules="[(val) => !!val || 'กรุณาเลือกหน่วยงานที่คืน']"
@filter="(inputValue:any,
doneFn:Function) => filterSelector(inputValue, doneFn,'filterOrgList'
) "
/>
</div> -->
<div class="col-12">
<q-input
class="inputgreen"

View file

@ -1,740 +0,0 @@
<script setup lang="ts">
import { ref, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { checkPermission } from "@/utils/permissions";
/** impotrType */
import type { OptionDataYear } from "@/modules/07_insignia/interface/index/Main";
import type { QTableProps, QInput } from "quasar";
/** impotrComponents */
import DialogForm from "@/modules/07_insignia/components/5_Borrow/DialogForm.vue";
/** impotrStores */
import { useBrrowDataStore } from "@/modules/07_insignia/storeBrrow";
import { useCounterMixin } from "@/stores/mixin";
const DataStore = useBrrowDataStore();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError } = mixin;
const $q = useQuasar();
const tab = ref<string>("");
/** ข้อมูล Table*/
const visibleColumns = ref<String[]>([
"action",
"no",
"status",
"citizenId",
"name",
"type",
"employeeType",
"date",
"volumeNo",
"section",
"dateReceive",
"page",
"number",
"vatnumber",
"datepay",
"typepay",
"address",
"borrowOrganization",
"borrowDate",
"returnOrganization",
"returnDate",
"returnReason",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "action",
align: "left",
label: "",
field: "",
},
{
name: "no",
align: "left",
label: "ลำดับ",
field: "no",
sortable: false,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "citizenId",
align: "left",
label: "เลขประจำตัวประชาชน",
field: "citizenId",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "name",
align: "left",
label: "ชื่อ - นามสกุล",
field: "name",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "employeeType",
align: "left",
label: "สถานภาพ",
field: "employeeType",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "type",
align: "left",
label: "ประเภทเครื่องราชฯ",
field: "type",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "dateReceive",
align: "left",
label: "วันที่ได้รับพระราชทาน",
field: "dateReceive",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "date",
align: "left",
label: "วันที่ในราชกิจนุเบกษา",
field: "date",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "volumeNo",
align: "left",
label: "เล่มที่ในราชกิจนุเบกษา",
field: "volumeNo",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "section",
align: "left",
label: "ตอนที่ในราชกิจนุเบกษา",
field: "section",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "page",
align: "left",
label: "หน้าในราชกิจนุเบกษา",
field: "page",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "number",
align: "left",
label: "ลำดับที่ในราชกิจจานุเบกษา",
field: "number",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "vatnumber",
align: "left",
label: "หมายเลขใบกำกับ",
field: "vatnumber",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "datepay",
align: "left",
label: "วันที่จ่ายใบกำกับฯ",
field: "datepay",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "typepay",
align: "left",
label: "รูปแบบการจ่าย",
field: "typepay",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "address",
align: "left",
label: "ที่อยู่ที่จ่าย",
field: "address",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "borrowOrganization",
align: "left",
label: "หน่วยงานที่ยืม",
field: "borrowOrganization",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "borrowDate",
align: "left",
label: "วันที่ยืม",
field: "borrowDate",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "returnOrganization",
align: "left",
label: "หน่วยงานที่คืน",
field: "returnOrganization",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "returnDate",
align: "left",
label: "วันที่คืน",
field: "returnDate",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "returnReason",
align: "left",
label: "เหตุผลการคืน",
field: "returnReason",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const filterRef = ref<QInput>();
const filter = ref<string>("");
const pagination = ref({
sortBy: "name",
descending: false,
page: 1,
rowsPerPage: 10,
});
const selectRound = ref<string>();
const selectRoundOption = ref<OptionDataYear[]>([]);
const filterSelectRoundOption = ref<any>([]);
const selectRoundAllOption = ref<OptionDataYear[]>([]);
const filterSelectRoundAllOption = ref<OptionDataYear[]>([]);
const type = ref<any[]>(DataStore.type);
const modal = ref<boolean>(false);
const action = ref<string>("");
const profileId = ref<string>("");
const roundYear = ref<any>();
const insigniaList = ref<any>([]);
const fileterInsigniaList = ref<any>([]);
const loadView = ref<boolean>(false);
const employeeClassOps = ref<any>(DataStore.employeeClassOps);
/** function เรียกรอบการเสนอขอพระราชทานเครื่องราชฯ*/
async function fecthRound() {
showLoader();
await http
.get(config.API.noteround())
.then(async (res) => {
let data = res.data.result;
if (data.length !== 0) {
selectRoundAllOption.value = [
{
name: "ทั้งหมด",
id: "0",
year: 0,
},
];
data.map((e: any) => {
selectRoundOption.value.push({
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
id: e.id,
year: e.year,
});
selectRoundAllOption.value.push({
name: "รอบการเสนอขอพระราชทานเครื่องราชฯ ปี" + " " + (e.year + 543),
id: e.id,
year: e.year,
});
});
filterSelectRoundAllOption.value = selectRoundAllOption.value;
selectRound.value = data[0].id;
filterSelectRoundOption.value = selectRoundOption.value;
yearRound.value = data[0].year;
roundYear.value = data[0].year;
if (roundYear.value) {
await fecthInsigniaType();
} else {
hideLoader();
}
}
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/** function เรียกประเภทเครื่องราชฯ*/
async function fecthInsignia() {
await http
.get(config.API.insigniaOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDataInsignia(data);
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
insigniaList.value = await DataStore.insigniaOp.filter(
(x: any) => x.type == tab.value || x.type == ""
);
});
}
/** function เรียกระดับเครื่องราชฯ Tab*/
async function fecthInsigniaType() {
await http(config.API.insigniaTypeOrg)
.then(async (res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);
tab.value = DataStore.insigniaType ? DataStore.insigniaType[0].name : "";
loadView.value = true;
await fecthInsignia();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {});
}
/** รอบการเสนอขอ*/
const yearRound = ref<number>();
/**
* function เลอกรอบการเสนอขอ
* @param round การเสนอขอ
*/
async function selectorRound(round: number) {
roundYear.value = round;
await fecthlistInsignia();
}
/** function เรียกรายชื่อการเสนอขอเครื่องราชฯ */
async function fecthlistInsignia() {
showLoader();
await http
.get(
config.API.insigniaManageBorrowList(Number(roundYear.value), tab.value)
)
.then(async (res) => {
await DataStore.fetchlistinsignia(res.data.result);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function closePopup */
function close() {
modal.value = false;
}
/** function closePopup และเเรียกข้อมูลรายชื่อการเสนอขอเครื่องราชฯ */
async function closeAndFecth() {
await fecthlistInsignia();
modal.value = false;
}
/** function openPopup เพิ่มรายการ ยืม-คืนเครื่องราชฯ*/
function addData() {
modal.value = true;
action.value = "addData";
}
/**
* function openPopup แกไขรายการ -นเครองราชฯ
* @param id profileId
*/
function editData(id: any) {
profileId.value = id;
action.value = "editData";
modal.value = true;
}
function resetFilter() {
// reset X
filter.value = "";
filterRef.value!.focus();
}
/**
* function นหาขอมลใน option
* @param val คำคนหา
* @param update function
* @param name Selec
*/
function filterSelector(val: any, update: Function, name: any) {
update(() => {
const needle = val.toLowerCase();
if (name === "employeeClassOps") {
// DataStore.employeeClass = "";
employeeClassOps.value = DataStore.employeeClassOps.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "fileterInsigniaList") {
// DataStore.insignia = null as any;
fileterInsigniaList.value = insigniaList.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterSelectRoundAllOption") {
// yearRound.value = null as any;
filterSelectRoundAllOption.value = selectRoundAllOption.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
}
/** Hook*/
onMounted(async () => {
await fecthRound();
});
/** function callblack ทำงานเมือมีการเปลี่ยน Tab*/
watch(tab, async () => {
insigniaList.value = await DataStore.insigniaOp.filter(
(x: any) => x.type == tab.value || x.type == ""
);
DataStore.insignia = "";
fileterInsigniaList.value = insigniaList.value;
fecthlistInsignia();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
-นเครองราชฯ
</div>
<q-card
flat
bordered
class="col-12 q-my-md q-mt-sm rounded-borders"
v-if="loadView == true"
>
<q-tabs
dense
v-model="tab"
align="left"
class="bg-white text-grey"
active-color="primary"
indicator-color="primary"
>
<div v-for="item in DataStore.insigniaType">
<q-tab :name="item.name" :label="item.label" />
</div>
</q-tabs>
<q-separator />
<q-tab-panels v-model="tab" animated>
<q-tab-panel
v-for="item in DataStore.insigniaType"
:key="item.name"
:name="item.name"
class="q-pa-md"
>
<div class="row col-12">
<div class="row col-12 q-col-gutter-sm">
<q-select
v-model="yearRound"
dense
outlined
lazy-rules
hide-bottom-space
:label="`${'รอบการเสนอขอเครื่องราชฯ'}`"
emit-value
map-options
use-input
option-label="name"
:options="filterSelectRoundAllOption"
option-value="year"
:borderless="false"
style="min-width: 150px"
@update:model-value="selectorRound"
@filter="(inputValue: any,
doneFn: Function) => filterSelector(inputValue, doneFn, 'filterSelectRoundAllOption'
)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
<q-space />
<q-input
class="col-xs-12 col-sm-3 col-md-2"
standout
dense
v-model="filter"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filter == ''" name="search" />
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
class="col-xs-12 col-sm-3 col-md-2"
/>
</div>
<q-card bordered class="q-pa-sm col-12 bg-grey-1 q-mt-sm">
<div class="row col-12 q-col-gutter-sm">
<q-select
v-model="DataStore.insignia"
dense
outlined
use-input
lazy-rules
hide-bottom-space
:label="`${'เครื่องราชฯ'}`"
emit-value
map-options
option-label="name"
:options="fileterInsigniaList"
option-value="id"
:readonly="false"
:borderless="false"
style="min-width: 230px"
@update:model-value="
DataStore.searchDatatable(
DataStore.insignia,
DataStore.employeeClass
)
"
@filter="(inputValue: any,
doneFn: Function) => filterSelector(inputValue, doneFn, 'fileterInsigniaList'
)"
>
<template v-if="DataStore.insignia !== ''" v-slot:append>
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
<q-select
class="col-2"
v-model="DataStore.employeeClass"
dense
outlined
lazy-rules
hide-bottom-space
:label="`${'สถานภาพ'}`"
emit-value
use-input
map-options
option-label="name"
:options="employeeClassOps"
option-value="id"
:readonly="false"
:borderless="false"
style="min-width: 240px"
@update:model-value="
DataStore.searchDatatable(
DataStore.insignia,
DataStore.employeeClass
)
"
@filter="(inputValue: any,
doneFn: Function) => filterSelector(inputValue, doneFn, 'employeeClassOps'
)"
>
<template
v-if="DataStore.employeeClass !== 'all'"
v-slot:append
>
</template>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
<div>
<q-btn
v-if="checkPermission($route)?.attrIsCreate"
@click="addData()"
flat
round
color="add"
icon="mdi-plus"
>
<q-tooltip>เพ</q-tooltip>
</q-btn>
</div>
</div>
</q-card>
</div>
<div class="col-12 q-pt-sm">
<d-table
:rows="DataStore.rows"
:columns="columns"
:visible-columns="visibleColumns"
:filter="filter"
row-key="id"
v-model:pagination="pagination"
:paging="true"
>
<template v-slot:body-cell="props">
<q-td :props="props">
<div v-if="props.col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div
v-else-if="
props.col.name == 'action' && props.row.returnDate == '-'
"
>
<q-td>
<q-btn
v-if="checkPermission($route)?.attrIsUpdate"
label="คืนเครื่องราชฯ"
@click="editData(props.row.id)"
color="blue"
/>
</q-td>
</div>
<div v-else-if="props.col.name == 'returnOrganization'">
{{
props.row.returnOrganization == null
? "-"
: props.row.returnOrganization
}}
</div>
<div v-else>
{{ props.value }}
</div>
</q-td>
</template>
</d-table>
</div>
</q-tab-panel>
</q-tab-panels>
</q-card>
<q-card v-else>
<div class="q-pa-md q-gutter-sm">
<q-banner inline-actions rounded class="bg-grey-1 text-center">
ไมอมลรอบการเสนอขอพระราชทานเครองราชอสรยาภรณ
</q-banner>
</div>
</q-card>
<DialogForm
:modal="modal"
:close="close"
:close-and-fecth="closeAndFecth"
:type="type"
:round-id="selectRound == '0' ? 'all' : selectRound"
:action="action"
:profile-id="profileId"
v-model:selectRoundOption="selectRoundOption"
v-model:filterSelectRoundOption="filterSelectRoundOption"
:type-id="tab"
/>
</template>
<style lang="scss" scoped>
.arrow {
transition: transform 0.5s;
}
.arrow-active {
transition: transform 0.5s;
transform: rotate(-90deg);
}
.bg-base {
background-color: #f3f3f398;
}
.v-enter-active,
.v-leave-active {
transition: opacity 0.5s ease;
}
.v-enter-from,
.v-leave-to {
opacity: 0;
}
.flexsave {
display: flex;
justify-content: flex-end;
}
</style>

View file

@ -1,27 +0,0 @@
<template>
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold">{{
tittle
}}</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="close"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
</template>
<script setup lang="ts">
const props = defineProps({
tittle: String,
close: {
type: Function,
default: () => console.log("not function"),
},
});
const close = async () => {
props.close();
};
</script>

View file

@ -5,6 +5,9 @@ import { useCounterMixin } from "@/stores/mixin";
import { useRoute } from "vue-router";
import { useQuasar } from "quasar";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
import type { ResponsePeriod } from "@/modules/07_insignia/interface/response/Main";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import http from "@/plugins/http";
@ -31,37 +34,45 @@ interface OptionReport {
title: string;
}
onMounted(async () => {
await fecthlistRound();
let report = optionReport.find((e: OptionReport) => e.id == typeReport);
report && (titleReport.value = report.title);
});
const splitterModel = ref(14);
const selectList = ref<any>();
const optionsList = ref<any>([{ id: 0, name: "เลือกกรอบการยื่นขอ" }]);
const filterOtion = ref<any>([]);
const optionsList = ref<OptionData[]>([{ id: 0, name: "เลือกกรอบการยื่นขอ" }]);
const filterOtion = ref<OptionData[]>([]);
const nextPage = () => {
/**
* งกนไปหนาถดไป
*/
function nextPage() {
if (page.value < numOfPages.value) {
page.value++;
}
};
const backPage = () => {
}
/**
* งกนยอนกล
*/
function backPage() {
if (page.value !== 1) {
page.value--;
}
};
}
const backHistory = () => {
/**
* งก Redirect ไปหน รายงานเครองราชอสรยาภรณ
*/
function backHistory() {
window.history.back();
};
}
const fecthlistRound = async () => {
/**
* งกนคงขอมลรอบการเสนอขอ
*/
async function fecthlistRound() {
showLoader();
await http
.get(config.API.listRoundInsignia())
.then((res: any) => {
optionsList.value = res.data.result.map((e: any) => ({
optionsList.value = res.data.result.map((e: ResponsePeriod) => ({
id: e.period_id,
year: e.period_year,
name: e.period_name,
@ -70,14 +81,24 @@ const fecthlistRound = async () => {
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
};
}
const updateSelect = () => {
/**
* งกนเลอกรอบการเสนอขอ
*/
function updateSelect() {
conditionDocument("show");
};
}
const conditionDocument = (type: string) => {
/**
* งกนโหลไฟลรายงาน
* @param type นามสกลไฟลองการ
*/
function conditionDocument(type: string) {
myForm.value?.validate().then(async (success: boolean) => {
if (success) {
if (type == "show") {
@ -87,18 +108,26 @@ const conditionDocument = (type: string) => {
}
}
});
};
}
const showDocument = (url: any) => {
/**
* งกแสดงรายงาน
* @param url
*/
function showDocument(url: any) {
const pdfData = usePDF(url);
setTimeout(() => {
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
}, 1000);
};
}
const downloadFile = (response: any, filename: string) => {
/**
* งกนโหลดไฟล
* @param response อมลทองการ
* @param filename อไฟล
*/
function downloadFile(response: any, filename: string) {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
@ -106,12 +135,14 @@ const downloadFile = (response: any, filename: string) => {
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
}
const downloadReport = async (
type: string = "pdf",
download: boolean = true
) => {
/**
* งกนโหลดไฟล
* @param type ประเภทไฟล
* @param download
*/
async function downloadReport(type: string = "pdf", download: boolean = true) {
showLoader();
await http
.get(config.API.reportInsignia(typeReport, type, selectList.value.id), {
@ -134,17 +165,30 @@ const downloadReport = async (
.finally(() => {
hideLoader();
});
};
const filterSelector = (val: any, update: Function, name: any) => {
}
/**
* function นหาขอมลใน option
* @param val คำคนหา
* @param update function
* @param name Selec
*/
function filterSelector(val: string, update: Function, name: string) {
update(() => {
const needle = val.toLowerCase();
if (name === "selectList") {
filterOtion.value = optionsList.value.filter(
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
};
}
onMounted(async () => {
await fecthlistRound();
let report = optionReport.find((e: OptionReport) => e.id == typeReport);
report && (titleReport.value = report.title);
});
</script>
<template>
@ -181,9 +225,9 @@ const filterSelector = (val: any, update: Function, name: any) => {
label="เลือกรอบ"
option-value="id"
option-label="name"
:rules="[(val) => !!val || 'กรุณาเลือกรอบ']"
:rules="[(val:string) => !!val || 'กรุณาเลือกรอบ']"
@update:model-value="updateSelect"
@filter="(inputValue:any,doneFn:Function) =>
@filter="(inputValue:string,doneFn:Function) =>
filterSelector(inputValue, doneFn,'selectList') "
>
<template v-slot:no-option>

View file

@ -1,89 +0,0 @@
<script setup lang="ts">
import { useRouter } from "vue-router";
// import { useInsigniaDataStore } from "@/modules/07_insignia/store";
const router = useRouter();
// const store = useInsigniaDataStore();
const nextPage = (type: string, title: string) => {
router.push(`/insignia/report/report/${type}`);
};
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายงานเครองราชอสรยาภรณ
</div>
<div>
<q-card flat bordered class="col-12 q-mt-sm">
<div class="q-pa-md">
<!-- <q-item to="/insignia/report/report-01" dense class="hover-green">
<q-item-section avatar>
<q-icon color="primary" name="mdi-file" size="xs" />
</q-item-section>
<q-item-section class="text-dark">
รายงาน ขร.1 - ขร.4
</q-item-section>
</q-item> -->
<q-item
clickable
@click="
nextPage(
'45',
'บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชอิสริยาภรณ์'
)
"
dense
class="hover-green"
>
<q-item-section avatar>
<q-icon color="primary" name="mdi-file" size="xs" />
</q-item-section>
<q-item-section class="text-dark">
ญชรายชอขาราชการผขอพระราชทานเครองราชอสรยาภรณ
</q-item-section>
</q-item>
<q-item
clickable
@click="
nextPage('43', 'บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี')
"
dense
class="hover-green"
>
<q-item-section avatar>
<q-icon color="primary" name="mdi-file" size="xs" />
</q-item-section>
<q-item-section class="text-dark">
ญชระดบผลการประเมนผลการปฏราชการในรอบ 5
</q-item-section>
</q-item>
<q-item
clickable
@click="nextPage('44', 'บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ')"
dense
class="hover-green"
>
<q-item-section avatar>
<q-icon color="primary" name="mdi-file" size="xs" />
</q-item-section>
<q-item-section class="text-dark">
ญชแสดงจำนวนชนตราเครองราชฯ
</q-item-section>
</q-item>
</div>
</q-card>
</div>
</template>
<style lang="scss" scope>
.q-item.hover-green:hover {
background-color: #d5f1ee57;
border-radius: 2px;
}
.q-item.hover-green {
padding: 10px;
}
</style>

View file

@ -1,423 +0,0 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QForm } from "quasar";
const mixin = useCounterMixin();
const { messageError, showLoader, hideLoader } = mixin;
const $q = useQuasar();
const myForm = ref<QForm>();
const pdfSrc = ref<any>();
const numOfPages = ref<number>(0);
const page = ref<number>(1);
const dialog = ref<boolean>(false);
onMounted(async () => {
await fecthlistRound();
});
const splitterModel = ref(14);
const fileId = ref<string>("");
const selectReport = ref<any>({ id: 39, name: "รายงานขร.1" });
const optionsReport = ref<any>([
{ id: 39, name: "รายงานขร.1" },
{ id: 40, name: "รายงานขร.2" },
{ id: 41, name: "รายงานขร.3" },
{ id: 42, name: "รายงานขร.4" },
]);
const selectList = ref<any>();
const optionsList = ref<any>([{ id: 0, name: "เลือกกรอบการยื่นขอ" }]);
const nextPage = () => {
if (page.value < numOfPages.value) {
page.value++;
}
};
const backPage = () => {
if (page.value !== 1) {
page.value--;
}
};
const backHistory = () => {
window.history.back();
};
const fecthlistRound = async () => {
await http
.get(config.API.listRoundInsignia())
.then((res: any) => {
optionsList.value = res.data.result.map((e: any) => ({
id: e.period_id,
year: e.period_year,
name: e.period_name,
}));
})
.catch((err) => {
messageError($q, err);
});
};
const updateSelect = () => {
conditionDocument("show");
};
const conditionDocument = (type: string) => {
myForm.value?.validate().then(async (success: boolean) => {
if (success) {
if (type == "show") {
await downloadReport("pdf", false);
} else {
await downloadReport(type, true);
}
}
});
};
const showDocument = (url: any) => {
const pdfData = usePDF(url);
setTimeout(() => {
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
}, 1000);
};
const downloadFile = (response: any, filename: string) => {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
const downloadReport = async (
type: string = "pdf",
download: boolean = true
) => {
showLoader();
await http
.get(
config.API.reportInsignia(
selectReport.value.id.toString(),
type,
selectList.value.id
),
{
responseType: "blob",
}
)
.then(async (res) => {
if (download) {
downloadFile(
res,
`${selectReport.value.name} ${selectList.value.name}.${type}`
);
} else {
const url = URL.createObjectURL(new Blob([res.data]));
showDocument(url);
}
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
};
</script>
<template>
<div class="toptitle">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="backHistory"
/>
รายงาน ขร.1 - ขร.4
</div>
<div>
<q-card flat bordered class="col-12 q-mt-sm">
<div class="q-pa-md q-gutter-y-sm">
<q-toolbar style="padding: 0">
<q-form ref="myForm" class="row items-center">
<q-select
use-input
fill-input
hide-selected
class="q-mr-sm"
dense
outlined
v-model="selectReport"
:options="optionsReport"
:label="optionsReport.name"
option-value="id"
option-label="name"
style="width: 150px"
@update:model-value="updateSelect"
/>
<q-select
class="q-pa-none"
use-input
fill-input
hide-selected
dense
outlined
v-model="selectList"
:options="optionsList"
label="เลือกรอบ"
option-value="id"
option-label="name"
:rules="[(val) => !!val || 'กรุณาเลือกรอบ']"
@update:model-value="updateSelect"
/>
</q-form>
<!-- style="width: 200px" -->
<q-space />
<div class="q-pa-ms q-gutter-sm" style="padding: 0">
<q-btn outline color="primary" icon="download" label="ดาวน์โหลด">
<q-menu>
<q-list style="min-width: 150px">
<q-item
clickable
v-close-popup
@click="conditionDocument('pdf')"
>
<q-item-section avatar
><q-icon color="red" name="mdi-file-pdf"
/></q-item-section>
<q-item-section>ไฟล .PDF</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="conditionDocument('docx')"
>
<q-item-section avatar
><q-icon color="blue" name="mdi-file-word"
/></q-item-section>
<q-item-section>ไฟล .docx</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="conditionDocument('xlsx')"
>
<q-item-section avatar
><q-icon color="green" name="mdi-file-excel"
/></q-item-section>
<q-item-section>ไฟล .xlsx</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
<q-btn
unelevated
icon="mdi-refresh"
color="primary"
@click="conditionDocument('show')"
/>
<q-btn
unelevated
color="blue"
icon="mdi-fullscreen"
@click="dialog = true"
/>
</div>
</q-toolbar>
<q-splitter
v-model="splitterModel"
horizontal
style="
height: 70vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 5px;
"
before-class="overflow-hidden disable"
separator-class="bg-white disabled"
>
<template v-slot:before>
<div class="q-px-sm">
<div class="row items-start items-center">
<div class="col">
<q-btn
padding="xs"
icon="mdi-chevron-left"
color="grey-2"
text-color="grey-5"
size="md"
class="my-auto"
@click="backPage"
:disable="page == 1"
/>
</div>
<div class="col-12 col-md-auto">
<div class="q-pa-md flex">
หนาท {{ page }} จาก {{ numOfPages }}
</div>
</div>
<div class="col text-right">
<q-btn
padding="xs"
icon="mdi-chevron-right"
color="grey-2"
text-color="grey-5"
size="md"
@click="nextPage"
:disable="page === numOfPages"
/>
</div>
</div>
</div>
</template>
<template v-slot:after>
<div class="q-pa-md">
<VuePDF ref="vuePDFRef" :pdf="pdfSrc" :page="page" fit-parent />
</div>
</template>
<template v-slot:default>
<div class="q-pa-md">
<div class="row items-start items-center">
<div class="col">
<q-btn
padding="xs"
icon="mdi-chevron-left"
color="grey-2"
text-color="grey-5"
size="md"
class="my-auto"
@click="backPage"
:disable="page == 1"
/>
</div>
<div class="col-12 col-md-auto">
<div class="q-pa-md flex">
หนาท {{ page }} จาก {{ numOfPages }}
</div>
</div>
<div class="col text-right">
<q-btn
padding="xs"
icon="mdi-chevron-right"
color="grey-2"
text-color="grey-5"
size="md"
@click="nextPage"
:disable="page === numOfPages"
/>
</div>
</div>
</div>
</template>
</q-splitter>
</div>
</q-card>
</div>
<!-- Dialog Full Screen -->
<q-dialog
v-model="dialog"
persistent
:maximized="true"
transition-show="slide-up"
transition-hide="slide-down"
>
<q-card class="bg-white">
<div class="flex justify-end items-center align-center q-mr-md q-mt-sm">
<q-btn
icon="close"
unelevated
round
dense
style="color: #ff8080; background-color: #ffdede"
size="12px"
v-close-popup
/>
</div>
<div class="q-pa-md">
<div class="row items-start items-center">
<div class="col">
<q-btn
padding="xs"
icon="mdi-chevron-left"
color="grey-2"
text-color="grey-5"
size="md"
class="my-auto"
@click="backPage"
:disable="page == 1"
/>
</div>
<div class="col-12 col-md-auto">
<div class="q-pa-md flex">
หนาท {{ page }} จาก {{ numOfPages }}
</div>
</div>
<div class="col text-right">
<q-btn
padding="xs"
icon="mdi-chevron-right"
color="grey-2"
text-color="grey-5"
size="md"
@click="nextPage"
:disable="page === numOfPages"
/>
</div>
</div>
<div class="row items- items-center">
<VuePDF ref="vuePDFRef" :pdf="pdfSrc" :page="page" fit-parent />
</div>
<div class="row items- items-end">
<div class="col">
<q-btn
padding="xs"
icon="mdi-chevron-left"
color="grey-2"
text-color="grey-5"
size="md"
class="my-auto"
@click="backPage"
:disable="page == 1"
/>
</div>
<div class="col-12 col-md-auto">
<div class="q-pa-md flex">
หนาท {{ page }} จาก {{ numOfPages }}
</div>
</div>
<div class="col text-right">
<q-btn
padding="xs"
icon="mdi-chevron-right"
color="grey-2"
text-color="grey-5"
size="md"
@click="nextPage"
:disable="page === numOfPages"
/>
</div>
</div>
</div>
</q-card>
</q-dialog>
</template>
<style lang="scss" scope>
.disabled {
pointer-events: none;
}
</style>