diff --git a/src/modules/02_users/components/Permissions/DialogAdd.vue b/src/modules/02_users/components/Permissions/DialogAdd.vue new file mode 100644 index 00000000..8d2e54de --- /dev/null +++ b/src/modules/02_users/components/Permissions/DialogAdd.vue @@ -0,0 +1,162 @@ + + + + + diff --git a/src/modules/02_users/interface/index/Main.ts b/src/modules/02_users/interface/index/Main.ts index e6dd68b5..e1685edd 100644 --- a/src/modules/02_users/interface/index/Main.ts +++ b/src/modules/02_users/interface/index/Main.ts @@ -1,4 +1,5 @@ interface Pagination { + page: number; rowsPerPage: number; } diff --git a/src/modules/02_users/interface/request/Main.ts b/src/modules/02_users/interface/request/Main.ts index cbc0bd3a..4f1cb8ac 100644 --- a/src/modules/02_users/interface/request/Main.ts +++ b/src/modules/02_users/interface/request/Main.ts @@ -16,4 +16,14 @@ interface Roles { id: string; name: string; } -export type { FormUser, FormRole, Roles }; + +interface FilterReqMaster { + id: string; + type: number; + isAll: boolean; + page: number; + pageSize: number; + keyword: string; + revisionId: string; +} +export type { FormUser, FormRole, Roles, FilterReqMaster }; diff --git a/src/modules/02_users/interface/response/Main.ts b/src/modules/02_users/interface/response/Main.ts index 0e58194c..ce675174 100644 --- a/src/modules/02_users/interface/response/Main.ts +++ b/src/modules/02_users/interface/response/Main.ts @@ -16,4 +16,84 @@ interface Roles { name: string; } -export type { Users, Roles }; +interface NodeTree { + labelName: string; + orgCode: string; + orgLevel: number; + orgName: string; + orgRevisionId: string; + orgRootName: string; + orgTreeCode: string; + orgTreeFax: string; + orgTreeId: string; + orgTreeName: string; + orgTreeOrder: number; + orgTreePhoneEx: string; + orgTreePhoneIn: string; + orgTreeRank: string; + orgTreeRankSub: string | null; + orgTreeShortName: string; + responsibility: string | null; + totalPosition: number; + totalPositionCurrentUse: number; + totalPositionCurrentVacant: number; + totalPositionNextUse: number; + totalPositionNextVacant: number; + totalRootPosition: number; + totalRootPositionCurrentUse: number; + totalRootPositionCurrentVacant: number; + totalRootPositionNextUse: number; + totalRootPositionNextVacant: number; + children: NodeTree; +} + +interface PosMaster { + fullNameCurrentHolder: null | string; + fullNameNextHolder: string; + id: string; + isSit: boolean; + isSpecial: boolean; + orgChild1Id: null | string; + orgChild2Id: null | string; + orgChild3Id: null | string; + orgChild4Id: null | string; + orgRootId: string; + orgShortname: string; + posExecutiveId: string; + posExecutiveName: string; + posLevelId: string; + posLevelName: string; + posMasterNo: 1; + posMasterNoPrefix: null | string; + posMasterNoSuffix: null | string; + posTypeId: string; + posTypeName: string; + positionArea: string; + positionExecutiveField: string; + positionField: string; + positionIsSelected: boolean; + positionName: string; + profilePosition: string; + profilePoslevel: null | string; + profilePostype: null | string; + reason: null | string; + positions: Position[]; +} + +interface Position { + id: string; + isSpecial: boolean; + posExecutiveId: string; + posExecutiveName: string; + posLevelId: string; + posLevelName: string; + posTypeId: string; + posTypeName: string; + positionArea: string; + positionExecutiveField: string; + positionField: string; + positionIsSelected: boolean; + positionName: string; +} + +export type { Users, Roles, NodeTree, PosMaster, Position }; diff --git a/src/modules/02_users/views/permissionsView.vue b/src/modules/02_users/views/permissionsView.vue index dac3eebe..2a84fc2c 100644 --- a/src/modules/02_users/views/permissionsView.vue +++ b/src/modules/02_users/views/permissionsView.vue @@ -4,8 +4,18 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; +/** importComponents*/ +import DialogAdd from "@/modules/02_users/components/Permissions/DialogAdd.vue"; + /** importType*/ import type { QTableProps } from "quasar"; +import type { Pagination } from "@/modules/02_users/interface/index/Main"; +import type { FilterReqMaster } from "@/modules/02_users/interface/request/Main"; +import type { + NodeTree, + PosMaster, + Position, +} from "@/modules/02_users/interface/response/Main"; /** importStore*/ import { usePermissionsStore } from "@/modules/02_users/stores/permissions"; @@ -13,11 +23,11 @@ import { useCounterMixin } from "@/stores/mixin"; const $q = useQuasar(); const store = usePermissionsStore(); -const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin(); +const { showLoader, hideLoader, messageError } = useCounterMixin(); /** Tree*/ const filter = ref(""); -const nodes = ref>([]); +const nodes = ref>([]); const lazy = ref(nodes); const expanded = ref([]); const nodeId = ref(""); @@ -45,7 +55,8 @@ const columns = ref([ row.orgShortname + (row.posMasterNoPrefix ? row.posMasterNoPrefix : "") + (row.posMasterNo ? row.posMasterNo : "") + - (row.posMasterNoSuffix ? row.posMasterNoSuffix : ""), + (row.posMasterNoSuffix ? row.posMasterNoSuffix : "") + + (row.isSit ? "(ทับที่)" : ""), headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -91,6 +102,15 @@ const columns = ref([ headerStyle: "font-size: 14px", style: "font-size: 14px", }, + { + name: "role", + align: "left", + label: "สิทธิ์การจัดการ", + sortable: false, + field: "role", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, ]); const columnsExpand = ref([ { @@ -166,7 +186,7 @@ const columnsExpand = ref([ style: "font-size: 14px", }, ]); -const reqMaster = reactive({ +const reqMaster = reactive({ id: "", type: 0, isAll: false, @@ -177,7 +197,14 @@ const reqMaster = reactive({ }); const maxPage = ref(0); const totalRow = ref(0); -const posMaster = ref([]); +const posMaster = ref([]); +const pagination = ref({ + page: reqMaster.page, + rowsPerPage: reqMaster.pageSize, +}); + +/** Dialog*/ +const modalDialogAdd = ref(false); /** function เรียกข้อมูลโครงสร้าง แบบปัจุบันและ แบบร่าง*/ async function fetchOrganizationActive() { @@ -209,9 +236,9 @@ async function fetchOrganizationActive() { * function fetch ข้อมูลของ Tree * @param id id โครงสร้าง */ -async function fetchDataTree(id: string) { +function fetchDataTree(id: string) { showLoader(); - await http + http .get(config.API.orgByid(id.toString())) .then((res) => { const data = res.data.result; @@ -230,26 +257,26 @@ async function fetchDataTree(id: string) { * @param id idTree * @param level levelTree */ -async function fetchDataTable(id: string, revisionId: string, level: number) { +function fetchDataTable(id: string, revisionId: string, level: number) { showLoader(); reqMaster.id = id; reqMaster.revisionId = revisionId; reqMaster.type = level; - await http + http .post(config.API.orgPosMasterList, reqMaster) .then(async (res) => { posMaster.value = []; - const dataMain: any = []; + const dataMain: PosMaster[] = []; maxPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize); totalRow.value = res.data.result.total; - res.data.result.data.forEach((e: any) => { + res.data.result.data.forEach((e: PosMaster) => { const p = e.positions; if (p.length !== 0) { - const a = p.find((el: any) => el.positionIsSelected === true); + const a = p.find((el: Position) => el.positionIsSelected === true); const { id, ...rest } = a ? a : p[0]; - const test = { ...e, ...rest }; - dataMain.push(test); + const pos = { ...e, ...rest }; + dataMain.push(pos); } }); posMaster.value = dataMain; @@ -263,40 +290,53 @@ async function fetchDataTable(id: string, revisionId: string, level: number) { }); } -function updateSelected(data: any) { +/** + * function เลือกข้อมูลโครางสร่้าง + * @param data + */ +function updateSelected(data: NodeTree) { nodeId.value = data.orgTreeId; fetchDataTable(data.orgTreeId, data.orgRevisionId, data.orgLevel); } -const pagination = ref({ - page: reqMaster.page, - rowsPerPage: reqMaster.pageSize, -}); - /** * function updatePagination * @param newPagination ข้อมูล Pagination ใหม่ */ -function updatePagination(newPagination: any) { +function updatePagination(newPagination: Pagination) { reqMaster.pageSize = newPagination.rowsPerPage; reqMaster.page = 1; } +function onClickAddRole(data: PosMaster) { + modalDialogAdd.value = true; +} + +/** callblck function ทำการ fetch ข้อมูล tree เมื่อมีการเปลี่ยน Tab ปัจจับัน,แบบร่าง*/ +watch( + () => store.typeOrganizational, + () => { + const id = + store.typeOrganizational === "current" ? store.activeId : store.draftId; + nodeId.value = ""; + posMaster.value = []; + reqMaster.id = ""; + reqMaster.type = 0; + reqMaster.isAll = false; + reqMaster.page = 1; + reqMaster.pageSize = 10; + reqMaster.keyword = ""; + reqMaster.revisionId = ""; + fetchDataTree(id); + } +); + /** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนหน้า*/ watch([() => reqMaster.pageSize], () => { fetchDataTable(reqMaster.id, reqMaster.revisionId, reqMaster.type); }); -watch( - () => store.typeOrganizational, - () => { - const id = - store.typeOrganizational === "current" ? store.activeId : store.draftId; - fetchDataTree(id); - posMaster.value = [] - } -); - +/** callblck function ทำการ fetch ข้อมูล Table เมื่อมีการเปลี่ยนจำนวนต่อแแแถว*/ watch( () => reqMaster.isAll, () => { @@ -415,9 +455,9 @@ onMounted(() => { +
-
@@ -501,27 +541,41 @@ onMounted(() => { :key="col.name" :props="props" > -
{{ col.value ? col.value : "-" }}
- + + + + + + +
+ +
จัดการสิทธิ์
+
+
+
+
+
+
+
@@ -623,6 +677,12 @@ onMounted(() => {
+ +