diff --git a/src/modules/14_KPI/components/competency/03ListLinkGroup.vue b/src/modules/14_KPI/components/competency/03ListLinkGroup.vue index e1719bc27..8a2319136 100644 --- a/src/modules/14_KPI/components/competency/03ListLinkGroup.vue +++ b/src/modules/14_KPI/components/competency/03ListLinkGroup.vue @@ -8,12 +8,13 @@ import { useRouter } from "vue-router"; import Header from "@/components/DialogHeader.vue"; import type { DataOption } from "@/modules/14_KPI/interface/index/Main"; +import type { ListGroup } from "@/modules/14_KPI/interface/request/Main"; import http from "@/plugins/http"; import config from "@/app.config"; const modal = ref(false); const router = useRouter(); -const rows = ref(); +const rows = ref([]); const editStatus = ref(false); const groupName = ref(""); const position = ref(null); @@ -207,9 +208,51 @@ async function deleteData(id: string) { // }); } +/** ดึงข้อมูล */ +async function getListGroup() { + showLoader(); + await http + .get(config.API.kpiGroup) + .then(async (res) => { + const data = res.data.result.data; + groupNameOp.value = data.map((item: ListGroup) => ({ + id: item.id, + name: item.nameGroupKPI, + })); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +/** ดึงข้อมูล */ +async function getCompetency() { + showLoader(); + await http + .get(config.API.kpiCapacity + `?type=GROUP`) + .then(async (res) => { + const data = res.data.result.data; + competencyOp.value = data.map((item: any) => ({ + id: item.id, + name: item.name, + })); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + /** เปลี่ยนเป็นหน้าเพิ่มข้อมูล */ function onAdd() { getOptions(); + getListGroup(); + getCompetency(); modal.value = true; } @@ -416,6 +459,7 @@ onMounted(async () => { label="กลุ่มงาน" outlined emit-value + class="inputgreen" map-options option-label="name" option-value="id" diff --git a/src/modules/14_KPI/interface/request/Main.ts b/src/modules/14_KPI/interface/request/Main.ts index 33bb7bfaa..51ab7b843 100644 --- a/src/modules/14_KPI/interface/request/Main.ts +++ b/src/modules/14_KPI/interface/request/Main.ts @@ -48,4 +48,8 @@ interface NewPagination { sortBy: string; } -export type { FormQueryRound, FormRound, FormCompetency, FormDataRole,NewPagination }; +interface ListGroup{ + id:string + nameGroupKPI:string +} +export type { FormQueryRound, FormRound, FormCompetency, FormDataRole,NewPagination,ListGroup }; diff --git a/src/modules/14_KPI/views/indicatorByRole.vue b/src/modules/14_KPI/views/indicatorByRole.vue index 6055ff2f9..374735f34 100644 --- a/src/modules/14_KPI/views/indicatorByRole.vue +++ b/src/modules/14_KPI/views/indicatorByRole.vue @@ -8,11 +8,16 @@ import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; import config from "@/app.config"; import type { NewPagination } from "@/modules/14_KPI/interface/request/Main"; +import type { DataOption } from "@/modules/14_KPI/interface/index/Main"; + /** use*/ const $q = useQuasar(); const router = useRouter(); const { showLoader, hideLoader, dialogRemove, success } = useCounterMixin(); +const positionOp = ref([]); +const positionMainOp = ref([]); + const maxPage = ref(1); const totalList = ref(1); //จำนวนข้อมูลรายการ @@ -49,21 +54,11 @@ const columns = ref([ ]); const visibleColumns = ref(["no", "including", "includingName"]); -const positionOp = ref([ - { id: "1", name: "นักจัดการทั่วไป 1" }, - { id: "2", name: "นักจัดการทั่วไป 2" }, -]); - -const roundOp = ref([ - { id: "1", name: "รอบเมษายน" }, - { id: "2", name: "รอบตุลาคม" }, -]); - const formFilter = reactive({ page: 1, pageSize: 10, - position: "1", - round: "1", + position: "", + round: "APR", keyword: "", }); const pagination = ref({ @@ -71,12 +66,21 @@ const pagination = ref({ rowsPerPage: formFilter.pageSize, }); +/** Option รอบการประเมิน*/ +const roundOp = ref([ + { id: "APR", name: "รอบเมษายน" }, + { + id: "OCT", + name: "รอบตุลาคม", + }, +]); + function fetchList() { showLoader(); http .get( config.API.kpiRoleMainList + - `?page=${formFilter.page}&pageSize=${formFilter.pageSize}` + `?page=${formFilter.page}&pageSize=${formFilter.pageSize}&round=${formFilter.round}&position=${formFilter.position}` ) .then((res) => { console.log(res); @@ -98,13 +102,12 @@ function onClickAddOrView(status: boolean = false, id: string = "") { function onClickDelete(id: number) { dialogRemove($q, () => { http - .delete(config.API.kpiRoleMainList+`/${id}`) - .then((res)=>{ - success($q, "ลบข้อมูลสำเร็จ"); - fetchList() - }).finally(()=>{ - - }) + .delete(config.API.kpiRoleMainList + `/${id}`) + .then((res) => { + success($q, "ลบข้อมูลสำเร็จ"); + fetchList(); + }) + .finally(() => {}); }); } @@ -125,8 +128,45 @@ watch( } ); +/** + * function ต้นหาข้อมูลของ Option + * @param val ค่าที่ต้องการฟิลเตอร์ + * @param update อัพเดทค่า + * @param refData ดาต้าที่ต้องการฟิลเตอร์ + */ +function filterOption(val: any, update: Function) { + update(() => { + positionOp.value = positionMainOp.value.filter( + (v: any) => v.name.indexOf(val) > -1 + ); + }); +} + +/** ดึงข้อมูลตำแหน่ง */ +function getOptions() { + http.get(config.API.orgSalaryPosition).then((res) => { + const dataOp = res.data.result; + const uniqueNames = new Set(); + const filteredData = dataOp + .filter((item: any) => { + if (!uniqueNames.has(item.positionName)) { + uniqueNames.add(item.positionName); + return true; + } + return false; + }) + .map((item: any) => ({ + id: item.positionName, + name: item.positionName, + })); + + positionMainOp.value = filteredData; + }); +} + onMounted(() => { fetchList(); + getOptions(); }); @@ -138,6 +178,36 @@ onMounted(() => {
+ + + + +
@@ -250,15 +321,12 @@ onMounted(() => {