hrms-mgt/src/modules/07_insignia/components/2_Manage/Tab1.vue
2024-11-18 13:15:01 +07:00

1543 lines
47 KiB
Vue

<script setup lang="ts">
import { onMounted, ref, computed, reactive, watch } from "vue";
import { useQuasar, QForm } from "quasar";
import { useInsigniaDataStore } from "@/modules/07_insignia/store";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import http from "@/plugins/http";
import config from "@/app.config";
/** import Type*/
import type { QTableProps } from "quasar";
import type {
OptionData,
Pagination,
DataProfileOtherSystem,
DataManageList,
} from "@/modules/07_insignia/interface/index/Main";
import type { CheckboxData } from "@/modules/07_insignia/interface/request/Main";
import type {
ResponseProfile,
ResponseInsigniaType,
} from "@/modules/07_insignia/interface/response/Main";
/** import components*/
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue";
import DialogInformation from "@/components/Dialogs/Information.vue";
import DialogHeader from "@/components/DialogHeader.vue";
import btnDownloadFile from "@/modules/07_insignia/components/2_Manage/downloadFile.vue";
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
/**use*/
const myForm = ref<QForm>();
const $q = useQuasar();
const DataStore = useInsigniaDataStore();
const mixin = useCounterMixin();
const {
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
dialogMessageNotify,
} = mixin;
/**
* 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); //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>(""); //ชื่อ 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<CheckboxData[]>([]);
const filterOrganizationOP = ref<OptionData[]>([]);
/** หัวตาราง*/
const visibleColumns = ref<string[]>([
"no",
"citizenId",
"name",
"employeeType",
"position",
"level",
"salary",
"insigniaType",
"insigniaSend",
"insigniaLevel",
"dateSend",
"note",
"warn",
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
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: "employeeType",
align: "left",
label: "สถานภาพ",
sortable: true,
field: "employeeType",
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: "salary",
align: "left",
label: "เงินเดือน",
sortable: true,
field: "salary",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "insigniaType",
align: "left",
label: "ชั้นตราเครื่องราชฯ ปัจจุบัน",
sortable: true,
field: "insigniaType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "insigniaSend",
align: "left",
label: "ประเภทเครื่องราชฯ ที่ยื่นขอ",
sortable: true,
field: "insigniaSend",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "insigniaLevel",
align: "left",
label: "ชั้นเครื่องราชฯ",
sortable: true,
field: "insigniaLevel",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "dateSend",
align: "left",
label: "วันที่ยื่นขอ",
sortable: true,
field: "dateSend",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "note",
align: "left",
label: "หมายเหตุ",
sortable: false,
field: "",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "warn",
align: "left",
label: "แจ้งเตือน",
sortable: false,
field: "",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const columns2 = ref<QTableProps["columns"]>([
{
name: "index",
required: true,
label: "ลำดับ",
field: "index",
align: "left",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "citizenId",
required: true,
label: "เลขประจำตัวประชาชน",
field: "citizenId",
align: "left",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "fullname",
required: true,
label: "ชื่อ-นามสกุล",
field: "fullname",
align: "left",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const rows2 = ref<DataProfileOtherSystem[]>([]); //รายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม
const person = ref<DataManageList>();
/** เช็คสถานนะแสดงปุ่มเพิ่ม*/
const checkStatus = computed(() => {
if (
DataStore.isStaff &&
(DataStore.requestStatus == "st1" || DataStore.requestStatus == "st4")
) {
return true;
} else return false;
});
/** เลือกหน่วยงาน*/
function changtypeOc() {
if (organization.value !== null) {
props.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
}
DataStore.typeOc = organization.value;
}
/** function เพิ่มรายชื่อ*/
async function clickmodalAdd() {
clearForm();
await fecthInsignia();
await fecthlistperson();
}
function onCloseModalAdd() {
modalAdd.value = false;
}
const maxPage = ref<number>(0);
const total = ref<number>(0);
const formFilter = reactive({
page: 1,
pageSize: 10,
searchField: "citizenId",
searchKeyword: "",
});
const filterOption = ref<OptionData[]>([
{
id: "citizenId",
name: "เลขประจำตัวประชาชน",
},
{
id: "fullName",
name: "ชื่อ - นามสกุล",
},
]);
/**
* function เรียกรายชื่อข้าราชการตามหน่วยงานที่จะเพิ่ม
* @param id หน่วยงาน
*/
async function fecthlistperson() {
showLoader();
http
.get(config.API.registryNewOtherSystem(""), { params: formFilter })
.then((res) => {
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
total.value = res.data.result.total;
let data = res.data.result.data.map((e: ResponseProfile) => ({
id: e.id,
rootId: e.rootId,
citizenId: e.citizenId,
fullname: `${e.prefix}${e.firstName} ${e.lastName}`,
position: e.position,
level: e.posLevel,
organizationOrganization: e.root,
}));
modalAdd.value = true;
rows2.value = data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** update ค่า เเถวข้อมูล */
function updatePageSize(newPagination: Pagination) {
formFilter.page = 1;
formFilter.pageSize = newPagination.rowsPerPage;
}
/** function ยืนยันการเพิ่มรายชื่อ*/
async function clickAdd() {
dataPerson.id
? await myForm.value!.validate().then((result: boolean) => {
if (result) {
dialogConfirm(
$q,
async () => {
await addlistperson(dataPerson.id);
},
"ยืนยันการเพิ่มรายชื่อคนที่ยื่นขอพระราชทานเครื่องราชฯ",
"ต้องการยืนยันการเพิ่มรายชื่อคนที่ยื่นขอพระราชทานเครื่องราชฯ นี้หรือไม่?"
);
}
})
: dialogMessageNotify($q, "กรุณาเลือกรายชื่อที่ต้องการเพิ่ม");
}
/**
* function เพิ่มรายชื่อ
* @param id personId
*/
async function addlistperson(id: string) {
showLoader();
let data = {
profileId: id,
insigniaId: insigniaType.value,
insigniaPeriodId: props.roundId,
reason: reason.value,
ocId: dataPerson.rootId,
};
await http
.post(config.API.insigniaCreate(), data)
.then(() => {
if (props.fecthInsigniaByOc) {
props.fecthInsigniaByOc(
props.roundId,
organization.value,
"officer",
props.tab
);
}
modalAdd.value = false;
success($q, "เพิ่มรายชื่อสำเร็จ");
})
.catch((err) => {
messageError($q, err);
hideLoader();
});
}
/**
* function openPopup แก้ไขเครื่องราชฯ
* @param props รายละเอียด
*/
async function clickmodalEdit(props: DataManageList) {
insignia.value = props.insigniaSend;
person.value = props;
modalEdit.value = true;
await fecthInsignia();
}
/**
* function downloadfile รายชื่อข้าราชการสามัญฯ
* @param response response
* @param filename ชื่อไฟล์
*/
async function 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);
}
/** function เรียก file รายชื่อข้าราชการสามัญฯ*/
async function downloadFileexcel() {
const findInsigniaId = DataStore.dataInsigniaType.find(
(e: ResponseInsigniaType) => e.name == DataStore.typeinsignia
);
showLoader();
await http
.put(
config.API.insigniaDowanload(DataStore.requestId),
{
profileType:
DataStore.employeeClass == "all" ? null : DataStore.employeeClass,
InsigniaId:
DataStore.typeinsignia == "all"
? null
: findInsigniaId
? findInsigniaId.id
: "",
},
{ responseType: "blob" }
)
.then(async (res) => {
await downloadFile(
res,
`รายชื่อข้าราชการสามัญฯ ${props.roundName}.xlsx`
);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function ยืนยันการแก้ไขเครื่องราช แก้ไขเครื่องราช API*/
async function clickSave() {
dialogConfirm(
$q,
async () => {
showLoader();
let data = {
insigniaId: insignia.value,
};
await http
.put(config.API.insigniaEdit(person.value ? person.value.id : ""), data)
.then(async () => {
await props?.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
success($q, "แก้ไขเครื่องราชฯ ที่ยื่นขอสำเร็จ");
modalEdit.value = false;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอ",
"ต้องการยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอนี้หรือไม่ ?"
);
}
/**
* function openPopup ไม่ยืนขอ
* @param id profileId
*/
function clickReject(id: string) {
modelPopupReject.value = true;
rowid.value = id;
}
/**
* function ยืนยันการไม่ยืนขอ
* @param reason หมายเหตุ
*/
async function savaReasonReject(reason: string) {
dialogConfirm($q, async () => {
await listreject(rowid.value, reason);
if (props.fecthStat) {
await props.fecthStat(DataStore.roundId);
}
});
}
/**
* function put ยืนยันการไม่ยืนขอ API
* @param profileId profileId
* @param reason หมายเหตุ
*/
async function listreject(profileId: string, reason: string) {
showLoader();
await http
.put(config.API.insigniaReject(profileId), { reason: reason })
.then(async () => {
await props?.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
success($q, "ย้ายข้อมูลสำเร็จ");
modelPopupReject.value = false;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function openPopup คนที่ถูกลบ*/
function clickDelete(id: string) {
modelPopupDelete.value = true;
rowid.value = id;
}
/** function closePopup คนที่ถูกลบ*/
function closemodelPopupDelete() {
modelPopupDelete.value = false;
}
/**
* function ยืนยัน การลบคนที่ถูกลบ
* @param reason หมายเหตุ
*/
async function savaReasonDelete(reason: string) {
dialogConfirm(
$q,
async () => {
await listdelete(rowid.value, reason);
if (props.fecthStat) {
await props.fecthStat(DataStore.roundId);
}
},
"ยืนยันการลบออกข้ออมูล",
"ต้องการยืนยันการลบข้อมูลนี้หรือไม่ ?"
);
}
/**
* function คนที่ถูกลบ API
* @param id profileId
* @param reason หมายเหตุ
*/
async function listdelete(id: string, reason: string) {
showLoader();
await http
.put(config.API.insigniaDelete(id), { reason: reason })
.then(async () => {
await props?.fecthInsigniaByOc?.(
props.roundId,
organization.value,
"officer",
props.tab
);
success($q, "ลบข้อมูลสำเร็จ");
closemodelPopupDelete();
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
hideLoader();
});
}
const dataPerson = reactive({
id: "",
position: "",
organizationOrganization: "",
level: "",
rootId: "",
});
const reason = ref<string>("");
/**
* function เลือกperson
* @paeam person
*/
function selectPerson(person: any) {
dataPerson.id = person.id;
dataPerson.position = person.position;
dataPerson.organizationOrganization = person.organizationOrganization;
dataPerson.level = person.level;
dataPerson.rootId = person.rootId;
}
/** function clearFormData*/
function clearForm() {
filterKeyword2.value = "";
dataPerson.id = "";
dataPerson.position = "";
dataPerson.organizationOrganization = "";
dataPerson.level = "";
reason.value = "";
insigniaType.value = "";
formFilter.page = 1;
formFilter.searchField = "citizenId";
formFilter.searchKeyword = "";
}
const insignia = ref<string>("");
const insigniaOptions = ref<OptionData[]>([]);
const insigniaType = ref<string>("");
/** function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insigniaOrg)
.then((res) => {
const listtype = res.data.result.map((e: ResponseInsigniaType) => ({
id: e.id,
name: e.name + `(${e.shortName})`,
}));
insigniaOptions.value = listtype;
})
.catch((e) => {
messageError($q, e);
});
}
const personId = ref<string>("");
/**
* function redirect to ทะเบียนประวัติ
* @param id profileId
*/
function nextPage(id: string) {
modalPersonal.value = true;
personId.value = id;
}
function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal;
}
/** ค้นหาข้อมุล table*/
const filterKeyword = ref<string>("");
const filterKeyword2 = ref<string>("");
const filterRef = ref<any>(null);
const resetFilter = () => {
filterKeyword.value = "";
filterKeyword2.value = "";
filterRef.value.focus();
};
const pagination = ref({
sortBy: "name",
descending: false,
page: 1,
rowsPerPage: 10,
});
const pagination2 = ref({
sortBy: "fullname",
descending: false,
page: 1,
rowsPerPage: 10,
});
/** function closePopup แก้ไข*/
function closeModalEdit() {
modalEdit.value = false;
}
/**
* function openPopup แสดงหมายเหตุ
* @param name ชื่อ
* @param requestNote หมายเหตุ
*/
function clickShowreson(name: string, requestNote: string) {
dialogTitle.value = "หมายเหตุ" + name;
dialogDesc.value = requestNote;
dialogNote.value = true;
}
/** function closePopu หมายเหตุ*/
function clickCloseReson() {
dialogNote.value = false;
}
/**
* function แสดงแจ้งเตือน
* @param markDiscipline มีโทษทางวินัย
* @param markLeave ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน
* @param markRate ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)
*/
function clickShowWarn(
markDiscipline: boolean,
markLeave: boolean,
markRate: boolean
) {
checkboxData.value = [
{ id: 1, name: "มีโทษทางวินัย", val: markDiscipline },
{
id: 2,
name: "ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น เนื่องจากลาเกิน",
val: markLeave,
},
{
id: 3,
name: "ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี ต่ำกว่าระดับดี (น้อยกว่าร้อยละ 70)",
val: markRate,
},
];
dialogWarn.value = true;
}
/**
* 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 === "typeinsigniaOptions") {
DataStore.typeinsignia = "";
typeinsigniaOptions.value = DataStore.typeinsigniaOptions.filter(
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "employeeClassOps") {
DataStore.employeeClass = "";
employeeClassOps.value = DataStore.employeeClassOps.filter(
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
} else if (name === "filterOrganizationOP") {
filterOrganizationOP.value = DataStore.optionsTypeOc.filter(
(v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1
);
}
});
}
/**
* function clearfilter เครื่องราช
* @param name ชื่อ selec
*/
function clearInsigniaFilters(name: string) {
if (name === "typeinsigniaOptions") {
DataStore.typeinsignia = "all";
typeinsigniaOptions.value = DataStore.typeinsigniaOptions;
} else if (name === "employeeClassOps") {
DataStore.employeeClass = "all";
employeeClassOps.value = DataStore.employeeClassOps;
}
}
watch(
() => DataStore.typeOc,
async () => {
filterOrganizationOP.value = await DataStore.optionsTypeOc;
organization.value = await DataStore.typeOc;
}
);
/** เช็คเเถวข้อมูลว่ามีการเปลี่ยนแปลงไหม */
watch(
() => formFilter.pageSize,
() => {
fecthlistperson();
}
);
/** Hook*/
onMounted(async () => {
filterOrganizationOP.value = await DataStore.optionsTypeOc;
organization.value = DataStore.typeOc;
if (organization.value !== "" || organization.value !== undefined) {
if (props.fecthInsigniaByOc) {
props.fecthInsigniaByOc(
props.roundId,
organization.value,
"officer",
props.tab
);
DataStore.mainTab = props.tab;
}
}
});
</script>
<template>
<div class="col-12 row q-pa-md">
<div class="row col-12">
<div class="row col-12 q-col-gutter-sm">
<q-select
v-if="DataStore.isOfficer"
v-model="organization"
label="หน่วยงาน"
dense
emit-value
map-options
:options="filterOrganizationOP"
option-value="id"
option-label="name"
lazy-rules
use-input
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
style="width: 400px"
@update:model-value="changtypeOc"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'filterOrganizationOP'
)"
/>
<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"
style="min-width: 140px"
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
:class="DataStore.isOfficer ? 'col-1' : 'col-3'"
v-model="DataStore.typeinsignia"
label="ประเภทเครื่องราชฯ ที่ยืนขอ"
dense
emit-value
map-options
:options="typeinsigniaOptions"
option-value="id"
option-label="name"
lazy-rules
hide-bottom-space
use-input
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
style="min-width: 320px"
@update:model-value="
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'typeinsigniaOptions'
)"
>
<template v-if="DataStore.typeinsignia !== 'all'" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="
clearInsigniaFilters('typeinsigniaOptions'),
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
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>
<q-select
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="width: 280px"
@update:model-value="
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'employeeClassOps'
)"
>
<template v-if="DataStore.employeeClass !== 'all'" v-slot:append>
<q-icon
name="cancel"
@click.stop.prevent="
clearInsigniaFilters('employeeClassOps'),
DataStore.searchDataTable(
DataStore.typeinsignia,
DataStore.employeeClass
)
"
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>
<q-space />
<div>
<q-btn
v-if="checkPermission($route)?.attrIsGet"
:disable="
DataStore.employeeClass === 'all' ||
DataStore.typeinsignia === 'all'
"
icon="mdi-download"
flat
round
color="primary"
@click="downloadFileexcel"
>
<q-tooltip>ดาวน์โหลด</q-tooltip>
</q-btn>
<q-btn
flat
round
color="add"
icon="mdi-plus"
@click="clickmodalAdd"
v-if="
(DataStore.isLock == false &&
DataStore.requestStatus == 'st5' &&
DataStore.isOfficer) ||
(checkStatus == true && checkPermission($route)?.attrIsCreate)
"
>
<q-tooltip>เพิ่ม</q-tooltip>
</q-btn>
</div>
</div>
</q-card>
<div class="col-12 q-pt-sm">
<d-table
ref="table"
:columns="columns"
:rows="DataStore.rows"
:filter="filterKeyword"
row-key="name"
flat
bordered
:paging="true"
dense
class="custom-header-table"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th
auto-width
v-if="
(DataStore.isLock == false &&
DataStore.requestStatus == 'st5') ||
checkStatus == true
"
/>
<q-th v-else auto-width></q-th>
<q-th auto-width></q-th>
<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
v-if="
(DataStore.isLock == false &&
DataStore.requestStatus == 'st5' &&
DataStore.isOfficer) ||
checkStatus == true
"
>
<q-btn
v-if="
DataStore.isOfficer ||
(DataStore.isStaff &&
(requestStatus == 'st1' || requestStatus == 'st4') &&
(checkPermission($route)?.attrIsGet ||
checkPermission($route)?.attrIsUpdate))
"
flat
dense
color="secondary"
icon="mdi-dots-horizontal-circle-outline"
round
>
<q-menu transition-show="jump-down" transition-hide="jump-up">
<q-list dense>
<!-- ดูข้อมูลทะเบียนประวัติ -->
<q-item
v-if="checkPermission($route)?.attrIsGet"
clickable
@click.stop="nextPage(props.row.profileId)"
v-close-popup
>
<q-item-section style="min-width: 0px" avatar>
<q-icon color="info" size="xs" name="mdi-eye" />
</q-item-section>
<q-item-section>ดูข้อมูลทะเบียนประวัติ</q-item-section>
</q-item>
<!-- แก้ไขเครื่องราชฯ ที่ยื่นขอ -->
<q-item
v-if="
checkPermission($route)?.attrIsGet &&
checkPermission($route)?.attrIsUpdate
"
clickable
@click.stop="clickmodalEdit(props.row)"
v-close-popup
>
<q-item-section style="min-width: 0px" avatar>
<q-icon color="edit" size="xs" name="edit" />
</q-item-section>
<q-item-section
>แก้ไขเครื่องราชฯ ที่ยื่นขอ</q-item-section
>
</q-item>
<!-- ไม่ยื่นขอ -->
<q-item
v-if="checkPermission($route)?.attrIsUpdate"
clickable
@click.stop="clickReject(props.row.id)"
v-close-popup
>
<q-item-section style="min-width: 0px" avatar>
<q-icon
color="blue"
size="xs"
name="mdi-alert-circle-outline"
/>
</q-item-section>
<q-item-section>ไม่ยื่นขอ</q-item-section>
</q-item>
<!-- ลบออก -->
<q-item
v-if="checkPermission($route)?.attrIsUpdate"
clickable
@click.stop="clickDelete(props.row.id)"
v-close-popup
>
<q-item-section style="min-width: 0px" avatar>
<q-icon color="red" size="xs" name="delete" />
</q-item-section>
<q-item-section>ลบออก</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
<q-td v-else auto-width>
<q-btn
v-if="checkPermission($route)?.attrIsGet"
icon="mdi-eye"
color="info"
flat
round
dense
@click.stop="nextPage(props.row.profileId)"
>
<q-tooltip>ดูข้อมูลทะเบียนประวัติ</q-tooltip>
</q-btn>
</q-td>
<q-td auto-width>
<btnDownloadFile
v-if="
props.row.insigniaSend == 'เหรียญจักรพรรดิมาลา' &&
checkPermission($route)?.attrIsGet
"
:profileId="props.row.profileId"
:round="DataStore.roundId"
:optionRound="DataStore.optionRound"
/>
</q-td>
<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="employeeType" :props="props">
{{ props.row.employeeType }}
</q-td>
<q-td key="position" :props="props">
{{ props.row.position }}
</q-td>
<q-td key="level" :props="props">
{{ props.row.level }}
</q-td>
<q-td key="salary" :props="props">
{{ Number(props.row.salary).toLocaleString() }}
</q-td>
<q-td key="insigniaType" :props="props">
{{ props.row.insigniaType }}
</q-td>
<q-td key="insigniaSend" :props="props">
{{ props.row.insigniaSend }}
</q-td>
<q-td key="insigniaLevel" :props="props">
{{ props.row.insigniaLevel }}
</q-td>
<q-td key="dateSend" :props="props">
{{ props.row.dateSend }}
</q-td>
<q-td key="note" class="text-center">
<q-btn
v-if="props.row.reason && checkPermission($route)?.attrIsGet"
icon="mdi-information-outline"
color="blue"
flat
round
dense
@click.stop="clickShowreson(props.row.name, props.row.reason)"
>
<q-tooltip>หมายเหตุ</q-tooltip>
</q-btn>
</q-td>
<q-td key="warn" class="text-center">
<q-btn
v-if="
props.row.statusMark && checkPermission($route)?.attrIsGet
"
icon="mdi-information-outline"
color="red"
flat
round
dense
@click.stop="
clickShowWarn(
props.row.markDiscipline,
props.row.markLeave,
props.row.markRate
)
"
>
<q-tooltip>แจ้งเตือน</q-tooltip></q-btn
>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</div>
</div>
<!-- add -->
<q-dialog v-model="modalAdd" persistent>
<q-card style="width: 900px; max-width: 80vw">
<DialogHeader tittle="เพิ่มรายชื่อ" :close="onCloseModalAdd" />
<q-separator />
<q-card-section class="q-pa-sm bg-grey-1">
<div class="row col-12 q-col-gutter-sm">
<div class="col-xs-12 col-sm-7">
<q-card flat bordered class="fit q-pa-sm">
<q-toolbar style="padding: 0">
<q-space />
<div class="row q-col-gutter-sm">
<q-select
dense
outlined
label="ค้นหาจาก"
v-model="formFilter.searchField"
option-label="name"
option-value="id"
:options="filterOption"
map-options
emit-value
@update:model-value="formFilter.searchKeyword = ''"
/>
<q-input
borderless
outlined
dense
debounce="300"
placeholder="ค้นหา"
v-model="formFilter.searchKeyword"
@keydown.enter="(formFilter.page = 1), fecthlistperson()"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
</q-toolbar>
<d-table
flat
bordered
dense
:rows="rows2"
:columns="columns2"
row-key="fullname"
class="custom-header-table"
v-model:pagination="pagination2"
:rows-per-page-options="[20, 25, 50, 100]"
@update:pagination="updatePageSize"
>
<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-tr>
</template>
<template v-slot:body="props">
<q-tr
:props="props"
class="cursor-pointer"
:class="{ 'text-primary': props.row.id === dataPerson.id }"
@click="selectPerson(props.row)"
>
<q-td style="width: 75px">
{{
(formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1
}}</q-td
>
<q-td style="width: 250px" key="citizenId" :props="props">
{{ props.row.citizenId }}
</q-td>
<q-td key="fullname" :props="props">
{{ props.row.fullname }}
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
ทั้งหมด {{ total }} รายการ
<q-pagination
v-model="formFilter.page"
active-color="primary"
color="dark"
:max="Number(maxPage)"
:max-pages="5"
size="sm"
boundary-links
direction-links
@update:model-value="fecthlistperson()"
></q-pagination>
</template>
</d-table>
</q-card>
</div>
<div class="col-xs-12 col-sm-5">
<q-card flat bordered class="fit q-pa-sm">
<q-form ref="myForm">
<div class="q-pa-md">
<div class="row q-gutter-sm">
<div class="col-12">
<q-input
borderless
outlined
dense
label="ตำแหน่งในสายงาน"
placeholder="ตำแหน่งในสายงาน"
v-model="dataPerson.position"
readonly
/>
</div>
<div class="col-12">
<q-input
borderless
outlined
dense
label="สังกัด"
placeholder="สังกัด"
v-model="dataPerson.organizationOrganization"
readonly
/>
</div>
<div class="col-12">
<q-input
borderless
outlined
dense
label="ระดับ"
placeholder="ระดับ "
v-model="dataPerson.level"
readonly
/>
</div>
<div class="col-12">
<q-select
v-model="insigniaType"
label="ประเภทเครื่องราชฯ"
dense
emit-value
map-options
:options="insigniaOptions"
option-value="id"
option-label="name"
lazy-rules
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
:rules="[
(val:string) => !!val || `กรุณาเลือกประเภทเครื่องราช`,
]"
/>
</div>
<div class="col-12">
<q-input
type="textarea"
class="full-width inputgreen cursor-pointer"
hide-bottom-space
outlined
dense
lazy-rules
:rules="[(val:string) => !!val || `กรุณากรอกหมายเหตุ`]"
v-model="reason"
:label="`หมายเหตุ`"
/>
</div>
</div>
</div>
</q-form>
</q-card>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn unelevated label="บันทึก" color="public" @click="clickAdd">
<q-tooltip>นท</q-tooltip>
</q-btn>
</q-card-actions>
</q-card>
</q-dialog>
<!-- Edit -->
<q-dialog v-model="modalEdit" persistent>
<q-card style="width: 450px; max-width: 80vw">
<q-form ref="myForm">
<DialogHeader
tittle="แก้ไขเครื่องราชฯ ที่ยื่นขอ"
:close="closeModalEdit"
/>
<q-separator />
<q-card-section class="q-pa-sm bg-grey-1">
<div class="row col-12 q-py-md">
<q-select
v-model="insignia"
label="ชื่อเครื่องราชฯ"
dense
emit-value
map-options
:options="insigniaOptions"
option-value="id"
option-label="name"
lazy-rules
hide-bottom-space
:readonly="false"
:borderless="false"
:outlined="true"
:hide-dropdown-icon="false"
style="width: 100%"
/>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
@click="clickSave"
class="q-px-md"
>
<q-tooltip>นท</q-tooltip>
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
<!-- popup เหตผลไมนขอ -->
<DialogPopupReason
v-model:modal="modelPopupReject"
title="เหตุผลการไม่ยื่นขอ"
label="หมายเหตุ"
:savaForm="savaReasonReject"
/>
<!-- เหตผลทลบออก -->
<DialogPopupReason
v-model:modal="modelPopupDelete"
title="เหตุผลการลบออก"
label="หมายเหตุ"
:click-close="closemodelPopupDelete"
:savaForm="savaReasonDelete"
/>
<!-- หมายเหต -->
<DialogInformation
:modal="dialogNote"
:title="dialogTitle"
:desc="dialogDesc"
:click-close="clickCloseReson"
/>
<!-- แจงเตอน -->
<q-dialog v-model="dialogWarn" persistent>
<q-card style="width: 800px; max-width: 80vw">
<q-toolbar class="q-py-md">
<q-toolbar-title class="text-h6">แจงเตอน </q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
v-close-popup
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
<q-separator />
<div class="q-pa-md">
<div class="q-gutter-sm">
<q-item
tag="label"
v-ripple
v-for="list in checkboxData"
:key="list.id"
>
<q-item-section avatar>
<q-checkbox
v-model="list.val"
:val="`${list.id}`"
color="teal"
disable
/>
<!-- <q-radio v-model="checkboxList" :val="list.id" color="teal" /> -->
</q-item-section>
<q-item-section>
<q-item-label>{{ list.name }}</q-item-label>
</q-item-section>
</q-item>
</div>
</div>
</q-card>
</q-dialog>
<PopupPersonal
:modal="modalPersonal"
:id="personId"
@update:modal="updatemodalPersonal"
/>
</template>