diff --git a/src/modules/13_salary/components/SalaryEmployeeLists/TabMain.vue b/src/modules/13_salary/components/SalaryEmployeeLists/TabMain.vue index 56747c560..dae239097 100644 --- a/src/modules/13_salary/components/SalaryEmployeeLists/TabMain.vue +++ b/src/modules/13_salary/components/SalaryEmployeeLists/TabMain.vue @@ -30,6 +30,9 @@ const { messageError, showLoader, hideLoader } = useCounterMixin(); /** props*/ const props = defineProps({ periodLatest: { type: Object as () => DataPeriodLatest, require: true }, + rootId: { type: String, require: true }, + periodId: { type: String, require: true }, + roundFilter: { type: Object, require: true }, }); const total = ref(); @@ -269,17 +272,17 @@ function fetchDataPeriod(id: string) { } /**function เปลี่ยนกลุ่ม*/ -function changeTabGroup() { - formFilter.page = 1; - formFilter.pageSize = 10; - formFilter.keyword = ""; - store.tabType = "PENDING"; - props.periodLatest && - store.fetchPeriodLatest(props?.periodLatest, store.tabGroup); - store.groupId && fetchDataQuota(store.groupId); - store.groupId && fetchDataPeriod(store.groupId); - splitterModel.value = store.roundMainCode === "APR" ? 13 : 16; -} +// function changeTabGroup() { +// formFilter.page = 1; +// formFilter.pageSize = 10; +// formFilter.keyword = ""; +// store.tabType = "PENDING"; +// props.periodLatest && +// store.fetchPeriodLatest(props?.periodLatest, store.tabGroup); +// store.groupId && fetchDataQuota(store.groupId); +// store.groupId && fetchDataPeriod(store.groupId); +// splitterModel.value = store.roundMainCode === "APR" ? 13 : 16; +// } /**function เปลี่ยนขั้น*/ function changeTabType() { @@ -296,20 +299,53 @@ function fetchDataPeriodNew() { } function onClickDownload(data: DataOption) { - console.log(data); - // showLoader(); - // http - // .get(config.API.salaryReportByid(salaryId.value)) - // .then((res) => { - // const dataList = res.data.result; - // genReportXLSX(dataList, "อัตราเงินเดือน"); - // }) - // .catch((e) => { - // messageError($q, e); - // }) - // .finally(() => { - // hideLoader(); - // }); + showLoader(); + if (data.id === "emp-08") { + const formData = { + type: "HAFT", + startDate: + props?.roundFilter?.shortCode === "APR" + ? `${props?.roundFilter?.year - 1}-10-01` + : `${props?.roundFilter?.year}-04-01`, + endDate: + props?.roundFilter?.shortCode === "APR" + ? `${props?.roundFilter?.year}-03-31` + : `${props?.roundFilter?.year}-09-30`, + }; + http + .post(config.API.leaveReportLeaveday("employee"), formData) + .then((res) => { + const dataList = res.data.result; + genReportXLSX(dataList, data.name); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + } else { + if (props.rootId && props.periodId) { + http + .get( + config.API.salaryReportListsByid( + data.id, + props.rootId, + props.periodId + ) + ) + .then((res) => { + const dataList = res.data.result; + genReportXLSX(dataList, data.name); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + } + } } const modalDialogInfoCriteria = ref(false);