สิทธิ์แก้ไขข้อมูลทะเบียนประวัติตำแหน่ง/เงินเดือน รอ API
This commit is contained in:
parent
c9ce8482b3
commit
7d452e9c0d
5 changed files with 886 additions and 0 deletions
|
|
@ -128,6 +128,12 @@ const menuList = readonly<any[]>([
|
||||||
path: "responsibilities",
|
path: "responsibilities",
|
||||||
role: ["SUPER_ADMIN", "ADMIN"],
|
role: ["SUPER_ADMIN", "ADMIN"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 2.0,
|
||||||
|
label: "ทะเบียนประวัติตำแหน่ง/เงินเดือน",
|
||||||
|
path: "rolePositionSalary",
|
||||||
|
role: ["SUPER_ADMIN", "ADMIN"],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,321 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { reactive, ref, watch } from "vue";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useDataStoreUser } from "@/modules/02_users/stores/main";
|
||||||
|
|
||||||
|
import type { QTableProps } from "quasar";
|
||||||
|
import type {
|
||||||
|
DataProfile,
|
||||||
|
Pagination,
|
||||||
|
} from "@/modules/02_users/interface/index/Main";
|
||||||
|
|
||||||
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
|
||||||
|
const $q = useQuasar();
|
||||||
|
const store = useDataStoreUser();
|
||||||
|
const { showLoader, hideLoader, messageError, success, dialogConfirm } =
|
||||||
|
useCounterMixin();
|
||||||
|
|
||||||
|
const modal = defineModel<boolean>("modal", { required: true });
|
||||||
|
const orgId = defineModel<string>("orgId", { required: true });
|
||||||
|
const props = defineProps({
|
||||||
|
fetchData: {
|
||||||
|
type: Function,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const qurey = reactive({
|
||||||
|
searchKeyword: "", // คำค้นหา
|
||||||
|
searchField: "fullName", // field ที่ต้องการค้นหา
|
||||||
|
page: 1, // หน้า
|
||||||
|
pageSize: 10, // จำนวนที่ต้องการ
|
||||||
|
});
|
||||||
|
|
||||||
|
const isEdit = ref<boolean>(false); // สิทธิ์แก้ไขข้อมูล
|
||||||
|
const isCheck = ref<boolean>(false); // สิทธิ์ตรวจสอบข้อมูล
|
||||||
|
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",
|
||||||
|
align: "left",
|
||||||
|
label: "ชื่อ-นามสกุล",
|
||||||
|
sortable: true,
|
||||||
|
field: (row) => `${row.prefix}${row.firstName} ${row.lastName}`,
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "posNo",
|
||||||
|
align: "left",
|
||||||
|
label: "เลขที่ตำแหน่ง",
|
||||||
|
sortable: true,
|
||||||
|
field: "posNo",
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "position",
|
||||||
|
align: "left",
|
||||||
|
label: "ตำแหน่งในสายงาน",
|
||||||
|
sortable: true,
|
||||||
|
field: "position",
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: "posType",
|
||||||
|
align: "left",
|
||||||
|
label: "ประเภทตำแหน่ง",
|
||||||
|
sortable: true,
|
||||||
|
field: (row) =>
|
||||||
|
`${row.posType ? row.posType : "-"} ${
|
||||||
|
row.posLevel ? `(${row.posLevel})` : ``
|
||||||
|
} `,
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันดึงข้อมูลรายชื่อ
|
||||||
|
* @param newPage โหลดหน้าแรก ถ้าเป็บ true โหลดหน้าแรก false ให้โหลดหน้าปัจจุบัน
|
||||||
|
*
|
||||||
|
* เก็บมูลรายชื่อไว่ใน rows.value
|
||||||
|
*/
|
||||||
|
async function onSearchListPerson(newPage: boolean = false) {
|
||||||
|
qurey.page = newPage ? 1 : qurey.page;
|
||||||
|
selected.value = [];
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.get(config.API.permissionOrgProfile, {
|
||||||
|
params: qurey,
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data.result;
|
||||||
|
maxPage.value = Math.ceil(data.total / qurey.pageSize);
|
||||||
|
total.value = data.total;
|
||||||
|
rows.value = data.data;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันยืนยันการเพิ่มราชื่อ
|
||||||
|
*
|
||||||
|
* เมื่อเพิ่มเสร็จจะดึงข้อมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้างตามหน่วยงาน
|
||||||
|
*/
|
||||||
|
function onSubmitPerson() {
|
||||||
|
const arrayId = selected.value.map((e: DataProfile) => e.id);
|
||||||
|
dialogConfirm(
|
||||||
|
$q,
|
||||||
|
async () => {
|
||||||
|
showLoader();
|
||||||
|
const body = {
|
||||||
|
nodeId: orgId.value,
|
||||||
|
isEdit: isEdit.value,
|
||||||
|
isCheck: isCheck.value,
|
||||||
|
personId: arrayId,
|
||||||
|
};
|
||||||
|
await http
|
||||||
|
.post(config.API.permissionOrg, body)
|
||||||
|
.then(async () => {
|
||||||
|
await props.fetchData?.(false);
|
||||||
|
success($q, "เพิ่มราชชื่อสำเร็จ");
|
||||||
|
onClose();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"ยืนยันการเพิ่มรายชื่อ",
|
||||||
|
"ต้องการยืนยันการเพิ่มรายชื่อนี้หรือไม่ ?"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function updatePagination
|
||||||
|
* @param newPagination ข้อมูล Pagination ใหม่
|
||||||
|
*/
|
||||||
|
function updatePagination(newPagination: Pagination) {
|
||||||
|
qurey.pageSize = newPagination.rowsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันปิด popup ราชชื่อ
|
||||||
|
*
|
||||||
|
* และกำหนดค่าของ qurey ไปเป็นค่า defult rows.value และ selected.value ไปเป็นค่าว่าง
|
||||||
|
*/
|
||||||
|
function onClose() {
|
||||||
|
modal.value = false;
|
||||||
|
qurey.page = 1;
|
||||||
|
qurey.pageSize = 10;
|
||||||
|
qurey.searchField = "fullName";
|
||||||
|
qurey.searchKeyword = "";
|
||||||
|
rows.value = [];
|
||||||
|
selected.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ดูการเปลี่ยนแปลงของ pageSize ใน queryBody
|
||||||
|
*
|
||||||
|
* เมื่อ pageSize มีการเปลี่ยนแปลงให้โหลดข้อมูลหน้าแรก
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => qurey.pageSize,
|
||||||
|
() => {
|
||||||
|
onSearchListPerson(true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-dialog v-model="modal" persistent>
|
||||||
|
<q-card style="min-width: 60%">
|
||||||
|
<DialogHeader :tittle="'รายชื่อ'" :close="onClose" />
|
||||||
|
<q-separator />
|
||||||
|
<q-card-section style="max-height: 50vh" class="scroll">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="row q-gutter-sm">
|
||||||
|
<q-checkbox
|
||||||
|
v-model="isEdit"
|
||||||
|
label="สิทธิ์แก้ไขข้อมูล"
|
||||||
|
@update:model-value="isCheck = false"
|
||||||
|
/>
|
||||||
|
<q-separator vertical inset />
|
||||||
|
<q-checkbox
|
||||||
|
v-model="isCheck"
|
||||||
|
label="สิทธิ์ตรวจสอบข้อมูล"
|
||||||
|
@update:model-value="isEdit = false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<q-toolbar style="padding: 0">
|
||||||
|
<q-select
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
v-model="qurey.searchField"
|
||||||
|
:options="store.searchFieldOption"
|
||||||
|
label="ค้นหาจาก"
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
style="width: 250px"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<q-toolbar-title>
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
v-model="qurey.searchKeyword"
|
||||||
|
label="คำค้น"
|
||||||
|
>
|
||||||
|
<!-- <template v-slot:append>
|
||||||
|
<q-icon name="search" />
|
||||||
|
</template> -->
|
||||||
|
</q-input>
|
||||||
|
</q-toolbar-title>
|
||||||
|
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
icon="search"
|
||||||
|
class="full-height"
|
||||||
|
label="ค้นหา"
|
||||||
|
color="primary"
|
||||||
|
@click="onSearchListPerson(true)"
|
||||||
|
/>
|
||||||
|
</q-toolbar>
|
||||||
|
</div>
|
||||||
|
<div class="col-12">
|
||||||
|
<d-table
|
||||||
|
:columns="columns"
|
||||||
|
:rows="rows"
|
||||||
|
:paging="true"
|
||||||
|
row-key="id"
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
dense
|
||||||
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
|
selection="multiple"
|
||||||
|
v-model:selected="selected"
|
||||||
|
@update:pagination="updatePagination"
|
||||||
|
>
|
||||||
|
<template v-slot:header="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-th auto-width>
|
||||||
|
<q-checkbox
|
||||||
|
keep-color
|
||||||
|
color="primary"
|
||||||
|
dense
|
||||||
|
v-model="props.selected"
|
||||||
|
/>
|
||||||
|
</q-th>
|
||||||
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
|
<span class="text-weight-medium">{{ col.label }}</span>
|
||||||
|
</q-th>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<td auto-width>
|
||||||
|
<q-checkbox
|
||||||
|
keep-color
|
||||||
|
color="primary"
|
||||||
|
dense
|
||||||
|
v-model="props.selected"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
|
<div>
|
||||||
|
{{ col.value ? col.value : "-" }}
|
||||||
|
</div>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
<template v-slot:pagination="scope">
|
||||||
|
ทั้งหมด {{ total }} รายการ
|
||||||
|
<q-pagination
|
||||||
|
v-model="qurey.page"
|
||||||
|
active-color="primary"
|
||||||
|
color="dark"
|
||||||
|
:max="maxPage"
|
||||||
|
:max-pages="5"
|
||||||
|
size="sm"
|
||||||
|
boundary-links
|
||||||
|
direction-links
|
||||||
|
@update:model-value="onSearchListPerson(false)"
|
||||||
|
></q-pagination>
|
||||||
|
</template>
|
||||||
|
</d-table>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-separator />
|
||||||
|
<q-card-actions align="right">
|
||||||
|
<q-btn
|
||||||
|
label="เพิ่ม"
|
||||||
|
color="public"
|
||||||
|
:disable="selected.length === 0"
|
||||||
|
@click="onSubmitPerson"
|
||||||
|
/>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</q-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
|
|
@ -58,6 +58,7 @@ interface DataTree {
|
||||||
createdFullName: string;
|
createdFullName: string;
|
||||||
createdUserId: string;
|
createdUserId: string;
|
||||||
id: string | null;
|
id: string | null;
|
||||||
|
orgTreeId?: string | null;
|
||||||
lastUpdateFullName: string;
|
lastUpdateFullName: string;
|
||||||
lastUpdateUserId: string;
|
lastUpdateUserId: string;
|
||||||
lastUpdatedAt: string;
|
lastUpdatedAt: string;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ const roleOrgview = () =>
|
||||||
const responsIbilitiesView = () =>
|
const responsIbilitiesView = () =>
|
||||||
import("@/modules/02_users/views/05_responsIbilities.vue");
|
import("@/modules/02_users/views/05_responsIbilities.vue");
|
||||||
|
|
||||||
|
/** roleOrganization */
|
||||||
|
const rolePositionSalary = () =>
|
||||||
|
import("@/modules/02_users/views/06_rolePositionSalary.vue");
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
path: "/users",
|
path: "/users",
|
||||||
|
|
@ -73,6 +77,14 @@ export default [
|
||||||
Role: ["SUPER_ADMIN", "ADMIN"],
|
Role: ["SUPER_ADMIN", "ADMIN"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/roles-position-salary",
|
||||||
|
name: "rolePositionSalary",
|
||||||
|
component: rolePositionSalary,
|
||||||
|
meta: {
|
||||||
|
Role: ["SUPER_ADMIN", "ADMIN"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/responsibilities",
|
path: "/responsibilities",
|
||||||
|
|
|
||||||
546
src/modules/02_users/views/06_rolePositionSalary.vue
Normal file
546
src/modules/02_users/views/06_rolePositionSalary.vue
Normal file
|
|
@ -0,0 +1,546 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, reactive, watch } from "vue";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useDataStoreUser } from "@/modules/02_users/stores/main";
|
||||||
|
import { tokenParsed } from "@/plugins/auth";
|
||||||
|
|
||||||
|
import type { QTableProps } from "quasar";
|
||||||
|
import type {
|
||||||
|
DataTree,
|
||||||
|
DataProfile,
|
||||||
|
Pagination,
|
||||||
|
} from "@/modules/02_users/interface/index/Main";
|
||||||
|
import type { QueryProfile } from "@/modules/02_users/interface/request/Main";
|
||||||
|
|
||||||
|
import DialogAddPerson from "@/modules/02_users/components/RolePositionSalary/DialogAddPerson.vue";
|
||||||
|
import PopupPersonal from "@/modules/02_users/components/RoleOrganization/DialogPersonal.vue";
|
||||||
|
|
||||||
|
const $q = useQuasar();
|
||||||
|
const store = useDataStoreUser();
|
||||||
|
const { showLoader, hideLoader, messageError, success, dialogRemove } =
|
||||||
|
useCounterMixin();
|
||||||
|
|
||||||
|
/******* โครงสร้าง *******/
|
||||||
|
const filter = ref<string>(""); // ค้นหาข้อมูลรายการโครงสร้าง
|
||||||
|
const nodeTree = ref<DataTree[]>([
|
||||||
|
{
|
||||||
|
ancestorDNA: "",
|
||||||
|
createdAt: "",
|
||||||
|
createdFullName: "",
|
||||||
|
createdUserId: "",
|
||||||
|
id: "",
|
||||||
|
orgTreeId: "",
|
||||||
|
lastUpdateFullName: "",
|
||||||
|
lastUpdateUserId: "",
|
||||||
|
lastUpdatedAt: "",
|
||||||
|
orgRevisionId: "",
|
||||||
|
orgRootCode: "",
|
||||||
|
orgRootFax: "",
|
||||||
|
orgRootName: "หน่วยงานทั้งหมด",
|
||||||
|
orgRootOrder: 0,
|
||||||
|
orgRootPhoneEx: "",
|
||||||
|
orgRootPhoneIn: "",
|
||||||
|
orgRootRank: "",
|
||||||
|
orgRootRankSub: "",
|
||||||
|
orgRootShortName: "",
|
||||||
|
responsibility: "",
|
||||||
|
isDeputy: false,
|
||||||
|
labelName: "หน่วยงานทั้งหมด",
|
||||||
|
},
|
||||||
|
]); // ข้อมูลรายการโครงสร้าง
|
||||||
|
const expanded = ref<Array<string>>([]); // เปิดรายการโครงสร้าง
|
||||||
|
const orgId = ref<string>(""); // id หน่วยงานที่เลือก
|
||||||
|
const modalPersonal = ref<boolean>(false);
|
||||||
|
const personId = ref<string>("");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันดึงข้อมูลโครงสร้าง
|
||||||
|
* เก็บข้อมูลโครงสร้างไว้ใน nodeTree
|
||||||
|
*/
|
||||||
|
async function fatchOrg() {
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.get(config.API.activeOrganization)
|
||||||
|
.then(async (res) => {
|
||||||
|
const data = await res.data.result;
|
||||||
|
if (data) {
|
||||||
|
await fetchDataTree(data.activeId);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function fetch ข้อมูลของ Tree
|
||||||
|
* @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);
|
||||||
|
|
||||||
|
if (data.length === 1) {
|
||||||
|
selectedOrg(data[0].orgTreeId);
|
||||||
|
} else if (data.length > 1) {
|
||||||
|
await fetchListPerson(); // ดึงข้อมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันเลือกหน่วยงาน
|
||||||
|
* @param id หน่วยงานที่เลือก
|
||||||
|
* กำหนดค่าของ qureyBody ให้เป็นค่า defult และกำหนดค่าของ qureyBody.id เป็นหน่วยงานที่เลือก
|
||||||
|
* และดึงข้อมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้างในหน่วยงานที่เลือก
|
||||||
|
*/
|
||||||
|
function selectedOrg(id: string) {
|
||||||
|
orgId.value = id;
|
||||||
|
qureyBody.id = id ? id : null;
|
||||||
|
qureyBody.searchKeyword = "";
|
||||||
|
qureyBody.searchField = "fullName";
|
||||||
|
qureyBody.page = 1;
|
||||||
|
fetchListPerson(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******* รายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง *******/
|
||||||
|
const qureyBody = reactive<QueryProfile>({
|
||||||
|
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 columns = ref<QTableProps["columns"]>([
|
||||||
|
{
|
||||||
|
name: "fullName",
|
||||||
|
align: "left",
|
||||||
|
label: "ชื่อ-นามสกุล",
|
||||||
|
sortable: true,
|
||||||
|
field: (row) => `${row.prefix}${row.firstName} ${row.lastName}`,
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "orgNew",
|
||||||
|
align: "left",
|
||||||
|
label: "หน่วยงานที่รับผิดชอบ",
|
||||||
|
sortable: true,
|
||||||
|
field: "orgNew",
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "isEdit",
|
||||||
|
align: "center",
|
||||||
|
label: "สิทธิ์แก้ไขข้อมูล",
|
||||||
|
sortable: false,
|
||||||
|
field: "isEdit",
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "isCheck",
|
||||||
|
align: "center",
|
||||||
|
label: "สิทธิ์ตรวจสอบข้อมูล",
|
||||||
|
sortable: false,
|
||||||
|
field: "isCheck",
|
||||||
|
headerStyle: "font-size: 14px",
|
||||||
|
style: "font-size: 14px",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const visibleColumns = ref<string[]>([
|
||||||
|
"fullName",
|
||||||
|
"orgNew",
|
||||||
|
"isEdit",
|
||||||
|
"isCheck",
|
||||||
|
]);
|
||||||
|
const modalAdd = ref<boolean>(false); // modal เพิ่มข้อมูลรายชื่อ
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันดึงข้อมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง
|
||||||
|
* @param newPage โหลดหน้าแรก ถ้าเป็บ true โหลดหน้าแรก false ให้โหลดหน้าปัจจุบัน
|
||||||
|
*
|
||||||
|
* เก็บมูลรายชื่อคนที่มีสิทธิ์จัดการโครงสร้างไว่ใน rows.value
|
||||||
|
*/
|
||||||
|
async function fetchListPerson(newPage: boolean = false) {
|
||||||
|
qureyBody.page = newPage ? 1 : qureyBody.page;
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.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; // จำนวนรายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง
|
||||||
|
rows.value = data.data;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ฟังก์ชันยืนยันการลบรายชื่อคนที่มีสิทธิ์จัดการโครงสร้าง
|
||||||
|
* @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); // โหลดข้อมูลจากหน้าปัจจุบันโดยไม่รีเซ็ต
|
||||||
|
} else {
|
||||||
|
await fetchListPerson(true); // โหลดข้อมูลหน้าแรก
|
||||||
|
}
|
||||||
|
success($q, "ลบข้อมูสำเร็จ");
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* function updatePagination
|
||||||
|
* @param newPagination ข้อมูล Pagination ใหม่
|
||||||
|
*/
|
||||||
|
function updatePagination(newPagination: Pagination) {
|
||||||
|
qureyBody.pageSize = newPagination.rowsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onOpenModalPersonal(id: string) {
|
||||||
|
personId.value = id;
|
||||||
|
modalPersonal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatemodalPersonal(modal: boolean) {
|
||||||
|
modalPersonal.value = modal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ดูการเปลี่ยนแปลงของ pageSize ใน queryBody
|
||||||
|
* เมื่อ pageSize มีการเปลี่ยนแปลงให้โหลดข้อมูลหน้าแรก
|
||||||
|
*/
|
||||||
|
watch(
|
||||||
|
() => qureyBody.pageSize,
|
||||||
|
() => {
|
||||||
|
fetchListPerson(true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/** hook ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
|
||||||
|
onMounted(async () => {
|
||||||
|
await fatchOrg(); // ดึงข้อมูลโครงสร้าง
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="toptitle text-dark col-12 row items-center">
|
||||||
|
สิทธิ์แก้ไขข้อมูลทะเบียนประวัติตำแหน่ง/เงินเดือน
|
||||||
|
</div>
|
||||||
|
<q-card style="height: 100%">
|
||||||
|
<q-card-section :horizontal="$q.screen.gt.sm">
|
||||||
|
<q-card-section class="col-lg-3 col-md-4 col-xs-12 q-gutter-sm">
|
||||||
|
<div>
|
||||||
|
<q-input dense outlined v-model="filter" label="ค้นหา">
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="search" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white tree-container q-pa-xs">
|
||||||
|
<q-tree
|
||||||
|
class="q-pa-sm q-gutter-sm"
|
||||||
|
dense
|
||||||
|
:nodes="nodeTree"
|
||||||
|
node-key="orgRootName"
|
||||||
|
label-key="labelName"
|
||||||
|
:filter="filter?.trim()"
|
||||||
|
no-results-label="ไม่พบข้อมูลที่ค้นหา"
|
||||||
|
no-nodes-label="ไม่มีข้อมูล"
|
||||||
|
v-model:expanded="expanded"
|
||||||
|
>
|
||||||
|
<template v-slot:default-header="prop">
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
|
||||||
|
:active="orgId == prop.node.orgTreeId"
|
||||||
|
active-class="my-list-link text-primary text-weight-medium"
|
||||||
|
@click.stop="selectedOrg(prop.node.orgTreeId)"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
v-if="prop.node.isDeputy == true"
|
||||||
|
class="text-info text-weight-medium"
|
||||||
|
>
|
||||||
|
{{ prop.node.orgRootName }}
|
||||||
|
</div>
|
||||||
|
<div v-else class="text-weight-medium">
|
||||||
|
{{ prop.node.orgRootName }}
|
||||||
|
</div>
|
||||||
|
<div class="text-weight-light text-grey-8">
|
||||||
|
{{
|
||||||
|
prop.node.orgRootCode == null
|
||||||
|
? null
|
||||||
|
: prop.node.orgRootCode
|
||||||
|
}}
|
||||||
|
{{
|
||||||
|
prop.node.orgRootShortName == null
|
||||||
|
? null
|
||||||
|
: prop.node.orgRootShortName
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-tree>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-separator :vertical="$q.screen.gt.sm" />
|
||||||
|
<q-card-section class="col-lg-9 col-md-8 col-xs-12" style="height: 85vh">
|
||||||
|
<q-card bordered style="height: 100%; border: 1px solid #d6dee1">
|
||||||
|
<div class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md">
|
||||||
|
รายชื่อคนที่มีสิทธิ์แก้ไขข้อมูลทะเบียนประวัติตำแหน่ง/เงินเดือน
|
||||||
|
</div>
|
||||||
|
<div class="col-12"><q-separator /></div>
|
||||||
|
<q-card-section style="height: 92%" class="scroll">
|
||||||
|
<div class="row col-12 q-col-md">
|
||||||
|
<q-btn
|
||||||
|
v-if="orgId"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
color="primary"
|
||||||
|
icon="add"
|
||||||
|
round
|
||||||
|
@click="modalAdd = true"
|
||||||
|
>
|
||||||
|
<q-tooltip>เพิ่มข้อมูล</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
<div class="row q-mt-sm q-col-gutter-sm">
|
||||||
|
<div class="col-12 col-sm-3 col-md-4 col-lg-2">
|
||||||
|
<q-select
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
v-model="qureyBody.searchField"
|
||||||
|
:options="store.searchFieldOption"
|
||||||
|
label="เลือกที่ต้องการค้นหา"
|
||||||
|
emit-value
|
||||||
|
map-options
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-6 col-md-5 col-lg-3">
|
||||||
|
<q-input
|
||||||
|
v-model="qureyBody.searchKeyword"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
lazy-rules
|
||||||
|
label="คำค้น"
|
||||||
|
hide-bottom-space
|
||||||
|
>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-3 col-md-3 col-lg-2">
|
||||||
|
<q-btn
|
||||||
|
outline
|
||||||
|
color="primary"
|
||||||
|
icon="search"
|
||||||
|
label="ค้นหา"
|
||||||
|
class="full-width full-height"
|
||||||
|
@click="fetchListPerson(true)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<q-space v-if="$q.screen.gt.md" />
|
||||||
|
<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-mt-sm">
|
||||||
|
<d-table
|
||||||
|
:columns="columns"
|
||||||
|
:rows="rows"
|
||||||
|
:paging="true"
|
||||||
|
row-key="id"
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
dense
|
||||||
|
:rows-per-page-options="[10, 25, 50, 100]"
|
||||||
|
@update:pagination="updatePagination"
|
||||||
|
:visible-columns="visibleColumns"
|
||||||
|
>
|
||||||
|
<template v-slot:header="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-th auto-width />
|
||||||
|
<q-th
|
||||||
|
v-for="col in props.cols"
|
||||||
|
:key="col.name"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
<span class="text-weight-medium">{{ col.label }}</span>
|
||||||
|
</q-th>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body="props">
|
||||||
|
<q-tr :props="props">
|
||||||
|
<q-td auto-width>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
color="red"
|
||||||
|
icon="delete"
|
||||||
|
round
|
||||||
|
@click.pervent="onDeletePerson(props.row.id)"
|
||||||
|
>
|
||||||
|
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-td>
|
||||||
|
<q-td
|
||||||
|
v-for="col in props.cols"
|
||||||
|
:key="col.name"
|
||||||
|
:props="props"
|
||||||
|
>
|
||||||
|
<div v-if="col.name === 'fullName'">
|
||||||
|
{{ col.value ? col.value : "-" }}
|
||||||
|
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
color="info"
|
||||||
|
icon="info"
|
||||||
|
round
|
||||||
|
@click.pervent="
|
||||||
|
onOpenModalPersonal(props.row.profileId)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<q-tooltip>ดูข้อมูล</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="col.name == 'isEdit'">
|
||||||
|
<q-icon
|
||||||
|
v-if="props.isEdit"
|
||||||
|
name="mdi-check"
|
||||||
|
size="sm"
|
||||||
|
color="primary"
|
||||||
|
></q-icon>
|
||||||
|
<div v-else>-</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="col.name == 'isCheck'">
|
||||||
|
<q-icon
|
||||||
|
v-if="props.isCheck"
|
||||||
|
name="mdi-check"
|
||||||
|
size="sm"
|
||||||
|
color="primary"
|
||||||
|
></q-icon>
|
||||||
|
<div v-else>-</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
{{ col.value ? col.value : "-" }}
|
||||||
|
</div>
|
||||||
|
</q-td>
|
||||||
|
</q-tr>
|
||||||
|
</template>
|
||||||
|
<template v-slot:pagination="scope">
|
||||||
|
ทั้งหมด {{ total }} รายการ
|
||||||
|
<q-pagination
|
||||||
|
v-model="qureyBody.page"
|
||||||
|
active-color="primary"
|
||||||
|
color="dark"
|
||||||
|
:max="maxPage"
|
||||||
|
:max-pages="5"
|
||||||
|
size="sm"
|
||||||
|
boundary-links
|
||||||
|
direction-links
|
||||||
|
@update:model-value="fetchListPerson(false)"
|
||||||
|
>
|
||||||
|
</q-pagination>
|
||||||
|
</template>
|
||||||
|
</d-table>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
|
||||||
|
<DialogAddPerson
|
||||||
|
v-model:modal="modalAdd"
|
||||||
|
v-model:org-id="orgId"
|
||||||
|
:fetch-data="fetchListPerson"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<PopupPersonal
|
||||||
|
:modal="modalPersonal"
|
||||||
|
:id="personId"
|
||||||
|
@update:modal="updatemodalPersonal"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<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>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue