fix CurrentPage ===> รายชื่อลูกจ้างชั่วคราว
This commit is contained in:
parent
8a0395da63
commit
76e83221d5
1 changed files with 17 additions and 17 deletions
|
|
@ -1,12 +1,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, reactive, watch } from "vue";
|
import { ref, onMounted, reactive, watch } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import {
|
import {
|
||||||
checkPermission,
|
checkPermission,
|
||||||
checkPermissionList,
|
checkPermissionList,
|
||||||
checkPermissionCreate,
|
checkPermissionCreate,
|
||||||
} from "@/utils/permissions";
|
} from "@/utils/permissions";
|
||||||
|
import { updateCurrentPage } from "@/utils/function";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useRegistryEmp } from "@/modules/08_registryEmployee/stores/registry-employee";
|
import { useRegistryEmp } from "@/modules/08_registryEmployee/stores/registry-employee";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
|
|
@ -43,7 +45,7 @@ const modalPos = ref<boolean>(false); //popup กำหนดตำแหน่
|
||||||
const modalSendOrder = ref<boolean>(false); //popup ส่งไปออกคำสั่ง
|
const modalSendOrder = ref<boolean>(false); //popup ส่งไปออกคำสั่ง
|
||||||
const dataRow = ref<DataEmployee>(); //ข้อมูลรายชื่อลูกจ้างชั่วคราวที่ต้องการกำหนดตำแหน่ง
|
const dataRow = ref<DataEmployee>(); //ข้อมูลรายชื่อลูกจ้างชั่วคราวที่ต้องการกำหนดตำแหน่ง
|
||||||
|
|
||||||
/** Table*/
|
/** Table */
|
||||||
const rows = ref<DataEmployee[]>([]); //รายชื่อลูกจ้างชั่วคราว
|
const rows = ref<DataEmployee[]>([]); //รายชื่อลูกจ้างชั่วคราว
|
||||||
const maxPage = ref<number>(0); //จำนวนหน้า
|
const maxPage = ref<number>(0); //จำนวนหน้า
|
||||||
const total = ref<number>(0); //จำนวนข้อมูล
|
const total = ref<number>(0); //จำนวนข้อมูล
|
||||||
|
|
@ -208,7 +210,7 @@ const visibleColumns = ref<String[]>([
|
||||||
"dateAppoint",
|
"dateAppoint",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/** ฟังก์ชันดึงข้อมูลรายชื่อลูกจ้างชั่วคราว*/
|
/** ฟังก์ชันดึงข้อมูลรายชื่อลูกจ้างชั่วคราว */
|
||||||
async function fetchList() {
|
async function fetchList() {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
|
|
@ -233,20 +235,19 @@ async function fetchList() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชันลบข้อมูลรายชื่อลูกจ้างชั่วคราว
|
* ฟังก์ชันลบข้อมูลรายชื่อลูกจ้างชั่วคราว
|
||||||
* @param id รายชื่อลูกจ้างชั่วคราวที่ต้องการลบ
|
* @param id รายชื่อลูกจ้างชั่วคราวที่ต้องการลบ
|
||||||
*/
|
*/
|
||||||
function onClickDelete(id: string) {
|
function onClickDelete(id: string) {
|
||||||
dialogRemove($q, async () => {
|
dialogRemove($q, async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
queryParams.page =
|
|
||||||
queryParams.page !== 1 &&
|
|
||||||
queryParams.page === maxPage.value &&
|
|
||||||
rows.value.length === 1
|
|
||||||
? queryParams.page - 1
|
|
||||||
: queryParams.page;
|
|
||||||
await http
|
await http
|
||||||
.delete(config.API.registryNew("-employee") + `/${id}`)
|
.delete(config.API.registryNew("-employee") + `/${id}`)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
|
queryParams.page = await updateCurrentPage(
|
||||||
|
queryParams.page,
|
||||||
|
maxPage.value,
|
||||||
|
rows.value.length
|
||||||
|
);
|
||||||
await fetchList();
|
await fetchList();
|
||||||
await success($q, "ลบข้อมูลสำเร็จ");
|
await success($q, "ลบข้อมูลสำเร็จ");
|
||||||
})
|
})
|
||||||
|
|
@ -261,13 +262,13 @@ function onClickDelete(id: string) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ฟังก์ชันดูข้อมูลรายชื่อลูกจ้างชั่วคราว ไปยัง ทะเบียนประวัติลูกจ้างชั่วคราว
|
* ฟังก์ชันดูข้อมูลรายชื่อลูกจ้างชั่วคราว ไปยัง ทะเบียนประวัติลูกจ้างชั่วคราว
|
||||||
* @param id รายชื่อลูกจ้างชั่วคราวที่ต้องการ
|
* @param id รายชื่อลูกจ้างชั่วคราวที่ต้องการ
|
||||||
*/
|
*/
|
||||||
function redirectToPageDetail(id: string) {
|
function redirectToPageDetail(id: string) {
|
||||||
router.push(`/registry-temp/${id}`);
|
router.push(`/registry-temp/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ฟังก์ชันเปิด popup เพิ่มข้อมูลลูกจ้างชั่วคราว*/
|
/** ฟังก์ชันเปิด popup เพิ่มข้อมูลลูกจ้างชั่วคราว */
|
||||||
function onClickAddEmployee() {
|
function onClickAddEmployee() {
|
||||||
modalAddEmployee.value = true;
|
modalAddEmployee.value = true;
|
||||||
}
|
}
|
||||||
|
|
@ -281,13 +282,13 @@ function onClickSelectPos(data: DataEmployee) {
|
||||||
dataRow.value = data;
|
dataRow.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ฟังก์ชันเปิด popup ส่งรายชื่อไปออกคำสั่ง*/
|
/** ฟังก์ชันเปิด popup ส่งรายชื่อไปออกคำสั่ง */
|
||||||
function onClickSendOrder() {
|
function onClickSendOrder() {
|
||||||
modalSendOrder.value = true;
|
modalSendOrder.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function updatePagination
|
* ฟังก์ชันอัพเดต Pagination
|
||||||
* @param newPagination ข้อมูล Pagination ใหม่
|
* @param newPagination ข้อมูล Pagination ใหม่
|
||||||
*/
|
*/
|
||||||
function updatePagination(newPagination: NewPagination) {
|
function updatePagination(newPagination: NewPagination) {
|
||||||
|
|
@ -295,7 +296,7 @@ function updatePagination(newPagination: NewPagination) {
|
||||||
queryParams.pageSize = newPagination.rowsPerPage;
|
queryParams.pageSize = newPagination.rowsPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ทำงานเมื่อมีการเปลี่่ยนจำนวนข้อมูลต่อหน้า*/
|
/** ทำงานเมื่อมีการเปลี่่ยนจำนวนข้อมูลต่อหน้า */
|
||||||
watch(
|
watch(
|
||||||
() => queryParams.pageSize,
|
() => queryParams.pageSize,
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -303,8 +304,7 @@ watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/** ทำงานเมื่อมีการเรียกใข้ Components
|
/** ทำงานเมื่อมีการเรียกใข้ Components */
|
||||||
*/
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchList();
|
await fetchList();
|
||||||
});
|
});
|
||||||
|
|
@ -467,7 +467,7 @@ onMounted(async () => {
|
||||||
dense
|
dense
|
||||||
color="red"
|
color="red"
|
||||||
icon="mdi-delete"
|
icon="mdi-delete"
|
||||||
@click.pervent="onClickDelete(props.row.id)"
|
@click.prevent="onClickDelete(props.row.id)"
|
||||||
>
|
>
|
||||||
<q-tooltip>ลบ </q-tooltip>
|
<q-tooltip>ลบ </q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue