fix(leave-history):edit API search-personal

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-10-08 15:07:56 +07:00
parent af7ac9e78b
commit fd717bbf49

View file

@ -5,28 +5,25 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useLeaveHistoryDataStore } from "@/modules/09_leave/stores/LeaveHistoryStore";
import { calculateFiscalYear } from "@/utils/function";
import { usePagination } from "@/composables/usePagination";
import type { QTableColumn } from "quasar";
import type {
DataOption,
DataPagination,
} from "@/modules/09_leave/interface/index/Main";
import type { DataOption } from "@/modules/09_leave/interface/index/Main";
import type {
DataLeaveType,
DataLeaveBeginning,
} from "@/modules/09_leave/interface/response/leaveHistory";
import DialogHeader from "@/components/DialogHeader.vue";
import { co } from "@fullcalendar/core/internal-common";
/** useStore*/
const $q = useQuasar();
const route = useRoute();
const { leaveTypeData } = storeToRefs(useLeaveHistoryDataStore());
const { findYear } = useLeaveHistoryDataStore();
const { dialogConfirm, showLoader, success, messageError, hideLoader } =
useCounterMixin();
@ -51,13 +48,10 @@ const formFilter = reactive({
});
const searchTypeOption = ref<DataOption[]>([
{ id: "citizenId", name: "เลขประจำตัวประชาชน" },
{ id: "firstName", name: "ชื่อ" },
{ id: "lastName", name: "นามสกุล" },
{ id: "fullName", name: "ชื่อ-นามสกุล" },
]);
const rows = ref<DataLeaveBeginning[]>([]);
const selected = ref<DataLeaveBeginning[]>([]);
const total = ref<number>(0);
const maxPage = ref<number>(0);
const columns = ref<QTableColumn[]>([
{
name: "citizenId",
@ -69,13 +63,16 @@ const columns = ref<QTableColumn[]>([
style: "font-size: 14px",
},
{
name: "fullName",
name: "firstName",
align: "left",
label: "ชื่อ-นามสกุล",
sortable: true,
field: "fullName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
return `${row.prefix || ""}${row.firstName || ""} ${row.lastName || ""}`;
},
},
]);
@ -100,9 +97,7 @@ async function onSubmit() {
: `${config.API.leaveBeginning}/${rowId.value}`;
const method = !isStatusEdit.value ? "post" : "put";
await http[method](pathAPI, {
profileId: !isStatusEdit.value
? selected.value[0].profileId
: profileId.value,
profileId: !isStatusEdit.value ? selected.value[0].id : profileId.value,
leaveTypeId: formData.leaveTypeId,
leaveYear: formData.leaveYear,
leaveDays: formData.leaveDays ? Number(formData.leaveDays) : 0,
@ -127,23 +122,26 @@ async function onSubmit() {
/** ฟังก์ชันเรียกรายชื่อคน*/
async function fetchDataPerson() {
await http
.post(config.API.leaveSearch(), {
citizenId:
formFilter.type === "citizenId" ? formFilter.keyword.trim() : "", //
firstname:
formFilter.type === "firstName" ? formFilter.keyword.trim() : "", //
lastname: formFilter.type === "lastName" ? formFilter.keyword.trim() : "", //
...params.value,
})
.then((res) => {
const result = res.data.result;
pagination.value.rowsNumber = result.total;
rows.value = result.data;
})
.catch((e) => {
messageError($q, e);
});
try {
const res = await http.post(
config.API.orgSearchPersonal(),
{
fieldName: formFilter.type,
keyword: formFilter.keyword.trim(),
system: (route.meta?.Key as string) || undefined,
},
{
params: {
...params.value,
},
}
);
const result = res.data.result;
pagination.value.rowsNumber = result.total;
rows.value = result.data;
} catch (e) {
messageError($q, e);
}
}
/**
@ -250,8 +248,6 @@ watch(modal, async (val) => {
filterLeaveTypeData(),
isStatusEdit.value && defineDataLeaveBeginning(rowData.value),
]);
} catch (error) {
console.log(error);
} finally {
hideLoader();
}
@ -274,12 +270,9 @@ watch(modal, async (val) => {
class="q-pa-none"
style="height: 50vh"
>
<div class="row no-wrap full-height">
<div class="row col-12 no-wrap full-height">
<!-- รายช -->
<div
class="q-pa-md overflow-auto col-md-8 col-xs-12"
v-if="!isStatusEdit"
>
<div class="col-8 overflow-auto q-pa-md" v-if="!isStatusEdit">
<div class="row q-col-gutter-sm">
<div class="col-12 col-sm-6 col-md-3">
<q-select
@ -323,7 +316,7 @@ watch(modal, async (val) => {
ref="table"
:columns="columns"
:rows="rows"
row-key="profileId"
row-key="id"
flat
bordered
:paging="true"
@ -375,7 +368,7 @@ watch(modal, async (val) => {
<q-separator vertical />
<!-- input -->
<div class="q-pa-md col">
<div class="col overflow-hidden q-pa-md">
<div class="row q-col-gutter-sm">
<div class="col-12">
<datepicker