diff --git a/src/modules/02_users/views/01_user.vue b/src/modules/02_users/views/01_user.vue index 6c5d5aa7..0ceba23f 100644 --- a/src/modules/02_users/views/01_user.vue +++ b/src/modules/02_users/views/01_user.vue @@ -2,11 +2,12 @@ import { ref, onMounted, watch } from "vue"; import { useQuasar } from "quasar"; -import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; +import { useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import { updateCurrentPage } from "@/utils/functions"; +import { tokenParsed } from "@/plugins/auth"; /** importType*/ import type { QTableProps } from "quasar"; @@ -15,6 +16,7 @@ import type { ItemsMenu, Pagination, } from "@/modules/02_users/interface/index/Main"; +import type { NodeTree } from "@/modules/02_users/interface/response/Main"; import type { Users, Roles } from "@/modules/02_users/interface/response/Main"; /** importComponents*/ @@ -32,8 +34,50 @@ const { dialogConfirm, } = useCounterMixin(); +/** Tree*/ +const activeId = ref(""); // id ของโครงสร้างที่ใช้งานอยู่ +const orgId = ref(null); // id ของ node ที่เลือก +const orgLevel = ref(null); // ระดับของ node ที่เลือก +const expanded = ref>([]); // ข้อมูล node ที่ขยาย +const filter = ref(""); // คำค้นหาใน tree +const nodeTree = ref>([ + { + labelName: "", + orgCode: "", + orgLevel: 0, + orgName: "", + orgRevisionId: "", + orgRootName: "", + orgTreeCode: "", + orgTreeFax: "", + orgTreeId: "", + orgTreeName: "หน่วยงานทั้งหมด", + orgTreeOrder: 0, + orgTreePhoneEx: "", + orgTreePhoneIn: "", + orgTreeRank: "", + orgTreeRankSub: "", + orgTreeShortName: "", + responsibility: "", + totalPosition: 0, + totalPositionCurrentUse: 0, + totalPositionCurrentVacant: 0, + totalPositionNextUse: 0, + totalPositionNextVacant: 0, + totalRootPosition: 0, + totalRootPositionCurrentUse: 0, + totalRootPositionCurrentVacant: 0, + totalRootPositionNextUse: 0, + totalRootPositionNextVacant: 0, + children: [] as NodeTree[], + isOfficer: false, + }, +]); +const lazy = ref(nodeTree); + /** Table*/ const keyword = ref(""); // คำค้นหา +const isAll = ref(true); // แสดงตำแหน่งทั้งหมด const rows = ref([]); // ข้อมูลรายาการผู้ใช้งาน const currentPage = ref(1); // หน้า const total = ref(0); // จำนวนรายการ @@ -118,12 +162,10 @@ const visibleColumns = ref([ "role", "enabled", ]); - /** เพิ่มข้อมูลผู้ใช้งาน*/ const modalDialogAdd = ref(false); // เปิด ปิด popup const isStatusEdit = ref(false); // สถานะการแก้ไข const userId = ref(""); // id ผู้ใช้งานที่ต้องการแก้ไข - // รายการตัวเลือก const itemMenu = ref([ { @@ -151,24 +193,72 @@ const itemMenu = ref([ type: "delete", }, ]); - const employeeClassMain = ref([ { id: "officer", name: "ข้าราชการ กทม.สามัญ" }, { id: "employee", name: "ลูกจ้างประจำ" }, ]); - const employeeClassOption = ref(employeeClassMain.value); +/** ฟังก์ชันเรียกข้อมูลโครงสร้าง แบบปัจุบัน*/ +async function fetchOrganizationActive() { + showLoader(); + await http + .get(config.API.activeOrganization) + .then(async (res) => { + const data = res.data.result; + if (data) { + activeId.value = data.activeId; + await fetchDataTree(data.activeId); + } + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + /** - * ฟังก์ชันดึงข้อมูลรายชื่อผู้ใช้งาน + * ฟังก์ชัน fetch ข้อมูลของโครงสร้าง + * @param id id โครงสร้าง */ +async function fetchDataTree(id: string) { + const tokenParsedData = await tokenParsed(); + const isSuperAdmin = tokenParsedData.role.includes("SUPER_ADMIN"); + if (!isSuperAdmin) { + nodeTree.value = []; + } + showLoader(); + await http + .get(config.API.orgByid(id.toString())) + .then(async (res) => { + const data = await res.data.result; + nodeTree.value.push(...data); + orgId.value = nodeTree.value[0].orgTreeId || ""; + await selectedOrg(nodeTree.value[0]); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +/** ฟังก์ชันดึงข้อมูลรายชื่อผู้ใช้งาน*/ async function fetchListUsers() { showLoader(); await http - .get( - config.API.managementUser + - `?pageSize=${pageSize.value}&page=${currentPage.value}&keyword=${keyword.value}&type=${employeeClass.value}` - ) + .post(config.API.managementUser + `/admin`, { + pageSize: pageSize.value, + page: currentPage.value, + keyword: keyword.value.trim(), + type: employeeClass.value, + isAll: isAll.value, + nodeId: orgId.value, + node: orgLevel.value, + }) .then(async (res) => { const data = await res.data.result; total.value = data.total; @@ -314,6 +404,19 @@ function filterFnOptions(val: string, update: Function, type: string) { } } +async function selectedOrg(data: NodeTree) { + orgId.value = data.orgTreeId; + orgLevel.value = data.orgLevel; + currentPage.value = 1; + // ดึงข้อมูลผู้ใช้งานตามหน่วยงานที่เลือก + await fetchListUsers(); +} + +async function onSearchData() { + currentPage.value = 1; + await fetchListUsers(); +} + /** * ดูการเปลี่ยนแปลงของจำนวนข้อมูลต่อหน้า * ดึงข้อมูลรายชื่อผู้ใช้งานตามจำนวนข้อมูลต่อหน้า @@ -330,7 +433,7 @@ watch( * ดึงข้อมูลรายชื่อผู้ใช้งาน */ onMounted(async () => { - await fetchListUsers(); + await fetchOrganizationActive(); }); @@ -341,161 +444,285 @@ onMounted(async () => { - -
- - - - + + + - เพิ่มผู้ใช้งาน - - - - - - - -
- -
- - - + +
+ + + + + + + +
+
+
+
+
+
+ + +
+
+ + เพิ่มผู้ใช้งาน + +
+
+
+
+
+
+
+ + แสดงตำแหน่งทั้งหมดภายใต้หน่วยงาน/ส่วนราชการที่เลือก + +
+
+ + + +
+
+ +
+
+
+
+
+ +
+ + + + + +
+
+
+
{ /> - + diff --git a/src/modules/02_users/views/03_permissionsView.vue b/src/modules/02_users/views/03_permissionsView.vue index 7ded91c7..81014b29 100644 --- a/src/modules/02_users/views/03_permissionsView.vue +++ b/src/modules/02_users/views/03_permissionsView.vue @@ -330,7 +330,7 @@ async function fetchDataTree(id: string) { nodes.value.push(...data); nodes.value[0].orgRevisionId = id; nodeId.value = nodes.value[0].orgTreeId; - await fetchDataTable(reqMaster.id, id, reqMaster.type); + await fetchDataTable(nodeId.value, id, nodes.value[0].orgLevel); }) .catch((err) => { messageError($q, err); diff --git a/src/modules/02_users/views/page02_rolesAndPermissionsDetail.vue b/src/modules/02_users/views/page02_rolesAndPermissionsDetail.vue index 12260682..609d037a 100644 --- a/src/modules/02_users/views/page02_rolesAndPermissionsDetail.vue +++ b/src/modules/02_users/views/page02_rolesAndPermissionsDetail.vue @@ -29,6 +29,10 @@ const attrPrivilegeOp = ref([ id: "ROOT", name: "มีสิทธิ์เข้าถึงข้อมูลในทุกระดับ", }, + { + id: "PARENT", + name: "มีสิทธิ์เข้าถึงข้อมูลในทุกระดับที่อยู่ภายใต้หน่วยงานของตัวเอง ยกเว้นระดับชั้นบนสุด", + }, { id: "CHILD", name: "มีสิทธิ์เข้าถึงข้อมูลเฉพาะระดับชั้นปัจจุบันของตัวเอง", @@ -320,6 +324,11 @@ onMounted(() => { ตั้งแต่ระดับของตัวเองลงไปชั้นล่างสุด และขึ้นไปถึงชั้นบนสุด +
+ PARENT-มีสิทธิ์เข้าถึงข้อมูลในทุกระดับที่อยู่ภายใต้หน่วยงานของตัวเอง + ยกเว้นระดับชั้นบนสุด +
CHILD-มีสิทธิ์เข้าถึงข้อมูลเฉพาะระดับชั้นปัจจุบันของตัวเอง