paging
This commit is contained in:
parent
ece1203d84
commit
4b316bcfe0
3 changed files with 56 additions and 17 deletions
|
|
@ -212,4 +212,5 @@ export default {
|
||||||
/**ปรับรายการเงินเดือนขึ้น-ลง*/
|
/**ปรับรายการเงินเดือนขึ้น-ลง*/
|
||||||
salarySwap: (dierction: string, id: string) =>
|
salarySwap: (dierction: string, id: string) =>
|
||||||
`${profile}salary/swap/${dierction}/${id}`,
|
`${profile}salary/swap/${dierction}/${id}`,
|
||||||
|
listProfileNew:(id:string,page:number,pageSize:number)=>`${profile}search/new-page/oc/${id}/officer?page=${page}&pageSize=${pageSize}`
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,19 @@
|
||||||
dense
|
dense
|
||||||
virtual-scroll
|
virtual-scroll
|
||||||
:virtual-scroll-sticky-size-start="48"
|
:virtual-scroll-sticky-size-start="48"
|
||||||
:rows-per-page-options="[10, 25, 50, 100]"
|
:pagination-label="paginationLabel"
|
||||||
v-model:pagination="pagination"
|
v-model:pagination="pagination"
|
||||||
>
|
>
|
||||||
<template v-slot:pagination="scope">
|
<template v-slot:pagination="scope">
|
||||||
<q-pagination
|
<q-pagination
|
||||||
v-model="currentPage"
|
v-model="currentPage"
|
||||||
active-color="primary"
|
active-color="primary"
|
||||||
color="dark"
|
color="dark"
|
||||||
:max="Number(maxPage)"
|
:max="Number(props.maxPage)"
|
||||||
size="sm"
|
size="sm"
|
||||||
boundary-links
|
boundary-links
|
||||||
direction-links
|
direction-links
|
||||||
></q-pagination>
|
></q-pagination>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:top="props">
|
<template v-slot:top="props">
|
||||||
|
|
@ -458,7 +458,7 @@ import PopupADdEmployee from "@/components/DialogAddEmployee.vue";
|
||||||
const currentPage = ref<number>(1);
|
const currentPage = ref<number>(1);
|
||||||
const maxPage = ref<number>(1);
|
const maxPage = ref<number>(1);
|
||||||
const page = ref<number>(1);
|
const page = ref<number>(1);
|
||||||
const rowsPerPage = ref<number>(10);
|
const rowsPerPage = ref<number>(20);
|
||||||
|
|
||||||
|
|
||||||
const attrs = ref<any>(useAttrs());
|
const attrs = ref<any>(useAttrs());
|
||||||
|
|
@ -519,6 +519,18 @@ const props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => console.log("not function"),
|
default: () => console.log("not function"),
|
||||||
},
|
},
|
||||||
|
maxPage: {
|
||||||
|
type: Number,
|
||||||
|
require: true,
|
||||||
|
},
|
||||||
|
rowsPerPage: {
|
||||||
|
type: Number,
|
||||||
|
require: true,
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
type: Number,
|
||||||
|
require: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
|
|
@ -543,6 +555,7 @@ const emit = defineEmits([
|
||||||
"update:reportYear",
|
"update:reportYear",
|
||||||
"update:reportNo",
|
"update:reportNo",
|
||||||
"update:reportType",
|
"update:reportType",
|
||||||
|
"update:pagination",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const updateInput = (value: string | number | null) => {
|
const updateInput = (value: string | number | null) => {
|
||||||
|
|
@ -643,26 +656,31 @@ function ocClickAddEmployee() {
|
||||||
modalEmployee.value = !modalEmployee.value;
|
modalEmployee.value = !modalEmployee.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getList(){
|
function updateProp(newPagination: any, page: number) {
|
||||||
console.log('GETok')
|
// ส่ง event ไปยัง parent component เพื่ออัพเดทค่า props
|
||||||
|
emit("update:pagination", newPagination, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => currentPage.value,
|
() => currentPage.value,
|
||||||
() => {
|
() => {
|
||||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
updateProp(pagination.value.rowsPerPage, currentPage.value);
|
||||||
getList();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => pagination.value.rowsPerPage,
|
() => pagination.value.rowsPerPage,
|
||||||
() => {
|
() => {
|
||||||
rowsPerPage.value = pagination.value.rowsPerPage;
|
|
||||||
currentPage.value = 1;
|
currentPage.value = 1;
|
||||||
getList();
|
updateProp(pagination.value.rowsPerPage, currentPage.value);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(()=>props.page,()=>{
|
||||||
|
if(props.page){
|
||||||
|
currentPage.value = props.page
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.icon-color {
|
.icon-color {
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,11 @@
|
||||||
:doSearch="doSearch"
|
:doSearch="doSearch"
|
||||||
:onExport="onExport"
|
:onExport="onExport"
|
||||||
:onTab="changeTab"
|
:onTab="changeTab"
|
||||||
|
:rowsPerPage="rowsPerPage"
|
||||||
|
:page="page"
|
||||||
|
:maxPage="maxPage"
|
||||||
|
@update:pagination="updatePagingProp"
|
||||||
|
:rows-per-page-options="[20, 50, 100, 200]"
|
||||||
>
|
>
|
||||||
<template #columns="props">
|
<template #columns="props">
|
||||||
<q-tr
|
<q-tr
|
||||||
|
|
@ -92,7 +97,7 @@
|
||||||
>
|
>
|
||||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
<div v-if="col.name == 'no'" class="table_ellipsis">
|
<div v-if="col.name == 'no'" class="table_ellipsis">
|
||||||
{{ props.rowIndex + 1 }}
|
{{ (page - 1) * Number(rowsPerPage) + props.rowIndex + 1 }}
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="col.name == 'isVerified'">
|
<div v-else-if="col.name == 'isVerified'">
|
||||||
<q-icon
|
<q-icon
|
||||||
|
|
@ -168,6 +173,10 @@ const store = useProfileDataStore();
|
||||||
const { profileData, changeProfileColumns } = store;
|
const { profileData, changeProfileColumns } = store;
|
||||||
const { changeTreeRegister, selectedRegister, expandedRegister } = dataStore;
|
const { changeTreeRegister, selectedRegister, expandedRegister } = dataStore;
|
||||||
|
|
||||||
|
const maxPage = ref<number>(1);
|
||||||
|
const rowsPerPage = ref<number>(20);
|
||||||
|
const page = ref<number>(1);
|
||||||
|
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai, messageError, typeRetire, showLoader, hideLoader } = mixin;
|
const { date2Thai, messageError, typeRetire, showLoader, hideLoader } = mixin;
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -1204,6 +1213,8 @@ const changeTab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSelected = async (id: string) => {
|
const onSelected = async (id: string) => {
|
||||||
|
rowsPerPage.value = 20;
|
||||||
|
page.value = 1;
|
||||||
await clickTree();
|
await clickTree();
|
||||||
await doSearch();
|
await doSearch();
|
||||||
};
|
};
|
||||||
|
|
@ -1355,12 +1366,15 @@ const doSearch = async () => {
|
||||||
if (selected.value == null || selected.value == "") return;
|
if (selected.value == null || selected.value == "") return;
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.post(config.API.searchProfileByOcId(selected.value, profileType.value), {
|
.post(
|
||||||
criterias: cirteria,
|
config.API.listProfileNew(selected.value, page.value, rowsPerPage.value),
|
||||||
})
|
{
|
||||||
|
criterias: cirteria,
|
||||||
|
}
|
||||||
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
let data = res.data.result;
|
let data = res.data.result.data;
|
||||||
|
maxPage.value = Math.ceil(res.data.result.totalRows / rowsPerPage.value);
|
||||||
rows.value = [];
|
rows.value = [];
|
||||||
data.map((e: ResponseObject) => {
|
data.map((e: ResponseObject) => {
|
||||||
rows.value.push({
|
rows.value.push({
|
||||||
|
|
@ -1451,6 +1465,12 @@ const onExport = () => {
|
||||||
const next = (id: string) => {
|
const next = (id: string) => {
|
||||||
router.push(`/registry/${id}`);
|
router.push(`/registry/${id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function updatePagingProp(rowPerpage: number, pageCurrent: number) {
|
||||||
|
rowsPerPage.value = rowPerpage;
|
||||||
|
page.value = pageCurrent;
|
||||||
|
doSearch();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scope>
|
<style lang="scss" scope>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue