fix(salary):sort
This commit is contained in:
parent
8e2aeef119
commit
e2c3c85a77
14 changed files with 440 additions and 826 deletions
|
|
@ -1,10 +1,11 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { updateCurrentPage } from "@/utils/function";
|
||||
import { usePagination } from "@/composables/usePagination";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
|
|
@ -12,10 +13,7 @@ import type {
|
|||
ListData,
|
||||
ResponseData,
|
||||
} from "@/modules/13_salary/interface/index/EmployeeChart";
|
||||
import type {
|
||||
NewPagination,
|
||||
DataOption,
|
||||
} from "@/modules/13_salary/interface/index/Main";
|
||||
import type { DataOption } from "@/modules/13_salary/interface/index/Main";
|
||||
import type { PosType } from "@/modules/13_salary/interface/response/salaryEmployeeChart";
|
||||
|
||||
/** importCompopnents*/
|
||||
|
|
@ -27,8 +25,12 @@ import { useCounterMixin } from "@/stores/mixin";
|
|||
const $q = useQuasar();
|
||||
const { dialogRemove, messageError, showLoader, hideLoader, success } =
|
||||
useCounterMixin();
|
||||
|
||||
const { pagination, params, onRequest, checkAndUpdatePage } = usePagination(
|
||||
"",
|
||||
getData
|
||||
);
|
||||
/** ข้อมูล Table*/
|
||||
const keyword = ref<string>("");
|
||||
const rows = ref<ListData[]>([]);
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
|
|
@ -44,16 +46,16 @@ const columns = ref<QTableProps["columns"]>([
|
|||
name: "posType",
|
||||
align: "left",
|
||||
label: "กลุ่มงาน",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "posType",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posName",
|
||||
name: "position",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "posName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -62,16 +64,16 @@ const columns = ref<QTableProps["columns"]>([
|
|||
name: "posLevel",
|
||||
align: "left",
|
||||
label: "ระดับชั้นงาน",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "posLevel",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "rateOldMin",
|
||||
name: "salaryMin",
|
||||
align: "left",
|
||||
label: "อัตราค่าจ้าง ขั้นต่ำสุด",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "rateOldMin",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -86,37 +88,37 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "rateMaxOld",
|
||||
name: "salary",
|
||||
align: "left",
|
||||
label: "อัตราค่าจ้าง ขั้นสูงสุดเดิม",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "rateMaxOld",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "groupRateHigh",
|
||||
name: "group",
|
||||
align: "left",
|
||||
label: "อัตราค่าจ้างสูงกว่า ฯ กลุ่มบัญชีค่าจ่าง",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "groupRateHigh",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "rateHighMax",
|
||||
name: "salaryMax",
|
||||
align: "left",
|
||||
label: "อัตราค่าจ้างสูงกว่า ฯ ขั้นสูงใหม่",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "rateHighMax",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "reson",
|
||||
name: "details",
|
||||
align: "left",
|
||||
label: "หมายเหตุ",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "reson",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -125,22 +127,15 @@ const columns = ref<QTableProps["columns"]>([
|
|||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"posType",
|
||||
"posName",
|
||||
"position",
|
||||
"posLevel",
|
||||
"rateOldMin",
|
||||
"salaryMin",
|
||||
"groupOld",
|
||||
"rateMaxOld",
|
||||
"groupRateHigh",
|
||||
"rateHighMax",
|
||||
"reson",
|
||||
"salary",
|
||||
"group",
|
||||
"salaryMax",
|
||||
"details",
|
||||
]);
|
||||
const formFilter = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keyword: "",
|
||||
});
|
||||
const maxPage = ref<number>(1); //จำนวนหน้า
|
||||
const totalList = ref<number>(0); //จำนวนรายการ
|
||||
|
||||
const modalForm = ref<boolean>(false); //Popup ข้อมูลหลักเกณฑ์
|
||||
const isStatusEdit = ref<boolean>(false); //สถานะการแก้ไข
|
||||
|
|
@ -151,11 +146,6 @@ const posTypeOpMain = ref<DataOption[]>([]); //ข้อมูลกลุ่ม
|
|||
const posTypeOp = ref<DataOption[]>([]); //ตัวเลือกข้อมูลรายการกลุ่มงาน
|
||||
const posType = ref<string | null>(""); //กลุ่มงาน
|
||||
|
||||
const pagination = ref({
|
||||
page: formFilter.page,
|
||||
rowsPerPage: formFilter.pageSize,
|
||||
});
|
||||
|
||||
/** ดึงข้อมูลกลุ่มงาน*/
|
||||
async function getPosType() {
|
||||
await http
|
||||
|
|
@ -184,18 +174,19 @@ async function getPosType() {
|
|||
|
||||
/** ดึงข้อมูลรายการหลักเกณฑ์ */
|
||||
async function getData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.salaryFormula() +
|
||||
`/?page=${formFilter.page}&pageSize=${
|
||||
formFilter.pageSize
|
||||
}&keyword=${formFilter.keyword.trim()}&posTypeId=${posType.value}`
|
||||
)
|
||||
.get(config.API.salaryFormula(), {
|
||||
params: {
|
||||
...params.value,
|
||||
keyword: keyword.value.trim(),
|
||||
posTypeId: posType.value,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
const data = res.data.result.data;
|
||||
totalList.value = res.data.result.total;
|
||||
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
|
||||
rows.value = data.map((item: ResponseData) => ({
|
||||
const result = res.data.result;
|
||||
pagination.value.rowsNumber = result.total;
|
||||
rows.value = result.data.map((item: ResponseData) => ({
|
||||
id: item.id,
|
||||
posType: item.posType,
|
||||
posName: item.position,
|
||||
|
|
@ -210,6 +201,9 @@ async function getData() {
|
|||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -224,28 +218,6 @@ function editPopup(params: ListData, type: string) {
|
|||
dataRow.value = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูลรายการตามหน้า
|
||||
* @param val หน้า
|
||||
*/
|
||||
async function updatePage(val: number) {
|
||||
try {
|
||||
showLoader();
|
||||
formFilter.page = val;
|
||||
await getData();
|
||||
} catch (error) {
|
||||
messageError($q, error);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
|
||||
/** function อัปเดทแถวต่อหน้า*/
|
||||
function updatePageSize(newPagination: NewPagination) {
|
||||
formFilter.page = 1;
|
||||
formFilter.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบรายการหลักเกณฑ์
|
||||
* @param id หลักเกณฑ์
|
||||
|
|
@ -256,11 +228,7 @@ function onClickDelete(id: string) {
|
|||
await http
|
||||
.delete(config.API.salaryFormula() + `/${id}`)
|
||||
.then(async () => {
|
||||
formFilter.page = await updateCurrentPage(
|
||||
formFilter.page,
|
||||
maxPage.value,
|
||||
rows.value.length
|
||||
);
|
||||
await checkAndUpdatePage(rows.value.length);
|
||||
await getData();
|
||||
await success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
|
|
@ -288,25 +256,10 @@ function filterSelector(val: string, update: Function) {
|
|||
|
||||
/** function fetch ข้อมูลรายการหน้าแรก */
|
||||
function filterFn() {
|
||||
formFilter.page = 1;
|
||||
pagination.value.page = 1;
|
||||
getData();
|
||||
}
|
||||
|
||||
/** callbackFunction ทำงานเมื่อมี่การอัปเดทแถว*/
|
||||
watch(
|
||||
() => formFilter.pageSize,
|
||||
async () => {
|
||||
try {
|
||||
showLoader();
|
||||
await getData();
|
||||
} catch (error) {
|
||||
messageError($q, error);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/** Hook */
|
||||
onMounted(async () => {
|
||||
try {
|
||||
|
|
@ -372,9 +325,9 @@ onMounted(async () => {
|
|||
borderless
|
||||
dense
|
||||
outlined
|
||||
v-model="formFilter.keyword"
|
||||
v-model="keyword"
|
||||
placeholder="ค้นหา"
|
||||
@keydown.enter.pervrnt="filterFn"
|
||||
@keydown.enter.prevent="filterFn"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
|
|
@ -397,7 +350,7 @@ onMounted(async () => {
|
|||
/>
|
||||
</q-toolbar>
|
||||
|
||||
<d-table
|
||||
<p-table
|
||||
flat
|
||||
bordered
|
||||
dense
|
||||
|
|
@ -408,7 +361,7 @@ onMounted(async () => {
|
|||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:visible-columns="visibleColumns"
|
||||
@update:pagination="updatePageSize"
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
@ -462,17 +415,13 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name === 'no'">
|
||||
{{
|
||||
(formFilter.page - 1) * Number(pagination.rowsPerPage) +
|
||||
props.rowIndex +
|
||||
1
|
||||
}}
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="
|
||||
col.name == 'rateOldMin' ||
|
||||
col.name == 'rateMaxOld' ||
|
||||
col.name == 'rateHighMax'
|
||||
col.name == 'salaryMin' ||
|
||||
col.name == 'salary' ||
|
||||
col.name == 'salaryMax'
|
||||
"
|
||||
>
|
||||
{{ col.value ? col.value.toLocaleString() : "-" }}
|
||||
|
|
@ -487,21 +436,7 @@ onMounted(async () => {
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
ทั้งหมด {{ totalList.toLocaleString() }} รายการ
|
||||
<q-pagination
|
||||
v-model="formFilter.page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="maxPage"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
@update:model-value="updatePage"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</d-table>
|
||||
</p-table>
|
||||
|
||||
<DialogFormCriteria
|
||||
v-model:modal="modalForm"
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRouter } from "vue-router";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { updateCurrentPage } from "@/utils/function";
|
||||
|
||||
import { usePagination } from "@/composables/usePagination";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { NewPagination } from "@/modules/13_salary/interface/index/Main";
|
||||
import type { FormFilter } from "@/modules/13_salary/interface/request/EmployeeChart";
|
||||
import type { EmployeeSalary } from "@/modules/13_salary/interface/response/salaryEmployeeChart";
|
||||
|
||||
/** importComponents*/
|
||||
|
|
@ -31,14 +30,10 @@ const {
|
|||
hideLoader,
|
||||
success,
|
||||
} = useCounterMixin();
|
||||
|
||||
const formFilter = reactive<FormFilter>({
|
||||
page: 1, //*หน้า
|
||||
pageSize: 10, //*จำนวนแถวต่อหน้า
|
||||
keyword: "", //keyword ค้นหา
|
||||
});
|
||||
const maxPage = ref<number>(1); //จำนวนหน้า
|
||||
const totalList = ref<number>(0); //จำนวนรายการ
|
||||
const { pagination, params, onRequest, checkAndUpdatePage } = usePagination(
|
||||
"",
|
||||
fetchListChart
|
||||
);
|
||||
|
||||
const modalDialogEmployeeChart = ref<boolean>(false); //popup ผังบัญชีค่าจ้างลูกจ้างประจำ
|
||||
const isStatusEdit = ref<boolean>(false); //สถานะการแก้ไข
|
||||
|
|
@ -50,12 +45,13 @@ const isActive = ref<boolean>(false); //สถานะการใช้งา
|
|||
|
||||
/** ข้อมูล Table*/
|
||||
const rows = ref<EmployeeSalary[]>([]); //รายการผังบัญชีค่าจ้างลูกจ้างประจำ
|
||||
const keyword = ref<string>(""); //คำค้นหา
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "name",
|
||||
align: "left",
|
||||
label: "ชื่อผังบัญชีอัตราค่าจ้าง",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "name",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -64,7 +60,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
name: "group",
|
||||
align: "left",
|
||||
label: "กลุ่มของผังบัญชีอัตราค่าจ้าง",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "group",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -73,7 +69,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
name: "startDate",
|
||||
align: "left",
|
||||
label: "วันที่มีผลบังคับใช้",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "startDate",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -82,7 +78,7 @@ const columns = ref<QTableProps["columns"]>([
|
|||
name: "isActive",
|
||||
align: "left",
|
||||
label: "สถานะการใช้งาน",
|
||||
sortable: false,
|
||||
sortable: true,
|
||||
field: "isActive",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
|
|
@ -101,16 +97,16 @@ const visibleColumns = ref<string[]>([
|
|||
async function fetchListChart() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.salaryEmployeeChart +
|
||||
`?page=${formFilter.page}&pageSize=${
|
||||
formFilter.pageSize
|
||||
}&keyword=${formFilter.keyword.trim()}`
|
||||
)
|
||||
.get(config.API.salaryEmployeeChart, {
|
||||
params: {
|
||||
...params.value,
|
||||
keyword: keyword.value.trim(),
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
rows.value = res.data.result.data;
|
||||
totalList.value = res.data.result.total;
|
||||
maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize);
|
||||
const result = res.data.result;
|
||||
pagination.value.rowsNumber = result.total;
|
||||
rows.value = result.data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -180,11 +176,7 @@ function onClickDelete(id: string) {
|
|||
http
|
||||
.delete(config.API.salaryEmployeeChartByid(id))
|
||||
.then(async () => {
|
||||
formFilter.page = await updateCurrentPage(
|
||||
formFilter.page,
|
||||
maxPage.value,
|
||||
rows.value.length
|
||||
);
|
||||
await checkAndUpdatePage(rows.value.length);
|
||||
await fetchListChart();
|
||||
await success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
|
|
@ -205,37 +197,12 @@ function onClickAdd() {
|
|||
modalDialogEmployeeChart.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* functionn fetch ข้อมูลรายการหน้าแรก*
|
||||
*/
|
||||
/** function fetch ข้อมูลรายการหน้าแรก*/
|
||||
function filterFn() {
|
||||
formFilter.page = 1;
|
||||
pagination.value.page = 1;
|
||||
fetchListChart();
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูลรายการตามหน้า
|
||||
* @param val หน้า
|
||||
*/
|
||||
function updatePage(val: number) {
|
||||
formFilter.page = val;
|
||||
fetchListChart();
|
||||
}
|
||||
|
||||
/** function อัปเดทแถวต่อหน้า*/
|
||||
function updatePageSize(newPagination: NewPagination) {
|
||||
formFilter.page = 1;
|
||||
formFilter.pageSize = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
/** callbackFuntioon ทำงานเมื่อมี่การอัปเดทแถว */
|
||||
watch(
|
||||
() => formFilter.pageSize,
|
||||
() => {
|
||||
fetchListChart();
|
||||
}
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
fetchListChart();
|
||||
});
|
||||
|
|
@ -257,7 +224,7 @@ onMounted(() => {
|
|||
borderless
|
||||
dense
|
||||
outlined
|
||||
v-model="formFilter.keyword"
|
||||
v-model="keyword"
|
||||
placeholder="ค้นหา"
|
||||
@keydown.enter.prevent="filterFn"
|
||||
>
|
||||
|
|
@ -281,7 +248,7 @@ onMounted(() => {
|
|||
class="col-xs-12 col-sm-3 col-md-2 q-ml-sm"
|
||||
/>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
<p-table
|
||||
flat
|
||||
bordered
|
||||
dense
|
||||
|
|
@ -290,7 +257,8 @@ onMounted(() => {
|
|||
row-key="name"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:visible-columns="visibleColumns"
|
||||
@update:pagination="updatePageSize"
|
||||
v-model:pagination="pagination"
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
|
|
@ -445,21 +413,7 @@ onMounted(() => {
|
|||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:pagination="scope">
|
||||
ทั้งหมด {{ totalList.toLocaleString() }} รายการ
|
||||
<q-pagination
|
||||
v-model="formFilter.page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="maxPage"
|
||||
:max-pages="5"
|
||||
size="sm"
|
||||
boundary-links
|
||||
direction-links
|
||||
@update:model-value="updatePage"
|
||||
></q-pagination>
|
||||
</template>
|
||||
</d-table>
|
||||
</p-table>
|
||||
|
||||
<!-- อัปโหลดเอกสารอ้างอิง -->
|
||||
<DialogEmployeeUpload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue