API สร้างโครงสร้าง
This commit is contained in:
parent
cf69df74ac
commit
f236159522
5 changed files with 338 additions and 265 deletions
|
|
@ -1,6 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { ListMenu } from "@/modules/02_organizationalNew/interface/index/Main";
|
||||
|
||||
|
|
@ -10,35 +12,45 @@ import DialogStructureDetail from "@/modules/02_organizationalNew/components/Str
|
|||
|
||||
/** importStore*/
|
||||
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
const stroe = useOrganizational();
|
||||
const store = useOrganizational();
|
||||
const { dialogRemove, showLoader, hideLoader, messageError, success } =
|
||||
useCounterMixin();
|
||||
const $q = useQuasar();
|
||||
|
||||
const props = defineProps({
|
||||
fetchDataTree: {
|
||||
type: Function,
|
||||
require: true,
|
||||
},
|
||||
});
|
||||
|
||||
const listAdd = ref<ListMenu[]>([
|
||||
{
|
||||
label: "เพิ่มส่วนราชการ",
|
||||
label: "เพิ่ม",
|
||||
icon: "add",
|
||||
type: "ADD",
|
||||
color: "primary",
|
||||
},
|
||||
{
|
||||
label: "แก้ไขหน่วยงาน",
|
||||
label: "แก้ไข",
|
||||
icon: "edit",
|
||||
type: "EDIT",
|
||||
color: "info",
|
||||
},
|
||||
{
|
||||
label: "ลบหน่วยงาน",
|
||||
label: "ลบ",
|
||||
icon: "mdi-trash-can-outline",
|
||||
type: "DEL",
|
||||
color: "red",
|
||||
},
|
||||
{
|
||||
label: "สำเนาหน่วยงาน",
|
||||
icon: "content_copy",
|
||||
type: "COPY",
|
||||
color: "blue",
|
||||
},
|
||||
// {
|
||||
// label: "สำเนาหน่วยงาน",
|
||||
// icon: "content_copy",
|
||||
// type: "COPY",
|
||||
// color: "blue",
|
||||
// },
|
||||
{
|
||||
label: "ดูประวัติหน่วยงาน",
|
||||
icon: "history",
|
||||
|
|
@ -51,12 +63,12 @@ const listAdd = ref<ListMenu[]>([
|
|||
type: "SORT",
|
||||
color: "green-7",
|
||||
},
|
||||
{
|
||||
label: "แก้ไขสถานะ",
|
||||
icon: "rule",
|
||||
type: "STATUS",
|
||||
color: "yellow-9",
|
||||
},
|
||||
// {
|
||||
// label: "แก้ไขสถานะ",
|
||||
// icon: "rule",
|
||||
// type: "STATUS",
|
||||
// color: "yellow-9",
|
||||
// },
|
||||
{
|
||||
label: "ดูรายละเอียด",
|
||||
icon: "mdi-eye",
|
||||
|
|
@ -73,7 +85,7 @@ const expanded = ref<Array<any>>([]);
|
|||
const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา");
|
||||
const noData = ref<string>("ไม่มีข้อมูล");
|
||||
const selected = ref("");
|
||||
const orgLevel = ref<string>("");
|
||||
const orgLevel = ref<number>(0);
|
||||
|
||||
const filterData = (node: any, filter: string) => {
|
||||
// ให้ทาง API ค้นหาให้
|
||||
|
|
@ -134,60 +146,60 @@ const updateSelected = (target: any) => {
|
|||
};
|
||||
|
||||
const onLazyLoad = (details: { node: any; key: any; done: any; fail: any }) => {
|
||||
console.log(details.node.organizationName);
|
||||
|
||||
if (details.node.organizationId == "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx01") {
|
||||
details.done([
|
||||
{
|
||||
organizationName: "กองบริหารทั่วไป",
|
||||
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx11",
|
||||
organizationLevel: 1,
|
||||
organizationNo: "00011",
|
||||
},
|
||||
{
|
||||
organizationName: "กองสรรหาบุคคล",
|
||||
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx12",
|
||||
organizationLevel: 1,
|
||||
organizationNo: "00011",
|
||||
},
|
||||
{
|
||||
organizationName: "สถาบันพัฒนาทรัพยากรบุคคลกรุงเทพมหานคร",
|
||||
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx13",
|
||||
organizationLevel: 1,
|
||||
organizationNo: "00011",
|
||||
children: [
|
||||
{
|
||||
organizationName: "ฝ่ายบริหารงานทั่วไป",
|
||||
organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx131",
|
||||
organizationLevel: 2,
|
||||
organizationNo: "00011",
|
||||
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,
|
||||
},
|
||||
]);
|
||||
}
|
||||
// console.log(details.node);
|
||||
// details.node = nodes.value.filter((e:any) => e.orgRootId === )
|
||||
// if (details.node.orgRootId == "00000000-0000-0000-0000-000000000000") {
|
||||
// details.done([
|
||||
// {
|
||||
// organizationName: "กองบริหารทั่วไป",
|
||||
// organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx11",
|
||||
// organizationLevel: 1,
|
||||
// organizationNo: "00011",
|
||||
// },
|
||||
// {
|
||||
// organizationName: "กองสรรหาบุคคล",
|
||||
// organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx12",
|
||||
// organizationLevel: 1,
|
||||
// organizationNo: "00011",
|
||||
// },
|
||||
// {
|
||||
// organizationName: "สถาบันพัฒนาทรัพยากรบุคคลกรุงเทพมหานคร",
|
||||
// organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx13",
|
||||
// organizationLevel: 1,
|
||||
// organizationNo: "00011",
|
||||
// children: [
|
||||
// {
|
||||
// organizationName: "ฝ่ายบริหารงานทั่วไป",
|
||||
// organizationId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx131",
|
||||
// organizationLevel: 2,
|
||||
// organizationNo: "00011",
|
||||
// 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);
|
||||
};
|
||||
|
||||
|
|
@ -228,18 +240,47 @@ function searchAndReplace(
|
|||
}
|
||||
|
||||
const dialogAgency = ref<boolean>(false);
|
||||
function onClickAgency(level: string) {
|
||||
const actionType = ref<string>("");
|
||||
const dataNode = ref<any>();
|
||||
function onClickAgency(level: number, node: any) {
|
||||
dialogAgency.value = !dialogAgency.value;
|
||||
orgLevel.value = level;
|
||||
dataNode.value = node;
|
||||
actionType.value = "ADD";
|
||||
}
|
||||
|
||||
const dialogDetail = ref<boolean>(false);
|
||||
function onClickDetail() {
|
||||
console.log(dialogDetail.value);
|
||||
|
||||
dialogDetail.value = !dialogDetail.value;
|
||||
}
|
||||
|
||||
async function onClickEdit(node: any) {
|
||||
dialogAgency.value = !dialogAgency.value;
|
||||
actionType.value = "EDIT";
|
||||
orgLevel.value = node.orgLevel;
|
||||
dataNode.value = node;
|
||||
}
|
||||
|
||||
async function onClickDel(type: number, id: string) {
|
||||
const level = store.checkLevel(type);
|
||||
dialogRemove($q, async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.orgLevelByid(level.toLocaleLowerCase(), id))
|
||||
.then(() => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(async () => {
|
||||
await props.fetchDataTree?.();
|
||||
await hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => nodeTEST.value,
|
||||
() => {
|
||||
|
|
@ -281,21 +322,21 @@ onMounted(async () => {
|
|||
<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'">
|
||||
<div class="col-2" v-if="store.typeOrganizational === 'draft'">
|
||||
<q-btn
|
||||
dense
|
||||
flat
|
||||
round
|
||||
color="primary"
|
||||
icon="add"
|
||||
@click="onClickAgency('DEPARTMENT')"
|
||||
@click="onClickAgency(0, {})"
|
||||
>
|
||||
<q-tooltip>เพิ่มหน่วยงาน</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
|
||||
<div
|
||||
:class="stroe.typeOrganizational === 'draft' ? 'col-10' : 'col-12'"
|
||||
:class="store.typeOrganizational === 'draft' ? 'col-10' : 'col-12'"
|
||||
>
|
||||
<q-input dense outlined v-model="filter" label="ค้นหา">
|
||||
<template v-slot:append>
|
||||
|
|
@ -323,8 +364,8 @@ onMounted(async () => {
|
|||
default-expand-all
|
||||
selected-color="primary"
|
||||
:nodes="lazy"
|
||||
node-key="organizationId"
|
||||
label-key="organizationName"
|
||||
node-key="orgTreeId"
|
||||
label-key="orgTreeId"
|
||||
:filter="filter"
|
||||
:no-results-label="notFound"
|
||||
:no-nodes-label="noData"
|
||||
|
|
@ -332,23 +373,24 @@ onMounted(async () => {
|
|||
v-model:expanded="expanded"
|
||||
v-model:selected="selected"
|
||||
@update:selected="updateSelected"
|
||||
@lazy-load="onLazyLoad"
|
||||
>
|
||||
<template v-slot:default-header="prop">
|
||||
{{ prop.node.organizationName }}
|
||||
{{ prop.node.orgTreeName }}
|
||||
|
||||
<q-btn
|
||||
v-if="store.typeOrganizational === 'draft'"
|
||||
flat
|
||||
dense
|
||||
icon="mdi-dots-vertical"
|
||||
class="q-pa-none q-ml-xs"
|
||||
v-if="stroe.typeOrganizational === 'draft'"
|
||||
color="grey-13"
|
||||
>
|
||||
<q-menu>
|
||||
<q-list
|
||||
dense
|
||||
v-for="(item, index) in listAdd"
|
||||
v-for="(item, index) in prop.node.orgLevel === 4
|
||||
? listAdd.slice(1, 6)
|
||||
: listAdd"
|
||||
:key="index"
|
||||
style="min-width: 100px"
|
||||
>
|
||||
|
|
@ -357,18 +399,42 @@ onMounted(async () => {
|
|||
v-close-popup
|
||||
@click="
|
||||
item.type === 'EDIT'
|
||||
? edit(prop.node.organizationId)
|
||||
? onClickEdit(prop.node)
|
||||
: item.type === 'ADD'
|
||||
? onClickAgency('TEST')
|
||||
? onClickAgency(prop.node.orgLevel + 1, prop.node)
|
||||
: item.type === 'DETAIL'
|
||||
? onClickDetail()
|
||||
: item.type === 'DEL'
|
||||
? onClickDel(prop.node.orgLevel, prop.node.orgTreeId)
|
||||
: null
|
||||
"
|
||||
>
|
||||
<q-item-section avatar>
|
||||
<q-icon :color="item.color" :name="item.icon" />
|
||||
</q-item-section>
|
||||
<q-item-section>{{ item.label }}</q-item-section>
|
||||
<div v-if="prop.node.orgLevel === 0">
|
||||
<q-item-section
|
||||
v-if="
|
||||
item.type === 'ADD' ||
|
||||
item.type === 'EDIT' ||
|
||||
item.type === 'DEL'
|
||||
"
|
||||
>{{ item.label }}หน่วยงาน</q-item-section
|
||||
>
|
||||
<q-item-section v-else>{{ item.label }}</q-item-section>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<q-item-section
|
||||
v-if="
|
||||
item.type === 'ADD' ||
|
||||
item.type === 'EDIT' ||
|
||||
item.type === 'DEL'
|
||||
"
|
||||
>{{ item.label }}ส่วนราชการ</q-item-section
|
||||
>
|
||||
<q-item-section v-else>{{ item.label }}</q-item-section>
|
||||
</div>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
|
|
@ -376,11 +442,27 @@ onMounted(async () => {
|
|||
</template>
|
||||
|
||||
<template v-slot:default-body="prop">
|
||||
<div v-if="prop.node.organizationNo">
|
||||
<span class="text-grey-13">{{ prop.node.organizationNo }}</span>
|
||||
<div v-if="prop.node.orgCode">
|
||||
<span class="text-grey-13">{{ prop.node.orgCode }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</q-tree>
|
||||
|
||||
<!-- <div class="q-pa-md q-gutter-sm">
|
||||
<q-tree :nodes="nodes" node-key="orgRootName" default-expand-all>
|
||||
<template v-slot:default-header="prop">
|
||||
<div class="row">
|
||||
<div class="text-weight-bold text-primary">
|
||||
{{ prop.node.orgRootName }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-slot:default-body="prop">
|
||||
|
||||
</template>
|
||||
</q-tree>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -390,6 +472,9 @@ onMounted(async () => {
|
|||
:modal="dialogAgency"
|
||||
:close="onClickAgency"
|
||||
v-model:orgLevel="orgLevel"
|
||||
:fetchDataTree="props.fetchDataTree"
|
||||
v-model:actionType="actionType"
|
||||
:dataNode="dataNode"
|
||||
/>
|
||||
|
||||
<!-- รายละเอียดโครงสร้าง -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue