Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2024-01-26 09:57:24 +07:00
commit ab7513d8a2
9 changed files with 852 additions and 201 deletions

View file

@ -0,0 +1,29 @@
<script setup lang="ts">
import { ref } from "vue";
import TreeView from "@/modules/02_organizationalNew/components/mainTree.vue";
import TableView from "@/modules/02_organizationalNew/components/tableTree.vue";
const showData = ref<boolean>(false);
</script>
<template>
<div class="col-12">
<q-card bordered class="col-12 row caedNone">
<div class="col-xs-12 col-sm-3 row">
<div class="col-12 row no-wrap bg-grey-1">
<TreeView />
<div class="col-12 row">
<q-separator :vertical="!$q.screen.lt.md" />
</div>
</div>
</div>
<div class="col-xs-12 col-sm-9 q-pa-md">
<div class="col-12 row items-center">
<TableView v-model:showData="showData" />
</div>
</div>
</q-card>
</div>
</template>
<style scoped></style>

View file

@ -0,0 +1,336 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
/** importStore*/
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
const stroe = useOrganizational();
const $q = useQuasar();
const showData = ref<boolean>(false);
const listAdd = ref<any>([
{
label: "เพิ่มส่วนราชการ",
icon: "add",
val: "ADD",
color: "primary",
},
{
label: "แก้ไขหน่วยงาน",
icon: "edit",
val: "EDIT",
color: "info",
},
{
label: "ลบหน่วยงาน",
icon: "mdi-trash-can-outline",
val: "DEL",
color: "red",
},
{
label: "สำเนาหน่วยงาน",
icon: "content_copy",
val: "COPY",
color: "blue",
},
{
label: "ดูประวัติหน่วยงาน",
icon: "history",
val: "HISTORY",
color: "purple",
},
{
label: "จัดลำดับ",
icon: "filter_list",
val: "SORT",
color: "green-7",
},
{
label: "แก้ไขสถานะ",
icon: "checklist_rtl",
val: "STATUS",
color: "yellow-9",
},
]);
const filter = ref<string>("");
const nodes = ref<Array<any>>([]);
const lazy = ref(nodes);
const expanded = ref<Array<any>>([]);
const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา");
const noData = ref<string>("ไม่มีข้อมูล");
const selected = ref("");
const filterData = (node: any, filter: string) => {
// API
nodes.value = [
{
organizationName: "สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร",
organizationId: "3b86d275-8259-427c-8da7-12813fe482eb",
organizationLevel: 0,
lazy: true,
children: [
{
organizationName: "กองบริหารทั่วไป",
organizationId: "3486d275-8159-427c-8da7-12813fe482eb",
organizationLevel: 1,
},
{
organizationName: "กองสรรหาบุคคล",
organizationId: "3486d275-8259-427c-8da7-12813fe400eb",
organizationLevel: 1,
},
{
organizationName: "สถาบันพัฒนาทรัพยากรบุคคลกรุงเทพมหานคร",
organizationId: "3486d275-8259-437c-8da7-12813fe482eb",
organizationLevel: 1,
children: [
{
organizationName: "ฝ่ายบริหารงานทั่วไป",
organizationId: "3486d275-8259-427c-8da7-12813ff482eb",
organizationLevel: 2,
},
{
organizationName: "ส่วนส่งเสริมการพัฒนาทรัพยากรบุคคล",
organizationId: "3486d275-8259-427c-8da7-12833fe482eb",
organizationLevel: 2,
},
],
},
],
},
{
organizationName: "สำนักปลัดกรุงเทพมหานคร",
organizationId: "3b86d275-8259-427c-8da7-12813fe482ec",
organizationLevel: 0,
},
];
// expanded id
expanded.value = [
"3b86d275-8259-427c-8da7-12813fe482eb",
"3486d275-8259-437c-8da7-12813fe482eb",
];
return node.organizationName && node.organizationName.indexOf(filter) > -1;
};
const updateSelected = (target: any) => {
console.log("updateSelected===>", target);
};
const onLazyLoad = (details: { node: any; key: any; done: any; fail: any }) => {
// call fail() if any error occurs
// setTimeout(() => {
// simulate loading and setting an empty node
// if (details.key.indexOf("data empty") > -1) {
// details.done([]);
// return;
// }
if (details.node.organizationId == "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx01") {
details.done([
{
organizationName: "กองบริหารทั่วไป",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx11",
organizationLevel: 1,
},
{
organizationName: "กองสรรหาบุคคล",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx12",
organizationLevel: 1,
},
{
organizationName: "สถาบันพัฒนาทรัพยากรบุคคลกรุงเทพมหานคร",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx13",
organizationLevel: 1,
children: [
{
organizationName: "ฝ่ายบริหารงานทั่วไป",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx131",
organizationLevel: 2,
children: [
{
organizationName: "กลุ่มงานวิเคราะห์การพัฒนาทรัพยากรบุคคล",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx1311",
organizationLevel: 3,
},
],
},
{
organizationName: "ส่วนส่งเสริมการพัฒนาทรัพยากรบุคคล",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx14",
organizationLevel: 2,
},
],
},
]);
} else if (
details.node.organizationId == "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx02"
) {
details.done([
{
organizationName: "สำนักงานการเจ้าหน้าที่",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx21",
organizationLevel: 1,
},
]);
}
// }, 500);
};
const breakLoop = ref<boolean>(false);
async function edit(selected: string) {
console.log("edit node tree id: " + selected);
breakLoop.value = false;
// Usage
const targetNodeId = selected;
const replacementNode = {
organizationName: `ชื่อใหม่ ${selected}`,
organizationId: selected,
};
for (let index = 0; index < nodes.value.length; index++) {
const element = nodes.value[index];
searchAndReplace(element, targetNodeId, replacementNode);
console.log("index===>", index);
console.log("breakLoop===>", breakLoop.value);
if (breakLoop.value) break;
}
}
function searchAndReplace(
treeNode: any,
organizationId: any,
replacementObject: any
) {
if (treeNode.organizationId === organizationId) {
Object.assign(treeNode, replacementObject);
breakLoop.value = true;
} else if (treeNode.children) {
for (const child of treeNode.children) {
searchAndReplace(child, organizationId, replacementObject);
}
}
}
onMounted(async () => {
nodes.value = [
{
organizationName: "สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx01",
organizationLevel: 0,
lazy: true,
},
{
organizationName: "สำนักปลัดกรุงเทพมหานคร",
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx02",
organizationLevel: 0,
lazy: true,
},
// {
// organizationName: "data empty",
// lazy: true,
// },
// {
// organizationName: "Node is not expandable",
// expandable: false,
// children: [{ organizationName: "Some node" }],
// },
];
});
</script>
<template>
<div class="col-12 q-py-md q-px-lg">
<div class="q-gutter-md">
<div class="row q-col-gutter-sm">
<div class="col-2" v-if="stroe.typeOrganizational === 'draft'">
<q-btn dense flat round color="primary" icon="add">
<q-tooltip>เพ</q-tooltip>
</q-btn>
</div>
<div
:class="stroe.typeOrganizational === 'draft' ? 'col-10' : 'col-12'"
>
<q-input dense outlined v-model="filter" label="ค้นหา">
<template v-slot:append>
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
</template>
</q-input>
</div>
</div>
<div
class="bg-white"
style="
height: 60vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 10px;
"
>
<q-tree
class="q-pa-sm"
dense
default-expand-all
selected-color="blue-6"
:nodes="lazy"
node-key="organizationId"
label-key="organizationName"
:filter="filter"
:no-results-label="notFound"
:no-nodes-label="noData"
:filter-method="filterData"
v-model:expanded="expanded"
v-model:selected="selected"
@update:selected="updateSelected"
@lazy-load="onLazyLoad"
>
<template v-slot:default-header="prop">
{{ prop.node.organizationName }}
<q-btn
flat
icon="mdi-dots-vertical"
class="q-pa-none q-ml-xs"
v-if="stroe.typeOrganizational === 'draft'"
>
<q-menu>
<q-list
style="min-width: 100px"
v-for="(item, index) in listAdd"
:key="index"
>
<q-item
clickable
v-close-popup
@click="
item.val === 'EDIT'
? edit(prop.node.organizationId)
: null
"
>
<q-item-section avatar>
<q-icon :color="item.color" :name="item.icon" />
</q-item-section>
<q-item-section>{{ item.label }}</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</template>
</q-tree>
</div>
</div>
</div>
</template>
<style scoped></style>

View file

@ -0,0 +1,6 @@
<script setup lang="ts"></script>
<template>
<div>Structure View</div>
</template>
<style scoped></style>

View file

@ -0,0 +1,176 @@
<script setup lang="ts">
import { ref } from "vue";
/** importType*/
import type { QTableProps } from "quasar";
/** importStore*/
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
const showData = defineModel<boolean>("showData", { required: true });
const stroe = useOrganizational();
const filter = ref<string>("");
const document = ref<any>([
{
name: "บัญชี 1",
val: "1",
},
{
name: "บัญชี 2",
val: "2",
},
{
name: "บัญชี 3",
val: "3",
},
]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "noPosition",
align: "left",
label: "เลขที่ตำแหน่ง",
sortable: true,
field: "noPosition",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "namePosition",
align: "left",
label: "ชื่อตำแหน่ง",
field: "namePosition",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "typePosition",
align: "left",
label: "ประเภทตำแหน่ง",
sortable: true,
field: "typePosition",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "levelPositoion",
align: "left",
label: "ระดับตำแหน่ง",
sortable: true,
field: "levelPositoion",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "isStatus",
align: "left",
label: "มีคนครองหรือไม่",
sortable: true,
field: "isStatus",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const rows = ref<any>([]);
</script>
<template>
<!-- TOOLBAR -->
<div class="col-12">
<q-toolbar style="padding: 0">
<div v-if="stroe.typeOrganizational === 'draft'">
<q-btn flat round dense color="primary" icon="add">
<q-tooltip>เพ</q-tooltip></q-btn
>
<q-btn flat round dense color="blue" icon="filter_list">
<q-tooltip>นหา</q-tooltip>
</q-btn>
</div>
<q-btn flat round dense color="blue-10" icon="save_alt">
<q-menu>
<q-list
style="min-width: 100px"
v-for="(item, index) in document"
:key="index"
>
<q-item clickable v-close-popup>
<q-item-section>{{ item.name }}</q-item-section>
</q-item>
</q-list>
</q-menu>
<q-tooltip>ดาวนโหลด</q-tooltip>
</q-btn>
<q-space />
<div class="row q-gutter-md">
<div>
<q-checkbox
keep-color
v-model="showData"
label="แสดงตำแหน่งทั้งหมด"
color="primary"
/>
</div>
<div><q-input outlined dense v-model="filter" label="ค้นหา" /></div>
</div>
</q-toolbar>
</div>
<!-- TABLE -->
<div class="col-12">
<d-table
ref="table"
:columns="columns"
:rows="rows"
row-key="id"
flat
bordered
:paging="true"
dense
class="custom-header-table"
:rows-per-page-options="[10, 25, 50, 100]"
>
<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-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 == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
<!-- <template v-slot:pagination="scope">
<q-pagination
v-model="currentPage"
active-color="primary"
color="dark"
:max="Number(props.maxPage)"
size="sm"
boundary-links
direction-links
></q-pagination>
</template> -->
</d-table>
</div>
</template>
<style scoped></style>