2024-03-08 10:49:49 +07:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* importType*
|
|
|
|
|
*/
|
|
|
|
|
import type { QTableProps } from "quasar";
|
2024-03-08 10:49:49 +07:00
|
|
|
import type { QForm } from "quasar";
|
2024-07-09 10:17:37 +07:00
|
|
|
import type { DataOption } from "@/modules/04_registryNew/interface/index/Main";
|
|
|
|
|
import type {
|
|
|
|
|
HistoryPos,
|
|
|
|
|
Position,
|
|
|
|
|
} from "@/modules/04_registryNew/interface/response/History";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* import components
|
|
|
|
|
*/
|
|
|
|
|
import DialogHeader from "@/components/DialogHeader.vue";
|
2024-03-08 10:49:49 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* importStore
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* use
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
const myForm = ref<QForm>();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const $q = useQuasar();
|
2024-07-09 10:17:37 +07:00
|
|
|
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
|
2024-03-08 10:49:49 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* props
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
const modal = defineModel<boolean>("modal", { required: true });
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* ตัวแปร
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
const employeeClass = ref<string>("");
|
|
|
|
|
const typeKeyword = ref<string>("");
|
|
|
|
|
const Keyword = ref<string>("");
|
|
|
|
|
const positionKeyword = ref<string>("");
|
|
|
|
|
const employeeClassOps = ref<DataOption[]>([
|
|
|
|
|
{ id: "officer", name: "ข้าราชการ กทม.สามัญ" },
|
|
|
|
|
{ id: "perm", name: "ลูกจ้างประจำ" },
|
|
|
|
|
]);
|
|
|
|
|
const typeKeywordOps = ref<DataOption[]>([
|
2024-06-26 14:15:54 +07:00
|
|
|
{ id: "no", name: "ตำแหน่งเลขที่" },
|
2024-03-08 10:49:49 +07:00
|
|
|
{ id: "position", name: "ตำแหน่ง" },
|
|
|
|
|
]);
|
|
|
|
|
const positionOps = ref<DataOption[]>([]);
|
2024-07-09 10:17:37 +07:00
|
|
|
const options = ref<DataOption[]>([]);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Table
|
|
|
|
|
*/
|
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
2024-03-08 10:49:49 +07:00
|
|
|
{
|
|
|
|
|
name: "no",
|
|
|
|
|
label: "ลำดับ",
|
|
|
|
|
field: "no",
|
|
|
|
|
align: "left",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "citizenId",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "เลขประจำตัวประชาชน",
|
|
|
|
|
field: "citizenId",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "name",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ชื่อ - นามสกุล",
|
|
|
|
|
field: "name",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "posNo",
|
|
|
|
|
align: "left",
|
2024-06-26 14:15:54 +07:00
|
|
|
label: "ตำแหน่งเลขที่",
|
2024-03-08 10:49:49 +07:00
|
|
|
field: "posNo",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "position",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ตำแหน่ง",
|
|
|
|
|
field: "position",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "date",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "วันที่ถือครอง",
|
|
|
|
|
field: "date",
|
2024-07-09 10:17:37 +07:00
|
|
|
format: (val, row) => `${date2Thai(val)}`,
|
2024-03-08 10:49:49 +07:00
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
]);
|
2024-07-09 10:17:37 +07:00
|
|
|
const rows = ref<HistoryPos[]>([]);
|
2024-03-08 10:49:49 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* function fetch ข้อมูลตำแหน่ง ข้าราชการ
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
function fecthPositionOfficer() {
|
|
|
|
|
http
|
|
|
|
|
.get(config.API.listPositionPathHistory)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
let data = res.data.result.items;
|
2024-07-09 10:17:37 +07:00
|
|
|
|
|
|
|
|
positionOps.value = data.map((e: Position) => ({
|
|
|
|
|
id: e.id,
|
|
|
|
|
name: e.name,
|
|
|
|
|
}));
|
2024-03-08 10:49:49 +07:00
|
|
|
options.value = positionOps.value;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-05-21 10:45:38 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* function fetch ข้อมูลตำแหน่ง ลูกจ้างประจำ
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
function fetchPositionPerm() {
|
|
|
|
|
http
|
|
|
|
|
.get(config.API.listPositionEmployeePositionHistory)
|
|
|
|
|
.then((res) => {
|
|
|
|
|
let data = res.data.result.items;
|
2024-07-09 10:17:37 +07:00
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
|
|
positionOps.value = data.map((e: Position) => ({
|
|
|
|
|
id: e.id,
|
|
|
|
|
name: e.name,
|
|
|
|
|
}));
|
2024-03-08 10:49:49 +07:00
|
|
|
options.value = positionOps.value;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* function เปลี่ยนประเภท
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
function changeEmployeeClass() {
|
|
|
|
|
typeKeyword.value = "";
|
|
|
|
|
Keyword.value = "";
|
|
|
|
|
positionKeyword.value = "";
|
|
|
|
|
rows.value = [];
|
|
|
|
|
}
|
2024-07-09 10:17:37 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function เลือกฟิลด์ที่จะค้นหา
|
|
|
|
|
* @param typeKeyword ประเภทฟิลด์
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
function selectTypeKeyword(typeKeyword: string) {
|
|
|
|
|
positionOps.value = [];
|
|
|
|
|
positionKeyword.value = "";
|
|
|
|
|
Keyword.value = "";
|
|
|
|
|
|
|
|
|
|
if (typeKeyword == "position" && employeeClass.value === "officer") {
|
|
|
|
|
fecthPositionOfficer();
|
|
|
|
|
} else if (typeKeyword == "position" && employeeClass.value === "perm") {
|
|
|
|
|
fetchPositionPerm();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* function ค้นหาประวัติถือครองตำแหน่ง
|
|
|
|
|
* @param type ประเภทข่าราชการ
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
function clickSearch(type: string) {
|
|
|
|
|
myForm.value!.validate().then((result: boolean) => {
|
|
|
|
|
if (result) {
|
|
|
|
|
showLoader();
|
|
|
|
|
let body = {};
|
|
|
|
|
if (typeKeyword.value === "no") {
|
|
|
|
|
Object.assign(body, {
|
|
|
|
|
posNo: Keyword.value,
|
|
|
|
|
});
|
|
|
|
|
} else if (typeKeyword.value === "position") {
|
|
|
|
|
Object.assign(body, {
|
2024-05-21 10:45:38 +07:00
|
|
|
position: positionKeyword.value,
|
2024-03-08 10:49:49 +07:00
|
|
|
});
|
|
|
|
|
}
|
2024-05-21 10:45:38 +07:00
|
|
|
const empType = type === "officer" ? "" : "-employee";
|
2024-03-08 10:49:49 +07:00
|
|
|
http
|
2024-05-21 10:45:38 +07:00
|
|
|
.post(config.API.registryNew(empType) + `/search/history/oc`, body)
|
2024-03-08 10:49:49 +07:00
|
|
|
.then((res) => {
|
|
|
|
|
let data = res.data.result;
|
|
|
|
|
if (data.length !== 0) {
|
2024-07-09 10:17:37 +07:00
|
|
|
rows.value = data.map((e: HistoryPos) => ({
|
2024-03-08 10:49:49 +07:00
|
|
|
id: e.id,
|
|
|
|
|
citizenId: e.citizenId,
|
2024-05-21 11:34:42 +07:00
|
|
|
name: e.fullName,
|
2024-03-08 10:49:49 +07:00
|
|
|
posNo: e.posNo,
|
|
|
|
|
position: e.position,
|
2024-07-09 10:17:37 +07:00
|
|
|
date: e.date,
|
2024-03-08 10:49:49 +07:00
|
|
|
}));
|
|
|
|
|
} else {
|
|
|
|
|
rows.value = [];
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
rows.value = [];
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-07-09 10:17:37 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function ค้นหาข่อมูล Optiion
|
|
|
|
|
* @param val คำค้นหา
|
|
|
|
|
* @param update function
|
|
|
|
|
*/
|
|
|
|
|
function filterFn(val: string, update: Function) {
|
2024-03-08 10:49:49 +07:00
|
|
|
if (val === "") {
|
|
|
|
|
update(() => {
|
|
|
|
|
options.value = positionOps.value;
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
update(() => {
|
|
|
|
|
options.value = positionOps.value.filter(
|
|
|
|
|
(e) => e.name.search(val) !== -1
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-09 10:17:37 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* function redirect ไปทะเบียนประวัติ
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
2024-03-08 10:49:49 +07:00
|
|
|
function clickRedirect(id: string) {
|
2024-05-21 11:34:42 +07:00
|
|
|
const url =
|
|
|
|
|
employeeClass.value === "officer"
|
|
|
|
|
? "registry-new"
|
|
|
|
|
: "registry-new-employee";
|
|
|
|
|
router.push(`${url}/${id}`);
|
2024-03-08 10:49:49 +07:00
|
|
|
}
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
/**
|
|
|
|
|
* function ปิด popup
|
|
|
|
|
*/
|
|
|
|
|
function closeDialog() {
|
|
|
|
|
modal.value = false;
|
|
|
|
|
employeeClass.value = "";
|
|
|
|
|
typeKeyword.value = "";
|
|
|
|
|
Keyword.value = "";
|
|
|
|
|
positionKeyword.value = "";
|
|
|
|
|
rows.value = [];
|
|
|
|
|
}
|
2024-03-08 10:49:49 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<q-dialog v-model="modal">
|
2024-05-21 10:45:38 +07:00
|
|
|
<q-card style="width: 850px; max-width: 80vw">
|
2024-07-09 10:17:37 +07:00
|
|
|
<DialogHeader :tittle="'ประวัติถือครองตำแหน่ง'" :close="closeDialog" />
|
|
|
|
|
|
2024-05-21 10:45:38 +07:00
|
|
|
<q-separator />
|
2024-03-15 16:09:29 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
<q-card-section class="q-pa-sm">
|
|
|
|
|
<q-form ref="myForm">
|
|
|
|
|
<div class="col-12 bg-grey-2 q-pa-sm">
|
|
|
|
|
<div class="col-12 row q-pb-sm q-col-gutter-sm items-center"></div>
|
|
|
|
|
<div class="q-col-gutter-xs row no-wrap">
|
|
|
|
|
<div class="col-4">
|
2024-03-15 17:20:36 +07:00
|
|
|
<q-select
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
:rules="[(val:string) => !!val || `${'กรุณาเลือก ประเภท'}`]"
|
|
|
|
|
outlined
|
2024-03-15 16:09:29 +07:00
|
|
|
dense
|
2024-03-15 17:20:36 +07:00
|
|
|
lazy-rules
|
|
|
|
|
v-model="employeeClass"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="employeeClassOps"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
:label="`${'ประเภท'}`"
|
|
|
|
|
use-input
|
|
|
|
|
input-debounce="0"
|
|
|
|
|
@update:model-value="changeEmployeeClass"
|
2024-03-15 16:09:29 +07:00
|
|
|
/>
|
2024-07-09 10:17:37 +07:00
|
|
|
</div>
|
|
|
|
|
<div class="col-3">
|
2024-03-15 17:20:36 +07:00
|
|
|
<q-select
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
:rules="[(val:string) => !!val || `${'กรุณาเลือก ฟิลด์ที่จะค้น'}`]"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
lazy-rules
|
|
|
|
|
v-model="typeKeyword"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="typeKeywordOps"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
:label="`${' เลือกฟิลด์ที่จะค้น'}`"
|
|
|
|
|
use-input
|
|
|
|
|
input-debounce="0"
|
|
|
|
|
@update:model-value="selectTypeKeyword(typeKeyword)"
|
|
|
|
|
/>
|
2024-07-09 10:17:37 +07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col" v-if="typeKeyword === 'no'">
|
2024-03-15 17:20:36 +07:00
|
|
|
<q-input
|
|
|
|
|
borderless
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
debounce="300"
|
|
|
|
|
v-model="Keyword"
|
2024-06-26 14:15:54 +07:00
|
|
|
placeholder="ตำแหน่งเลขที่"
|
|
|
|
|
:rules="[(val:string) => !!val || `${'กรุณากรอก ตำแหน่งเลขที่'}`]"
|
2024-03-15 17:20:36 +07:00
|
|
|
hide-bottom-space
|
|
|
|
|
/>
|
2024-07-09 10:17:37 +07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col" v-if="typeKeyword === 'position'">
|
2024-03-15 17:20:36 +07:00
|
|
|
<q-select
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
:rules="[(val:string) => !!val || `${'กรุณาเลือก ตำแหน่ง'}`]"
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
v-model="positionKeyword"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="options"
|
|
|
|
|
option-label="name"
|
|
|
|
|
option-value="id"
|
|
|
|
|
:label="`${' เลือกตำแหน่ง'}`"
|
|
|
|
|
use-input
|
|
|
|
|
input-debounce="0"
|
|
|
|
|
@filter="filterFn"
|
|
|
|
|
behavior="menu"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:no-option>
|
|
|
|
|
<q-item>
|
|
|
|
|
<q-item-section class="text-grey">
|
|
|
|
|
ไม่มีข้อมูล
|
|
|
|
|
</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</template></q-select
|
|
|
|
|
>
|
2024-03-15 16:09:29 +07:00
|
|
|
</div>
|
2024-03-08 10:49:49 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
<q-space />
|
2024-03-08 10:49:49 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
<q-btn
|
|
|
|
|
color="primary"
|
|
|
|
|
icon="mdi-magnify"
|
|
|
|
|
label="ค้นหา"
|
|
|
|
|
@click="clickSearch(employeeClass)"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-03-08 10:49:49 +07:00
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
<div class="col-12 q-mt-sm">
|
|
|
|
|
<d-table
|
|
|
|
|
flat
|
|
|
|
|
dense
|
|
|
|
|
bordered
|
|
|
|
|
:rows="rows"
|
|
|
|
|
:columns="columns"
|
|
|
|
|
row-key="order"
|
|
|
|
|
no-data-label="ไม่มีข้อมูล"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:header="props">
|
|
|
|
|
<q-tr :props="props">
|
|
|
|
|
<q-th
|
|
|
|
|
v-for="col in props.cols"
|
|
|
|
|
:key="col.name"
|
|
|
|
|
:props="props"
|
|
|
|
|
>
|
|
|
|
|
<div class="text-grey-7 text-weight-medium">
|
|
|
|
|
<span class="row">{{ col.label }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</q-th>
|
|
|
|
|
</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-if="col.name === 'citizenId'"
|
|
|
|
|
class="text-primary"
|
|
|
|
|
@click="clickRedirect(props.row.id)"
|
|
|
|
|
>
|
|
|
|
|
{{ props.row.citizenId ?? "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
v-else-if="col.name === 'name'"
|
|
|
|
|
class="text-primary"
|
|
|
|
|
@click="clickRedirect(props.row.id)"
|
|
|
|
|
>
|
|
|
|
|
{{ props.row.name ?? "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="table_ellipsis2">
|
|
|
|
|
{{ col.value ? col.value : "-" }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
</d-table>
|
|
|
|
|
</div>
|
|
|
|
|
</q-form>
|
|
|
|
|
</q-card-section>
|
2024-03-08 10:49:49 +07:00
|
|
|
</q-card>
|
|
|
|
|
</q-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-07-09 10:17:37 +07:00
|
|
|
<style scoped></style>
|