Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2024-01-31 11:02:51 +07:00
commit 69771682eb
11 changed files with 414 additions and 342 deletions

View file

@ -70,13 +70,15 @@ async function save() {
showLoader(); showLoader();
await http await http
.put(config.API.insigniaSort(id.value), { id: dataPost }) .put(config.API.insigniaSort(id.value), { id: dataPost })
.then(() => {
store.row = rows.value;
})
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
}) })
.finally(() => { .finally(() => {
hideLoader(); hideLoader();
store.row = rows.value; // props.fetchData(id.value);
props.fetchData(id.value);
}); });
} }

View file

@ -34,6 +34,10 @@ const props = defineProps({
type: Object, type: Object,
require: true, require: true,
}, },
edit: {
type: Function,
require: true,
},
}); });
const $q = useQuasar(); const $q = useQuasar();
@ -56,9 +60,9 @@ const orgLevelOption = ref<DataOption[]>([]);
const orgNameRef = ref<Object | null>(null); const orgNameRef = ref<Object | null>(null);
const orgShortNameRef = ref<Object | null>(null); const orgShortNameRef = ref<Object | null>(null);
const orgCodeRef = ref<Object | null>(null); const orgCodeRef = ref<Object | null>(null);
const orgPhoneExRef = ref<Object | null>(null); // const orgPhoneExRef = ref<Object | null>(null);
const orgPhoneInRef = ref<Object | null>(null); // const orgPhoneInRef = ref<Object | null>(null);
const orgFaxRef = ref<Object | null>(null); // const orgFaxRef = ref<Object | null>(null);
const orgLevelRef = ref<Object | null>(null); const orgLevelRef = ref<Object | null>(null);
const formData = reactive<FormDataAgency>({ const formData = reactive<FormDataAgency>({
@ -76,9 +80,9 @@ const objectComplaintsRef: FormAgencyRef = {
orgName: orgNameRef, orgName: orgNameRef,
orgShortName: orgShortNameRef, orgShortName: orgShortNameRef,
orgCode: orgCodeRef, orgCode: orgCodeRef,
orgPhoneEx: orgPhoneExRef, // orgPhoneEx: orgPhoneExRef,
orgPhoneIn: orgPhoneInRef, // orgPhoneIn: orgPhoneInRef,
orgFax: orgFaxRef, // orgFax: orgFaxRef,
orgLevel: orgLevelRef, orgLevel: orgLevelRef,
}; };
@ -134,8 +138,6 @@ function onSubmit() {
["org" + type + "Rank"]: formData.orgLevel, ["org" + type + "Rank"]: formData.orgLevel,
[nameId]: rootId, [nameId]: rootId,
}; };
console.log(body);
if (actionType.value === "ADD") { if (actionType.value === "ADD") {
await http await http
.post(config.API.createOrgLevel(type.toLocaleLowerCase()), body) .post(config.API.createOrgLevel(type.toLocaleLowerCase()), body)
@ -164,6 +166,7 @@ function onSubmit() {
) )
.then((res) => { .then((res) => {
console.log(res); console.log(res);
props.edit?.(props.dataNode?.orgTreeId, type, body);
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
}) })
.catch((err) => { .catch((err) => {
@ -171,7 +174,7 @@ function onSubmit() {
messageError($q, err); messageError($q, err);
}) })
.finally(async () => { .finally(async () => {
await props.fetchDataTree?.(); // await props.fetchDataTree?.();
await closeClear(); await closeClear();
await hideLoader(); await hideLoader();
})); }));
@ -211,7 +214,10 @@ watch(
formData.orgPhoneIn = props.dataNode.orgTreePhoneIn; formData.orgPhoneIn = props.dataNode.orgTreePhoneIn;
formData.orgFax = props.dataNode.orgTreeFax; formData.orgFax = props.dataNode.orgTreeFax;
formData.orgLevel = props.dataNode.orgTreeRank; formData.orgLevel = props.dataNode.orgTreeRank;
orgLevelOption.value = orgLevelOptionMain.value.slice(1, 4); orgLevelOption.value =
props.dataNode.orgTreeRank === "DEPARTMENT"
? orgLevelOptionMain.value
: orgLevelOptionMain.value.slice(1, 4);
} }
} }
} }
@ -221,25 +227,18 @@ watch(
const tittleName = computed(() => { const tittleName = computed(() => {
let name = ""; let name = "";
if (actionType.value === "ADD") { if (actionType.value === "ADD") {
if (level.value === 1) { name = level.value === 0 ? "เพิ่มหน่วยงาน" : "เพิ่มส่วนราชการ";
name = "เพิ่มหน่วยงาน";
} else {
name = "เพิ่มส่วนราชการ";
}
} else { } else {
if (level.value === 0) { name = level.value === 0 ? "แก้ไขหน่วยงาน" : "แก้ไขเพิ่มส่วนราชการ";
name = "แก้ไขหน่วยงาน";
} else {
name = "แก้ไขเพิ่มส่วนราชการ";
}
} }
return name; return name;
}); });
</script> </script>
<template> <template>
<template> <template>
<q-dialog v-model="props.modal" persistent> <q-dialog v-model="props.modal" persistent>
<q-card style="min-width: 50vw"> <q-card style="min-width: 60vw">
<form @submit.prevent="validateForm"> <form @submit.prevent="validateForm">
<DialogHeader :tittle="tittleName" :close="closeClear" /> <DialogHeader :tittle="tittleName" :close="closeClear" />
<q-separator /> <q-separator />
@ -252,9 +251,17 @@ const tittleName = computed(() => {
dense dense
outlined outlined
for="#ocName" for="#ocName"
label="ชื่อหน่วยงาน" :label="level == 0 ? 'ชื่อหน่วยงาน' : 'ชื่อส่วนราชการ'"
hide-bottom-space hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกชื่อหน่วยงาน'}`]" :rules="[
(val) =>
!!val ||
`${
level == 0
? 'กรุณากรอกชื่อหน่วยงาน'
: 'กรุณากรอกชื่อส่วนราชการ'
}`,
]"
/> />
</div> </div>
<div class="col-2"> <div class="col-2">
@ -276,9 +283,17 @@ const tittleName = computed(() => {
dense dense
outlined outlined
for="#ocNo" for="#ocNo"
label="รหัสหน่วยงาน" :label="level == 0 ? 'รหัสหน่วยงาน' : 'รหัสส่วนราชการ'"
hide-bottom-space hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกรหัสหน่วยงาน'}`]" :rules="[
(val) =>
!!val ||
`${
level == 0
? 'กรุณากรอกรหัสหน่วยงาน'
: 'กรุณากรอกรหัสส่วนราชการ'
}`,
]"
/> />
</div> </div>
<div class="col-4"> <div class="col-4">
@ -295,8 +310,18 @@ const tittleName = computed(() => {
map-options map-options
v-model="formData.orgLevel" v-model="formData.orgLevel"
:options="orgLevelOption" :options="orgLevelOption"
label="ระดับของหน่วยงาน" :label="
:rules="[(val) => !!val || `${'กรุณาเลือกระดับของหน่วยงาน'}`]" level == 0 ? 'ระดับของหน่วยงาน' : 'ระดับของส่วนราชการ'
"
:rules="[
(val) =>
!!val ||
`${
level == 0
? 'กรุณาเลือกระดับของหน่วยงาน'
: 'กรุณาเลือกระดับของส่วนราชการ'
}`,
]"
lazy-rules lazy-rules
/> />
</div> </div>
@ -309,11 +334,6 @@ const tittleName = computed(() => {
for="#telOut" for="#telOut"
label="หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก" label="หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก"
hide-bottom-space hide-bottom-space
:rules="[
(val) =>
!!val ||
`${'กรุณากรอกหมายเลขโทรศัพท์ที่ติดต่อจากภายนอก'}`,
]"
/> />
</div> </div>
<div class="col-4"> <div class="col-4">
@ -325,10 +345,6 @@ const tittleName = computed(() => {
for="#telIn" for="#telIn"
label="หมายเลขโทรศัพท์ที่ติดต่อจากภายใน" label="หมายเลขโทรศัพท์ที่ติดต่อจากภายใน"
hide-bottom-space hide-bottom-space
:rules="[
(val) =>
!!val || `${'กรุณากรอกหมายเลขโทรศัพท์ที่ติดต่อจากภายใน'}`,
]"
/> />
</div> </div>
<div class="col-4"> <div class="col-4">
@ -340,7 +356,6 @@ const tittleName = computed(() => {
for="#tel" for="#tel"
label="หมายเลขโทรสาร" label="หมายเลขโทรสาร"
hide-bottom-space hide-bottom-space
:rules="[(val) => !!val || `${'กรุณากรอกหมายเลขโทรสาร'}`]"
/> />
</div> </div>
</div> </div>

View file

@ -42,12 +42,6 @@ const listMenu = ref<ListMenu[]>([
type: "copy", type: "copy",
color: "blue-6", color: "blue-6",
}, },
{
label: "แก้ไข",
icon: "edit",
type: "edit",
color: "primary",
},
{ {
label: "ลบ", label: "ลบ",
icon: "delete", icon: "delete",
@ -308,16 +302,17 @@ watch(
); );
function addPosition(data: RowDetailPositions) { function addPosition(data: RowDetailPositions) {
const isIdExist = rows.value.some(item => item.positionId === data.positionId); const isIdExist = rows.value.some(
(item) => item.positionId === data.positionId
);
if (!isIdExist) { if (!isIdExist) {
rows.value = [data, ...rows.value]; rows.value = [data, ...rows.value];
} }
} }
function deleteData(id: string) {
function deleteData(id:string){ const dataRow = rows.value;
const dataRow = rows.value
const updatedRows = dataRow.filter((item: any) => item.positionId !== id); const updatedRows = dataRow.filter((item: any) => item.positionId !== id);
rows.value = updatedRows; rows.value = updatedRows;
} }
@ -326,7 +321,7 @@ function deleteData(id:string){
<template> <template>
<q-dialog v-model="props.modal" persistent> <q-dialog v-model="props.modal" persistent>
<q-card style="min-width: 96vw"> <q-card style="min-width: 96vw">
<DialogHeader :tittle="`เพิ่มตำแหน่ง`" :close="props.close" /> <DialogHeader tittle="เพิ่มอัตรากำลัง" :close="props.close" />
<q-separator /> <q-separator />
<q-card-section class="q-pa-sm"> <q-card-section class="q-pa-sm">
@ -341,7 +336,7 @@ function deleteData(id:string){
<div <div
class="col-12 text-weight-medium bg-grey-1 q-py-xs q-px-md" class="col-12 text-weight-medium bg-grey-1 q-py-xs q-px-md"
> >
เลขทตำแหน อมลอตรากำล
</div> </div>
<div class="col-12"><q-separator /></div> <div class="col-12"><q-separator /></div>
<div class="row q-col-gutter-sm col-12 q-pa-sm"> <div class="row q-col-gutter-sm col-12 q-pa-sm">
@ -352,7 +347,7 @@ function deleteData(id:string){
outlined outlined
readonly readonly
for="#shortName" for="#shortName"
label="ชื่อย่อหน่วยงาน" label="อักษรย่อ"
/> />
</div> </div>
<div class="col-3"> <div class="col-3">
@ -443,8 +438,8 @@ function deleteData(id:string){
color="red" color="red"
@click="deleteData(props.row.positionId)" @click="deleteData(props.row.positionId)"
> >
<q-tooltip>ลบขอม</q-tooltip> <q-tooltip>ลบขอม</q-tooltip>
</q-btn> </q-btn>
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>

View file

@ -31,15 +31,28 @@ const formData = reactive<any>({
}); });
async function fetchDetailTree(id: string, type: string) { async function fetchDetailTree(id: string, type: string) {
showLoader();
await http await http
.get(config.API.orgLevelByid(type.toLocaleLowerCase(), id)) .get(config.API.orgLevelByid(type.toLocaleLowerCase(), id))
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
formData.orgName = data[`org${type}Name`]; const range = data[`org${type}Rank`];
formData.agencyName = data[`org${type}Name`]; formData.orgName =
formData.orgType = data[`org${type}Name`]; range == "DEPARTMENT"
formData.orgLevel = data[`org${type}Rank`]; ? data[`org${type}Name`] + ` (${data[`org${type}ShortName`]})`
formData.status = data[`org${type}Name`]; : "-";
formData.agencyName =
range != "DEPARTMENT"
? data[`org${type}Name`] + ` (${data[`org${type}ShortName`]})`
: "-";
formData.orgType = range != "DEPARTMENT" ? "ส่วนราชการ" : "หน่วยงาน";
formData.orgLevel = store.convertType(range);
formData.status =
store.typeOrganizational === "current"
? "ปกติ"
: store.typeOrganizational === "draft"
? "แบบร่าง"
: "ยุบเลิก";
formData.orgPhoneEx = data[`org${type}PhoneEx`]; formData.orgPhoneEx = data[`org${type}PhoneEx`];
formData.orgPhoneIn = data[`org${type}PhoneIn`]; formData.orgPhoneIn = data[`org${type}PhoneIn`];
formData.orgFax = data[`org${type}Fax`]; formData.orgFax = data[`org${type}Fax`];
@ -59,10 +72,10 @@ function close() {
watch( watch(
() => modal.value, () => modal.value,
() => { async () => {
if (modal.value == true) { if (modal.value == true) {
const type = store.checkLevel(orgLevel.value); const type = await store.checkLevel(orgLevel.value);
fetchDetailTree(treeId.value, type); await fetchDetailTree(treeId.value, type);
} }
} }
); );
@ -76,88 +89,60 @@ watch(
<q-card-section> <q-card-section>
<div class="q-px-md"> <div class="q-px-md">
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold"> <div class="col-4 text-bold">หนวยงาน</div>
<div>
<p>หนวยงาน</p>
</div>
</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">
<p>{{ formData.orgName }} ({{ formData.orgShortName }})</p> <p>{{ formData.orgName }}</p>
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold"> <div class="col-4 text-bold">วนราชการ</div>
<div>
<p>วนราชการ</p>
</div>
</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">
<p>{{ formData.agencyName }}</p> <p>{{ formData.agencyName }}</p>
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold"> <div class="col-4 text-bold">ประเภท</div>
<div>
<p>ประเภท</p>
</div>
</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">
<p>{{ formData.orgType }}</p> <p>{{ formData.orgType }}</p>
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold"> <div class="col-4 text-bold">ระด</div>
<div>
<p>ระด</p>
</div>
</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">
<p>{{ formData.orgLevel }}</p> <p>{{ formData.orgLevel }}</p>
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold"> <div class="col-4 text-bold">สถานะ</div>
<div>
<p>สถานะ</p>
</div>
</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">
<p>{{ formData.status }}</p> <p>{{ formData.status }}</p>
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold">
<div>
<p class="q-ma-none">เบอรโทร</p>
</div>
</div>
<div class="col-8 text-grey-8">
<p class="q-ma-none">
{{
formData.orgPhoneEx ? `ภายนอก ${formData.orgPhoneEx}` : ""
}}
</p>
</div>
</div>
<div class="row q-col-gutter-sm"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="offset-4 col-8 text-grey-8"> <div class="col-4 text-bold">เบอรโทร</div>
<p> <div class="col-8 text-grey-8">
{{ <p v-if="formData.orgPhoneEx != ''">
formData.orgPhoneIn ? `ภายใน ${formData.orgPhoneIn}` : "" {{ `ภายนอก ${formData.orgPhoneEx}` }}
}} </p>
<p v-if="formData.orgPhoneIn != ''">
{{ `ภายใน ${formData.orgPhoneIn}` }}
</p>
<p
v-show="
formData.orgPhoneEx == '' && formData.orgPhoneIn == ''
"
>
-
</p> </p>
</div> </div>
</div> </div>
<div class="row q-col-gutter-sm q-mb-xs"> <div class="row q-col-gutter-sm q-mb-xs">
<div class="col-4 text-bold"> <div class="col-4 text-bold">Fax</div>
<div>
<p>Fax</p>
</div>
</div>
<div class="col-8 text-grey-8"> <div class="col-8 text-grey-8">
<p>{{ formData.orgFax }}</p> <p v-if="formData.orgFax != ''">{{ formData.orgFax }}</p>
<p v-else>-</p>
</div> </div>
</div> </div>
</div> </div>

View file

@ -5,7 +5,7 @@ import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
/** importType*/ /** importType*/
import type { DataActive } from "@/modules/02_organizationalNew/interface/response/organizational"; import type { OrgTree } from "@/modules/02_organizationalNew/interface/response/organizational";
import TreeView from "@/modules/02_organizationalNew/components/mainTree.vue"; import TreeView from "@/modules/02_organizationalNew/components/mainTree.vue";
import TableView from "@/modules/02_organizationalNew/components/tableTree.vue"; import TableView from "@/modules/02_organizationalNew/components/tableTree.vue";
@ -18,39 +18,51 @@ const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin(); const { showLoader, hideLoader, messageError } = useCounterMixin();
const showData = ref<boolean>(false); const showData = ref<boolean>(false);
const nodeTree = ref<any>(); const nodeTree = ref<OrgTree[]>();
const historyId = defineModel<string>("historyId", { required: true });
const count = defineModel<number>("count", { required: true });
// defineProps<{ dataActive: DataActive }>(); // defineProps<{ dataActive: DataActive }>();
async function fetchDataTree() { async function fetchDataTree(id: string) {
showLoader(); showLoader();
const id = // const id =
store.typeOrganizational === "current" ? store.activeId : store.draftId; // store.typeOrganizational === "current" ? store.activeId : store.draftId;
id && // id &&
(await http await http
.get(config.API.orgByid(id.toString())) .get(config.API.orgByid(id.toString()))
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
nodeTree.value = data; nodeTree.value = data;
console.log(res); })
}) .catch((err) => {
.catch((err) => { messageError($q, err);
messageError($q, err); })
}) .finally(() => {
.finally(() => { hideLoader();
hideLoader(); });
}));
// console.log(nodeTree.value); // console.log(nodeTree.value);
} }
onMounted(async () => { onMounted(async () => {
await fetchDataTree(); const id =
store.typeOrganizational === "current" ? store.activeId : store.draftId;
id && (await fetchDataTree(id));
}); });
watch(
() => count.value,
() => {
fetchDataTree(historyId.value);
}
);
watch( watch(
() => store.typeOrganizational, () => store.typeOrganizational,
() => { () => {
fetchDataTree(); const id =
store.typeOrganizational === "current" ? store.activeId : store.draftId;
id && store.typeOrganizational !== "old" && fetchDataTree(id);
} }
); );
</script> </script>

View file

@ -5,6 +5,7 @@ import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import type { ListMenu } from "@/modules/02_organizationalNew/interface/index/Main"; import type { ListMenu } from "@/modules/02_organizationalNew/interface/index/Main";
import type { OrgTree } from "@/modules/02_organizationalNew/interface/response/organizational";
/** importComponents*/ /** importComponents*/
import DialogAgency from "@/modules/02_organizationalNew/components/DialogFormAgency.vue"; import DialogAgency from "@/modules/02_organizationalNew/components/DialogFormAgency.vue";
@ -52,7 +53,7 @@ const listAdd = ref<ListMenu[]>([
// color: "blue", // color: "blue",
// }, // },
{ {
label: "ดูประวัติหน่วยงาน", label: "ประวัติ",
icon: "history", icon: "history",
type: "HISTORY", type: "HISTORY",
color: "purple", color: "purple",
@ -77,9 +78,9 @@ const listAdd = ref<ListMenu[]>([
}, },
]); ]);
const nodeTEST = defineModel<any>("nodeTree", { required: true }); const nodeTEST = defineModel<OrgTree[]>("nodeTree", { default: [] });
const filter = ref<string>(""); const filter = ref<string>("");
const nodes = ref<Array<any>>([]); const nodes = ref<Array<OrgTree>>([]);
const lazy = ref(nodes); const lazy = ref(nodes);
const expanded = ref<Array<any>>([]); const expanded = ref<Array<any>>([]);
const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา"); const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา");
@ -87,137 +88,42 @@ const noData = ref<string>("ไม่มีข้อมูล");
const selected = ref(""); const selected = ref("");
const orgLevel = ref<number>(0); const orgLevel = ref<number>(0);
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) => { const updateSelected = (target: any) => {
console.log("updateSelected===>", target); console.log("updateSelected===>", target);
}; };
const onLazyLoad = (details: { node: any; key: any; done: any; fail: any }) => {
// 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);
};
const breakLoop = ref<boolean>(false); const breakLoop = ref<boolean>(false);
async function edit(selected: string) { async function edit(id: string, type: string, data: any) {
console.log("edit node tree id: " + selected); const data2 = {
orgName: data[`org${type}Name`],
orgShortName: data[`org${type}ShortName`],
orgCode: data[`org${type}Code`],
orgPhoneEx: data[`org${type}PhoneEx`],
orgPhoneIn: data[`org${type}PhoneIn`],
orgFax: data[`org${type}Fax`],
orgLevel: data[`org${type}Rank`],
};
breakLoop.value = false; breakLoop.value = false;
// Usage // Usage
const targetNodeId = selected; const targetNodeId = id;
const replacementNode = { const replacementNode = {
organizationName: `ชื่อใหม่ ${selected}`, orgTreeName: data2.orgName,
organizationId: selected, orgTreeShortName: data2.orgShortName,
orgCode: data2.orgCode,
orgTreePhoneEx: data2.orgPhoneEx,
orgTreePhoneIn: data2.orgPhoneIn,
orgTreeFax: data2.orgFax,
orgTreeRank: data2.orgLevel,
}; };
for (let index = 0; index < nodes.value.length; index++) { for (let index = 0; index < nodes.value.length; index++) {
const element = nodes.value[index]; const element = nodes.value[index];
searchAndReplace(element, targetNodeId, replacementNode); if (type !== "edit") {
searchAndReplace(element, targetNodeId, replacementNode);
} else deleteNode(element, targetNodeId);
console.log("index===>", index); console.log("index===>", index);
console.log("breakLoop===>", breakLoop.value); console.log("breakLoop===>", breakLoop.value);
if (breakLoop.value) break; if (breakLoop.value) break;
@ -226,10 +132,10 @@ async function edit(selected: string) {
function searchAndReplace( function searchAndReplace(
treeNode: any, treeNode: any,
organizationId: any, organizationId: string,
replacementObject: any replacementObject: any
) { ) {
if (treeNode.organizationId === organizationId) { if (treeNode.orgTreeId === organizationId) {
Object.assign(treeNode, replacementObject); Object.assign(treeNode, replacementObject);
breakLoop.value = true; breakLoop.value = true;
} else if (treeNode.children) { } else if (treeNode.children) {
@ -239,12 +145,32 @@ function searchAndReplace(
} }
} }
function deleteNode(treeNode: any, organizationId: any): boolean {
// console.log("tttttttttttttt", treeNode.orgTreeId, organizationId);
if (treeNode.orgTreeId === organizationId) {
treeNode.children = [];
breakLoop.value = true;
} else if (treeNode.children) {
for (let i = 0; i < treeNode.children.length; i++) {
const child = treeNode.children[i];
if (deleteNode(child, organizationId)) {
treeNode.children.splice(i, 1);
i--; // i
}
}
}
return false;
}
const dialogAgency = ref<boolean>(false); const dialogAgency = ref<boolean>(false);
const actionType = ref<string>(""); const actionType = ref<string>("");
const dataNode = ref<any>(); const dataNode = ref<any>();
const treeId = ref<string>(""); const treeId = ref<string>("");
function onClickAgency(level: number, node: any) { function onClickAgency(level: number, node: OrgTree | {}) {
dialogAgency.value = !dialogAgency.value; dialogAgency.value = !dialogAgency.value;
orgLevel.value = level; orgLevel.value = level;
dataNode.value = node; dataNode.value = node;
@ -253,12 +179,13 @@ function onClickAgency(level: number, node: any) {
const dialogDetail = ref<boolean>(false); const dialogDetail = ref<boolean>(false);
function onClickDetail(id: string, level: number) { function onClickDetail(id: string, level: number) {
showLoader();
treeId.value = id; treeId.value = id;
dialogDetail.value = !dialogDetail.value; dialogDetail.value = !dialogDetail.value;
orgLevel.value = level; orgLevel.value = level;
} }
async function onClickEdit(node: any) { async function onClickEdit(node: OrgTree) {
dialogAgency.value = !dialogAgency.value; dialogAgency.value = !dialogAgency.value;
actionType.value = "EDIT"; actionType.value = "EDIT";
orgLevel.value = node.orgLevel; orgLevel.value = node.orgLevel;
@ -267,12 +194,15 @@ async function onClickEdit(node: any) {
async function onClickDel(type: number, id: string) { async function onClickDel(type: number, id: string) {
const level = store.checkLevel(type); const level = store.checkLevel(type);
dialogRemove($q, async () => { dialogRemove($q, async () => {
// edit(id, "edit", {});
showLoader(); showLoader();
await http await http
.delete(config.API.orgLevelByid(level.toLocaleLowerCase(), id)) .delete(config.API.orgLevelByid(level.toLocaleLowerCase(), id))
.then(() => { .then(() => {
success($q, "ลบข้อมูลสำเร็จ"); success($q, "ลบข้อมูลสำเร็จ");
// edit(id, "edit", {});
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -291,34 +221,7 @@ watch(
} }
); );
onMounted(async () => { onMounted(async () => {});
// setTimeout(() => {
// console.log(nodessd.value);
// }, 200);
// 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> </script>
<template> <template>
@ -368,17 +271,33 @@ onMounted(async () => {
selected-color="primary" selected-color="primary"
:nodes="lazy" :nodes="lazy"
node-key="orgTreeId" node-key="orgTreeId"
label-key="orgTreeId" label-key="orgTreeName"
:filter="filter" :filter="filter"
:no-results-label="notFound" :no-results-label="notFound"
:no-nodes-label="noData" :no-nodes-label="noData"
:filter-method="filterData"
v-model:expanded="expanded" v-model:expanded="expanded"
v-model:selected="selected" v-model:selected="selected"
@update:selected="updateSelected" @update:selected="updateSelected"
> >
<template v-slot:default-header="prop"> <template v-slot:default-header="prop">
{{ prop.node.orgTreeName }} <!-- {{ prop.node.orgTreeName }} -->
<div class="row items-center q-px-xs q-pt-xs q-gutter-sm">
<!--แสดงชอแผนก มพวหนา คลกแลวกาง/ Tree-->
<div>
<div class="text-weight-medium">
{{ prop.node.orgTreeName }}
</div>
<div class="text-weight-light">
{{ prop.node.orgCode == null ? null : prop.node.orgCode }}
{{
prop.node.orgTreeShortName == null
? null
: prop.node.orgTreeShortName
}}
</div>
</div>
</div>
<q-btn <q-btn
v-if="store.typeOrganizational === 'draft'" v-if="store.typeOrganizational === 'draft'"
@ -418,12 +337,15 @@ onMounted(async () => {
<div v-if="prop.node.orgLevel === 0"> <div v-if="prop.node.orgLevel === 0">
<q-item-section <q-item-section
v-if=" v-if="
item.type === 'ADD' ||
item.type === 'EDIT' || item.type === 'EDIT' ||
item.type === 'DEL' item.type === 'DEL' ||
item.type === 'HISTORY'
" "
>{{ item.label }}หนวยงาน</q-item-section >{{ item.label }}หนวยงาน</q-item-section
> >
<q-item-section v-else-if="item.type === 'ADD'"
>{{ item.label }}วนราชการ</q-item-section
>
<q-item-section v-else>{{ item.label }}</q-item-section> <q-item-section v-else>{{ item.label }}</q-item-section>
</div> </div>
@ -432,7 +354,8 @@ onMounted(async () => {
v-if=" v-if="
item.type === 'ADD' || item.type === 'ADD' ||
item.type === 'EDIT' || item.type === 'EDIT' ||
item.type === 'DEL' item.type === 'DEL' ||
item.type === 'HISTORY'
" "
>{{ item.label }}วนราชการ</q-item-section >{{ item.label }}วนราชการ</q-item-section
> >
@ -442,13 +365,54 @@ onMounted(async () => {
</q-list> </q-list>
</q-menu> </q-menu>
</q-btn> </q-btn>
<q-btn
v-else
flat
dense
icon="mdi-dots-vertical"
class="q-pa-none q-ml-xs"
color="grey-13"
>
<q-menu>
<q-list
dense
v-for="(item, index) in listAdd.slice(5, 6)"
:key="index"
style="min-width: 100px"
>
<q-item
clickable
v-close-popup
@click="
item.type === 'EDIT'
? onClickEdit(prop.node)
: item.type === 'ADD'
? onClickAgency(prop.node.orgLevel + 1, prop.node)
: item.type === 'DETAIL'
? onClickDetail(prop.node.orgTreeId, prop.node.orgLevel)
: 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>
</q-item>
</q-list>
</q-menu>
</q-btn>
</template> </template>
<template v-slot:default-body="prop"> <!-- <template v-slot:default-body="prop">
<div v-if="prop.node.orgCode"> <div v-if="prop.node.orgCode">
<span class="text-grey-13">{{ prop.node.orgCode }}</span> <span class="text-grey-13"
>{{ prop.node.orgCode }} {{ prop.node.orgTreeShortName }}</span
>
</div> </div>
</template> </template> -->
</q-tree> </q-tree>
<!-- <div class="q-pa-md q-gutter-sm"> <!-- <div class="q-pa-md q-gutter-sm">
@ -478,6 +442,7 @@ onMounted(async () => {
:fetchDataTree="props.fetchDataTree" :fetchDataTree="props.fetchDataTree"
v-model:actionType="actionType" v-model:actionType="actionType"
:dataNode="dataNode" :dataNode="dataNode"
:edit="edit"
/> />
<!-- รายละเอยดโครงสราง --> <!-- รายละเอยดโครงสราง -->

View file

@ -42,9 +42,9 @@ interface FormAgencyRef {
orgName: object | null; orgName: object | null;
orgShortName: object | null; orgShortName: object | null;
orgCode: object | null; orgCode: object | null;
orgPhoneEx: object | null; // orgPhoneEx: object | null;
orgPhoneIn: object | null; // orgPhoneIn: object | null;
orgFax: object | null; // orgFax: object | null;
orgLevel: object | null; orgLevel: object | null;
[key: string]: any; [key: string]: any;
} }

View file

@ -5,4 +5,30 @@ interface DataActive {
draftName: string; draftName: string;
} }
export type { DataActive }; interface OrgTree {
orgTreeId: string;
orgRootId: string;
orgLevel: number;
orgTreeName: string;
orgTreeShortName: string;
orgTreeCode: string;
orgCode: string;
orgTreeRank: string;
orgTreeOrder: number | null;
orgRootCode: string;
orgTreePhoneEx: string;
orgTreePhoneIn: string;
orgTreeFax: string;
orgRevisionId: string;
children: OrgTree[];
}
interface OrgRevision {
orgRevisionCreatedAt: string | null;
orgRevisionId: string;
orgRevisionIsCurrent: boolean;
orgRevisionIsDraft: boolean;
orgRevisionName: string;
}
export type { DataActive, OrgTree, OrgRevision };

View file

@ -32,6 +32,21 @@ export const useOrganizational = defineStore("organizationalStore", () => {
} }
} }
function convertType(type: string) {
switch (type) {
case "DEPARTMENT":
return "ระดับสำนัก";
case "OFFICE":
return "ระดับกอง/สำนักงาน/ส่วนราชการ/โรงพยาบาล/เทียบเท่ากอง";
case "DIVISION":
return "ระดับส่วน/กลุ่มภารกิจ";
case "SECTION":
return "ระดับฝ่าย/กลุ่มงาน";
default:
return "-";
}
}
return { return {
typeOrganizational, typeOrganizational,
statusView, statusView,
@ -39,6 +54,7 @@ export const useOrganizational = defineStore("organizationalStore", () => {
// //
fetchDataActive, fetchDataActive,
checkLevel, checkLevel,
convertType,
draftId, draftId,
activeId, activeId,
}; };

View file

@ -6,6 +6,7 @@ import config from "@/app.config";
/** importType*/ /** importType*/
import type { DataOption } from "@/modules/02_organizationalNew/interface/index/Main"; import type { DataOption } from "@/modules/02_organizationalNew/interface/index/Main";
import type { OrgRevision } from "@/modules/02_organizationalNew/interface/response/organizational";
/** importComponents*/ /** importComponents*/
import ListView from "@/modules/02_organizationalNew/components/listView.vue"; import ListView from "@/modules/02_organizationalNew/components/listView.vue";
@ -13,7 +14,6 @@ import StructureView from "@/modules/02_organizationalNew/components/structureVi
import DialogFormNewStructure from "@/modules/02_organizationalNew/components/DialogNewStructure.vue"; import DialogFormNewStructure from "@/modules/02_organizationalNew/components/DialogNewStructure.vue";
import DialogDateTime from "@/modules/02_organizationalNew/components/DialogFormDateTime.vue"; import DialogDateTime from "@/modules/02_organizationalNew/components/DialogFormDateTime.vue";
import DialogHistory from "@/modules/02_organizationalNew/components/DialogHistory.vue"; import DialogHistory from "@/modules/02_organizationalNew/components/DialogHistory.vue";
import DialogStructureDetail from "@/modules/02_organizationalNew/components/StructureDetail.vue";
import DialogPositionDetail from "@/modules/02_organizationalNew/components/PositionDetail.vue"; import DialogPositionDetail from "@/modules/02_organizationalNew/components/PositionDetail.vue";
/** importStore*/ /** importStore*/
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational"; import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
@ -23,7 +23,6 @@ const $q = useQuasar();
const { showLoader, hideLoader, messageError } = useCounterMixin(); const { showLoader, hideLoader, messageError } = useCounterMixin();
const modalNewStructure = ref<boolean>(false); const modalNewStructure = ref<boolean>(false);
const modalStructureDetail = ref<boolean>(false);
const modalPositionDetail = ref<boolean>(false); const modalPositionDetail = ref<boolean>(false);
const stroe = useOrganizational(); const stroe = useOrganizational();
@ -82,6 +81,32 @@ async function fetchOrganizationActive() {
}); });
} }
const itemHistory = ref<DataOption[]>([]);
const historyId = ref<string>("");
async function fetchHistory() {
// showLoader();
await http
.get(config.API.organizationHistoryNew)
.then((res) => {
console.log(res);
const data = res.data.result;
const filterData = data.filter(
(e: OrgRevision) => !e.orgRevisionIsDraft && !e.orgRevisionIsCurrent
);
itemHistory.value = filterData.map((e: OrgRevision) => ({
id: e.orgRevisionId,
name: e.orgRevisionName,
}));
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
const typeStructure = ref<string>(""); const typeStructure = ref<string>("");
function ocClickAddStructure(type: string) { function ocClickAddStructure(type: string) {
modalNewStructure.value = !modalNewStructure.value; modalNewStructure.value = !modalNewStructure.value;
@ -94,12 +119,18 @@ function onClickDateTime() {
} }
const modalHistory = ref<boolean>(false); const modalHistory = ref<boolean>(false);
function onClickHistory() { const count = ref<number>(0);
modalHistory.value = !modalHistory.value; const labelHistory = ref<string>("ประวัติโครงสร้าง");
function onClickHistory(id: string, name: string) {
historyId.value = id;
labelHistory.value = name;
count.value++;
// modalHistory.value = !modalHistory.value;
} }
onMounted(async () => { onMounted(async () => {
await fetchOrganizationActive(); await fetchOrganizationActive();
await fetchHistory();
}); });
</script> </script>
<template> <template>
@ -164,19 +195,46 @@ onMounted(async () => {
:outline="stroe.typeOrganizational === 'current' ? false : true" :outline="stroe.typeOrganizational === 'current' ? false : true"
color="blue" color="blue"
label="ปัจจุบัน" label="ปัจจุบัน"
@click="stroe.typeOrganizational = 'current'" @click="
(stroe.typeOrganizational = 'current'),
(labelHistory = 'ประวัติโครงสร้าง')
"
:disable="ishasActive" :disable="ishasActive"
/> />
<q-btn <q-btn
:outline="stroe.typeOrganizational === 'draft' ? false : true" :outline="stroe.typeOrganizational === 'draft' ? false : true"
color="blue" color="blue"
label="แบบร่าง" label="แบบร่าง"
@click="stroe.typeOrganizational = 'draft'" @click="
(stroe.typeOrganizational = 'draft'),
(labelHistory = 'ประวัติโครงสร้าง')
"
:disable="ishasDraft" :disable="ishasDraft"
/> />
<q-btn-dropdown
color="blue"
:label="labelHistory"
@click="stroe.typeOrganizational = 'old'"
:outline="stroe.typeOrganizational === 'old' ? false : true"
>
<q-list>
<q-item
dense
clickable
v-close-popup
v-for="(item, index) in itemHistory"
:key="index"
@click="onClickHistory(item.id, item.name)"
>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</q-btn-group> </q-btn-group>
<q-btn-dropdown color="green" label="ปรับโครงสร้าง"> <q-btn-dropdown color="green" label="ประวัติโครงสร้าง">
<q-list> <q-list>
<q-item <q-item
dense dense
@ -193,15 +251,9 @@ onMounted(async () => {
</q-list> </q-list>
</q-btn-dropdown> </q-btn-dropdown>
<q-btn <!-- <q-btn flat round color="primary" icon="history">
flat
round
color="primary"
icon="history"
@click="onClickHistory"
>
<q-tooltip>ประวโครงสราง</q-tooltip> <q-tooltip>ประวโครงสราง</q-tooltip>
</q-btn> </q-btn> -->
<q-space /> <q-space />
<q-btn <q-btn
flat flat
@ -221,7 +273,11 @@ onMounted(async () => {
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
<q-card-section style="padding: 0px"> <q-card-section style="padding: 0px">
<ListView v-if="stroe.statusView === 'list'" /> <ListView
v-if="stroe.statusView === 'list'"
v-model:historyId="historyId"
v-model:count="count"
/>
<StructureView v-if="stroe.statusView === 'tree'" /> <StructureView v-if="stroe.statusView === 'tree'" />
</q-card-section> </q-card-section>
</q-card> </q-card>
@ -243,7 +299,7 @@ onMounted(async () => {
<DialogHistory :modal="modalHistory" :close="onClickHistory" /> <DialogHistory :modal="modalHistory" :close="onClickHistory" />
<!-- รายละเอยดโครงสราง --> <!-- รายละเอยดโครงสราง -->
<DialogStructureDetail v-model:structure-detail="modalStructureDetail" /> <!-- <DialogStructureDetail v-model:structure-detail="modalStructureDetail" /> -->
<!-- รายละเอยดตำแหน --> <!-- รายละเอยดตำแหน -->
<DialogPositionDetail v-model:position-detail="modalPositionDetail" /> <DialogPositionDetail v-model:position-detail="modalPositionDetail" />

View file

@ -988,8 +988,8 @@ profileData.salary.columns.length == 0
"positionType", "positionType",
"positionLevel", "positionLevel",
"positionExecutive", "positionExecutive",
"positionExecutiveSide", // "positionExecutiveSide",
"salaryClass", // "salaryClass",
"salaryRef", "salaryRef",
"refCommandNo", "refCommandNo",
]) ])
@ -1127,28 +1127,28 @@ const columns = ref<QTableProps["columns"]>([
sort: (a: string, b: string) => sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, },
{ // {
name: "positionExecutiveSide", // name: "positionExecutiveSide",
align: "left", // align: "left",
label: "ด้านทางการบริหาร", // label: "",
sortable: true, // sortable: true,
field: "positionExecutiveSide", // field: "positionExecutiveSide",
headerStyle: "font-size: 14px", // headerStyle: "font-size: 14px",
style: "font-size: 14px", // style: "font-size: 14px",
sort: (a: string, b: string) => // sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), // a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, // },
{ // {
name: "salaryClass", // name: "salaryClass",
align: "left", // align: "left",
label: "ตำแหน่ง (รายละเอียด)", // label: " ()",
sortable: true, // sortable: true,
field: "salaryClass", // field: "salaryClass",
headerStyle: "font-size: 14px", // headerStyle: "font-size: 14px",
style: "font-size: 14px", // style: "font-size: 14px",
sort: (a: string, b: string) => // sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), // a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
}, // },
{ {
name: "salaryRef", name: "salaryRef",
align: "left", align: "left",