กำหนดสิทธิ์จัดการโครงสร้าง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-06 16:30:07 +07:00
parent 6e9c8bf593
commit 09fdfe9f20
2 changed files with 81 additions and 27 deletions

View file

@ -30,16 +30,15 @@ const props = defineProps({
}); });
const qurey = reactive({ const qurey = reactive({
searchKeyword: "", searchKeyword: "", //
searchField: "fullName", searchField: "fullName", // field
page: 1, page: 1, //
pageSize: 10, pageSize: 10, //
}); });
const selected = ref<DataProfile[]>([]); const selected = ref<DataProfile[]>([]); //
const rows = ref<DataProfile[]>([]); const rows = ref<DataProfile[]>([]); //
const total = ref<number>(0); const total = ref<number>(0); //
const maxPage = ref<number>(0); const maxPage = ref<number>(0); //
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "fullName", name: "fullName",
@ -83,6 +82,12 @@ const columns = ref<QTableProps["columns"]>([
}, },
]); ]);
/**
* งกนดงขอมลรายช
* @param newPage โหลดหนาแรก าเป true โหลดหนาแรก false ใหโหลดหนาปจจ
*
* เกบมลรายชอไวใน rows.value
*/
async function onSearchListPerson(newPage: boolean = false) { async function onSearchListPerson(newPage: boolean = false) {
qurey.page = newPage ? 1 : qurey.page; qurey.page = newPage ? 1 : qurey.page;
selected.value = []; selected.value = [];
@ -105,6 +110,11 @@ async function onSearchListPerson(newPage: boolean = false) {
}); });
} }
/**
* งกนยนยนการเพมราช
*
* เมอเพมเสรจจะดงขอมลรายชอคนททธดการโครงสรางตามหนวยงาน
*/
function onSubmitPerson() { function onSubmitPerson() {
dialogConfirm( dialogConfirm(
$q, $q,
@ -142,6 +152,11 @@ function updatePagination(newPagination: Pagination) {
qurey.pageSize = newPagination.rowsPerPage; qurey.pageSize = newPagination.rowsPerPage;
} }
/**
* งกนป popup ราชช
*
* และกำหนดคาของ qurey ไปเปนค defult rows.value และ selected.value ไปเปนคาวาง
*/
function onClose() { function onClose() {
modal.value = false; modal.value = false;
qurey.page = 1; qurey.page = 1;
@ -152,6 +167,11 @@ function onClose() {
selected.value = []; selected.value = [];
} }
/**
* การเปลยนแปลงของ pageSize ใน queryBody
*
* เม pageSize การเปลยนแปลงใหโหลดขอมลหนาแรก
*/
watch( watch(
() => qurey.pageSize, () => qurey.pageSize,
() => { () => {
@ -165,7 +185,7 @@ watch(
<q-card style="min-width: 60%"> <q-card style="min-width: 60%">
<DialogHeader :tittle="'รายชื่อ'" :close="onClose" /> <DialogHeader :tittle="'รายชื่อ'" :close="onClose" />
<q-separator /> <q-separator />
<q-card-section> <q-card-section style="max-height: 50vh" class="scroll">
<div class="col-12"> <div class="col-12">
<q-toolbar style="padding: 0"> <q-toolbar style="padding: 0">
<q-select <q-select

View file

@ -28,7 +28,12 @@ const nodeTree = ref<DataTree[]>([]); // ข้อมูลรายการโ
const expanded = ref<Array<string>>([]); // const expanded = ref<Array<string>>([]); //
const orgId = ref<string>(""); // id const orgId = ref<string>(""); // id
async function fatchOrgg() { /**
* งกนดงขอมลโครงสราง
*
* เกบขอมลโครงสรางไวใน nodeTree
*/
async function fatchOrg() {
showLoader(); showLoader();
await http await http
.get(config.API.permissionOrg) .get(config.API.permissionOrg)
@ -44,23 +49,34 @@ async function fatchOrgg() {
}); });
} }
/**
* งกนเลอกหนวยงาน
* @param id หนวยงานทเลอก
*
* กำหนดคาของ qureyBody ใหเปนค defult และกำหนดคาของ qureyBody.id เปนหนวยงานทเลอก
* และดงขอมลรายชอคนททธดการโครงสรางในหนวยงานทเลอก
*/
function selectedOrg(id: string) { function selectedOrg(id: string) {
orgId.value = id; orgId.value = id;
qureyBody.id = id; qureyBody.id = id;
qureyBody.searchKeyword = "";
qureyBody.searchField = "fullName";
qureyBody.page = 1;
qureyBody.pageSize = 10;
fetchListPerson(true); fetchListPerson(true);
} }
/******* รายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง *******/ /******* รายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง *******/
const qureyBody = reactive<QueryProfile>({ const qureyBody = reactive<QueryProfile>({
searchKeyword: "", searchKeyword: "", //
searchField: "fullName", searchField: "fullName", // field
page: 1, page: 1, //
pageSize: 10, pageSize: 10, //
id: null, id: null, //
}); });
const rows = ref<DataProfile[]>([]); const rows = ref<DataProfile[]>([]); //
const total = ref<number>(0); const total = ref<number>(0); //
const maxPage = ref<number>(0); const maxPage = ref<number>(0); //
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
name: "fullName", name: "fullName",
@ -112,9 +128,14 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px", style: "font-size: 14px",
}, },
]); ]);
const modalAdd = ref<boolean>(false); // modal
const modalAdd = ref<boolean>(false); /**
* งกนดงขอมลรายชอคนททธดการโครงสราง
* @param newPage โหลดหนาแรก าเป true โหลดหนาแรก false ใหโหลดหนาปจจ
*
* เกบมลรายชอคนททธดการโครงสรางไวใน rows.value
*/
async function fetchListPerson(newPage: boolean = false) { async function fetchListPerson(newPage: boolean = false) {
qureyBody.page = newPage ? 1 : qureyBody.page; qureyBody.page = newPage ? 1 : qureyBody.page;
showLoader(); showLoader();
@ -122,8 +143,8 @@ async function fetchListPerson(newPage: boolean = false) {
.post(config.API.permissionOrgProfile, qureyBody) .post(config.API.permissionOrgProfile, qureyBody)
.then(async (res) => { .then(async (res) => {
const data = await res.data.result; const data = await res.data.result;
maxPage.value = Math.ceil(data.total / qureyBody.pageSize); maxPage.value = Math.ceil(data.total / qureyBody.pageSize); //
total.value = data.total; total.value = data.total; //
rows.value = data.data; rows.value = data.data;
}) })
.catch((err) => { .catch((err) => {
@ -134,19 +155,27 @@ async function fetchListPerson(newPage: boolean = false) {
}); });
} }
/**
* งกนยนยนการลบรายชอคนททธดการโครงสราง
* @param id รายชอคนททธดการโครงสราง
*
* ลบเสรจจะโหลดขอมลรายชอคนททธดการโครงสราง
*/
function onDeletePerson(id: string) { function onDeletePerson(id: string) {
dialogRemove($q, async () => { dialogRemove($q, async () => {
showLoader(); showLoader();
await http await http
.delete(config.API.permissionOrg + `/${id}`) .delete(config.API.permissionOrg + `/${id}`)
.then(async () => { .then(async () => {
// maxPage.value 1
if (maxPage.value !== 1) { if (maxPage.value !== 1) {
// page 1
if (rows.value.length === 1) { if (rows.value.length === 1) {
qureyBody.page = qureyBody.page - 1; qureyBody.page = qureyBody.page - 1;
} }
await fetchListPerson(false); await fetchListPerson(false); //
} else { } else {
await fetchListPerson(true); await fetchListPerson(true); //
} }
success($q, "ลบข้อมูสำเร็จ"); success($q, "ลบข้อมูสำเร็จ");
}) })
@ -167,6 +196,11 @@ function updatePagination(newPagination: Pagination) {
qureyBody.pageSize = newPagination.rowsPerPage; qureyBody.pageSize = newPagination.rowsPerPage;
} }
/**
* การเปลยนแปลงของ pageSize ใน queryBody
*
* เม pageSize การเปลยนแปลงใหโหลดขอมลหนาแรก
*/
watch( watch(
() => qureyBody.pageSize, () => qureyBody.pageSize,
() => { () => {
@ -180,8 +214,8 @@ watch(
*/ */
onMounted(async () => { onMounted(async () => {
await Promise.all([ await Promise.all([
fatchOrgg(), // fatchOrg(), //
fetchListPerson(), fetchListPerson(), //
]); ]);
}); });
</script> </script>