อัตรากำลังลูกจ้างประจำฯ
This commit is contained in:
parent
748a878deb
commit
4091d21270
3 changed files with 162 additions and 646 deletions
|
|
@ -1,11 +1,10 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import type { QTableProps } from "quasar";
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import DialogAddPosition from "@/modules/16_positionEmployee/components/DialogAddPosition.vue";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
FormDataPosition,
|
||||
FormPositionRef,
|
||||
|
|
@ -22,8 +21,10 @@ import type {
|
|||
DataPosition,
|
||||
} from "@/modules/16_positionEmployee/interface/response/organizational";
|
||||
import type { FilterMaster } from "@/modules/16_positionEmployee/interface/request/organizational";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import DialogAddPosition from "@/modules/16_positionEmployee/components/DialogAddPosition.vue";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
const props = defineProps({
|
||||
modal: Boolean,
|
||||
|
|
@ -43,7 +44,7 @@ const reqMaster = defineModel<FilterMaster>("reqMaster", { required: true });
|
|||
const isReadonly = ref<boolean>(false); // อ่านได้อย่างเดียว
|
||||
const isDisValidate = ref<boolean>(false);
|
||||
const isPosition = ref<boolean>(false);
|
||||
const succession = ref<boolean>(false); // id ของตำแหน่งที่จะสืบทอด
|
||||
|
||||
const dataCopy = ref<any>();
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
|
|
@ -56,26 +57,15 @@ const {
|
|||
dialogRemove,
|
||||
dialogMessageNotify,
|
||||
} = mixin;
|
||||
const selected = ref<any>([]);
|
||||
|
||||
const search = ref<string>("");
|
||||
const type = ref<string>("positionName");
|
||||
const optionFilter = ref<DataOption[]>([
|
||||
{ id: "positionName", name: "ตำแหน่งในสายงาน" },
|
||||
{ id: "positionField", name: "สายงาน" },
|
||||
{ id: "positionType", name: "ประเภทตำแหน่ง" },
|
||||
{ id: "positionLevel", name: "ระดับตำแหน่ง" },
|
||||
{ id: "positionExecutive", name: "ตำแหน่งทางการบริหาร" },
|
||||
{ id: "positionExecutiveField", name: "ด้านทางการบริหาร" },
|
||||
{ id: "positionArea", name: "ด้าน/สาขา" },
|
||||
{ id: "positionName", name: "ชื่อตำแหน่ง" },
|
||||
{ id: "positionType", name: "กลุ่มงาน" },
|
||||
{ id: "positionLevel", name: "ระดับชั้นงาน" },
|
||||
]);
|
||||
|
||||
const typeOpsMain = ref<DataOption[]>([]);
|
||||
const levelOpsMain = ref<DataOption[]>([]);
|
||||
const executiveOpsMain = ref<DataOption[]>([]);
|
||||
const executiveOps = ref<DataOption[]>([]);
|
||||
const typeOps = ref<DataOption[]>([]);
|
||||
const levelOps = ref<any[]>([]);
|
||||
|
||||
const listMenu = ref<ListMenu[]>([
|
||||
{
|
||||
label: "คัดลอก",
|
||||
|
|
@ -99,19 +89,10 @@ const listMenu = ref<ListMenu[]>([
|
|||
|
||||
const rows = ref<RowDetailPositions[]>([]);
|
||||
const rowsPositionSelect = ref<RowDetailPositions[]>([]);
|
||||
const ocLevelOp = ref<DataOption[]>([]);
|
||||
|
||||
const prefixNoRef = ref<Object | null>(null);
|
||||
const positionNoRef = ref<Object | null>(null);
|
||||
|
||||
const positionNameRef = ref<Object | null>(null);
|
||||
const positionFieldRef = ref<Object | null>(null);
|
||||
const positionTypeRef = ref<Object | null>(null);
|
||||
const positionLevelRef = ref<Object | null>(null);
|
||||
const positionExecutiveRef = ref<Object | null>(null);
|
||||
const positionExecutiveFieldRef = ref<Object | null>(null);
|
||||
const positionAreaRef = ref<Object | null>(null);
|
||||
|
||||
const formData = reactive<FormDataPosition>({
|
||||
shortName: props.shortName,
|
||||
prefixNo: "",
|
||||
|
|
@ -119,32 +100,12 @@ const formData = reactive<FormDataPosition>({
|
|||
suffixNo: "",
|
||||
});
|
||||
|
||||
const formPositionSelect = reactive<FormPositionSelect>({
|
||||
positionId: "",
|
||||
positionName: "",
|
||||
positionField: "",
|
||||
positionType: "",
|
||||
positionLevel: "",
|
||||
positionExecutive: "",
|
||||
positionExecutiveField: "",
|
||||
positionArea: "",
|
||||
});
|
||||
/** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */
|
||||
const objectPositionRef: FormPositionRef = {
|
||||
prefixNo: prefixNoRef,
|
||||
positionNo: positionNoRef,
|
||||
};
|
||||
|
||||
const objectPositionSelectRef: FormPositionSelectRef = {
|
||||
positionName: positionNameRef,
|
||||
positionField: positionFieldRef,
|
||||
positionType: positionTypeRef,
|
||||
positionLevel: positionLevelRef,
|
||||
positionExecutive: positionExecutiveRef,
|
||||
positionExecutiveField: positionExecutiveFieldRef,
|
||||
positionArea: positionAreaRef,
|
||||
};
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
|
|
@ -156,27 +117,18 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionName",
|
||||
name: "posDictName",
|
||||
align: "left",
|
||||
label: "ตำแหน่งในสายงาน",
|
||||
label: "ชื่อตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "positionName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionField",
|
||||
align: "left",
|
||||
label: "สายงาน",
|
||||
sortable: true,
|
||||
field: "positionField",
|
||||
field: "posDictName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeName",
|
||||
align: "left",
|
||||
label: "ประเภทตำเเหน่ง",
|
||||
label: "กลุ่มงาน",
|
||||
sortable: true,
|
||||
field: "posTypeName",
|
||||
headerStyle: "font-size: 14px",
|
||||
|
|
@ -185,49 +137,18 @@ const columns = ref<QTableProps["columns"]>([
|
|||
{
|
||||
name: "posLevelName",
|
||||
align: "left",
|
||||
label: "ระดับตำแหน่ง",
|
||||
label: "ระดับชั้นงาน",
|
||||
sortable: true,
|
||||
field: "posLevelName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posExecutiveName",
|
||||
align: "left",
|
||||
label: "ตำแหน่งทางการบริหาร",
|
||||
sortable: true,
|
||||
field: "posExecutiveName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionExecutiveField",
|
||||
align: "left",
|
||||
label: "ด้านทางการบริหาร",
|
||||
sortable: true,
|
||||
field: "positionExecutiveField",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionArea",
|
||||
align: "left",
|
||||
label: "ด้าน/สาขา",
|
||||
sortable: true,
|
||||
field: "positionArea",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"positionName",
|
||||
"positionField",
|
||||
"posDictName",
|
||||
"posTypeName",
|
||||
"posLevelName",
|
||||
"posExecutiveName",
|
||||
"positionExecutiveField",
|
||||
"positionArea",
|
||||
]);
|
||||
|
||||
async function fetchPosition(id: string) {
|
||||
|
|
@ -249,68 +170,6 @@ async function fetchPosition(id: string) {
|
|||
});
|
||||
}
|
||||
|
||||
const dataLevel = ref<any>();
|
||||
/** function เรียกรายการประเภทตำแหน่ง */
|
||||
async function fetchType() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgPosType)
|
||||
.then((res) => {
|
||||
dataLevel.value = res.data.result;
|
||||
typeOpsMain.value = res.data.result.map((e: OptionType) => ({
|
||||
id: e.id,
|
||||
name: e.posTypeName,
|
||||
}));
|
||||
typeOps.value = typeOpsMain.value;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** function เรียกรายการระดับตำแหน่ง */
|
||||
// async function fetchLevel() {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.orgPosLevel)
|
||||
// .then((res) => {
|
||||
// levelOpsMain.value = res.data.result.map((e: OptionLevel) => ({
|
||||
// id: e.id,
|
||||
// name: e.posLevelName,
|
||||
// }));
|
||||
// levelOps.value = levelOpsMain.value;
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// messageError($q, err);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// }
|
||||
|
||||
/** function เรียกรายการตำแหน่งทางการบริหาร */
|
||||
async function fetchExecutive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgPosExecutive)
|
||||
.then((res) => {
|
||||
executiveOpsMain.value = res.data.result.map((e: OptionExecutive) => ({
|
||||
id: e.id,
|
||||
name: e.posExecutiveName,
|
||||
}));
|
||||
executiveOps.value = executiveOpsMain.value;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
|
||||
function validateForm() {
|
||||
const hasError = [];
|
||||
|
|
@ -332,36 +191,14 @@ function validateForm() {
|
|||
}
|
||||
}
|
||||
|
||||
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
|
||||
// function validateFormPositionEdit() {
|
||||
// isDisValidate.value = false;
|
||||
// const hasError = [];
|
||||
// for (const key in objectPositionSelectRef) {
|
||||
// if (Object.prototype.hasOwnProperty.call(objectPositionSelectRef, key)) {
|
||||
// const property = objectPositionSelectRef[key];
|
||||
// if (property.value && typeof property.value.validate === "function") {
|
||||
// const isValid = property.value.validate();
|
||||
// hasError.push(isValid);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (hasError.every((result) => result === true)) {
|
||||
// onSubmitSelectEdit();
|
||||
// }
|
||||
// }
|
||||
|
||||
/** ฟังชั่น บันทึก */
|
||||
function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
showLoader();
|
||||
const positionsData = rows.value.map((e: any) => ({
|
||||
posDictName: e.positionName, //ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)
|
||||
posDictField: e.positionField, //สายงาน
|
||||
posDictName: e.posDictName, //ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)
|
||||
posTypeId: e.posTypeId, //*ประเภทตำแหน่ง
|
||||
posLevelId: e.posLevelId, //*ระดับตำแหน่ง
|
||||
posExecutiveId: e.posExecutiveId ? e.posExecutiveId : "", //ตำแหน่งทางการบริหาร
|
||||
posDictExecutiveField: e.positionExecutiveField, //ด้านทางการบริหาร
|
||||
posDictArea: e.positionArea, //ด้าน/สาขา
|
||||
isSpecial: e.isSpecial,
|
||||
}));
|
||||
const body = {
|
||||
posMasterNoPrefix: formData.prefixNo, //*Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)
|
||||
|
|
@ -375,83 +212,23 @@ function onSubmit() {
|
|||
positions: positionsData,
|
||||
// succession: succession.value,
|
||||
};
|
||||
|
||||
showLoader();
|
||||
props.actionType === "ADD"
|
||||
? await http
|
||||
.post(config.API.orgPosMaster, body)
|
||||
.then(() => {
|
||||
success($q, "เพิ่มข้อมูลสำเร็จ");
|
||||
props.fetchDataTable?.(
|
||||
reqMaster.value.id,
|
||||
reqMaster.value.type,
|
||||
false
|
||||
);
|
||||
props.getSummary?.();
|
||||
close();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
})
|
||||
: props.rowId &&
|
||||
(await http
|
||||
.put(config.API.orgPosMasterById(props.rowId), body)
|
||||
.then(() => {
|
||||
success($q, "แก้ไขข้อมูลสำเร็จ");
|
||||
props.fetchDataTable?.(
|
||||
reqMaster.value.id,
|
||||
reqMaster.value.type,
|
||||
false
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
close();
|
||||
hideLoader();
|
||||
}));
|
||||
try {
|
||||
const url =
|
||||
props.actionType === "ADD"
|
||||
? config.API.orgPosMasterEmp
|
||||
: config.API.orgPosMasterByIdEmp(props.rowId);
|
||||
await http[props.actionType === "ADD" ? "post" : "put"](url, body);
|
||||
success($q, "บันทีกข้อมูลสำเร็จ");
|
||||
props.getSummary?.();
|
||||
props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false);
|
||||
close();
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
});
|
||||
}
|
||||
/** ฟังชั่น บันทึก */
|
||||
// function onSubmitSelectEdit() {
|
||||
// dialogConfirm(
|
||||
// $q,
|
||||
// async () => {
|
||||
// showLoader();
|
||||
// const body = {
|
||||
// posDictName: formPositionSelect.positionName,
|
||||
// posDictField: formPositionSelect.positionField, //สายงาน
|
||||
// posTypeId: formPositionSelect.positionType, //*ประเภทตำแหน่ง
|
||||
// posLevelId: formPositionSelect.positionLevel, //*ระดับตำแหน่ง
|
||||
// posExecutiveId:
|
||||
// formPositionSelect.positionExecutive !== ""
|
||||
// ? formPositionSelect.positionExecutive
|
||||
// : null, //ตำแหน่งทางการบริหาร
|
||||
// posDictExecutiveField: formPositionSelect.positionExecutiveField, //ด้านทางการบริหาร
|
||||
// posDictArea: formPositionSelect.positionArea, //ด้าน/สาขา
|
||||
// };
|
||||
// await http
|
||||
// .post(config.API.orgPosPosition, body)
|
||||
// .then(() => {
|
||||
// success($q, "เพิ่มข้อมูลสำเร็จ");
|
||||
|
||||
// clearFormPositionSelect();
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// messageError($q, err);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
// },
|
||||
// "ยืนยันการเพิ่มตำแหน่ง",
|
||||
// "ต้องการยืนยันการเพิ่มตำแหน่งนี้ใช่หรือไม่?"
|
||||
// );
|
||||
// }
|
||||
|
||||
/** input ค้นหา */
|
||||
const searchRef = ref<any>(null);
|
||||
|
|
@ -461,7 +238,7 @@ async function searchInput() {
|
|||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.orgPosPosition +
|
||||
config.API.orgEmployeePos +
|
||||
`?keyword=${search.value}&type=${type.value}`
|
||||
)
|
||||
.then((res) => {
|
||||
|
|
@ -476,16 +253,6 @@ async function searchInput() {
|
|||
}
|
||||
}
|
||||
|
||||
// function updateSelectType(val: string) {
|
||||
// const listLevel = dataLevel.value.find((e: any) => e.id === val);
|
||||
// levelOpsMain.value = listLevel.posLevels.map((e: OptionLevel) => ({
|
||||
// id: e.id,
|
||||
// name: e.posLevelName,
|
||||
// }));
|
||||
// levelOps.value = levelOpsMain.value;
|
||||
// formPositionSelect.positionLevel = "";
|
||||
// }
|
||||
|
||||
/**
|
||||
* คัดลอกข้อมูล
|
||||
* @param data ข้อมูลตำแหน่ง
|
||||
|
|
@ -502,7 +269,6 @@ function editDetiail(data: RowDetailPositions) {
|
|||
isEdit.value = true;
|
||||
modalAdd.value = true;
|
||||
dataCopy.value = data;
|
||||
console.log(isEdit.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -515,60 +281,16 @@ function inputEdit(val: boolean) {
|
|||
"full-width cursor-pointer inputgreen": !val,
|
||||
};
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modal,
|
||||
() => {
|
||||
if (props.modal === true) {
|
||||
fetchType();
|
||||
// fetchLevel();
|
||||
fetchExecutive();
|
||||
|
||||
if (props.actionType === "ADD") {
|
||||
rowsPositionSelect.value = [];
|
||||
search.value = "";
|
||||
rows.value = [];
|
||||
clearFormPositionSelect();
|
||||
formData.prefixNo = "";
|
||||
formData.positionNo = "";
|
||||
formData.suffixNo = "";
|
||||
} else {
|
||||
props.rowId && fetchPosition(props.rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
async function addPosition(data: RowDetailPositions) {
|
||||
const isIdExist = await rows.value.some(
|
||||
(item: any) =>
|
||||
item.posExecutiveId == data.posExecutiveId &&
|
||||
item.positionField == data.positionField &&
|
||||
item.posLevelId == data.posLevelId &&
|
||||
item.posTypeId == data.posTypeId &&
|
||||
item.positionArea == data.positionArea &&
|
||||
item.positionExecutiveField == data.positionExecutiveField &&
|
||||
item.positionName == data.positionName &&
|
||||
item.isSpecial == data.isSpecial
|
||||
);
|
||||
|
||||
if (!isIdExist) {
|
||||
rows.value = [...rows.value, data];
|
||||
// rows.value.push(data);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteData(id: string) {
|
||||
const dataRow = rows.value;
|
||||
const updatedRows = dataRow.filter((item: any) => item.id !== id);
|
||||
rows.value = updatedRows;
|
||||
function addPosition(data: RowDetailPositions) {
|
||||
rows.value = [];
|
||||
rows.value.push(data);
|
||||
}
|
||||
|
||||
function deletePos(id: string) {
|
||||
dialogRemove($q, () => {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.orgPosPositionById(id))
|
||||
.delete(config.API.orgEmployeePosById(id))
|
||||
.then(() => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
|
|
@ -582,19 +304,11 @@ function deletePos(id: string) {
|
|||
});
|
||||
}
|
||||
|
||||
async function clearFormPositionSelect() {
|
||||
isDisValidate.value = await true;
|
||||
formPositionSelect.positionId = "";
|
||||
formPositionSelect.positionName = "";
|
||||
formPositionSelect.positionField = "";
|
||||
formPositionSelect.positionType = "";
|
||||
formPositionSelect.positionLevel = "";
|
||||
formPositionSelect.positionExecutive = "";
|
||||
formPositionSelect.positionExecutiveField = "";
|
||||
formPositionSelect.positionArea = "";
|
||||
function clearFormPositionSelect() {
|
||||
isDisValidate.value = true;
|
||||
|
||||
setTimeout(async () => {
|
||||
isDisValidate.value = await false;
|
||||
setTimeout(() => {
|
||||
isDisValidate.value = false;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
|
|
@ -609,6 +323,25 @@ async function emitSearch(keyword: string, typeSelect: string) {
|
|||
|
||||
await searchInput();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modal,
|
||||
() => {
|
||||
if (props.modal === true) {
|
||||
if (props.actionType === "ADD") {
|
||||
rowsPositionSelect.value = [];
|
||||
search.value = "";
|
||||
rows.value = [];
|
||||
clearFormPositionSelect();
|
||||
formData.prefixNo = "";
|
||||
formData.positionNo = "";
|
||||
formData.suffixNo = "";
|
||||
} else {
|
||||
props.rowId && fetchPosition(props.rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -684,7 +417,7 @@ async function emitSearch(keyword: string, typeSelect: string) {
|
|||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="idcard"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
|
|
@ -742,18 +475,6 @@ async function emitSearch(keyword: string, typeSelect: string) {
|
|||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
flat
|
||||
dense
|
||||
icon="mdi-delete"
|
||||
class="q-pa-none q-ml-xs"
|
||||
color="red"
|
||||
@click="deleteData(props.row.id)"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue