Refactoring code module 05_placement

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-19 15:02:44 +07:00
parent 202fbf27b6
commit 4678ead38e
75 changed files with 3110 additions and 10795 deletions

View file

@ -1,7 +1,8 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
@ -11,7 +12,6 @@ import config from "@/app.config";
* importType
*/
import type { QForm } from "quasar";
import type { ResponseTitle } from "@/modules/05_placement/interface/response/Receive";
import type {
appointmentData,
ResponseData,
@ -37,8 +37,7 @@ const {
dialogConfirm,
} = mixin;
const modalPersonal = ref<boolean>(false);
const dataProfile = ref<DataProfile>();
const dataProfile = ref<DataProfile>(); //
const appointment = ref<appointmentData>({
citizenId: "",
@ -49,42 +48,33 @@ const appointment = ref<appointmentData>({
const myForm = ref<QForm | null>(null);
const edit = ref<boolean>(false);
const profileId = ref<string>("");
const organizationPositionOld = ref<string>("");
const positionTypeOld = ref<string>("");
const positionLevelOld = ref<string>("");
const posNo = ref<string>("");
const salary = ref<number>(0);
const educationOld = ref<string>("");
const reason = ref<string>("");
const date = ref<Date | null>(null);
const educationOld = ref<string>(""); //
const organizationPositionOld = ref<string>(""); ///
const positionTypeOld = ref<string>(""); //
const positionLevelOld = ref<string>(""); //
const posNo = ref<string>(""); //
const salary = ref<number>(0); //
const date = ref<Date | null>(null); //
const reason = ref<string>(""); //
const status = ref<string>("");
const avatar = ref<string>("");
const title = ref<ResponseTitle>({
fullname: "",
organizationPositionOld: "",
positionLevelOld: "",
positionTypeOld: "",
});
const fullName = ref<string>("");
/**
* fetch รายละเอยดการปรบระดบชนงานลกจาง
*/
function fecthappointmentByid() {
async function fecthappointmentByid() {
showLoader();
http
await http
.get(config.API.appointEmployeeByid(paramsId.toString()))
.then((res: ResponseData) => {
dataProfile.value = res.data.result as unknown as DataProfile;
const data = res.data.result;
appointment.value = data;
profileId.value = data.profileId;
title.value.fullname = `${data.prefix === null ? "" : data.prefix}${
fullName.value = `${data.prefix === null ? "" : data.prefix}${
data.firstName ?? "-"
} ${data.lastName ?? "-"}`;
title.value.organizationPositionOld = data.organizationPositionOld ?? "-";
title.value.positionLevelOld = data.positionLevelOld ?? "-";
title.value.positionTypeOld = data.positionTypeOld ?? "-";
(status.value = data.status),
(educationOld.value = data.educationOld ?? "-");
organizationPositionOld.value = data.organizationPositionOld;
@ -94,7 +84,6 @@ function fecthappointmentByid() {
salary.value = data.salary ?? 0;
reason.value = data.reason;
date.value = data.positionDate;
avatar.value = data.avatar ?? "";
})
.catch((e) => {
messageError($q, e);
@ -186,7 +175,7 @@ onMounted(() => {
class="q-mr-sm"
@click="router.push(`/placement/appoint-employee`)"
/>
รายละเอยดการปรบระดบชนงานลกจาง{{ title.fullname }}
รายละเอยดการปรบระดบชนงานลกจาง{{ fullName }}
</div>
<CardProfile :data="dataProfile as DataProfile" :type="'employee'" />

View file

@ -1,34 +0,0 @@
<script setup lang="ts">
const props = defineProps({
title: String,
close: {
type: Function,
default: () => console.log("not function"),
},
});
const close = async () => {
props.close();
};
</script>
<template>
<q-toolbar class="q-py-md">
<q-toolbar-title class="header-text">{{ title }}</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="close"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
</template>
<style scoped lang="scss">
.header-text {
font-size: 18px;
font-weight: 600;
line-height: 26px;
color: #35373c;
}
</style>

View file

@ -1,19 +1,16 @@
<script setup lang="ts">
import { ref, computed, watchEffect } from "vue";
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { UserData } from "@/modules/05_placement/interface/response/AppointMent";
import DialogHeader from "@/components/DialogHeader.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useTransferDataStore } from "@/modules/05_placement/store";
const storeFn = useTransferDataStore();
const { statusText } = storeFn;
const $q = useQuasar();
const mixin = useCounterMixin();
const {
showLoader,
@ -24,24 +21,23 @@ const {
date2Thai,
} = mixin;
const $q = useQuasar();
const selected = ref<[]>([]);
const checkSelected = computed(() => {
if (selected.value.length === 0) {
return true;
}
});
const props = defineProps({
Modal: Boolean,
clickClose: Function,
fecthlistappointment: Function,
fetchData: Function,
nextPage: Function,
optionsType: Array,
rows2: Array,
filterKeyword2: String,
type: String,
});
const emit = defineEmits([
"update:filterKeyword2",
"update:type",
"update:selected",
]);
const selected = ref<[]>([]); //
const visibleColumns2 = ref<string[]>([
"no",
"citizenId",
@ -49,6 +45,11 @@ const visibleColumns2 = ref<string[]>([
"organizationName",
"dateOfBirth",
]);
/**
* ปเดทคคนหา
* @param value ตำคนหา
*/
const columns2 = ref<QTableProps["columns"]>([
{
name: "no",
@ -98,62 +99,62 @@ const columns2 = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
// const pageNext = (item: object) => {
// props.nextPage?.(item);
// };
const emit = defineEmits([
"update:filterKeyword2",
"update:type",
"update:selected",
]);
const updateInput = (value: any) => {
function updateInput(value: any) {
emit("update:filterKeyword2", value);
};
}
const updateInputType = (value: string) => {
emit("update:type", value);
};
//
const Reset = () => {
/**
* เซตคาในชองคนหา
*/
function Reset() {
emit("update:filterKeyword2", "");
};
// modal
const clickAddlist = () => {
dialogConfirm($q, () => createdAppoint());
};
}
//
const createdAppoint = async () => {
let pId: string[] = [];
let Type = props.type as string;
selected.value.forEach((e: UserData) => {
pId.push(e.id);
});
let data = {
id: pId,
};
showLoader();
await http
.post(config.API.appointEmployeeOrder(Type), data)
.then(async () => {
await props.fecthlistappointment?.();
await props.clickClose?.();
await success($q, "บันทึกสำเร็จ");
selected.value = [];
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
/**
* งกนยนยนสงไปออกคำส
*/
function clickAddlist() {
dialogConfirm($q, async () => {
let pId: string[] = [];
let Type = props.type as string;
selected.value.forEach((e: UserData) => {
pId.push(e.id);
});
};
let data = {
id: pId,
};
showLoader();
await http
.post(config.API.appointEmployeeOrder(Type), data)
.then(async () => {
await props.fetchData?.();
await props.clickClose?.();
await success($q, "บันทึกสำเร็จ");
selected.value = [];
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
}
watchEffect(() => {
if (props.Modal === true) {
selected.value = [];
/**
* เม props.modal เป true
*
* กำหนดให selected เปนคาวาง
*/
watch(
() => props.Modal,
() => {
if (props.Modal === true) {
selected.value = [];
}
}
});
);
</script>
<template>
<q-dialog v-model="props.Modal">
@ -297,7 +298,7 @@ watchEffect(() => {
label="ส่งไปออกคำสั่ง"
@click="clickAddlist"
color="public"
:disable="checkSelected"
:disable="selected.length === 0"
><q-tooltip>งไปออกคำส</q-tooltip></q-btn
>
</q-card-actions>

View file

@ -1,546 +0,0 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { checkPermission } from "@/utils/permissions";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
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 type {
listAppointType,
resData,
orgFilter,
} from "@/modules/05_placement/interface/response/AppointMent";
import type { OpType } from "@/modules/05_placement/interface/response/Main";
import http from "@/plugins/http";
import config from "@/app.config";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogOrgSelectEmployee from "@/components/Dialogs/DialogOrgSelectEmployee.vue"; //
const typeModal = ref<string>("");
const posType = ref<string>("");
const posLevel = ref<string>("");
const position = ref<string>("");
const dataRows = ref<any[]>([]);
const $q = useQuasar();
const modal = ref<boolean>(false);
const storeFn = useTransferDataStore();
const { statusText } = storeFn;
const mixin = useCounterMixin(); //
const {
showLoader,
hideLoader,
success,
messageError,
date2Thai,
dialogRemove,
} = mixin;
const router = useRouter();
const rows = ref<listAppointType[]>([]);
const rows2 = ref<listAppointType[]>([]);
const modalTree = ref<boolean>(false);
const personalId = ref<string>("");
const filterKeyword = ref<string>("");
const filterKeyword2 = ref<string>("");
const filterRef = ref<any>(null);
const listRecevice = ref<resData[]>([]);
const optionsType = ref<OpType[]>([]);
const type = 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 รายการปรบระดบชนงานลกจาง
*/
function fecthlistappointment() {
showLoader();
rows.value = [];
http
.get(config.API.appointEmployee())
.then((res) => {
let response = res.data.result;
listRecevice.value = response;
rows.value = response;
//
rows2.value = rows.value.filter(
(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 รายการปรบระดบชนงานลกจาง
*/
const 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();
});
});
};
/**
* 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;
}
/**
* เป popup เลอกหนวยงาน
* @param data อมลหนวยงาน
* @param type ประเภท าย,ปร
*/
function openModalTree(data: any, type: string) {
typeModal.value = type;
personalId.value = data.id;
dataRows.value = data;
posType.value = data.posTypeNameOld;
posLevel.value = data.posLevelNameOld;
position.value = data.positionOld;
modalTree.value = true;
}
/**
* นยนการบนทกขอมลเลอกตำแหน
*/
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,
typeCommand: data.typeCommand,
};
showLoader();
http
.put(config.API.appointmentPosition(personalId.value), dataAppoint)
.then(async () => {
await fecthlistappointment();
await success($q, "บันทึกสำเร็จ");
modalTree.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
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">
<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">
<q-item
v-if="
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrIsGet &&
props.row.status !== 'REPORT' &&
props.row.status !== 'DONE'
"
clickable
v-close-popup
@click="openModalTree(props.row, 'SLIP')"
>
<q-item-section style="min-width: 0px" avatar>
<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)?.attrIsUpdate &&
checkPermission($route)?.attrIsGet &&
props.row.status !== 'REPORT' &&
props.row.status !== 'DONE'
"
clickable
v-close-popup
@click="openModalTree(props.row, 'MOVE')"
>
<q-item-section style="min-width: 0px" avatar>
<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
@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>
<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 == '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"
:clickClose="clickClose"
:optionsType="optionsType"
:rows2="rows2"
v-model:filterKeyword2="filterKeyword2"
v-model:type="type"
:nextPage="nextPage"
:fecthlistappointment="fecthlistappointment"
/>
<DialogOrgSelectEmployee
:title="`เลือกหน่วยงานที่รับการปรับระดับชั้นงาน`"
v-model:modal="modalTree"
v-model:type="typeModal"
:posType="posType"
:posLevel="posLevel"
:position="position"
:dataRows="dataRows"
:onSubmit="onSave"
/>
</template>
<style scoped lang="scss"></style>

View file

@ -1,700 +0,0 @@
<script setup lang="ts">
import { useQuasar, QForm } from "quasar";
import { onMounted, reactive, ref, watch } from "vue";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const mixin = useCounterMixin(); //
const {
date2Thai,
hideLoader,
messageError,
showLoader,
success,
dialogConfirm,
} = mixin; //
const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา");
const noData = ref<string>("ไม่พบข้อมูลผังโครงสร้าง");
const checkValidate = ref<boolean>(false);
const myFormPosition = ref<any>();
const selected = ref<string>("");
const selectedFile = ref<string>("");
const dataRespone = ref<any>();
const personal = ref<any>();
const expanded = ref<string[]>([]);
const treeData = ref<Array<any>>([]);
const placementPosition = ref<any>([]);
const search = ref<string>("");
const filterRef = ref<any>(null);
const id = ref<string>("");
const editDataStatus = ref<boolean>(false);
// Set form field
let dataForm = reactive({
personalId: "",
containDate: new Date(),
posNoId: "",
positionId: "",
positionLevelId: "",
positionLineId: "",
positionPathSideId: "",
positionTypeId: "",
});
onMounted(async () => {
// await fetchPublishFile();
// await loadTreeData();
await fetchplacementPosition();
});
// const fetchPublishFile = async () => {
// await http
// .get(config.API.getPublishFileHistory)
// .then((res) => {
// let data = res.data.result;
// selectedFile.value = data[0].fileName;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// hideLoader();
// });
// };
// json
// const loadTreeData = async () => {
// expanded.value = [];
// await http
// .get(`${config.s3ClusterUrl}${selectedFile.value}`)
// .then((res: any) => {
// treeData.value = res.data;
// dataRespone.value = res.data;
// // Filter objects with "name" null
// const filteredData = res.data.filter(filterByPersonIdNull);
// treeData.value = filteredData;
// })
// .catch((e: any) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
// };
function filterByPersonIdNull(obj: any) {
if (obj.name === null && obj.isCondition != true) {
return true;
}
if (obj.children && obj.children.length > 0) {
obj.children = obj.children.filter(filterByPersonIdNull);
return obj.children.length > 0;
}
return false;
}
// position
const fetchplacementPosition = async () => {
await http
.get(config.API.apppointmentPositionUse())
.then((res: any) => {
placementPosition.value = res.data.result;
})
.catch((e: any) => {
messageError($q, e);
});
};
const props = defineProps({
personalId: String,
modal: Boolean,
close: {
type: Function,
default: () => console.log("close modal"),
},
personal: Object,
});
const myFilterMethod = (node: any, filter: string) => {
const filt = filter;
return (
(node.name && node.name.indexOf(filt) > -1) ||
(node.organizationName && node.organizationName.indexOf(filt) > -1) ||
(node.positionNum && node.positionNum.indexOf(filt) > -1) ||
(node.positionName && node.positionName.indexOf(filt) > -1) ||
(node.governmentCode &&
node.governmentCode.toString().indexOf(filt) > -1) ||
(node.agency && node.agency.indexOf(filt) > -1) ||
(node.government && node.government.indexOf(filt) > -1) ||
(node.department && node.department.indexOf(filt) > -1) ||
(node.pile && node.pile.indexOf(filt) > -1) ||
(node.organizationShortName &&
node.organizationShortName.indexOf(filt) > -1) ||
(node.positionSideName && node.positionSideName.indexOf(filt) > -1) ||
(node.executivePosition && node.executivePosition.indexOf(filt) > -1) ||
(node.executivePositionSide &&
node.executivePositionSide.indexOf(filt) > -1) ||
(node.positionLevel && node.positionLevel.indexOf(filt) > -1)
);
};
const validateData = async () => {
checkValidate.value = true;
await myFormPosition.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
const saveAppoint = async () => {
myFormPosition.value.validate().then(async (result: boolean) => {
if (props.personalId !== undefined) {
id.value = props.personalId.toString();
}
if (result) {
const dataAppoint = await {
recruitDate: dataForm.containDate,
posNoId: dataForm.posNoId,
positionId: dataForm.positionId,
positionLevelId: dataForm.positionLevelId,
positionLineId: dataForm.positionLineId,
positionPathSideId: dataForm.positionPathSideId,
positionTypeId: dataForm.positionTypeId,
};
showLoader();
await http
.put(config.API.appointEmployeePosition(id.value), dataAppoint)
.then(() => {
success($q, "บันทึกสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await closeAndClear();
// await fetchPublishFile();
// await loadTreeData();
await fetchplacementPosition();
hideLoader();
});
}
});
};
const closeModal = () => {
if (editDataStatus.value == true) {
dialogConfirm(
$q,
async () => {
editDataStatus.value = false;
await closeAndClear();
},
`ข้อมูลมีการแก้ไข`,
`ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`
);
} else {
closeAndClear();
}
};
const closeAndClear = async () => {
await props.close();
editDataStatus.value = false;
selected.value = "";
dataForm.personalId = "";
dataForm.containDate = new Date();
dataForm.posNoId = "";
dataForm.positionId = "";
dataForm.positionLevelId = "";
dataForm.positionLineId = "";
dataForm.positionPathSideId = "";
dataForm.positionTypeId = "";
};
//
const posNoOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
// /
const positionPathSideOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionTypeOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionLineOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionLevelOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
const selectedPosition = async (data: any) => {
if (data.name == null && selected.value != data.keyId) {
editDataStatus.value = true;
selected.value = data.keyId;
// posNo Options
posNoOptions.value = [
{
label: data.positionNum,
value: data.positionNumId,
},
];
dataForm.posNoId = data.positionNumId;
// position Options
positionOptions.value = [
{
label: data.positionName,
value: data.positionNameId,
},
];
dataForm.positionId = data.positionNameId;
// positionPathSide Options
let positionPathSideArr: any = [];
if (data.positionSideNameObj && data.positionSideNameObj != null) {
data.positionSideNameObj.map((x: any) => {
positionPathSideArr.push({
label: x.Name,
value: x.Id,
});
});
positionPathSideOptions.value = positionPathSideArr;
dataForm.positionPathSideId =
positionPathSideArr.length > 1 || positionPathSideArr.length == 0
? ""
: positionPathSideArr[0].value;
}
// positionType Options
positionTypeOptions.value = [
{
label: data.positionType,
value: data.positionTypeId,
},
];
dataForm.positionTypeId = data.positionTypeId;
// positionLine Options
positionLineOptions.value = [
{
label: data.positionLine,
value: data.positionLineId,
},
];
dataForm.positionLineId = data.positionLineId;
// positionLevel Options
let positionLevelsArr: any = [];
if (data.positionLevelObj != null) {
data.positionLevelObj.map((x: any) => {
positionLevelsArr.push({
label: x.Name,
value: x.Id,
});
});
positionLevelOptions.value = positionLevelsArr;
dataForm.positionLevelId =
positionLevelsArr.length > 1 || positionLevelsArr.length == 0
? ""
: positionLevelsArr[0].value;
dataForm.positionLevelId = data.positionLevelObj[0].Id;
}
} else if (selected.value == data.keyId) {
selected.value = "";
dataForm.posNoId = "";
dataForm.positionId = "";
dataForm.positionLevelId = "";
dataForm.positionLineId = "";
dataForm.positionPathSideId = "";
dataForm.positionTypeId = "";
}
};
const checkPosition = (val: string) => {
const num = placementPosition.value.findIndex((e: string) => e === val);
return num;
};
watch(props, () => {
expanded.value = [];
const dataPersonal = props.personal;
if (dataPersonal) {
dataPersonal.map((data: any) => {
personal.value = data;
});
}
if (personal.value) {
let findData: any = null;
dataRespone.value.map((x: any) => {
findData = findByPerson(x);
if (findData != null) {
selectedPosition(findData);
for (let i = 3; i <= findData.keyId.length; i += 2) {
expanded.value.push(findData.keyId.slice(0, i));
}
}
});
}
});
function findByPerson(element: any): any {
if (
element.positionNumId &&
element.positionLineId === personal.value.positionLineId &&
element.positionTypeId === personal.value.positionTypeId &&
element.positionNumId === personal.value.posNoId &&
(element.positionLevelObj === null ||
element.positionLevelObj[0].Id === personal.value.positionLevelId)
) {
return element;
} else if (element.children) {
var i;
var result = null;
for (i = 0; result == null && i < element.children.length; i++) {
result = findByPerson(element.children[i]);
}
return result;
}
return null;
}
</script>
<template>
<q-dialog v-model="props.modal" persistent>
<q-card style="width: 900px; max-width: 80vw">
<q-form ref="myFormPosition">
<DialogHeader :tittle="'เลือกหน่วยงาน'" :close="closeModal" />
<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 row">
<q-card flat bordered class="fit q-pa-sm">
<q-scroll-area visible style="height: 70vh">
<q-input
outlined
dense
ref="filterRef"
v-model="search"
placeholder="ค้นหา"
class="q-mb-sm"
>
<template v-slot:append>
<q-icon name="mdi-magnify" />
</template>
</q-input>
<div class="q-pa-sm q-gutter-sm">
<q-tree
no-transition
dense
:nodes="treeData"
node-key="keyId"
:filter="search"
:no-results-label="notFound"
:no-nodes-label="noData"
:filter-method="myFilterMethod"
v-model:expanded="expanded"
>
<template v-slot:header-organization="prop">
<div class="col">
<div
class="row items-center q-px-xs q-pt-xs q-gutter-sm"
>
<!--แสดงชอแผนก มพวหนา คลกแลวกาง/ Tree-->
<div class="text-weight-medium">
{{ prop.node.organizationName }}
</div>
<q-badge
v-if="prop.node.totalPositionVacant > 0"
rounded
color="red"
outline
:label="prop.node.totalPositionVacant"
/>
<q-space />
</div>
<div class="col items-center q-px-xs q-pt-xs">
<div class="text-weight-medium text-grey-7">
{{ prop.node.governmentCode }}
{{ prop.node.organizationShortName }}
</div>
</div>
</div>
</template>
<template v-slot:header-person="prop">
<q-item
clickable
:active="selected == prop.node.keyId"
@click="selectedPosition(prop.node)"
:disable="
prop.node.name != null ||
checkPosition(prop.node.positionNumId) != -1
"
active-class="my-list-link text-primary text-weight-medium"
class="row items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<img
v-if="
prop.node.avatar == '' ||
prop.node.avatar ==
'https://cdn.quasar.dev/img/boy-avatar.png'
"
src="@/assets/avatar_user.jpg"
class="col-xs-1 col-sm-2"
style="
width: 28px;
height: 28px;
border-radius: 50%;
"
/>
<img
v-else
:src="prop.node.avatar"
class="col-xs-1 col-sm-2"
style="
width: 28px;
height: 28px;
border-radius: 50%;
"
/>
<!--=====ตำแหนงวาง แดง=====-->
<div
v-if="prop.node.name == null"
class="q-px-sm text-weight-medium text-red"
>
าง
</div>
<!--=====วหน เขยว=====-->
<div v-else-if="prop.node.positionLeaderFlag">
<div
class="q-px-sm text-weight-medium text-primary"
>
{{ prop.node.name }}
</div>
</div>
<!--=====กนอง ปกต=====-->
<div v-else>
<div class="q-px-sm text-weight-medium">
{{ prop.node.name }}
</div>
</div>
<!--อทายชอคน แสดงสปกต-->
<div class="q-pr-sm">
{{ prop.node.positionName }}
</div>
<div class="q-pr-sm">
{{ prop.node.positionNum }}
</div>
<div class="q-pr-sm">
{{ prop.node.positionLevel }}
</div>
<q-icon
v-if="prop.node.positionLeaderFlag"
class="q-mr-sm"
size="15px"
color="primary"
name="mdi-bookmark"
></q-icon>
<q-space />
</q-item>
</template>
</q-tree>
</div>
</q-scroll-area>
</q-card>
</div>
<div class="col-xs-12 col-sm-5">
<q-card flat bordered class="fit q-pa-sm">
<q-scroll-area visible style="height: 70vh">
<div class="row col-12 q-col-gutter-xs">
<div class="col-xs-12 col-sm-12 col-md-12"></div>
<div class="col-xs-12 col-sm-12 col-md-12">
<datepicker
menu-class-name="modalfix"
v-model="dataForm.containDate"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="full-width inputgreen cursor-pointer"
outlined
dense
:model-value="
date2Thai(new Date(dataForm.containDate))
"
:rules="[(val: string) => !!val || `${'วันที่รายงานตัว'}`]"
:label="`${'วันที่รายงานตัว'}`"
hide-bottom-space
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<q-space />
<div class="col-xs-12 col-sm-12 col-md-12">
<q-select
class="full-width inputgreen cursor-pointer custom-input"
outlined
standout
dense
hide-bottom-space
lazy-rules
:options="posNoOptions"
v-model="dataForm.posNoId"
:label="`${'ตำแหน่งเลขที่'}`"
map-options
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-select
outlined
class="full-width inputgreen cursor-pointer custom-input"
standout
dense
hide-bottom-space
lazy-rules
:options="positionOptions"
v-model="dataForm.positionId"
:label="`${'ตำแหน่ง'}`"
map-options
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-select
outlined
class="full-width inputgreen cursor-pointer custom-input"
standout
dense
hide-bottom-space
lazy-rules
emit-value
:options="positionPathSideOptions"
v-model="dataForm.positionPathSideId"
:label="`${'ด้าน/สาขา'}`"
map-options
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-select
outlined
class="full-width inputgreen cursor-pointer custom-input"
standout
dense
hide-bottom-space
lazy-rules
:options="positionTypeOptions"
v-model="dataForm.positionTypeId"
:label="`${'ประเภทตำแหน่ง'}`"
map-options
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-select
outlined
class="full-width inputgreen cursor-pointer custom-input"
standout
dense
hide-bottom-space
lazy-rules
:options="positionLineOptions"
v-model="dataForm.positionLineId"
:label="`${'สายงาน'}`"
map-options
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-select
outlined
class="full-width inputgreen cursor-pointer custom-input"
standout
dense
lazy-rules
:options="positionLevelOptions"
v-model="dataForm.positionLevelId"
:label="`${'ระดับ'}`"
hide-bottom-space
:rules="[(val: string) => !!val || `${'กรุณาเลือกระดับ'}`]"
emit-value
map-options
/>
</div>
</div>
</q-scroll-area>
</q-card>
</div>
</div>
</q-card-section>
<q-separator />
<DialogFooter
:editvisible="true"
:validate="validateData"
:save="saveAppoint"
v-model:modalEdit="editDataStatus"
/>
</q-form>
</q-card>
</q-dialog>
</template>
<style scoped lang="scss">
.q-tree__node-header {
padding: 0px;
margin-top: 0px;
border-radius: 4px;
outline: 0;
}
.my-list-link {
color: rgb(118, 168, 222);
border-radius: 5px;
background: #a3d3fb48 !important;
font-weight: 600;
border: 1px solid rgba(175, 185, 196, 0.217);
}
</style>