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

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

View file

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