fix bug
This commit is contained in:
parent
ab19e5937f
commit
21cb24bbaf
5 changed files with 162 additions and 73 deletions
|
|
@ -9,7 +9,14 @@ import { useRoute } from "vue-router";
|
|||
/** Use */
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, success, showLoader, hideLoader, dialogConfirm } = mixin;
|
||||
const {
|
||||
messageError,
|
||||
success,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
dialogConfirm,
|
||||
findOrgName,
|
||||
} = mixin;
|
||||
const route = useRoute();
|
||||
const retireld_params = route.params.id;
|
||||
|
||||
|
|
@ -82,7 +89,7 @@ watch(modal, () => {
|
|||
}
|
||||
});
|
||||
|
||||
function findOrgName(obj: any) {
|
||||
function findOrgChildName(obj: any) {
|
||||
if (obj) {
|
||||
let name =
|
||||
obj.orgChild4Name != null && obj.orgChild3Name != null
|
||||
|
|
@ -120,36 +127,77 @@ function findOrgName(obj: any) {
|
|||
|
||||
const formPagePersonList = reactive({ keyword: "", pageSize: 10, page: 1 });
|
||||
const maxPage = ref<number>(1);
|
||||
const totalList = ref<number>(0);
|
||||
|
||||
// fecth profile
|
||||
const fecthProfile = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.orgProfileProbation, formPagePersonList)
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(
|
||||
res.data.result.total / formPagePersonList.pageSize
|
||||
);
|
||||
rows.value = res.data.result.data.map((e: any) => ({
|
||||
id: e.id,
|
||||
prefix:e.prefix,
|
||||
firstName:e.firstName,
|
||||
lastName:e.lastName,
|
||||
fullname: e.prefix + e.firstName + " " + e.lastName,
|
||||
position: e.position,
|
||||
level:
|
||||
e.posTypeName && e.posLevelName
|
||||
? e.posTypeName + " (" + e.posLevelName + ")"
|
||||
: "-",
|
||||
organizationOrganization: findOrgName(e),
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
if (props?.dataProfile?.type === "OFFICER") {
|
||||
showLoader();
|
||||
formPagePersonList.keyword =
|
||||
formPagePersonList.keyword === null ? "" : formPagePersonList.keyword;
|
||||
await http
|
||||
.post(config.API.orgProfileProbation, formPagePersonList)
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(
|
||||
res.data.result.total / formPagePersonList.pageSize
|
||||
);
|
||||
totalList.value = res.data.result.total;
|
||||
rows.value = res.data.result.data.map((e: any) => ({
|
||||
id: e.id,
|
||||
prefix: e.prefix,
|
||||
firstName: e.firstName,
|
||||
lastName: e.lastName,
|
||||
fullname: e.prefix + e.firstName + " " + e.lastName,
|
||||
position: e.position,
|
||||
level:
|
||||
e.posTypeName && e.posLevelName
|
||||
? e.posTypeName + " (" + e.posLevelName + ")"
|
||||
: "-",
|
||||
organizationOrganization: findOrgChildName(e),
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
} else {
|
||||
let queryParams: any = {
|
||||
page: formPagePersonList.page,
|
||||
pageSize: formPagePersonList.pageSize,
|
||||
searchKeyword: formPagePersonList.keyword,
|
||||
searchField: "fullName",
|
||||
type: "perm",
|
||||
};
|
||||
http
|
||||
.get(config.API.registryNew("-employee"), { params: queryParams })
|
||||
.then((res) => {
|
||||
maxPage.value = Math.ceil(
|
||||
res.data.result.total / formPagePersonList.pageSize
|
||||
);
|
||||
totalList.value = res.data.result.total;
|
||||
rows.value = res.data.result.data.map((e: any) => ({
|
||||
id: e.id,
|
||||
prefix: e.prefix,
|
||||
firstName: e.firstName,
|
||||
lastName: e.lastName,
|
||||
fullname: e.prefix + e.firstName + " " + e.lastName,
|
||||
position: e.position,
|
||||
level:
|
||||
e.posTypeName && e.posLevelName
|
||||
? e.posTypeName + " (" + e.posLevelName + ")"
|
||||
: "-",
|
||||
organizationOrganization: findOrgName(e),
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// ยืนยันการเพิ่มราชชื่อ
|
||||
|
|
@ -183,20 +231,17 @@ const updateListData = (retireld: string, pId: string) => {
|
|||
props.UpdateListId(retireld, pId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Setiting Pagination
|
||||
*/
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
sortBy: "fullname",
|
||||
descending: true,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
const paginationLabel = (start: number, end: number, total: number) => {
|
||||
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
||||
else return start + "-" + end + " ใน " + total;
|
||||
};
|
||||
function updatePageSize(newPagination: any) {
|
||||
formPagePersonList.page = 1;
|
||||
formPagePersonList.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => formPagePersonList.pageSize,
|
||||
() => {
|
||||
fecthProfile();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -232,17 +277,18 @@ const paginationLabel = (start: number, end: number, total: number) => {
|
|||
borderless
|
||||
outlined
|
||||
dense
|
||||
debounce="300"
|
||||
v-model="filter"
|
||||
clearable
|
||||
v-model="formPagePersonList.keyword"
|
||||
placeholder="ค้นหา"
|
||||
style="width: 850px; max-width: auto"
|
||||
@keyup.enter="(formPagePersonList.page = 1), fecthProfile()"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</q-toolbar>
|
||||
<q-table
|
||||
<d-table
|
||||
flat
|
||||
bordered
|
||||
dense
|
||||
|
|
@ -250,9 +296,8 @@ const paginationLabel = (start: number, end: number, total: number) => {
|
|||
:columns="columns"
|
||||
row-key="name"
|
||||
class="custom-header-table"
|
||||
:filter="filter"
|
||||
:pagination-label="paginationLabel"
|
||||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
@update:pagination="updatePageSize"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
@ -266,12 +311,19 @@ const paginationLabel = (start: number, end: number, total: number) => {
|
|||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td>{{ props.rowIndex + 1 }}</q-td>
|
||||
<q-td>{{
|
||||
(formPagePersonList.page - 1) *
|
||||
Number(formPagePersonList.pageSize) +
|
||||
props.rowIndex +
|
||||
1
|
||||
}}</q-td>
|
||||
<q-td key="fullname" :props="props">
|
||||
{{ props.row.prefix ? props.row.prefix:'' }}{{ props.row.firstName ? props.row.firstName:'' }} {{ props.row.lastName ? props.row.lastName:'' }}
|
||||
{{ props.row.prefix ? props.row.prefix : ""
|
||||
}}{{ props.row.firstName ? props.row.firstName : "" }}
|
||||
{{ props.row.lastName ? props.row.lastName : "" }}
|
||||
</q-td>
|
||||
<q-td key="position" :props="props">
|
||||
{{ props.row.position ? props.row.position:'-' }}
|
||||
{{ props.row.position ? props.row.position : "-" }}
|
||||
</q-td>
|
||||
<q-td key="level" :props="props">{{ props.row.level }}</q-td>
|
||||
<q-td
|
||||
|
|
@ -293,17 +345,19 @@ const paginationLabel = (start: number, end: number, total: number) => {
|
|||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
ทั้งหมด {{ totalList }} รายการ
|
||||
<q-pagination
|
||||
v-model="pagination.page"
|
||||
v-model="formPagePersonList.page"
|
||||
color="primary"
|
||||
:max="scope.pagesNumber"
|
||||
:max="maxPage"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
@update:model-value="fecthProfile"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</q-table>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue