เเบบร่าง(ไม่สมบูรณ์) popup รายการแต่งตั้งลูกจ้างประจำ

This commit is contained in:
setthawutttty 2023-10-10 16:13:33 +07:00
parent f013815908
commit 1077c48c8d

View file

@ -7,6 +7,7 @@ import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/05_placement/store";
import Dialogbody from "@/modules/05_placement/components/AppointEmployee/Dialogbody.vue";
import DialogOrgTree from "@/modules/05_placement/components/AppointEmployee/Modal.vue";
import DialogHeader from "@/modules/05_placement/components/AppointMent/DialogHeader.vue";
import type {
listAppointType,
resData,
@ -28,12 +29,15 @@ const {
messageError,
date2Thai,
dialogRemove,
dialogConfirm,
dialogMessageNotify
} = mixin;
const rowsPosition = ref<any>([]);
const router = useRouter();
const rows = ref<listAppointType[]>([]);
const rows2 = ref<listAppointType[]>([]);
const modalTree = ref<boolean>(false);
const ModalEmployee = ref<boolean>(false)
const personal = ref<resData[]>([]);
const personalId = ref<string>("");
const filterKeyword = ref<string>("");
@ -42,7 +46,7 @@ const filterRef = ref<any>(null);
const listRecevice = ref<resData[]>([]);
const optionsType = ref<OpType[]>([]);
const type = ref<string>("");
const selectedPosition = ref<any>([]);
const visibleColumns = ref<string[]>([
"no",
"citizenId",
@ -52,12 +56,124 @@ const visibleColumns = ref<string[]>([
"createdAt",
"status",
]);
const visibleColumnsPosition = ref<String[]>([
"organizationOrganizationName",
"organizationAgencyName",
"organizationGovernmentAgencyName",
"organizationShortNameName",
"organizationTypeName",
"organizationLevelName",
"positionEmployeeLineName",
"positionEmployeePositionName",
"posNo",
]);
const pagination = ref({
sortBy: "createdAt",
descending: true,
page: 1,
rowsPerPage: 10,
});
const columnsPosition = ref<QTableProps["columns"]>([
{
name: "organizationOrganizationName",
align: "left",
label: "หน่วยงาน",
sortable: true,
field: "organizationOrganizationName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "organizationAgencyName",
align: "left",
label: "รหัสหน่วยงาน",
sortable: true,
field: "organizationAgencyName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "organizationGovernmentAgencyName",
align: "left",
label: "รหัสส่วนราชการ",
sortable: true,
field: "organizationGovernmentAgencyName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "organizationShortNameName",
align: "left",
label: "ชื่อย่อหน่วยงาน",
sortable: true,
field: "organizationShortNameName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "organizationTypeName",
align: "left",
label: "ประเภทหน่วยงาน",
sortable: true,
field: "organizationTypeName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "organizationLevelName",
align: "left",
label: "ระดับหน่วยงาน",
sortable: true,
field: "organizationLevelName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionEmployeeLineName",
align: "left",
label: "สายงาน",
sortable: true,
field: "positionEmployeeLineName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "positionEmployeePositionName",
align: "left",
label: "ตำแหน่ง",
sortable: true,
field: "positionEmployeePositionName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "posNo",
align: "left",
label: "เลขที่ตำแหน่ง",
sortable: true,
field: "posNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -201,10 +317,79 @@ const fecthTypeOption = async () => {
});
};
//
const openModalTree = (id: string) => {
const openModalEmployee = async(id: string) => {
personalId.value = id;
personal.value = listRecevice.value.filter((e) => e.id === id);
modalTree.value = true;
await getPosition(id)
};
const getPosition = async (id:string) => {
showLoader();
await http
.get(config.API.organizationEmployeePositionId(id))
.then((res) => {
const { result } = res.data;
let data: any[] = [];
result.map((r: any) => {
data.push({
id: r.id,
agency: r.agency,
conditionNote: r.conditionNote,
department: r.department,
government: r.government,
isActive: r.isActive,
isCondition: r.isCondition,
isDirector: r.isDirector,
organizationUserNote: r.organizationUserNote,
qualification: r.qualification,
pile: r.pile,
posNo: r.posNo,
positionCondition: r.positionCondition,
positionMasterUserNote: r.positionMasterUserNote,
organizationOrder: r.organizationOrder,
organizationFaxId: r.organizationFaxId,
organizationLevelId: r.organizationLevelId,
organizationOrganizationId: r.organizationOrganizationId,
organizationTelExternalId: r.organizationTelExternalId,
organizationTelInternalId: r.organizationTelInternalId,
organizationTypeId: r.organizationTypeId,
positionEmployeeStatusId: r.positionEmployeeStatusId,
positionEmployeeLineId: r.positionEmployeeLineId,
positionEmployeePositionId: r.positionEmployeePositionId,
organizationAgencyId: r.organizationAgencyId,
organizationGovernmentAgencyId: r.organizationGovernmentAgencyId,
organizationShortNameId: r.organizationShortNameId,
organizationFaxName: r.organizationFaxName,
organizationLevelName: r.organizationLevelName,
organizationOrganizationName: r.organizationOrganizationName,
organizationTelExternalName: r.organizationTelExternalName,
organizationTelInternalName: r.organizationTelInternalName,
organizationTypeName: r.organizationTypeName,
positionEmployeeStatusName: r.positionEmployeeStatusName,
positionEmployeeLineName: r.positionEmployeeLineName,
positionEmployeePositionName: r.positionEmployeePositionName,
organizationAgencyName: r.organizationAgencyName,
organizationGovernmentAgencyName: r.organizationGovernmentAgencyName,
organizationShortNameName: r.organizationShortNameName,
positionEmployeeLevels: r.positionEmployeeLevels,
positionEmployeePositionSides: r.positionEmployeePositionSides,
use: r.use,
});
});
const index = data.findIndex((r: any) => r.use == true);
if (index >= 0) {
selectedPosition.value = [data[index]];
}
rowsPosition.value = data;
ModalEmployee.value = true;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
};
//
const clickDelete = (id: string) => {
@ -247,6 +432,7 @@ const resetFilter = () => {
// modal
const clickClose = () => {
modal.value = false;
ModalEmployee.value = false;
};
// modal
const popup = () => {
@ -254,6 +440,51 @@ const popup = () => {
filterKeyword2.value = "";
fecthTypeOption();
};
const checkSave = () => {
dialogConfirm($q, async () => await saveData());
};
//
const saveData = async () => {
if (selectedPosition.value.length == 0) {
dialogMessageNotify($q, "ไม่สามารถบันทึกข้อมูลได้ กรุณาเลือกตำแหน่ง");
return;
} else {
await savePosition();
}
};
//
const savePosition = async () => {
clickClose();
// showLoader();
// const data = {
// organizationEmployeeId: selectedPosition.value[0].id,
// };
// await http
// .put(config.API.organizationEmployeePositionId(id.value), data)
// .then((res) => {
// success($q, "");
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// await nodeTree();
// clickClose();
// });
};
// // dialog
// const modalOpenClose = () => {
// modal.value = !modal.value;
// if (!modal.value) {
// selectedPosition.value = [];
// rowsPosition.value = [];
// id.value = "";
// }
// };
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
@ -438,7 +669,7 @@ const popup = () => {
<q-item
clickable
v-close-popup
@click="openModalTree(props.row.personalId)"
@click="openModalEmployee(props.row.personalId)"
>
<q-item-section
style="min-width: 0px"
@ -479,7 +710,85 @@ const popup = () => {
</div>
</div>
</q-card>
<q-dialog v-model="ModalEmployee" persistent>
<q-card style="width: 70vw; max-width: 70vw">
<DialogHeader title="กำหนดตำแหน่ง" :close="clickClose" />
<q-separator />
<q-card-section class="q-pa-sm">
<div class="row justify-end">
<div class="col-5">
<q-toolbar style="padding: 0">
<q-input
borderless
outlined
dense
ref="filterRef"
debounce="300"
v-model="filterKeyword2"
placeholder="ค้นหา"
style="width: 850px; max-width: auto"
>
<template v-slot:append>
<q-icon v-if="filterKeyword2 == ''" name="search" />
<q-icon
v-if="filterKeyword2 !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<q-select
v-model="visibleColumnsPosition"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columnsPosition"
option-value="name"
options-cover
style="min-width: 150px"
class="gt-xs q-ml-sm"
/>
</q-toolbar>
</div>
</div>
<d-table
:rows="rowsPosition"
:columns="columnsPosition"
:filter="filterKeyword2"
row-key="id"
selection="single"
v-model:selected="selectedPosition"
:visible-columns="visibleColumnsPosition"
>
<template v-slot:body-selection="scope">
<q-checkbox
keep-color
color="primary"
dense
v-model="scope.selected"
/>
</template>
</d-table>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
dense
unelevated
label="บันทึก"
color="public"
@click="checkSave"
class="q-px-md"
>
</q-btn>
</q-card-actions>
</q-card>
</q-dialog>
<Dialogbody
v-model:Modal="modal"
:clickClose="clickClose"