อัตรากำลังลูกจ้างประจำ ฯ => refactor code

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-25 15:00:26 +07:00
parent 7e2350eef8
commit 81e0a82b0e
18 changed files with 377 additions and 188 deletions

View file

@ -4,33 +4,48 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/**
* importType
*/
import type {
ResGroup,
ResLevel,
} from "@/modules/01_metadataNew/interface/response/positionEmployee/Main";
import type { ObjectPosRef } from "@/modules/01_metadataNew/interface/index/positionEmployee";
import type { DataOption } from "@/modules/16_positionEmployee/interface/index/Main";
import type { OptionType } from "@/modules/16_positionEmployee/interface/response/organizational";
/**
* importComponents
*/
import DialogHeader from "@/components/DialogHeader.vue";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin";
const isSpecial = ref<boolean>(false);
/**
* use
*/
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, messageError, success } = mixin;
/**
* props
*/
const modal = defineModel<boolean>("modalAdd", { required: true });
const isEditCheck = defineModel<boolean>("isEdit", { required: true });
const props = defineProps({
emitSearch: Function,
getData: Function,
data: Object,
levelOp: Object,
});
const modal = defineModel<boolean>("modalAdd", { required: true });
const isEditCheck = defineModel<boolean>("isEdit", { required: true });
const $q = useQuasar();
const mixin = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, messageError, success } = mixin;
const isDisValidate = ref<boolean>(false);
const isSpecial = ref<boolean>(false);
const formDataPos = reactive({
posName: "",
posTypeName: "",
@ -49,7 +64,9 @@ const posTypeMain = ref<ResGroup[]>([]);
const posTypeOp = ref<DataOption[]>([]);
const posLevelOp = ref<DataOption[]>([]);
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
/**
* งกนตรวจสอบความถกตองของขอมลในฟอร
*/
function validateFormPositionEdit() {
isDisValidate.value = false;
const hasError = [];
@ -80,9 +97,9 @@ async function submit() {
? config.API.orgEmployeePos
: config.API.orgEmployeePosById(props?.data?.id);
await http[!isEditCheck.value ? "post" : "put"](url, body);
success($q, "บันทีกข้อมูลสำเร็จ");
props.emitSearch?.(formDataPos.posName, "positionName");
close();
await props.emitSearch?.(formDataPos.posName, "positionName");
await success($q, "บันทีกข้อมูลสำเร็จ");
await close();
} catch (err) {
messageError($q, err);
} finally {

View file

@ -4,22 +4,17 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type {
FormDataPosition,
FormPositionRef,
DataOption,
FormPositionSelect,
RowDetailPositions,
FormPositionSelectRef,
ListMenu,
} from "@/modules/16_positionEmployee/interface/index/Main";
import type {
OptionType,
OptionLevel,
OptionExecutive,
DataPosition,
} from "@/modules/16_positionEmployee/interface/response/organizational";
import type { FilterMaster } from "@/modules/16_positionEmployee/interface/request/organizational";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogAddPosition from "@/modules/16_positionEmployee/components/DialogAddPosition.vue";
@ -705,7 +700,6 @@ watch(
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</d-table>

View file

@ -1,20 +1,42 @@
<script setup lang="ts">
import { ref, computed, watch } from "vue";
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type { HistoryPos } from "@/modules/16_positionEmployee/interface/response/organizational";
/**
* importCompoonents
*/
import Header from "@/components/DialogHeader.vue";
/**
* import*Store
*/
import { useCounterMixin } from "@/stores/mixin";
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
/**
* use
*/
const store = usePositionEmp();
const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin();
const $q = useQuasar();
/**
* props
*/
const modal = defineModel<boolean>("modal", { required: true });
const props = defineProps({
rowId: {
type: String,
},
});
const columns = ref<QTableProps["columns"]>([
{
@ -73,15 +95,13 @@ const columns = ref<QTableProps["columns"]>([
]);
const rows = ref<any[]>([]);
const props = defineProps({
rowId: {
type: String,
},
});
async function fetchHistoryPos(id: string) {
/**
* function เรยกขอมลประวตำแหน
* @param id
*/
function fetchHistoryPos(id: string) {
showLoader();
await http
http
.get(config.API.orgPosHistory(id))
.then((res) => {
const data: HistoryPos[] = res.data.result;
@ -102,6 +122,9 @@ async function fetchHistoryPos(id: string) {
});
}
/**
* callback function ทำงานเม modal === true
*/
watch(
() => modal.value,
() => {

View file

@ -4,6 +4,9 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type {
OrgTree,
@ -15,11 +18,20 @@ import type {
} from "@/modules/16_positionEmployee/interface/request/organizational";
import type { DataTree } from "@/modules/16_positionEmployee/interface/index/organizational";
/**
* importCompoonents
*/
import HeaderDialog from "@/components/DialogHeader.vue";
/**
* import*Store
*/
import { useCounterMixin } from "@/stores/mixin";
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
/**
* use
*/
const $q = useQuasar();
const store = usePositionEmp();
const {
@ -31,13 +43,15 @@ const {
success,
} = useCounterMixin();
/**
* props
*/
const modal = defineModel<boolean>("modal", { required: true });
const reqMaster = defineModel<FilterMaster>("reqMaster", { required: true });
const totalPage = defineModel<number>("totalPage", { required: true });
const nodeTree = defineModel<OrgTree[]>("nodeTree", { required: true });
const columns = defineModel<QTableProps[]>("columns", {});
const rows = defineModel<PosMaster2[]>("rows", { required: true });
const props = defineProps({
fetchDataTree: {
type: Function,
@ -66,11 +80,17 @@ const levelTree = ref<number>(0);
const filterTable = ref<string>("");
const selectedFilter = ref<PosMaster2[]>([]);
/**
* function เช filter
*/
function resetFilter() {
filterTree.value = "";
filterRef.value.focus();
}
/**
* function เลอกขอมลหนวยงาน
*/
function updateSelected(data: DataTree) {
levelTree.value = data.orgLevel;
selectedTree.value = data.orgTreeId;
@ -82,6 +102,9 @@ const isDisable = computed(() => {
} else return false;
});
/**
* function นยนการยายแหนงจากหนวยงาน/วนราชการปจจ
*/
function onClickMovePos() {
if (selectedTree.value === "" || selectedTree.value === null) {
dialogMessageNotify($q, "กรุณาเลือกหน่วยงานที่จะย้ายไป");

View file

@ -26,16 +26,6 @@ function close() {
<q-separator />
<q-card-section>
<div class="q-px-md">
<!-- <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">
<div>
<p>ตำแหนงเลขท</p>
</div>
</div>
<div class="col-8 text-grey-8">
<p>{{ prosp?.dataDetailPos?.posMasterNo }}</p>
</div>
</div> -->
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">
<div>

View file

@ -4,7 +4,9 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
/** importType*/
/**
* importType
*/
import type { QTableProps } from "quasar";
import type {
Position,
@ -22,14 +24,20 @@ import type {
TypePos,
} from "@/modules/16_positionEmployee/interface/response/organizational";
/** importCompoonents*/
/**
* importCompoonents
*/
import DialogHeader from "@/components/DialogHeader.vue";
/** import*Store*/
/**
* import*Store
*/
import { useCounterMixin } from "@/stores/mixin";
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
/** use*/
/**
* use
*/
const $q = useQuasar();
const store = usePositionEmp();
const {
@ -41,7 +49,9 @@ const {
dialogMessageNotify,
} = useCounterMixin();
/** props*/
/**
* props
*/
const modal = defineModel<boolean>("modal", { required: true });
const props = defineProps({
fetchActive: {
@ -60,7 +70,6 @@ const props = defineProps({
});
const isReadonly = ref<boolean>(false); //
const isDisValidate = ref<boolean>(false);
const typeOpsMain = ref<DataOption[]>([]);
const levelOpsMain = ref<DataOption[]>([]);
const typeOps = ref<DataOption[]>([]);
@ -78,7 +87,11 @@ const formData = reactive<FormPositionFilter>({
status: "",
});
/** Table*/
/**
* อม Table
*/
const row = ref<Position[]>([]);
const rowResult = ref<SeaechResult[]>([]);
const visibleColumnsResult = ref<String[]>([
"no",
"citizenId",
@ -182,18 +195,20 @@ const columnsResult = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const row = ref<Position[]>([]);
const rowResult = ref<SeaechResult[]>([]);
/** function closePopup*/
/**
* function closePopup
*/
function close() {
modal.value = false;
}
/** function เรียกข้อมูลประเภทตำแหน่ง*/
async function fetchType() {
/**
* function เรยกขอมลประเภทตำแหน
*/
function fetchType() {
showLoader();
await http
http
.get(config.API.orgEmployeeType)
.then((res) => {
dataLevel.value = res.data.result;
@ -222,7 +237,9 @@ function inputEdit(val: boolean) {
};
}
/** function เรียกข้แมูลระดับตำแหน่ง*/
/**
* function เรยกขแมลระดบตำแหน
*/
function updateSelectType(val: string) {
const listLevel: any = dataLevel.value.find((e: TypePos) => e.id === val);
levelOpsMain.value = listLevel?.posLevels.map((e: OptionLevel) => ({
@ -233,7 +250,9 @@ function updateSelectType(val: string) {
formData.positionLevel = "";
}
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
/**
* งกนตรวจสอบความถกตองของขอมลในฟอร
*/
function validateForm() {
if (selected.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกรายการตำแหน่ง");
@ -244,7 +263,9 @@ function validateForm() {
}
}
/** function ยืนยันการบันทึกข้อมูล */
/**
* function นยนการบนทกขอม
*/
function onSubmit() {
dialogConfirm(
$q,
@ -281,8 +302,11 @@ const page = ref<number>(1);
const pageSize = ref<number>(10);
const totalPage = ref<number>(0);
const selectedProfile = ref<SeaechResult[]>([]);
/** functiuon ค้นหาคนครอง */
async function searchData() {
/**
* functiuon นหาคนครอง
*/
function searchData() {
showLoader();
const reqBody = {
posTypeId: formData.positionType, // id
@ -292,7 +316,7 @@ async function searchData() {
pageSize: pageSize.value, //*
keyword: formData.personal, //
};
await http
http
.post(config.API.orgSearchProfileEmp, reqBody)
.then((res) => {
totalPage.value = Math.ceil(res.data.result.total / pageSize.value);
@ -315,13 +339,17 @@ async function searchData() {
});
}
/** function update PageSize*/
/**
* function update PageSize
*/
function updatePagination(newPagination: NewPagination) {
pageSize.value = newPagination.rowsPerPage;
page.value = 1;
}
/** function เคลียร์Form*/
/**
* function เคลยรForm
*/
function clearForm() {
formData.positionType = "";
formData.positionLevel = "";
@ -334,13 +362,17 @@ function clearForm() {
isSit.value = false;
}
/** function เคลียร์ตำแหน่ง*/
/**
* function เคลยรตำแหน
*/
function clearPosition() {
formData.positionType = "";
formData.positionLevel = "";
}
/** callback function ทำงานเมื่อเปิด popup*/
/**
* callback function ทำงานเมอเป popup
*/
watch(
() => modal.value,
async () => {
@ -376,7 +408,9 @@ watch(
}
);
/** callback function ทำงานการค้นหาข้อมุลคนครองเมื่อมีการ update Pagination*/
/**
* callback function ทำงานการคนหาขอมลคนครองเมอมการ update Pagination
*/
watch([() => page.value, () => pageSize.value], () => {
searchData();
});

View file

@ -3,20 +3,42 @@ import { ref, watch, defineProps } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type { DataSortPos } from "@/modules/02_organizationalNew/interface/index/organizational";
/**
* importComponents
*/
import DialogHeader from "@/components/DialogHeader.vue";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin";
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
/**
* use
*/
const $q = useQuasar();
const store = usePositionEmp();
const { dialogConfirm, showLoader, success, hideLoader, messageError } =
useCounterMixin();
/**
* props
*/
const modal = defineModel<boolean>("sortPosition", { required: true });
const rows = ref<any[]>([]);
const props = defineProps({
fetchDataTable: Function,
});
/** ข้อมูล Table*/
const rows = ref<DataSortPos[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
@ -28,22 +50,22 @@ const columns = ref<QTableProps["columns"]>([
},
]);
const props = defineProps({
fetchDataTable: Function,
});
function onDrop(from: any, to: any) {
onDropRow(from, to);
}
function onDropRow(from: any, to: any) {
/**
* fiunction ดลำด
* @param from ตำแหนงป
* @param to ตำแหนงทจะยายไป
*/
function onDrop(from: number, to: number) {
rows.value.splice(to, 0, rows.value.splice(from, 1)[0]);
}
/**
* function นทกการจดลำด
*/
function save() {
dialogConfirm($q, () => {
const data = rows.value;
const dataId = data.map((item: any) => item.id);
const dataId = data.map((item: DataSortPos) => item.id);
showLoader();
http
.post(config.API.orgPosSortEmp, {
@ -51,10 +73,10 @@ function save() {
type: store.level,
sortId: dataId,
})
.then((res) => {
.then(async () => {
await props.fetchDataTable?.(store.treeId, store.level, false);
await success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchDataTable?.(store.treeId, store.level, false);
})
.catch((e) => {
messageError($q, e);
@ -65,6 +87,9 @@ function save() {
});
}
/**
* function เรยกรายการขอมลตำแหน
*/
function getData() {
showLoader();
http
@ -79,6 +104,7 @@ function getData() {
})
.then((res) => {
const dataList = res.data.result.data;
const dataMap = dataList.map((item: any) => ({
id: item.id,
name: `${item.orgShortname}${
@ -100,6 +126,9 @@ function getData() {
});
}
/**
* callback function ทำงานเม modal = true ทำการเรยกขอมลตำแหน
*/
watch(
() => modal.value,
() => {

View file

@ -49,7 +49,9 @@ const selectedTree = ref<string>("");
const filterRef = ref();
const levelTree = ref<number>(0);
/** function เรียกข้อมูล Tree แบบ ปัจจุบัน*/
/**
* function เรยกขอม Tree แบบ จจ
*/
async function fetchTree() {
showLoader();
const id: string = store.activeId ? store.activeId?.toString() : "";
@ -66,16 +68,20 @@ async function fetchTree() {
});
}
/** resetFilterTree*/
/**
* resetFilterTree
*/
function resetFilter() {
filterTree.value = "";
filterRef.value.focus();
}
/** function เลือกหน่วยงาน*/
/**
* function เลอกหนวยงาน
*/
async function updateSelected(data: DataTree) {
levelTree.value = data.orgLevel;
selectedTree.value = data.orgTreeId;
levelTree.value = await data.orgLevel;
selectedTree.value = await data.orgTreeId;
reqMaster.id = await data.orgTreeId;
reqMaster.type = await data.orgLevel;
await fetchTable();
@ -116,7 +122,9 @@ const reqMaster = reactive<FilterMaster>({
const totalRow = ref<number>(0);
const selectedPos = ref<PosMaster[]>([]);
/** function เรียกข้อมูล Table Position*/
/**
* function เรยกขอม Table Position
*/
async function fetchTable() {
selectedPos.value = [];
await http
@ -148,13 +156,17 @@ function updatePagination(newPagination: NewPagination) {
reqMaster.page = 1;
}
/** funcion ค้นหาข้อมูลใน Table*/
/**
funcion นหาขอมลใน Table
*/
async function filterKeyword() {
reqMaster.page = 1;
fetchTable();
reqMaster.page = await 1;
await fetchTable();
}
/** function ยืนยันกาสืบทอดตำแหน่ง */
/**
* function นยนกาสบทอดตำแหน
*/
function onClickConfirm() {
if (selectedPos.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกตำแหน่งสืบทอด");
@ -186,20 +198,26 @@ function onClickConfirm() {
}
}
/** callblck function ทำการ fetch ข้อมูล tree เมื่อเปิด popup*/
/**
* callblck function ทำการ fetch อม tree เมอเป popup
*/
watch(
() => modal.value,
async () => {
modal.value ? await fetchTree() : clearForm();
() => {
modal.value ? fetchTree() : clearForm();
}
);
/** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนหน้า*/
/**
* callblck function ทำการ fetch อม Table เมอมการเปลยนหน
*/
watch([() => reqMaster.page, () => reqMaster.pageSize], async () => {
await fetchTable();
});
/** function clear ข้อมูล*/
/**
* function clear อม
*/
function clearForm() {
nodeTree.value = [];
rows.value = [];

View file

@ -5,7 +5,6 @@ import http from "@/plugins/http";
import config from "@/app.config";
/** importType*/
import type { OrgTree } from "@/modules/16_positionEmployee/interface/response/organizational";
import type { DataTree } from "@/modules/16_positionEmployee/interface/index/organizational";

View file

@ -5,20 +5,21 @@ import config from "@/app.config";
import http from "@/plugins/http";
import genreport from "@/plugins/genreportxlsx";
/** importType*/
/**
* importType
*/
import type { QTableProps } from "quasar";
import type {
ListMenu,
NewPagination,
} from "@/modules/16_positionEmployee/interface/index/Main";
import type { FilterMaster } from "@/modules/16_positionEmployee/interface/request/organizational";
import type {
PosMaster2,
OrgTree,
} from "@/modules/16_positionEmployee/interface/response/organizational";
import type { PosMaster2 } from "@/modules/16_positionEmployee/interface/response/organizational";
import type { DataPosition } from "@/modules/16_positionEmployee/interface/index/organizational";
/** importComponents*/
/**
* importComponents
*/
import DialogFormPosotion from "@/modules/16_positionEmployee/components/DialogFormPosition.vue";
import DialogPositionDetail from "@/modules/16_positionEmployee/components/DialogPositionDetail.vue";
import DialogSort from "@/modules/16_positionEmployee/components/DialogSortPosition.vue";
@ -27,23 +28,29 @@ import DialogHistoryPos from "@/modules/16_positionEmployee/components/DialogHis
import DialogSelectPerson from "@/modules/16_positionEmployee/components/DialogSelectPerson.vue";
import DialogSuccession from "@/modules/16_positionEmployee/components/DialogSuccession.vue";
/** importStore*/
/**
* importStore
*/
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
import { useCounterMixin } from "@/stores/mixin";
/**
* ues
*/
const $q = useQuasar();
const store = usePositionEmp();
const { showLoader, hideLoader, messageError, success, dialogRemove } =
useCounterMixin();
/** prosp*/
/**
* prosp
*/
const nodeTree = defineModel<any>("nodeTree", { required: true });
const orgLevel = defineModel<number>("orgLevel", { required: true });
const treeId = defineModel<string>("treeId", { required: true });
const reqMaster = defineModel<FilterMaster>("reqMaster", { required: true });
const totalPage = defineModel<number>("totalPage", { required: true });
const posMaster = defineModel<PosMaster2[]>("posMaster", { required: true });
// const shortName = defineModel<string>("shortName", { required: true });
const props = defineProps({
filterKeyword: { type: Function, require: true, default: () => {} },
fetchDataTable: {
@ -63,7 +70,17 @@ const props = defineProps({
},
});
const modalSelectPerson = ref<boolean>(false);
/**
* modal popup
*/
const dialogDetail = ref<boolean>(false); //
const modalSelectPerson = ref<boolean>(false); //
const dialogPosition = ref<boolean>(false); //
const modalSort = ref<boolean>(false); //
const modalDialogMMove = ref<boolean>(false); //
const modalDialogSuccession = ref<boolean>(false); //
const modalDialogHistoryPos = ref<boolean>(false); //
const rowId = ref<string>("");
const actionType = ref<string>("");
/** ListMenu Table*/
@ -86,32 +103,6 @@ const listMenu = ref<ListMenu[]>([
type: "MOVE",
color: "blue-10",
},
// {
// label: "",
// icon: "mdi-account-multiple-outline",
// type: "INHERIT",
// color: "deep-orange",
// },
// {
// label: "",
// icon: "history",
// type: "HISTORY",
// color: "deep-purple",
// },
]);
const document = ref<any>([
{
name: "บัญชี 1",
val: "report1",
},
{
name: "บัญชี 2",
val: "report2",
},
{
name: "บัญชี 3",
val: "report3",
},
]);
/** columns*/
@ -172,7 +163,6 @@ const columns = ref<QTableProps["columns"]>([
},
]);
const dialogPosition = ref<boolean>(false);
/**
* function openPopup เพมอตรากำล
* @param type ประเภท
@ -184,7 +174,6 @@ function onClickPosition(type: string, id: string) {
dialogPosition.value = !dialogPosition.value;
}
const dialogDetail = ref<boolean>(false);
const dataDetailPos = ref<DataPosition[]>([]);
/**
* function รายละเอยดประวตำแหน
@ -218,13 +207,13 @@ function onClickDelete(id: string) {
});
}
const modalSort = ref<boolean>(false);
/** fdunction จัดลำดับตำแหน่ง */
/**
* fdunction ดลำดบตำแหน
*/
function onClickSort() {
modalSort.value = true;
}
const modalDialogMMove = ref<boolean>(false);
const typeMove = ref<string>("");
/**
* function openPopup ายตำแหน
@ -237,7 +226,6 @@ function onClickMovePos(id: string, type: string) {
rowId.value = id;
}
const modalDialogHistoryPos = ref<boolean>(false);
/**
* function ประวตำแหน
* @param id ID ตำแหน
@ -256,13 +244,17 @@ function updatePagination(newPagination: NewPagination) {
reqMaster.value.page = 1;
}
/** function openPopup เลือกตนครอง*/
/**
* function openPopup เลอกตนครอง
*/
function openSelectPerson(data: DataPosition[]) {
modalSelectPerson.value = true;
dataDetailPos.value = data;
}
/** ลบคนครอง */
/**
* ลบคนครอง
*/
function removePerson(id: string) {
dialogRemove(
$q,
@ -291,14 +283,17 @@ function removePerson(id: string) {
);
}
const modalDialogSuccession = ref<boolean>(false);
/** function openPopup สืบทอดตำแหน่ง*/
/**
* function openPopup บทอดตำแหน
*/
function onClickInherit(id: string) {
modalDialogSuccession.value = !modalDialogSuccession.value;
rowId.value = id;
}
/** ดึงข้อมูลสถิติจำนวนด้านบน*/
/**
* งขอมลสถจำนวนดานบน
*/
function getSummary() {
showLoader();
http
@ -331,22 +326,6 @@ function getSummary() {
});
}
/** function DownloadReport*/
async function onClickDownloadReport(val: string, name: string) {
showLoader();
await http
.get(config.API.orgReportEmp(val))
.then((res) => {
const data = res.data.result;
if (data) {
genreport(data, name);
}
})
.catch((err) => {
messageError($q, err);
});
}
const pagination = ref({
page: reqMaster.value.page,
rowsPerPage: reqMaster.value.pageSize,

View file

@ -26,13 +26,12 @@ const store = usePositionEmp();
const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const nodeTree = ref<OrgTree[]>(); // Tree
const nodeTree = ref<OrgTree[]>([]); // Tree
const nodeId = ref<string>(""); // id Tree
const orgLevel = ref<number>(0); // levelTree
const isLoad = ref<boolean>(false); // loadTable
const isLoadTree = ref<boolean>(false); // loadTable
const mainTree = ref<OrgTree>();
const selected = ref<string>("");
const reqMaster = reactive<FilterMaster>({
@ -53,10 +52,10 @@ const shortName = ref<string>("");
* function fetch อมลของ Tree
* @param id id โครงสราง
*/
async function fetchDataTree(id: string) {
function fetchDataTree(id: string) {
isLoadTree.value = false;
showLoader();
await http
http
.get(config.API.orgByid(id.toString()))
.then((res) => {
const data = res.data.result;
@ -78,9 +77,8 @@ async function fetchDataTree(id: string) {
* @param id idTree
* @param level levelTree
*/
async function fetchDataTable(id: string, level: number, action: boolean) {
function fetchDataTable(id: string, level: number, action: boolean) {
searchAndReplaceOrgName(nodeTree.value, id);
orgLevel.value = level;
reqMaster.id = id;
reqMaster.type = level;
@ -99,7 +97,7 @@ async function fetchDataTable(id: string, level: number, action: boolean) {
if (action === true) {
isLoad.value = true;
}
await http
http
.post(config.API.orgPosMasterListEmp, reqMaster)
.then(async (res) => {
posMaster.value = [];
@ -127,7 +125,9 @@ async function fetchDataTable(id: string, level: number, action: boolean) {
});
}
/** ดึงข้อมูลสถิติจำนวนด้านบน*/
/**
* งขอมลสถจำนวนดานบน
*/
function getSummary() {
http
.post(config.API.orgSummaryEmp, {
@ -152,13 +152,20 @@ function getSummary() {
});
}
/** funcion ค้นหาข้อมูลใน Table*/
async function filterKeyword() {
/**
* funcion นหาขอมลใน Table
*/
function filterKeyword() {
reqMaster.page = 1;
action1.value === false &&
fetchDataTable(reqMaster.id, reqMaster.type, false);
}
/**
* function นหาช
* @param data อม Tree
* @param targetId tree
*/
function searchAndReplaceOrgName(data: any, targetId: string) {
for (const child of data) {
if (child.orgTreeId === targetId) {
@ -173,20 +180,26 @@ function searchAndReplaceOrgName(data: any, targetId: string) {
return false; // Not found in this branch
}
/**lifecycle Hook*/
/**
* lifecycle Hook
*/
onMounted(() => {
setTimeout(async () => {
store.activeId && (await fetchDataTree(store.activeId));
}, 200);
});
/** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนหน้า*/
/**
* callblck function ทำการ fetch อม Table เมอมการเปลยนหน
*/
watch([() => reqMaster.page, () => reqMaster.pageSize], () => {
action1.value === false &&
fetchDataTable(reqMaster.id, reqMaster.type, false);
});
/** callblck function ทำการ fetch ข้อมูล Table เมื่อแสดงตำแหน่งทั้งหมด*/
/**
* callblck function ทำการ fetch อม Table เมอแสดงตำแหนงทงหมด
*/
watch(
() => reqMaster.isAll,
() => {

View file

@ -97,6 +97,24 @@ interface FormPositionFilter {
status: string;
}
interface DataSortPos {
id: string;
name: string;
posMasterNo: number;
posMasterNoPrefix: string;
posMasterNoSuffix: string;
}
interface DataSortAgency {
name: string;
orgLevel: number;
orgRevisionId: string;
orgRootId: string;
orgTreeId: string;
orgTreeName: string;
orgTreeShortName: string;
}
export type {
DataPosition,
Position,
@ -104,4 +122,6 @@ export type {
DataTree,
SeaechResult,
FormPositionFilter,
DataSortPos,
DataSortAgency,
};