Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m45s

* develop:
  แก้ข้อความอธิบายสิทธิ์ PARENT
  fix(roles):add permission PARENT
  fix(permission):bug fix send id
  fix(user): delete revisionId
This commit is contained in:
Warunee Tamkoo 2025-10-14 11:40:43 +07:00
commit ea4baf4b71
3 changed files with 414 additions and 163 deletions

View file

@ -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<string>(""); // id
const orgId = ref<string | null>(null); // id node
const orgLevel = ref<number | null>(null); // node
const expanded = ref<Array<string | number>>([]); // node
const filter = ref<string>(""); // tree
const nodeTree = ref<Array<NodeTree>>([
{
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<string>(""); //
const isAll = ref<boolean>(true); //
const rows = ref<Users[]>([]); //
const currentPage = ref<number>(1); //
const total = ref<number>(0); //
@ -118,12 +162,10 @@ const visibleColumns = ref<string[]>([
"role",
"enabled",
]);
/** เพิ่มข้อมูลผู้ใช้งาน*/
const modalDialogAdd = ref<boolean>(false); // popup
const isStatusEdit = ref<boolean>(false); //
const userId = ref<string>(""); // id
//
const itemMenu = ref<ItemsMenu[]>([
{
@ -151,24 +193,72 @@ const itemMenu = ref<ItemsMenu[]>([
type: "delete",
},
]);
const employeeClassMain = ref<DataOption[]>([
{ id: "officer", name: "ข้าราชการ กทม.สามัญ" },
{ id: "employee", name: "ลูกจ้างประจำ" },
]);
const employeeClassOption = ref<DataOption[]>(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();
});
</script>
@ -341,161 +444,285 @@ onMounted(async () => {
</div>
</div>
<q-card flast bordered class="q-pa-md">
<div class="items-center col-12 row q-col-gutter-sm">
<q-select
outlined
dense
v-model="employeeClass"
:options="employeeClassOption"
label="สถานภาพ"
emit-value
map-options
option-label="name"
option-value="id"
use-input
hide-selected
fill-input
style="width: 300px"
@update:model-value="(currentPage = 1), fetchListUsers()"
@filter="(inputValue: string,
doneFn: Function) => filterFnOptions(inputValue, doneFn,'employeeClass')"
><template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template>
</q-select>
<q-btn
class="q-ml-sm"
flat
round
dense
color="primary"
icon="add"
@click="openDialog()"
<q-card flat bordered>
<q-card-section :horizontal="$q.screen.gt.xs">
<!-- Tree -->
<q-card-section
class="col-lg-3 col-md-4 col-sm-5 col-xs-12 q-col-gutter-sm"
>
<q-tooltip>เพมผใชงาน </q-tooltip>
</q-btn>
<q-space />
<q-input
borderless
dense
outlined
v-model="keyword"
placeholder="ค้นหา"
@keydown.enter.prevent="(currentPage = 1), fetchListUsers()"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
style="min-width: 140px"
/>
</div>
<div class="col-12 q-pt-sm">
<d-table
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
:paging="true"
dense
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
@update:pagination="updatePagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width></q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name === 'enabled'">
<q-icon
:name="col.value ? 'check' : 'close'"
:color="col.value ? 'primary' : 'red'"
size="24px"
/>
<div class="col-12">
<div class="q-gutter-sm">
<div class="row q-col-gutter-sm q-pl-sm">
<div class="col-12">
<q-input dense outlined v-model="filter" label="ค้นหา">
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td>
<q-btn
flat
</div>
<div class="bg-white tree-container q-pa-xs">
<q-tree
class="q-pa-sm q-gutter-sm"
dense
icon="mdi-dots-vertical"
class="q-pa-none q-ml-xs"
color="grey-13"
size="12px"
default-expand-all
:nodes="lazy"
node-key="orgTreeId"
label-key="labelName"
:filter="filter?.trim()"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
v-model:expanded="expanded"
>
<q-menu>
<q-list dense style="min-width: 200px">
<q-item
v-for="(item, index) in props.row.enabled
? itemMenu.filter((e) => e.type !== 'open')
: itemMenu.filter((e) => e.type !== 'close')"
:key="index"
clickable
v-close-popup
@click.stop="onClickAction(item.type, props.row)"
>
<q-item-section>
<div class="row items-center">
<q-icon
:color="item.color"
size="17px"
:name="item.icon"
/>
<div class="q-pl-md">{{ item.label }}</div>
<template v-slot:default-header="prop">
<q-item
@click.stop="selectedOrg(prop.node)"
:active="orgId == prop.node.orgTreeId"
clickable
active-class="my-list-link text-primary text-weight-medium"
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<div>
<div
:class="
prop.node.isOfficer
? 'text-weight-medium text-blue'
: 'text-weight-medium'
"
>
<div
v-if="
prop.node.isDeputy == true &&
prop.node.orgLevel == 0
"
class="text-info"
>
{{ prop.node.orgTreeName }}
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="currentPage"
active-color="primary"
color="dark"
:max="Number(maxPage)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchListUsers"
></q-pagination>
</template>
</d-table>
</div>
<div v-else>
{{ prop.node.orgTreeName }}
</div>
{{ prop.node.isOfficer ? "(สกจ.)" : "" }}
</div>
<div class="text-weight-light text-grey-8">
{{
prop.node.orgCode == null ? null : prop.node.orgCode
}}
{{
prop.node.orgTreeShortName == null
? null
: prop.node.orgTreeShortName
}}
</div>
</div>
</q-item>
</template>
</q-tree>
</div>
</div>
</div>
</q-card-section>
<q-separator :vertical="$q.screen.gt.xs" />
<!-- Table -->
<q-card-section
class="col-lg-9 col-md-8 col-sm-7 col-xs-12"
style="height: 85vh"
>
<div class="col-12 q-col-gutter-sm scroll" style="height: 100%">
<div class="col-12">
<div class="col-12 row q-col-gutter-sm items-end">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-3">
<div class="row q-col-gutter-sm items-center">
<div class="col-11">
<q-select
outlined
dense
v-model="employeeClass"
:options="employeeClassOption"
label="สถานภาพ"
emit-value
map-options
option-label="name"
option-value="id"
use-input
hide-selected
fill-input
@update:model-value="onSearchData"
@filter="(inputValue: string,
doneFn: Function) => filterFnOptions(inputValue, doneFn,'employeeClass')"
><template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="col-1">
<q-btn
flat
round
dense
color="primary"
icon="add"
@click="openDialog()"
>
<q-tooltip>เพมผใชงาน </q-tooltip>
</q-btn>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-0 col-md-0 col-lg-3"></div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
<div class="row q-col-gutter-sm items-center">
<div class="col-4">
<q-checkbox
keep-color
v-model="isAll"
label="แสดงตำแหน่งทั้งหมด"
color="primary"
@update:model-value="onSearchData"
>
<q-tooltip
>แสดงตำแหนงทงหมดภายใตหนวยงาน/วนราชการทเลอก</q-tooltip
>
</q-checkbox>
</div>
<div class="col-5">
<q-input
borderless
dense
outlined
v-model="keyword"
placeholder="ค้นหา"
@keydown.enter.prevent="onSearchData"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
<div class="col-3">
<q-select
v-model="visibleColumns"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
/>
</div>
</div>
</div>
</div>
</div>
<div class="col-12">
<d-table
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
:paging="true"
dense
:rows-per-page-options="[10, 25, 50, 100]"
:visible-columns="visibleColumns"
@update:pagination="updatePagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width></q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<div v-if="col.name === 'enabled'">
<q-icon
:name="col.value ? 'check' : 'close'"
:color="col.value ? 'primary' : 'red'"
size="24px"
/>
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
<q-td>
<q-btn
flat
dense
icon="mdi-dots-vertical"
class="q-pa-none q-ml-xs"
color="grey-13"
size="12px"
>
<q-menu>
<q-list dense style="min-width: 200px">
<q-item
v-for="(item, index) in props.row.enabled
? itemMenu.filter((e) => e.type !== 'open')
: itemMenu.filter((e) => e.type !== 'close')"
:key="index"
clickable
v-close-popup
@click.stop="onClickAction(item.type, props.row)"
>
<q-item-section>
<div class="row items-center">
<q-icon
:color="item.color"
size="17px"
:name="item.icon"
/>
<div class="q-pl-md">{{ item.label }}</div>
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
งหมด {{ total }} รายการ
<q-pagination
v-model="currentPage"
active-color="primary"
color="dark"
:max="Number(maxPage)"
size="sm"
boundary-links
direction-links
:max-pages="5"
@update:model-value="fetchListUsers"
></q-pagination>
</template>
</d-table>
</div>
</div>
</q-card-section>
</q-card-section>
</q-card>
<DialogAddUser
@ -507,4 +734,19 @@ onMounted(async () => {
/>
</template>
<style scoped></style>
<style scoped>
.tree-container {
overflow: auto;
height: 76vh;
border: 1px solid #e6e6e7;
border-radius: 10px;
}
.my-list-link {
color: rgb(118, 168, 222);
border-radius: 5px;
background: #a3d3fb48 !important;
font-weight: 600;
border: 1px solid rgba(175, 185, 196, 0.217);
}
</style>

View file

@ -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);

View file

@ -29,6 +29,10 @@ const attrPrivilegeOp = ref<DataOption[]>([
id: "ROOT",
name: "มีสิทธิ์เข้าถึงข้อมูลในทุกระดับ",
},
{
id: "PARENT",
name: "มีสิทธิ์เข้าถึงข้อมูลในทุกระดับที่อยู่ภายใต้หน่วยงานของตัวเอง ยกเว้นระดับชั้นบนสุด",
},
{
id: "CHILD",
name: "มีสิทธิ์เข้าถึงข้อมูลเฉพาะระดับชั้นปัจจุบันของตัวเอง",
@ -320,6 +324,11 @@ onMounted(() => {
งแตระดบของตวเองลงไปชนลางส
และขนไปถงชนบนส
</div>
<div class="row no-wrap">
<strong>PARENT</strong
>-ทธเขาถงขอมลในทกระดบทอยภายใตหนวยงานของตวเอง
ยกเวนระดบชนบนส
</div>
<div class="row no-wrap">
<strong>CHILD</strong
>-ทธเขาถงขอมลเฉพาะระดบชนปจจนของตวเอง