- {{
- (formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
- }}
+ {{ props.rowIndex + 1 }}
{{ findOrgNameHtml(props.row) }}
@@ -563,7 +547,7 @@ function onClickViewInfo(type: string, id: string) {
-
+
+
("modal", { required: true });
@@ -47,26 +48,26 @@ const columns = ref([
name: "citizenId",
align: "left",
label: "เลขประจำตัวประชาชน",
- sortable: false,
+ sortable: true,
field: "citizenId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
- name: "fullName",
+ name: "firstName",
align: "left",
label: "ชื่อ-นามสกุล",
- field: "fullName",
- sortable: false,
+ field: "firstName",
+ sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
- name: "posNo",
+ name: "orgShortName",
align: "left",
label: "ตำแหน่งเลขที่",
- sortable: false,
- field: "posNo",
+ sortable: true,
+ field: "orgShortName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
@@ -79,7 +80,7 @@ const columns = ref([
name: "position",
align: "left",
label: "ตำแหน่ง",
- sortable: false,
+ sortable: true,
field: "position",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -88,17 +89,17 @@ const columns = ref([
name: "posType",
align: "left",
label: "กลุ่มงาน",
- sortable: false,
+ sortable: true,
field: "posType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
- name: "posLevelName",
+ name: "posLevel",
align: "left",
label: "ระดับชั้นงาน",
- sortable: false,
- field: "posLevelName",
+ sortable: true,
+ field: "posLevel",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
@@ -110,19 +111,21 @@ const columns = ref([
]);
/** ข้อมูุลค้นหา*/
const formFilter = reactive({
- page: 1,
- pageSize: 10,
keyword: "",
rootId: "",
year: 0,
period: "",
});
-const maxPage = ref(1);
/** function close popup*/
function closeModal() {
modal.value = false;
- formFilter.page = 1;
+ pagination.value = {
+ page: 1,
+ rowsPerPage: 10,
+ rowsNumber: 0,
+ };
+
formFilter.keyword = "";
}
@@ -133,12 +136,17 @@ async function fetchListPerson() {
formFilter.period = store.roundMainCode;
formFilter.year = store.roundYear;
+ const body = {
+ ...params.value,
+ ...formFilter,
+ };
+
await http
- .post(config.API.salaryListPersonEmp, formFilter)
+ .post(config.API.salaryListPersonEmp, body)
.then((res) => {
- const data = res.data.result.data;
- maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
- rows.value = data;
+ const result = res.data.result;
+ pagination.value.rowsNumber = result.total;
+ rows.value = result.data;
})
.catch((err) => {
messageError($q, err);
@@ -186,20 +194,9 @@ function onClickAddPerson(data: DataPerson) {
);
}
-/** function update Pagination*/
-async function updatePagePagination() {
- fetchListPerson();
-}
-
-/** function updatePageSize*/
-function updatePageSizePagination(newPagination: NewPagination) {
- formFilter.page = 1;
- formFilter.pageSize = newPagination.rowsPerPage;
-}
-
/** function ค้นหาข้อมูลตาม keyword*/
function searchData() {
- formFilter.page = 1;
+ pagination.value.page = 1;
fetchListPerson();
}
@@ -212,14 +209,6 @@ watch(
}
}
);
-
-/** callblack function เรียกข้อมูลรายชื่อคนเลื่อนเงินเดือน เมื่อมีการเปลี่ยน PageSize*/
-watch(
- () => formFilter.pageSize,
- () => {
- updatePagePagination();
- }
-);
@@ -244,7 +233,7 @@ watch(
-
@@ -284,13 +274,9 @@ watch(
:props="props"
>
- {{
- (formFilter.page - 1) * formFilter.pageSize +
- props.rowIndex +
- 1
- }}
+ {{ props.rowIndex + 1 }}
-
+
{{
`${props.row.prefix}${props.row.firstName} ${props.row.lastName}`
}}
@@ -301,20 +287,7 @@ watch(
-
-
-
-
+
diff --git a/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue b/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue
index e9107eb53..aad9c683f 100644
--- a/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue
+++ b/src/modules/13_salary/components/05_salaryListsEmployee/TabMain.vue
@@ -1,14 +1,15 @@
@@ -343,7 +318,7 @@ watch(
borderless
dense
outlined
- v-model="formFilter.keyword"
+ v-model="keyword"
placeholder="ค้นหา"
@keydown.enter.prevent="searchData"
>
@@ -374,7 +349,7 @@ watch(
/>
-
@@ -476,7 +452,6 @@ watch(
>
{{
- (formFilter.page - 1) * formFilter.pageSize +
props.rowIndex +
1 +
(store.tabType == "FULL" && props.row.isReserve == true
@@ -484,10 +459,10 @@ watch(
: "")
}}
-
+
{{ `${props.row.orgShortName} ${props.row.posMasterNo}` }}
-
+
{{
`${props.row.prefix}${props.row.firstName} ${props.row.lastName}`
}}
@@ -539,21 +514,7 @@ watch(
-
- ทั้งหมด {{ props?.total?.toLocaleString() }} รายการ
-
-
-
+
-import { ref, watch } from "vue";
+import { ref } from "vue";
import { useQuasar } from "quasar";
import { checkPermission } from "@/utils/permissions";
-import { updateCurrentPage } from "@/utils/function";
+
import { useCounterMixin } from "@/stores/mixin";
import { useSalaryEmployeeListSDataStore } from "@/modules/13_salary/store/SalaryEmployeeListsStore";
import http from "@/plugins/http";
@@ -12,7 +12,6 @@ import config from "@/app.config";
/** importType*/
import type { QTableColumn } from "quasar";
import type { NewPagination } from "@/modules/13_salary/interface/index/Main";
-import type { DataFilter } from "@/modules/13_salary/interface/index/SalaryList";
/** importComponents*/
import DialogAddPerson from "@/modules/13_salary/components/05_salaryListsEmployee//DialogAddPerson.vue";
@@ -37,21 +36,18 @@ const {
} = useCounterMixin();
/** Props*/
-const formFilter = defineModel("formFilter", { required: true });
-const maxPage = defineModel("maxPage", { required: true });
const isClose = defineModel("isClose", { required: true });
-const snapShot = defineModel("snapShot");
-
+const pagination = defineModel("pagination", {
+ required: true,
+});
+const keyword = defineModel("keyword", { required: true });
const props = defineProps({
rows: { type: Array, required: true },
fetchDataTable: {
type: Function,
required: true,
},
- maxPage: {
- type: Number,
- required: true,
- },
+
total: {
type: Number,
required: true,
@@ -60,6 +56,14 @@ const props = defineProps({
type: Boolean,
required: true,
},
+ onRequest: {
+ type: Function,
+ required: true,
+ },
+ checkAndUpdatePage: {
+ type: Function,
+ required: true,
+ },
});
/** ข้อมูล Table*/
@@ -74,11 +78,11 @@ const columns = ref([
style: "font-size: 14px",
},
{
- name: "fullName",
+ name: "firstName",
align: "left",
label: "ชื่อ-นามสกุล",
- sortable: false,
- field: "fullName",
+ sortable: true,
+ field: "firstName",
format(val, row) {
return `${row.prefix}${row.firstName} ${row.lastName}`;
},
@@ -86,11 +90,11 @@ const columns = ref([
style: "font-size: 14px",
},
{
- name: "posNo",
+ name: "orgShortName",
align: "left",
label: "ตำแหน่งเลขที่",
- sortable: false,
- field: "posNo",
+ sortable: true,
+ field: "orgShortName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format(val, row) {
@@ -105,7 +109,7 @@ const columns = ref([
align: "left",
label: "ตำแหน่ง",
field: "position",
- sortable: false,
+ sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
@@ -113,7 +117,7 @@ const columns = ref([
name: "posType",
align: "left",
label: "กลุ่มงาน",
- sortable: false,
+ sortable: true,
field: "posType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -123,7 +127,7 @@ const columns = ref([
align: "left",
label: "ระดับชั้นงาน",
field: "posLevel",
- sortable: false,
+ sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
@@ -131,7 +135,7 @@ const columns = ref([
name: "group",
align: "left",
label: "ผังค่าจ้าง(เดิม)",
- sortable: false,
+ sortable: true,
field: "group",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -143,7 +147,7 @@ const columns = ref([
name: "salaryLevel",
align: "left",
label: "ขั้น(เดิม)",
- sortable: false,
+ sortable: true,
field: "salaryLevel",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -153,7 +157,7 @@ const columns = ref([
align: "left",
label: "ค่าจ้าง",
field: "amount",
- sortable: false,
+ sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
@@ -217,8 +221,8 @@ const columns = ref([
]);
const visibleColumns = ref([
"no",
- "fullName",
- "posNo",
+ "firstName",
+ "orgShortName",
"posType",
"position",
"posLevel",
@@ -313,22 +317,9 @@ function onClickMoveLevel(id: string, typeVal: string, isReserveVal: boolean) {
isReserve.value = isReserveVal;
}
-/** function updatePageTable*/
-function updatePagePagination() {
- props.fetchDataTable?.();
-}
-
-/**
- * function updatePageSizeTable
- */
-function updatePageSizePagination(newPagination: NewPagination) {
- formFilter.value.page = 1;
- formFilter.value.pageSize = newPagination.rowsPerPage;
-}
-
/** function ค้นหาข้อมูล Table*/
function searchData() {
- formFilter.value.page = 1;
+ pagination.value.page = 1;
props.fetchDataTable?.();
}
@@ -364,23 +355,9 @@ function onClickMoveLevelMulti() {
/** ฟังก์ชันอัปเดตหน้าปัจจุบันและดึงข้อมูล */
async function updateCurrentPageAndfetchData() {
- formFilter.value.page = await updateCurrentPage(
- formFilter.value.page,
- props.maxPage,
- props.rows.length
- );
+ await props.checkAndUpdatePage(props.rows.length);
await props.fetchDataTable?.();
}
-
-/**
- * callblack function เรียกข้อมูลรายชื่อใหม่ เมื่อมีการเปลี่ยน PageSize
- */
-watch(
- () => formFilter.value.pageSize,
- () => {
- updatePagePagination();
- }
-);
@@ -418,7 +395,7 @@ watch(
borderless
dense
outlined
- v-model="formFilter.keyword"
+ v-model="keyword"
placeholder="ค้นหา"
@keydown.enter.prevent="searchData"
>
@@ -444,7 +421,7 @@ watch(
class="q-ml-sm"
/>
-
@@ -530,9 +508,7 @@ watch(
- {{
- (formFilter.page - 1) * formFilter.pageSize + props.rowIndex + 1
- }}
+ {{ props.rowIndex + 1 }}
{{ findOrgNameHtml(props.row) }}
@@ -589,21 +565,7 @@ watch(
-
- ทั้งหมด {{ props.total?.toLocaleString() }} รายการ
-
-
-
+
(false); //popup เพิ่ม,แก้ไข ผังบัญชีเงินเดือน
@@ -38,22 +42,23 @@ const rowId = ref(""); // id รายการผังบัญชี
/** Table*/
const rows = ref([]); //รายการผังบัญชีเงินเดือน
+const keyword = ref(""); //keyword ค้นหา
const columns = ref([
{
name: "name",
align: "left",
label: "ชื่อผังบัญชีอัตราเงินเดือน",
- sortable: false,
+ sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
- name: "posList",
+ name: "posType",
align: "left",
label: "ประเภทผังบัญชีเงินเดือน",
- sortable: false,
- field: "posList",
+ sortable: true,
+ field: "posType",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
@@ -61,7 +66,7 @@ const columns = ref([
name: "startDate",
align: "left",
label: "วันที่มีผลบังคับใช้",
- sortable: false,
+ sortable: true,
field: "startDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -70,7 +75,7 @@ const columns = ref([
name: "isActive",
align: "center",
label: "สถานะการใช้งาน",
- sortable: false,
+ sortable: true,
field: "isActive",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -78,19 +83,11 @@ const columns = ref([
]);
const visibleColumns = ref([
"name",
- "posList",
+ "posType",
"startDate",
"isActive",
]);
-/** queryString */
-const formQuery = reactive({
- page: 1, //*หน้า
- pageSize: 10, //*จำนวนแถวต่อหน้า
- keyword: "", //keyword ค้นหา
-});
-const maxPage = ref(1); //จำนวนหน้า
-const total = ref(); //จำนวนรายการ
const isActive = ref(false); //สถานะการใช้งาน
const typeAction = ref(""); //ประเภทการกระทำ
const dataSalary = ref(); //ข้อมูลรายการผังบัญชีเงินเดือนที่ต้องการแก้ไข
@@ -98,19 +95,17 @@ const dataSalary = ref(); //ข้อมูลรายการผั
/** ฟังก์ชันดึงข้อมูลรายการผังบัญชีเงินเดือน */
async function fetchListSalaly() {
showLoader();
- const page = formQuery.page.toString();
- const pageSize = formQuery.pageSize.toString();
- const keyword = formQuery.keyword.toString().trim();
await http
- .get(
- config.API.salaryChart +
- `?page=${page}&pageSize=${pageSize}&keyword=${keyword}`
- )
+ .get(config.API.salaryChart, {
+ params: {
+ ...params.value,
+ keyword: keyword.value.trim(),
+ },
+ })
.then(async (res) => {
- const data = await res.data.result;
- rows.value = data.data;
- total.value = data.total;
- maxPage.value = Math.ceil(data.total / formQuery.pageSize);
+ const result = await res.data.result;
+ pagination.value.rowsNumber = result.total;
+ rows.value = result.data;
})
.catch((err) => {
messageError($q, err);
@@ -145,7 +140,7 @@ function onClickSalaryRate(id: string) {
* ฟังก์ชันคัดลอกข้อมูลรายการผังบัญชีเงินเดือน
* @param id บัญชีเงินเดือน
*/
-function onClickCoppy(id: string) {
+function onClickCopy(id: string) {
showLoader();
http
.post(config.API.salaryChartCopy, { id: id })
@@ -171,12 +166,7 @@ function onClickDelete(id: string) {
await http
.delete(config.API.salaryChartByid(id))
.then(async () => {
- formQuery.page = await updateCurrentPage(
- formQuery.page,
- maxPage.value,
- rows.value.length
- );
-
+ await checkAndUpdatePage(rows.value.length);
await fetchListSalaly();
success($q, "ลบข้อมูลสำเร็จ");
})
@@ -202,28 +192,12 @@ function onClickUpload(type: string, id: string, active: boolean) {
isActive.value = active;
}
-/**
- * ฟังก์ชัน updatePagination
- * @param newPagination ข้อมูล Pagination ใหม่
- */
-function updatePagination(newPagination: NewPagination) {
- formQuery.page = 1;
- formQuery.pageSize = newPagination.rowsPerPage;
-}
-
/** ฟังก์ชัน ค้นหาข้อมูลตาม keyword */
-function filterFn(page: number) {
- page !== 1 ? (formQuery.page = 1) : fetchListSalaly();
+function filterFn() {
+ pagination.value.page = 1;
+ fetchListSalaly();
}
-/** callbackFunction ทำงานเมื่อมีการ เปลี่ยนแถว */
-watch(
- () => formQuery.pageSize,
- () => {
- fetchListSalaly();
- }
-);
-
/** hooklifecycle*/
onMounted(() => {
fetchListSalaly();
@@ -255,9 +229,9 @@ onMounted(() => {
borderless
dense
outlined
- v-model="formQuery.keyword"
+ v-model="keyword"
placeholder="ค้นหา"
- @keydown.enter.prevent="filterFn(formQuery.page)"
+ @keydown.enter.prevent="filterFn()"
>
@@ -281,7 +255,7 @@ onMounted(() => {
-
{
:paging="true"
dense
:rows-per-page-options="[10, 25, 50, 100]"
- @update:pagination="updatePagination"
:visible-columns="visibleColumns"
+ v-model:pagination="pagination"
+ @request="onRequest"
>
@@ -399,7 +374,7 @@ onMounted(() => {
v-if="checkPermission($route)?.attrIsCreate"
clickable
v-close-popup
- @click.stop="onClickCoppy(props.row.id)"
+ @click.stop="onClickCopy(props.row.id)"
>
@@ -442,7 +417,7 @@ onMounted(() => {
size="24px"
/>
-
+
ประเภทตำแหน่ง
ระดับตำแหน่ง
@@ -464,7 +439,7 @@ onMounted(() => {
}}
- {{ col.value ? date2Thai(col.value) : "" }}
+ {{ col.value ? date2Thai(col.value) : "-" }}
{{ col.value ? col.value : "-" }}
@@ -472,21 +447,7 @@ onMounted(() => {
-
- ทั้งหมด {{ total?.toLocaleString() }} รายการ
-
-
-
+
diff --git a/src/modules/13_salary/views/03_salaryRound.vue b/src/modules/13_salary/views/03_salaryRound.vue
index 00e7d8a8c..4decb6ded 100644
--- a/src/modules/13_salary/views/03_salaryRound.vue
+++ b/src/modules/13_salary/views/03_salaryRound.vue
@@ -7,6 +7,7 @@ import { updateCurrentPage } from "@/utils/function";
import { useCounterMixin } from "@/stores/mixin";
import { useSalaryDataStore } from "@/modules/13_salary/store/SalaryStore";
import { calculateFiscalYear } from "@/utils/function";
+import { usePagination } from "@/composables/usePagination";
import config from "@/app.config";
import http from "@/plugins/http";
@@ -30,6 +31,10 @@ const {
dialogConfirm,
success,
} = useCounterMixin();
+const { pagination, params, onRequest, checkAndUpdatePage } = usePagination(
+ "",
+ getData
+);
const idRound = ref
(""); //id รอบการขึ้นเงินเดือน
@@ -44,8 +49,6 @@ const yearData = ref(0); //ปีงบประมาณ
/** Table*/
const year = ref(0); //ปีงบประมาณ
const filterKeyword = ref(""); //คำค้นหา
-const maxPage = ref(1); //จำนวนหน้า
-const totalList = ref(0); //จำนวนรายการ
const page = ref(1); //หน้า
const rowsPerPage = ref(10); //จำนวนรายการต่อหน้า
const columns = ref([
@@ -62,7 +65,7 @@ const columns = ref([
name: "period",
align: "left",
label: "รอบการขึ้นเงินเดือน",
- sortable: false,
+ sortable: true,
field: "period",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -71,7 +74,7 @@ const columns = ref([
name: "year",
align: "left",
label: "ปีงบประมาณ",
- sortable: false,
+ sortable: true,
field: "year",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -80,7 +83,7 @@ const columns = ref([
name: "effectiveDate",
align: "left",
label: "วันที่มีผลบังคับใช้",
- sortable: false,
+ sortable: true,
field: "effectiveDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@@ -112,11 +115,6 @@ const visibleColumns = ref([
"isActive",
"isClose",
]);
-const pagination = ref({
- descending: false,
- page: page.value,
- rowsPerPage: rowsPerPage.value,
-});
/**ฟังก์ชัน เปิด Dialog เพิ่มรอบการขึ้นเงินเดือน */
function clickAdd() {
@@ -128,15 +126,17 @@ function clickAdd() {
async function getData() {
showLoader();
await http
- .get(
- config.API.salaryPeriod() +
- `?page=${page.value}&pageSize=${rowsPerPage.value}&keyword=${filterKeyword.value}&year=${year.value}`
- )
+ .get(config.API.salaryPeriod(), {
+ params: {
+ ...params.value,
+ keyword: filterKeyword.value.trim(),
+ year: year.value,
+ },
+ })
.then(async (res) => {
- const data = await res.data.result;
- dataStore.fetchDataMap(data.data);
- maxPage.value = Math.ceil(data.total / rowsPerPage.value);
- totalList.value = data.total;
+ const result = await res.data.result;
+ pagination.value.rowsNumber = result.total;
+ dataStore.fetchDataMap(result.data);
})
.catch((e) => {
messageError($q, e);
@@ -168,12 +168,7 @@ function deleteData(id: string) {
await http
.delete(config.API.salaryPeriod() + `/${id}`)
.then(async () => {
- page.value = await updateCurrentPage(
- page.value,
- maxPage.value,
- dataStore.rows.length
- );
-
+ await checkAndUpdatePage(dataStore.rows.length);
await getData();
await success($q, "ลบข้อมูลสำเร็จ");
})
@@ -231,23 +226,6 @@ function dialogClose(id: string) {
);
}
-/**
- * ฟังก์ชันอัปเดท แถวต่อหน้า
- * @param newPagination
- */
-function updatePageSize(newPagination: NewPagination) {
- page.value = 1;
- rowsPerPage.value = newPagination.rowsPerPage;
-}
-
-/** ฟังก์ชันทำเมื่อมีการอัปเดท แถวต่อหน้า แล้ว fetch รายการรอบการขึ้นเงินเดือน */
-watch(
- () => rowsPerPage.value,
- () => {
- getData();
- }
-);
-
/** Hooklifecycle */
onMounted(async () => {
year.value = calculateFiscalYear(new Date());
@@ -338,7 +316,7 @@ onMounted(async () => {
-
{
:visible-columns="dataStore.visibleColumns"
v-model:pagination="pagination"
:rows-per-page-options="[10, 25, 50, 100]"
- @update:pagination="updatePageSize"
+ @request="onRequest"
>
-
- ทั้งหมด {{ totalList?.toLocaleString() }} รายการ
-
-
@@ -478,11 +443,7 @@ onMounted(async () => {
- {{
- (page - 1) * Number(pagination.rowsPerPage) +
- props.rowIndex +
- 1
- }}
+ {{ props.rowIndex + 1 }}
{{ date2Thai(props.row.effectiveDate) }}
@@ -516,7 +477,7 @@ onMounted(async () => {
-
+