Refactoring code module 01_metadata => 03_positionEmployee

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-05 16:44:08 +07:00
parent a8d794abe6
commit 24c0b87ec8
22 changed files with 324 additions and 348 deletions

View file

@ -1,31 +1,22 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
/** importType*/
import type { QTableProps } from "quasar";
import type {
ObjectPosRef,
FormQuery,
} from "@/modules/01_metadata/interface/index/positionEmployee";
import type {
DataOption,
RowDetailPositions,
} from "@/modules/01_metadata/interface/request/position/index";
import type { FormQuery } from "@/modules/01_metadata/interface/index/positionEmployee";
import type { DataOption } from "@/modules/01_metadata/interface/request/position/index";
import type {
ResGroup,
ResLevel,
ResPossition,
} from "@/modules/01_metadata/interface/response/positionEmployee/Main";
/**importComponets*/
import DialogHeader from "@/components/DialogHeader.vue";
/**importStore*/
import { useCounterMixin } from "@/stores/mixin";
/**use*/
const $q = useQuasar();
const mixin = useCounterMixin();
@ -38,6 +29,7 @@ const {
dialogRemove,
} = mixin;
//table
const rows = ref<ResPossition[]>([]);
const columns = ref<QTableProps["columns"]>([
{
@ -83,47 +75,80 @@ const visibleColumns = ref<string[]>([
"posTypeName",
"posLevelName",
]);
const formQuery = reactive<FormQuery>({
type: "positionName",
keyword: "",
});
//
const optionFilter = ref<DataOption[]>([
{ id: "positionName", name: "ชื่อตำแหน่ง" },
{ id: "positionType", name: "กลุ่มงาน" },
{ id: "positionLevel", name: "ระดับชั้นงาน" },
]);
const formQuery = reactive<FormQuery>({
type: "positionName",
keyword: "",
});
const modalDialog = ref<boolean>(false);
const isStatusEdit = ref<boolean>(false);
const posId = ref<string>("");
const formDataPos = reactive({
posName: "",
posTypeName: "",
posLevelName: "",
});
const posNameRef = ref<object | null>(null);
const posTypeNameRef = ref<object | null>(null);
const posLevelNameRef = ref<object | null>(null);
const objectRef: ObjectPosRef = {
posName: posNameRef,
posTypeName: posTypeNameRef,
posLevelName: posLevelNameRef,
};
const posTypeMain = ref<ResGroup[]>([]);
const posTypeOp = ref<DataOption[]>([]);
const posLevelOp = ref<DataOption[]>([]);
function deletePos(id: string) {
dialogRemove($q, () => {
/**
* งกนดงขอมลรายการตำแหนงจาก API
* @param statusType สถานะการสงประเภทคนหา (true = ไมงประเภทคนหา)
*
* เกบขอมลรายการตำแหนงจากไวใน rows.value
*/
async function fetchData(statusType: boolean = false) {
showLoader();
await http
.get(
config.API.orgEmployeePos +
`?keyword=${formQuery.keyword}&type=${statusType ? "" : formQuery.type}`
)
.then(async (res) => {
rows.value = await res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* งกนยนยนการบนทกขอมลตำแหน
*
* เม isStatusEdit เป false จะทำการเพมขอมลรายการขอมลตำแหน าไมจะทำการแกไขขอม
* และเมอเพมขอมลเสรจจำทำการดงขอมลรายการตำแหนงใหม
*/
function onSubmit() {
dialogConfirm($q, async () => {
const body = {
posDictName: formDataPos.posName,
posTypeId: formDataPos.posTypeName,
posLevelId: formDataPos.posLevelName,
};
showLoader();
http
.delete(config.API.orgEmployeePosById(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
fetchData();
// Phat API
const url = !isStatusEdit.value
? config.API.orgEmployeePos
: config.API.orgEmployeePosById(posId.value);
await http[!isStatusEdit.value ? "post" : "put"](url, body)
.then(async () => {
await fetchData();
success($q, "บันทีกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
@ -134,41 +159,61 @@ function deletePos(id: string) {
});
}
async function onClickOpenDialog(typeEdit: boolean = false, data: any = []) {
modalDialog.value = true;
/**
* งกนยนยนการลบรายการขอมลตำแหน
*
* @param id รายการขอมลตำแหนงทจะลบ
* เมอลบขอมลเสรจจำทำการดงขอมลรายการตำแหนงใหม
*/
function deletePos(id: string) {
dialogRemove($q, async () => {
showLoader();
await http
.delete(config.API.orgEmployeePosById(id))
.then(async () => {
await fetchData();
success($q, "ลบข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
/**
* งกนเป popup เพอแกไขหรอคดลอกขอมลตำแหน
* @param typeEdit สถานะการแกไข (true = แกไข, false = เพมใหมหรอคดลอก)
* @param data อมลตำแหนงทองการแกไขหรอคดลอก
*/
async function onClickOpenDialog(
typeEdit: boolean = false,
data: ResPossition = {} as ResPossition
) {
isStatusEdit.value = typeEdit;
modalDialog.value = true;
//
await fetchType();
updatePosTypeName(data.posTypeId);
isStatusEdit.value = typeEdit;
modalDialog.value = true;
// id
await updatePosTypeName(data.posTypeId);
if (data) {
posId.value = data.id;
setTimeout(() => {
formDataPos.posName = data.posDictName;
formDataPos.posTypeName = data.posTypeId;
formDataPos.posLevelName = data.posLevelId;
}, 200);
formDataPos.posName = data.posDictName;
formDataPos.posTypeName = data.posTypeId;
formDataPos.posLevelName = data.posLevelId;
}
}
async function fetchData(statusFetch: boolean = false) {
showLoader();
await http
.get(
config.API.orgEmployeePos +
`?keyword=${formQuery.keyword}&type=${
statusFetch ? "" : formQuery.type
}`
)
.then((res) => {
rows.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* งกนดงขอมลกลมงาน
*/
async function fetchType() {
if (posTypeMain.value.length === 0) {
showLoader();
@ -191,47 +236,11 @@ async function fetchType() {
}
}
async function onClickSubmit() {
const hasError = [];
for (const key in objectRef) {
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
const property = objectRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
dialogConfirm($q, () => {
submit();
});
}
}
async function submit() {
const body = {
posDictName: formDataPos.posName,
posTypeId: formDataPos.posTypeName,
posLevelId: formDataPos.posLevelName,
};
showLoader();
try {
const url = !isStatusEdit.value
? config.API.orgEmployeePos
: config.API.orgEmployeePosById(posId.value);
await http[!isStatusEdit.value ? "post" : "put"](url, body);
success($q, "บันทีกข้อมูลสำเร็จ");
fetchData();
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
closeDialog();
}
}
function updatePosTypeName(id: string) {
/**
* งกนหาตวเลอกระดบชนงานตาม ID กลมงาน
* @param id กลมงาน
*/
async function updatePosTypeName(id: string) {
const posLevel = posTypeMain.value.find((e: ResGroup) => e.id === id);
posLevelOp.value =
posLevel?.posLevels.map((e: ResLevel) => ({
@ -241,6 +250,10 @@ function updatePosTypeName(id: string) {
formDataPos.posLevelName = "";
}
/**
* งกนป Popup แกไขหรอคดลอกขอมลตำแหน
* และกำหนด formDataPos ไปเปนคาวาง
*/
function closeDialog() {
modalDialog.value = false;
formDataPos.posName = "";
@ -248,8 +261,11 @@ function closeDialog() {
formDataPos.posLevelName = "";
}
onMounted(() => {
fetchData(true);
/**
* hook ทำงานเม Components กเรยกใชงาน
*/
onMounted(async () => {
await fetchData(true);
});
</script>
<template>
@ -403,7 +419,7 @@ onMounted(() => {
<q-dialog v-model="modalDialog" class="dialog" persistent>
<q-card style="width: 350px">
<form @submit.prevent="onClickSubmit">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<DialogHeader
:tittle="`${
isStatusEdit
@ -426,7 +442,7 @@ onMounted(() => {
label="ชื่อตำแหน่ง"
lazy-rules
hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกชื่อตำแหน่ง'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อตำแหน่ง'}`]"
class="inputgreen"
/>
</div>
@ -445,7 +461,7 @@ onMounted(() => {
option-value="id"
lazy-rules
hide-bottom-space
:rules="[(val) => !!val || `${'กรุณาเลือกกลุ่มงาน'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือกกลุ่มงาน'}`]"
@update:model-value="updatePosTypeName"
class="inputgreen"
/>
@ -466,7 +482,7 @@ onMounted(() => {
option-value="id"
lazy-rules
hide-bottom-space
:rules="[(val) => !!val || `${'กรุณาเลือกระดับชั้นงาน'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือกระดับชั้นงาน'}`]"
class="inputgreen"
/>
</div>
@ -476,7 +492,7 @@ onMounted(() => {
<q-card-actions align="right">
<q-btn type="submit" :label="`บันทึก`" color="public" />
</q-card-actions>
</form>
</q-form>
</q-card>
</q-dialog>
</template>

View file

@ -1,28 +1,22 @@
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import { useRouter } from "vue-router";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
/** importType*/
import type { QTableProps } from "quasar";
import type { ObjectGroupRef } from "@/modules/01_metadata/interface/index/positionEmployee";
import type { ResGroup } from "@/modules/01_metadata/interface/response/positionEmployee/Main";
import type { FrmDataGroup } from "@/modules/01_metadata/interface/request/positionEmployee";
/** importComponents*/
import dialogHeader from "@/components/DialogHeader.vue";
/** importStore*/
import { usePositionEmployeeDataStore } from "@/modules/01_metadata/stores/positionEmployeeStore";
import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const store = usePositionEmployeeDataStore();
const router = useRouter();
const mixin = useCounterMixin();
const {
dialogRemove,
dialogConfirm,
@ -30,8 +24,11 @@ const {
messageError,
showLoader,
hideLoader,
} = mixin;
} = useCounterMixin();
//Table
const rows = ref<ResGroup[]>([]); //
const filterKeyword = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([
{
name: "posTypeName",
@ -67,35 +64,28 @@ const visibleColumns = ref<string[]>([
"posTypeRank",
]);
/** from เพิ่มข้อมูลกลุ่มงาน */
//
const formDataGroup = reactive<FrmDataGroup>({
posTypeName: "",
posTypeShortName: "",
posTypeRank: null,
});
/** formRef*/
const posTypeNameRef = ref<Object | null>(null);
const posTypeShortNameRef = ref<Object | null>(null);
const posTypeRankRef = ref<Object | null>(null);
const objectGroupRef: ObjectGroupRef = {
posTypeName: posTypeNameRef,
posTypeShortName: posTypeShortNameRef,
posTypeRank: posTypeRankRef,
};
const editId = ref<string>("");
const filterKeyword = ref<string>("");
const dialog = ref<boolean>(false);
const dialogStatus = ref<string>("");
const rows = ref<ResGroup[]>([]);
/**
* งกนดงขอมลรายการกลมงาน API
*
* เกบขอมลรรายการกลมงานไวใน rows.value
*/
async function fetchData() {
showLoader();
await http
.get(config.API.orgEmployeeType)
.then(async (res) => {
rows.value = res.data.result;
rows.value = await res.data.result;
})
.catch((err) => {
messageError($q, err);
@ -105,54 +95,47 @@ async function fetchData() {
});
}
async function onClickSubmit() {
const hasError = [];
for (const key in objectGroupRef) {
if (Object.prototype.hasOwnProperty.call(objectGroupRef, key)) {
const property = objectGroupRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
dialogConfirm($q, () => {
submit();
});
}
/**
* งกนเป popup แกไขขอมลกลมงาน
* @param data อมลกลมงานทจะแกไข
*
* กำหนด dialogStatus เป edit และกำหนดให ฟอรมขอมลกลมงาน เป อมลทจะแกไข
*
*/
function onClickOpenDialogEdit(data: ResGroup) {
dialogStatus.value = "edit";
dialog.value = true;
editId.value = data.id;
formDataGroup.posTypeName = data.posTypeName;
formDataGroup.posTypeShortName = data.posTypeShortName;
formDataGroup.posTypeRank = data.posTypeRank;
}
async function submit() {
const body: FrmDataGroup = {
posTypeName: formDataGroup.posTypeName,
posTypeShortName: formDataGroup.posTypeShortName,
posTypeRank: Number(formDataGroup.posTypeRank),
};
showLoader();
try {
/**
* นยนการบนทกขอมลรายการกลมงาน
*
* dialogStatus เป 'create' จะทำการเพมขอมลรายการกลมงาน าไมจะทำการแกไขขอม
* เมอบนทกขอมลเสรจจะเรยก function fetchData() เพอดงขอมลรายการกลมงานใหม
*
*/
function onSubmit() {
dialogConfirm($q, async () => {
showLoader();
const body: FrmDataGroup = {
posTypeName: formDataGroup.posTypeName,
posTypeShortName: formDataGroup.posTypeShortName,
posTypeRank: Number(formDataGroup.posTypeRank),
};
// Path API
const url =
dialogStatus.value === "create"
? config.API.orgEmployeeType
: config.API.orgEmployeeTypeById(editId.value);
await http[dialogStatus.value === "create" ? "post" : "put"](url, body);
success($q, "บันทีกข้อมูลสำเร็จ");
fetchData();
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
closeDialog();
}
}
function onClickDelete(id: string) {
dialogRemove($q, () => {
showLoader();
http
.delete(config.API.orgEmployeeTypeById(id))
.then(() => {
fetchData();
await http[dialogStatus.value === "create" ? "post" : "put"](url, body)
.then(async () => {
await fetchData();
success($q, "บันทีกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
@ -163,32 +146,31 @@ function onClickDelete(id: string) {
});
}
function onClickOpenDialogEdit(data: ResGroup) {
dialogStatus.value = "edit";
dialog.value = true;
editId.value = data.id;
formDataGroup.posTypeName = data.posTypeName;
formDataGroup.posTypeShortName = data.posTypeShortName;
formDataGroup.posTypeRank = data.posTypeRank;
}
/**
* งกนไปหนารายการระดบชนงาน
* @param id กลมงาน
*/
function onClickDetail(id: string) {
router.push(`/master-data/position-employee/level/${id}`);
}
/**
* งกนป popup แกไขหรอเพมขอมลกลมงาน
*
* และกำหนดให ฟอรมขอมลกลมงาน เปนคาวาง
*/
function closeDialog() {
dialog.value = false;
clearFormData();
}
function clearFormData() {
formDataGroup.posTypeName = "";
formDataGroup.posTypeShortName = "";
formDataGroup.posTypeRank = null;
}
onMounted(() => {
fetchData();
/**
* hook ทำงานเม Components กเรยกใชงาน
*/
onMounted(async () => {
await fetchData();
});
</script>
@ -268,17 +250,6 @@ onMounted(() => {
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<!-- <q-btn
color="red"
flat
dense
round
icon="mdi-delete"
clickable
@click.stop="onClickDelete(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn> -->
</q-td>
<q-td v-for="col in props.cols" :key="col.id">
{{ col.value ? col.value : "-" }}
@ -289,7 +260,7 @@ onMounted(() => {
<q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="width: 350px">
<form @submit.prevent="onClickSubmit">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<q-card-section class="flex justify-between" style="padding: 0">
<dialog-header
:tittle="
@ -313,7 +284,7 @@ onMounted(() => {
lazy-rules
borderless
bg-color="white"
:rules="[(val) => val.length > 0 || 'กรุณากรอกชื่อกลุ่มงาน']"
:rules="[(val:string) => val.length > 0 || 'กรุณากรอกชื่อกลุ่มงาน']"
hide-bottom-space
class="inputgreen"
/>
@ -329,7 +300,7 @@ onMounted(() => {
label="อักษรย่อกลุ่มงาน"
lazy-rules
hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกอักษรย่อกลุ่มงาน'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกอักษรย่อกลุ่มงาน'}`]"
class="inputgreen"
/>
</div>
@ -345,7 +316,7 @@ onMounted(() => {
borderless
min="1"
bg-color="white"
:rules="[(val) => val != undefined || 'กรุณากรอกระดับกลุ่มงาน']"
:rules="[(val:string) => val != undefined || 'กรุณากรอกระดับกลุ่มงาน']"
hide-bottom-space
mask="############"
class="inputgreen"
@ -354,19 +325,11 @@ onMounted(() => {
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
id="onSubmit"
type="submit"
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
>
<q-btn id="onSubmit" type="submit" label="บันทึก" color="public">
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-card-actions>
</form>
</q-form>
</q-card>
</q-dialog>
</template>

View file

@ -11,7 +11,7 @@ import type {
ResGroup,
ResLevel,
} from "@/modules/01_metadata/interface/response/positionEmployee/Main";
import type { ObjectLevelRef } from "@/modules/01_metadata/interface/index/positionEmployee";
import type { DataGroup } from "@/modules/01_metadata/interface/index/positionEmployee";
import type { FormDataLevel } from "@/modules/01_metadata/interface/request/positionEmployee";
/** importComponts*/
@ -23,21 +23,15 @@ import { useCounterMixin } from "@/stores/mixin";
/**use*/
const $q = useQuasar();
const storeOption = useMainOptionDataStore();
const route = useRoute();
const router = useRouter();
const posName = ref<string>("");
const posTypeId = ref<string>(route.params.id.toString());
const {
dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
} = useCounterMixin();
const storeOption = useMainOptionDataStore();
const { dialogConfirm, showLoader, hideLoader, messageError, success } =
useCounterMixin();
// Table
const rows = ref<DataGroup[]>([]); //
const filter = ref<string>(""); //
const columns = ref<QTableProps["columns"]>([
{
name: "no",
@ -60,7 +54,7 @@ const columns = ref<QTableProps["columns"]>([
{
name: "posTypeName",
align: "left",
label: "กลุ่มงาน",
label: "ระดับชั้นงาน",
sortable: true,
field: "posTypeName",
headerStyle: "font-size: 14px",
@ -77,42 +71,38 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const rows = ref<any>([]);
const visibleColumns = ref<string[]>([
"no",
"posLevelName",
"posTypeName",
"posLevelAuthority",
]);
const filter = ref<string>("");
const levelId = ref<string>("");
const titleName = ref<string | null>("");
const posTypeId = ref<string>(route.params.id.toString()); // id
const titleName = ref<string | null>(""); //
const levelId = ref<string>(""); // id
const isStatusEdit = ref<boolean>(false); //
const modalDialog = ref<boolean>(false); // popup
//
const formDataLevel = reactive<FormDataLevel>({
posLevelName: null,
posTypeName: "",
posLevelAuthority: "",
});
/** formRef*/
const posLevelNameRef = ref<Object | null>(null);
const commanderRef = ref<Object | null>(null);
const objectLevelRef: ObjectLevelRef = {
posLevelName: posLevelNameRef,
posLevelAuthority: commanderRef,
};
const id = ref<string>(route.params.id.toString());
function fetchData() {
/**
* งกนดงขอมลรายการระดบชนงาน API
*
* เกบขอมลรรายการระดบชนงานไวใน rows.value
*/
async function fetchData() {
showLoader();
http
.get(config.API.orgEmployeeTypeById(id.value))
.then((res) => {
await http
.get(config.API.orgEmployeeTypeById(posTypeId.value))
.then(async (res) => {
titleName.value = res.data.result.posTypeName ?? null;
formDataLevel.posTypeName = res.data.result.posTypeName;
rows.value = res.data.result.posLevels.map((x: any) => ({
rows.value = await res.data.result.posLevels.map((x: ResLevel) => ({
...x,
posTypeName: res.data.result.posTypeName,
}));
@ -125,9 +115,17 @@ function fetchData() {
});
}
const isStatusEdit = ref<boolean>(false);
const modalDialog = ref<boolean>(false);
function onClickOpenDialog(statusEdit: boolean = false, data: any = []) {
/**
* งกนเป popup แกไขขอมลระดบชนงาน
* @param data อมลระดบชนงานทจะแกไข
*
* กำหนด isStatusEdit เป true และกำหนดให ฟอรมขอมลระดบชนงาน เป อมลทจะแกไข
*
*/
function onClickOpenDialog(
statusEdit: boolean = false,
data: DataGroup = {} as DataGroup
) {
isStatusEdit.value = statusEdit;
modalDialog.value = true;
@ -141,6 +139,11 @@ function onClickOpenDialog(statusEdit: boolean = false, data: any = []) {
}
}
/**
* งกนป popup แกไขหรอเพมขอมลระดบชนงาน
*
* และกำหนดให ฟอรมขอมลระดบชนงาน เปนคาวาง
*/
function onClickCloseDialog() {
modalDialog.value = false;
formDataLevel.posLevelName = null;
@ -148,66 +151,57 @@ function onClickCloseDialog() {
formDataLevel.posLevelAuthority = "";
}
function onClickSubmit() {
const hasError = [];
for (const key in objectLevelRef) {
if (Object.prototype.hasOwnProperty.call(objectLevelRef, key)) {
const property = objectLevelRef[key];
if (property.value && typeof property.value.validate === "function") {
const isValid = property.value.validate();
hasError.push(isValid);
}
}
}
if (hasError.every((result) => result === true)) {
dialogConfirm($q, () => {
submit();
});
}
}
async function submit() {
const body = {
posLevelName: Number(formDataLevel.posLevelName),
posTypeId: posTypeId.value,
posLevelRank: Number(formDataLevel.posLevelName),
posLevelAuthority: formDataLevel.posLevelAuthority,
};
showLoader();
try {
/**
* นยนการบนทกขอมลรายการระดบชนงาน
*
* dialogStatus เป 'false' จะทำการเพมขอมลรายการระดบชนงาน าไมจะทำการแกไขขอม
* เมอบนทกขอมลเสรจจะเรยก function fetchData() เพอดงขอมลรายการระดบชนงานใหม
*
*/
function onSubmit() {
dialogConfirm($q, async () => {
showLoader();
const body = {
posLevelName: Number(formDataLevel.posLevelName),
posTypeId: posTypeId.value,
posLevelRank: Number(formDataLevel.posLevelName),
posLevelAuthority: formDataLevel.posLevelAuthority,
};
// Phat APi
const url = !isStatusEdit.value
? config.API.orgEmployeelevel
: config.API.orgEmployeelevelById(levelId.value);
await http[!isStatusEdit.value ? "post" : "put"](url, body);
success($q, "บันทีกข้อมูลสำเร็จ");
fetchData();
onClickCloseDialog();
} catch (err) {
messageError($q, err);
} finally {
hideLoader();
}
}
function onClickDelete(id: string) {
dialogRemove($q, () => {
http
.delete(config.API.orgEmployeelevelById(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
fetchData();
await http[!isStatusEdit.value ? "post" : "put"](url, body)
.then(async () => {
await fetchData();
success($q, "บันทีกข้อมูลสำเร็จ");
onClickCloseDialog();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
/**
* งกนแปลงตำแหนงผอำนาจ
* @param val าของผอำนาจ
* @returns ตำแหนงผอำนาจ
*/
function convertPosLevelAuthority(val: string) {
const result = storeOption.posLevelAuthorityOption.find((e) => e.id === val);
return result?.label;
}
/**
* hook ทำงานเม Components กเรยกใชงาน
*
* าม posTypeId จะดงขอมลรายการระดบชนงาน
*/
onMounted(() => {
posTypeId.value && fetchData();
});
@ -295,16 +289,6 @@ onMounted(() => {
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<!-- <q-btn
color="red"
flat
dense
round
icon="mdi-delete"
@click="onClickDelete(props.row.id)"
>
<q-tooltip>ลบขอม</q-tooltip>
</q-btn> -->
</q-td>
<q-td v-for="(col, index) in props.cols" :key="col.id">
<div v-if="col.name == 'no'">
@ -325,7 +309,7 @@ onMounted(() => {
<q-dialog v-model="modalDialog" class="dialog" persistent>
<q-card style="width: 350px">
<form @submit.prevent="onClickSubmit">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<q-card-section class="flex justify-between" style="padding: 0">
<DialogHeader
:tittle="isStatusEdit ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
@ -333,7 +317,7 @@ onMounted(() => {
/>
</q-card-section>
<q-separator color="grey-4" />
<q-separator />
<q-card-section class="row q-gutter-y-md">
<div class="col-12">
<q-input
@ -346,8 +330,10 @@ onMounted(() => {
borderless
bg-color="white"
hide-bottom-space
mask="#######################################"
:rules="[(val) => !!val || 'กรุณากรอกระดับชั้นงาน']"
mask="#"
reverse-fill-mask
:rules="[(val:string) => !!val || 'กรุณากรอกระดับชั้นงาน']"
class="inputgreen"
/>
</div>
@ -366,7 +352,8 @@ onMounted(() => {
borderless
bg-color="white"
hide-bottom-space
:rules="[(val) => !!val || 'กรุณาเลือกผู้มีอำนาจสั่งบรรจุ']"
:rules="[(val:string) => !!val || 'กรุณาเลือกผู้มีอำนาจสั่งบรรจุ']"
class="inputgreen"
/>
</div>
@ -374,7 +361,7 @@ onMounted(() => {
<q-select
ref="posTypeIdRef"
v-model="formDataLevel.posTypeName"
label="กลุ่มงาน"
label="ระดับชั้นงาน"
outlined
dense
bg-color="white"
@ -384,21 +371,13 @@ onMounted(() => {
/>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
id="onSubmit"
type="submit"
dense
unelevated
label="บันทึก"
color="public"
class="q-px-md"
>
<q-btn id="onSubmit" type="submit" label="บันทึก" color="public">
<q-tooltip>นทกขอม</q-tooltip>
</q-btn>
</q-card-actions>
</form>
</q-form>
</q-card>
</q-dialog>
</template>

View file

@ -35,7 +35,7 @@ const formExecutive = reactive<RowListForm>({
/**
* นยนการบนทกขอมลรายการตำแหนงทางการบรหาร
*
* isEdit เป false จะทำการเพมขอมลรายการตำแหนงทางการบรหาร าไมจะทำการแกไขขอม
* isEdit เป false จะทำการเพมขอมลรายการตำแหนงทางการบรหาร าไมจะทำการแกไขขอม
* เมอบนทกขอมลเสรจจะเรยก function props.getData() เพอดงขอมลรายการตำแหนงทางการบรหาร
*
*/

View file

@ -25,4 +25,18 @@ interface FormQuery {
keyword: string;
}
export type { ObjectGroupRef, ObjectLevelRef, ObjectPosRef, FormQuery };
interface DataGroup {
id: string;
posLevelAuthority: string;
posLevelName: number;
posLevelRank: number;
posTypeName: string;
}
export type {
ObjectGroupRef,
ObjectLevelRef,
ObjectPosRef,
FormQuery,
DataGroup,
};

View file

@ -21,6 +21,7 @@ interface ResPossition {
posLevelName: number;
posTypeId: string;
posTypeName: string;
posTypeShortName: string;
}
export type { ResGroup, ResLevel, ResPossition };

View file

@ -16,7 +16,7 @@ const personalSubDistrict = () =>
const positionPage = () =>
import("@/modules/01_metadata/views/02_position.vue"); //ข้อมูลตำแหน่งข้าราชการ ฯ
const positionLevelPage = () =>
import("@/modules/01_metadata/components/position/ListLevel.vue"); //รายการระดับของประเภทตำแหน่งทั่วไป
import("@/modules/01_metadata/components/position/TypeDetail.vue"); //รายการระดับของประเภทตำแหน่งทั่วไป
/**
*
@ -24,7 +24,7 @@ const positionLevelPage = () =>
const positionEmployeePage = () =>
import("@/modules/01_metadata/views/03_positionEmployee.vue"); //ข้อมูลตำแหน่งลูกจ้างประจำ
const positionEmployeeLevelPage = () =>
import("@/modules/01_metadata/components/position-employee/03ListLevel.vue"); //รายการระดับชั้นงานบริการพื้นฐาน
import("@/modules/01_metadata/components/position-employee/GroupDetail.vue"); //รายการระดับชั้นงานบริการพื้นฐาน
/**
*

View file

@ -5,14 +5,14 @@ import { usePersonalDataStore } from "@/modules/01_metadata/stores/personalStore
import type { MainTabs } from "@/modules/01_metadata/interface/index/Main";
import ListPrefix from "@/modules/01_metadata/components/personal/01ListPrefix.vue"; //
import ListRank from "@/modules/01_metadata/components/personal/02ListRank.vue"; //
import ListGender from "@/modules/01_metadata/components/personal/03ListGender.vue"; //
import ListRelationship from "@/modules/01_metadata/components/personal/04ListRelationship.vue"; //
import ListBloodGroup from "@/modules/01_metadata/components/personal/05ListBloodGroup.vue"; //
import ListReligion from "@/modules/01_metadata/components/personal/06ListReligion.vue"; //
import ListProvince from "@/modules/01_metadata/components/personal/07ListProvince.vue"; //
import ListEducation from "@/modules/01_metadata/components/personal/08ListEducationLevel.vue"; //
import ListPrefix from "@/modules/01_metadata/components/personal/01_Prefix.vue"; //
import ListRank from "@/modules/01_metadata/components/personal/02_Rank.vue"; //
import ListGender from "@/modules/01_metadata/components/personal/03_Gender.vue"; //
import ListRelationship from "@/modules/01_metadata/components/personal/04_Relationship.vue"; //
import ListBloodGroup from "@/modules/01_metadata/components/personal/05_BloodGroup.vue"; //
import ListReligion from "@/modules/01_metadata/components/personal/06_Religion.vue"; //
import ListProvince from "@/modules/01_metadata/components/personal/07_Province.vue"; //
import ListEducation from "@/modules/01_metadata/components/personal/08_EducationLevel.vue"; //
const store = usePersonalDataStore();

View file

@ -5,9 +5,9 @@ import { usePositionDataStore } from "../stores/positionListStore";
import type { MainTabs } from "@/modules/01_metadata/interface/index/Main";
import ListPosition from "@/modules/01_metadata/components/position/01ListPosition.vue"; //
import ListType from "@/modules/01_metadata/components/position/02ListType.vue"; //
import ListExecutive from "@/modules/01_metadata/components/position/03ListExecutive.vue"; //
import ListPosition from "@/modules/01_metadata/components/position/01_Position.vue"; //
import ListType from "@/modules/01_metadata/components/position/02_Type.vue"; //
import ListExecutive from "@/modules/01_metadata/components/position/03_Executive.vue"; //
const store = usePositionDataStore();

View file

@ -1,13 +1,20 @@
div
<script setup lang="ts">
import { ref, onMounted } from "vue";
import ListPosition from "@/modules/01_metadata/components/position-employee/01ListPosition.vue";
import ListType from "@/modules/01_metadata/components/position-employee/02ListType.vue";
import { usePositionEmployeeDataStore } from "../stores/positionEmployeeStore";
// const store.pathLocation = ref<string>("list_position");
const tabs = ref<Array<any>>([]);
import type { MainTabs } from "@/modules/01_metadata/interface/index/Main";
import ListPosition from "@/modules/01_metadata/components/position-employee/01_PositionMain.vue"; //
import ListType from "@/modules/01_metadata/components/position-employee/02_GroupMain.vue"; //
const store = usePositionEmployeeDataStore();
const tabs = ref<Array<MainTabs>>([]); // Tab
/**
* hook ทำงานเม Components กเรยกใชงาน
*/
onMounted(() => {
const tabsPerson = [
{ label: "ตำแหน่ง", value: "list_position" },
@ -51,10 +58,6 @@ onMounted(() => {
<q-tab-panel name="list_type">
<ListType v-if="store.pathLocation == 'list_type'" />
</q-tab-panel>
<q-tab-panel name="list_executive">
<ListExecutive v-if="store.pathLocation == 'list_executive'" />
</q-tab-panel>
</q-tab-panels>
</q-card>
</template>