diff --git a/src/modules/06_retirement/components/ListRetirement/AddList.vue b/src/modules/06_retirement/components/ListRetirement/AddList.vue index 865c20433..a9e7a4636 100644 --- a/src/modules/06_retirement/components/ListRetirement/AddList.vue +++ b/src/modules/06_retirement/components/ListRetirement/AddList.vue @@ -16,7 +16,10 @@ const id = route.params.id; const props = defineProps({ retireld: String, listId: String, - UpdateListId: Function, + UpdateListId: { + type: Function, + default: () => console.log("UpdateListId"), + }, }); const modal = ref(false); @@ -125,11 +128,8 @@ watch(modal, () => { fecthlistRetire(); } }); -const updateListId = (val: any) => { - listId.value = val; - if (props.UpdateListId) { - props.UpdateListId(listId.value); - } +const updateListData = (retireld: string, pId: string) => { + props.UpdateListId(retireld, pId); }; const fecthlistRetire = async () => { showLoader(); @@ -199,12 +199,12 @@ const clickAdd = (props: any) => { persistent: true, }) .onOk(async () => { - console.log("เพิ่มข้อมูล"); + // console.log("เพิ่มข้อมูล"); await http .put(config.API.profileRetire(retireld.value), { profileId: data }) .then((res) => { success($q, "เพิ่มข้อมูลสำเร็จ"); - updateListId(data); + updateListData(retireld.value, data); }) .catch((e) => { messageError($q, e); diff --git a/src/modules/06_retirement/components/ListRetirement/TableList.vue b/src/modules/06_retirement/components/ListRetirement/TableList.vue index aa9311d18..29f390b44 100644 --- a/src/modules/06_retirement/components/ListRetirement/TableList.vue +++ b/src/modules/06_retirement/components/ListRetirement/TableList.vue @@ -19,23 +19,23 @@ const modalNote = ref(false); const note = ref(""); const retireProfileId = ref(""); const retireld = ref(); -const listId = ref(""); +const profileId = ref(""); onMounted(() => { - console.log(route.params); - if (route.params.id === undefined) { + // console.log(route.params); + if (retireld_params === undefined) { fecthlistprofile(type_params, year_params); - } - if (route.params.id !== undefined) { + } else { fecthlist(retireld_params); } }); + const fecthlistprofile = async (type: any, year: any) => { showLoader(); await http .get(config.API.profile(type, year)) .then((res: any) => { - console.log(res); + // console.log(res); retireld.value = res.data.result.id; rows.value = res.data.result.profile.map((e: any) => ({ id: e.id, @@ -62,10 +62,11 @@ const fecthlist = async (id: any) => { await http .get(config.API.listRetire(id)) .then((res: any) => { - console.log(res); + // console.log(res); retireld.value = res.data.result.id; rows.value = res.data.result.map((e: any) => ({ id: e.id, + profileId: e.profileId, order: e.order, fixname: e.prefix, name: e.fullName, @@ -76,7 +77,7 @@ const fecthlist = async (id: any) => { positionLavel: e.positionEmployeeLevel, bureau: e.oc, })); - console.log(rows.value); + // console.log(rows.value); }) .catch((e: any) => { messageError($q, e); @@ -250,7 +251,7 @@ const visibleColumns = ref([ const filter = ref(""); const clickDelete = (prop: any) => { - console.log(prop.id); + // console.log(prop.id); $q.dialog({ title: "ยืนยันการลบข้อมูล", message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?", @@ -270,7 +271,7 @@ const clickDelete = (prop: any) => { messageError($q, e); }) .finally(() => { - if (route.params.id === undefined) { + if (retireld_params === undefined) { fecthlistprofile(type_params, year_params); } else fecthlist(retireld_params); }); @@ -285,7 +286,7 @@ const fetchReason = async (val: string) => { await http .get(config.API.reasonId(val)) .then((res: any) => { - console.log(res.data.result); + // console.log(res.data.result); note.value = res.data.result.reason; retireProfileId.value = res.data.result.id; @@ -305,7 +306,7 @@ const saveNote = () => { persistent: true, }) .onOk(async () => { - console.log("บันทึกข้อมูล"); + // console.log("บันทึกข้อมูล"); await http .post(config.API.createnote(), { retireProfileId: retireProfileId.value, @@ -330,13 +331,10 @@ const visibleNote = computed(() => { return true; } }); -watch(listId, () => { - if (route.params.id === undefined) { - fecthlistprofile(type_params, year_params); - } else fecthlist(retireld_params); -}); -const UpdateListId = (newListId: string) => { - listId.value = newListId; + +const UpdateListId = async (retireld: string, pId: string) => { + profileId.value = pId + await fecthlist(retireld) }; // const saveList = () => { // $q.dialog({ @@ -366,14 +364,13 @@ const UpdateListId = (newListId: string) => { // .onDismiss(() => {}); // }; const classrow = (prop: any) => { - console.log(prop.id); - if (prop.id === listId.value) { - return "color: #26a69a "; + if (prop.profileId === profileId.value) { + return "color: #26a69a; border: 1px solid #26a69a;"; } else return ""; }; const paging = ref(true); const pagination = ref({ - sortBy: "fullname", + sortBy: "order", descending: true, page: 1, rowsPerPage: 10, @@ -403,8 +400,8 @@ const paginationLabel = (start: number, end: number, total: number) => { diff --git a/src/modules/06_retirement/views/Main.vue b/src/modules/06_retirement/views/Main.vue index b5a054580..6574a1f67 100644 --- a/src/modules/06_retirement/views/Main.vue +++ b/src/modules/06_retirement/views/Main.vue @@ -246,15 +246,15 @@ const visibleColumns2 = ref(["no", "name", "retireNumber"]); const getYear = () => { yearOptions.length = 0; yearOptions.push(currentYear + 543); - console.log(yearOptions); + // console.log(yearOptions); get(type.value, currentYear); fiscalyear.value = currentYear + 543; }; -const get = async (type: string, year: string) => { +const get = async (type: string, year: any) => { await http .get(config.API.retirement(type, year)) .then((res) => { - console.log(res); + // console.log(res); rows.value = []; let data = res.data.result; @@ -410,7 +410,7 @@ const paginationLabel = (start: string, end: string, total: string) => { else return start + "-" + end + " ใน " + total; }; const nextPage = (prop: any) => { - console.log(prop.id); + // console.log(prop.id); router.push(`/retirement/listretire/${prop.id}/${type.value}`); };