hrms-mgt/src/modules/05_placement/views/07_appointEmployeeMain.vue

547 lines
18 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
2024-09-19 15:02:44 +07:00
import { checkPermission } from "@/utils/permissions";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/05_placement/store";
2024-09-19 15:02:44 +07:00
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
2024-06-12 13:12:12 +07:00
import type {
listAppointType,
resData,
} from "@/modules/05_placement/interface/response/AppointMent";
import type { OpType } from "@/modules/05_placement/interface/response/Main";
import DialogOrgSelectEmployee from "@/components/Dialogs/DialogOrgSelectEmployee.vue"; //เลือกหน่วยงาน
2024-09-19 15:02:44 +07:00
import Dialogbody from "@/modules/05_placement/components/AppointEmployee/DialogOrders.vue";
2024-05-17 16:37:55 +07:00
const $q = useQuasar();
2024-09-19 15:02:44 +07:00
const router = useRouter();
const storeFn = useTransferDataStore();
const { statusText } = storeFn;
const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง
const {
showLoader,
hideLoader,
success,
messageError,
date2Thai,
dialogRemove,
} = mixin;
const personalId = ref<string>("");
2024-09-19 15:02:44 +07:00
const modal = ref<boolean>(false); //แสดง popup ส่งไปออกคำสั่ง
const modalTree = ref<boolean>(false); //แสดง popup เลือกหน่วยงานที่รับการปรับระดับชั้นงาน
const typeModal = ref<string>(""); //ประเภท popup ปรับระดับชั้นงาน,รับย้าย
const posType = ref<string>(""); //ประเภทตำแหน่ง
const posLevel = ref<string>(""); //ระดับตำแหน่ง
const position = ref<string>(""); //ตำแหน่ง
const dataRows = ref<any[]>([]);
const filterRef = ref<any>(null);
2024-09-19 15:02:44 +07:00
const listRecevice = ref<resData[]>([]); //ข้อมูลรายการปรับระดับชั้นงานลูกจ้าง
const optionsType = ref<OpType[]>([]);
const type = ref<string>("");
2024-09-19 15:02:44 +07:00
// Table
const rows = ref<listAppointType[]>([]); //รายการปรับระดับชั้นงานลูกจ้าง
const rows2 = ref<listAppointType[]>([]); //รายการออกคำสั่ง
const filterKeyword = ref<string>(""); //คำค้นหารายการปรับระดับชั้นงานลูกจ้าง
const filterKeyword2 = ref<string>(""); //คำค้นหารายการออกคำสั่ง
const visibleColumns = ref<string[]>([
"no",
"citizenId",
"fullname",
"organizationName",
"dateOfBirth",
"createdAt",
"status",
]);
const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
});
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: "fullname",
align: "left",
label: "ชื่อ-นามสกุล",
sortable: true,
field: "fullname",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "organizationName",
align: "left",
label: "หน่วยงานที่รับปรับระดับชั้นงาน-ย้าย",
sortable: true,
field: "organizationName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "dateOfBirth",
align: "left",
label: "วัน/เดือน/ปี เกิด",
sortable: true,
field: "dateOfBirth",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "createdAt",
align: "left",
label: "วันที่ดำเนินการ",
sortable: true,
field: "createdAt",
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",
},
]);
/**
* เซ input
*/
function resetFilter() {
filterKeyword.value = "";
filterKeyword2.value = "";
filterRef.value.focus();
}
/**
* fetch รายการปรบระดบชนงานลกจาง
*/
2024-09-19 15:02:44 +07:00
async function fecthlistappointment() {
showLoader();
2024-09-19 15:02:44 +07:00
await http
.get(config.API.appointEmployee())
2024-09-19 15:02:44 +07:00
.then(async (res) => {
let response = await res.data.result;
listRecevice.value = response;
rows.value = response;
2024-05-17 16:37:55 +07:00
//หารายชื่อส่งไปออกคำสั่ง
rows2.value = rows.value.filter(
2024-05-17 16:37:55 +07:00
(e: any) =>
e.root !== null &&
e.status !== "REPORT" &&
e.status !== "DONE" &&
e.educationOld &&
e.organizationPositionOld &&
e.positionTypeOld &&
e.positionLevelOld &&
e.positionNumberOld &&
e.salary !== null &&
e.positionDate
);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* นยนลบรายการปรบระดบชนงานลกจาง
* @param id รายการปรบระดบชนงานลกจาง
*/
2024-09-19 15:02:44 +07:00
function clickDelete(id: string) {
dialogRemove($q, () => {
showLoader();
http
.delete(config.API.appointEmployeeByid(id))
.then(async () => {
await fecthlistappointment();
await success($q, "ลบข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
2024-09-19 15:02:44 +07:00
}
/**
* redialect รายละเอยดการปรบระดบชนงานลกจาง
* @param id รายการปรบระดบชนงานลกจาง
*/
function nextPage(id: string) {
router.push({
path: `appoint-employee/detail/${id}`,
});
}
/**
* เป popup งไปออกคำส
*/
function popup() {
modal.value = true;
filterKeyword2.value = "";
}
/**
* popup งไปออกคำส
*/
function clickClose() {
modal.value = false;
}
2024-05-17 16:37:55 +07:00
/**
* เป popup เลอกหนวยงาน
* @param data อมลหนวยงาน
* @param type ประเภท าย,ปร
*/
function openModalTree(data: any, type: string) {
2024-05-17 17:20:50 +07:00
typeModal.value = type;
2024-05-17 16:37:55 +07:00
personalId.value = data.id;
dataRows.value = data;
posType.value = data.posTypeNameOld;
posLevel.value = data.posLevelNameOld;
position.value = data.positionOld;
modalTree.value = true;
2024-05-17 16:37:55 +07:00
}
/**
* นยนการบนทกขอมลเลอกตำแหน
*/
2024-05-17 16:37:55 +07:00
function onSave(data: any) {
const dataAppoint = {
node: data.node,
nodeId: data.nodeId,
orgRevisionId: data.orgRevisionId,
positionId: data.positionId,
posMasterNo: data.posMasterNo,
positionName: data.positionName,
posTypeId: data.posTypeId,
posTypeName: data.posTypeName,
posLevelId: data.posLevelId,
posLevelName: data.posLevelName,
reportingDate: data.reportingDate,
posmasterId: data.posmasterId,
2024-05-17 17:20:50 +07:00
typeCommand: data.typeCommand,
2024-05-17 16:37:55 +07:00
};
showLoader();
http
.put(config.API.appointmentPosition(personalId.value), dataAppoint)
.then(async () => {
await fecthlistappointment();
await success($q, "บันทึกสำเร็จ");
2024-05-17 16:37:55 +07:00
modalTree.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
2024-05-17 16:37:55 +07:00
hideLoader();
});
}
2024-09-19 15:02:44 +07:00
onMounted(() => {
fecthlistappointment();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายการปรบระดบชนงานลกจาง
</div>
<q-card flat bordered class="col-12 q-mt-sm">
<q-separator />
<div class="row q-pa-md">
<div class="col-12">
<div class="row col-12">
<q-btn
v-if="checkPermission($route)?.attrIsUpdate"
@click="popup()"
size="14px"
flat
round
color="add"
icon="mdi-account-arrow-right"
>
<q-tooltip>งไปออกคำส</q-tooltip>
</q-btn>
<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 q-ml-sm"
/>
</div>
<div class="col-12 q-pt-sm">
<d-table
:columns="columns"
:rows="rows"
:filter="filterKeyword"
row-key="citizenId"
:visible-columns="visibleColumns"
v-model:pagination="pagination"
>
<template v-slot:header="props">
<q-tr :props="props">
2024-07-26 16:25:10 +07:00
<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="
(props.row.status !== 'REPORT' &&
props.row.status !== 'DONE' &&
checkPermission($route)?.attrIsGet) ||
(checkPermission($route)?.attrIsDelete &&
props.row.status !== 'REPORT' &&
props.row.status !== 'DONE') ||
(checkPermission($route)?.attrIsGet &&
checkPermission($route)?.attrIsDelete) ||
checkPermission($route)?.attrIsGet
"
icon="mdi-dots-horizontal-circle-outline"
color="secondary"
flat
round
dense
>
<q-menu
transition-show="jump-down"
transition-hide="jump-up"
>
<q-list dense style="min-width: 200px">
2024-05-17 16:37:55 +07:00
<q-item
v-if="
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrIsGet &&
props.row.status !== 'REPORT' &&
props.row.status !== 'DONE'
"
2024-05-17 16:37:55 +07:00
clickable
v-close-popup
@click="openModalTree(props.row, 'SLIP')"
2024-05-17 17:20:50 +07:00
>
<q-item-section style="min-width: 0px" avatar>
2024-05-17 17:20:50 +07:00
<q-icon
color="primary"
size="xs"
name="mdi-bookmark-outline"
/>
</q-item-section>
<q-item-section
>เลอกหนวยงานทบปรบระดบชนงาน</q-item-section
>
2024-05-17 17:20:50 +07:00
</q-item>
<q-item
v-if="
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrIsGet &&
props.row.status !== 'REPORT' &&
props.row.status !== 'DONE'
"
2024-05-17 17:20:50 +07:00
clickable
v-close-popup
@click="openModalTree(props.row, 'MOVE')"
2024-05-17 16:37:55 +07:00
>
<q-item-section style="min-width: 0px" avatar>
2024-05-17 16:37:55 +07:00
<q-icon
color="primary"
size="xs"
name="mdi-bookmark-outline"
/>
</q-item-section>
<q-item-section
>เลอกหนวยงานทบยาย</q-item-section
>
</q-item>
<q-item
v-if="checkPermission($route)?.attrIsGet"
clickable
v-close-popup
@click="nextPage(props.row.id)"
>
<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)?.attrIsDelete &&
props.row.status !== 'REPORT' &&
props.row.status !== 'DONE'
"
clickable
v-close-popup
2024-05-17 16:37:55 +07:00
@click="clickDelete(props.row.id)"
>
<q-item-section style="min-width: 0px" avatar>
<q-icon color="red" size="xs" name="mdi-delete" />
</q-item-section>
<q-item-section>ลบ</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
2024-08-13 09:47:49 +07:00
<q-td v-for="col in props.cols" :key="col.name" :props="props">
2024-07-26 16:25:10 +07:00
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'fullname'">
{{
props.row.firstName
? `${props.row.prefix ?? ""}${
props.row.firstName ?? ""
} ${props.row.lastName ?? ""}`
: "-"
}}
</div>
<div v-else-if="col.name == 'status'">
{{ props.row.status ? statusText(props.row.status) : "-" }}
</div>
<div v-else-if="col.name == 'dateOfBirth'">
{{
props.row.dateOfBirth
? date2Thai(props.row.dateOfBirth)
: "-"
}}
</div>
<div v-else-if="col.name == 'organizationName'">
<div class="col-4">
<div class="text-weight-medium">
{{ props.row.root !== null ? props.row.root : "-" }}
{{
props.row.rootShortName !== null
? `(${props.row.rootShortName})`
: ""
}}
</div>
<div class="text-weight-light">
{{
props.row.nodeName !== null ? props.row.nodeName : ""
}}
{{
props.row.nodeShortName !== null
? `(${props.row.nodeShortName}${props.row.posMasterNo})`
: ""
}}
</div>
</div>
</div>
<div v-else-if="col.name == 'createdAt'">
{{
props.row.createdAt ? date2Thai(props.row.createdAt) : "-"
}}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</div>
</div>
</q-card>
<Dialogbody
v-model:Modal="modal"
2024-09-19 15:02:44 +07:00
v-model:filter-keyword2="filterKeyword2"
v-model:type="type"
2024-09-19 15:02:44 +07:00
:click-close="clickClose"
:options-type="optionsType"
:rows2="rows2"
:next-page="nextPage"
:fetch-data="fecthlistappointment"
/>
2024-05-17 16:37:55 +07:00
<DialogOrgSelectEmployee
:title="`เลือกหน่วยงานที่รับการปรับระดับชั้นงาน`"
v-model:modal="modalTree"
2024-05-17 17:20:50 +07:00
v-model:type="typeModal"
2024-09-19 15:02:44 +07:00
:pos-type="posType"
:pos-level="posLevel"
2024-05-17 16:37:55 +07:00
:position="position"
2024-09-19 15:02:44 +07:00
:data-rows="dataRows"
2024-05-17 16:37:55 +07:00
:onSubmit="onSave"
/>
</template>
<style scoped lang="scss"></style>