Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2024-02-01 13:45:31 +07:00
commit 0cda16d094
4 changed files with 78 additions and 86 deletions

View file

@ -108,7 +108,7 @@ function validateForm() {
/** ฟังชั่น บันทึก */ /** ฟังชั่น บันทึก */
function onSubmit() { function onSubmit() {
dialogConfirm($q, async () => { dialogConfirm($q, async () => {
// showLoader(); showLoader();
const type = store.checkLevel(level.value); const type = store.checkLevel(level.value);
const nameId = const nameId =
level.value === 0 level.value === 0
@ -142,14 +142,14 @@ function onSubmit() {
await http await http
.post(config.API.createOrgLevel(type.toLocaleLowerCase()), body) .post(config.API.createOrgLevel(type.toLocaleLowerCase()), body)
.then(() => { .then(() => {
props.fetchDataTree(store.draftId);
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
closeClear();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
}) })
.finally(() => { .finally(() => {
props.fetchDataTree(store.draftId);
closeClear();
hideLoader(); hideLoader();
}); });
} else { } else {
@ -170,15 +170,14 @@ function onSubmit() {
body, body,
props.dataNode?.orgRootCode props.dataNode?.orgRootCode
); );
closeClear();
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
}) })
.catch((err) => { .catch((err) => {
console.log(err);
messageError($q, err); messageError($q, err);
}) })
.finally(async () => { .finally(async () => {
// await props.fetchDataTree?.(); // await props.fetchDataTree?.();
closeClear();
hideLoader(); hideLoader();
})); }));
} }
@ -289,6 +288,9 @@ const tittleName = computed(() => {
for="#ocNo" for="#ocNo"
:label="level == 0 ? 'รหัสหน่วยงาน' : 'รหัสส่วนราชการ'" :label="level == 0 ? 'รหัสหน่วยงาน' : 'รหัสส่วนราชการ'"
hide-bottom-space hide-bottom-space
maxlength="2"
type="number"
class="inputNumber"
:rules="[ :rules="[
(val) => (val) =>
!!val || !!val ||
@ -373,3 +375,15 @@ const tittleName = computed(() => {
</q-dialog> </q-dialog>
</template> </template>
</template> </template>
<style scoped>
.inputNumber >>> input[type="number"] {
-moz-appearance: textfield;
}
.inputNumber >>> input::-webkit-outer-spin-button,
.inputNumber >>> input::-webkit-inner-spin-button {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
</style>

View file

@ -7,13 +7,6 @@ import type { QTableProps } from "quasar";
import DialogHeader from "@/components/DialogHeader.vue"; import DialogHeader from "@/components/DialogHeader.vue";
import type {
FormDataNewStructure,
FormNewStructureRef,
DataOption,
HistoryType,
} from "@/modules/02_organizationalNew/interface/index/Main";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational"; import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
@ -22,6 +15,16 @@ const store = useOrganizational();
const { dialogConfirm, showLoader, success, hideLoader, messageError } = const { dialogConfirm, showLoader, success, hideLoader, messageError } =
useCounterMixin(); useCounterMixin();
const type = defineModel<number>("type", { required: true });
const props = defineProps({
fetchDataTree: {
type: Function,
require: true,
default: () => "",
},
});
const modal = defineModel<boolean>("sortAgency", { required: true }); const modal = defineModel<boolean>("sortAgency", { required: true });
const modalSort = defineModel<Array<any>>("data", { required: true }); const modalSort = defineModel<Array<any>>("data", { required: true });
const rows = ref<any>([]); const rows = ref<any>([]);
@ -46,6 +49,7 @@ function onDropRow(from: any, to: any) {
function save() { function save() {
dialogConfirm($q, () => { dialogConfirm($q, () => {
showLoader();
const data = rows.value; const data = rows.value;
const dataId = data.map((item: any) => item.orgTreeId); const dataId = data.map((item: any) => item.orgTreeId);
http http
@ -56,12 +60,15 @@ function save() {
}) })
.then((res) => { .then((res) => {
modal.value = false; modal.value = false;
props.fetchDataTree(store.draftId);
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => {}); .finally(() => {
hideLoader();
});
}); });
} }
watch( watch(
@ -90,7 +97,7 @@ watch(
<q-card style="min-width: 50vw"> <q-card style="min-width: 50vw">
<!-- <form @submit.prevent="validateForm"> --> <!-- <form @submit.prevent="validateForm"> -->
<DialogHeader <DialogHeader
:tittle="`จัดลำดับการแสดงผล`" :tittle="`จัดลำดับ${type == 0 ? 'หน่วยงาน' : 'ส่วนราชการ'}`"
:close="() => (modal = false)" :close="() => (modal = false)"
/> />
<q-separator /> <q-separator />

View file

@ -37,14 +37,8 @@ async function fetchDetailTree(id: string, type: string) {
.then((res) => { .then((res) => {
const data = res.data.result; const data = res.data.result;
const range = data[`org${type}Rank`]; const range = data[`org${type}Rank`];
formData.orgName = data[`org${type}orgRootName`] ? data[`org${type}orgRootName`] : '-'; formData.orgName = data.orgRootName ? data.orgRootName : "-";
// range == "DEPARTMENT" formData.agencyName = data.orgName ? data.orgName : "-";
// ? data[`org${type}Name`] + ` (${data[`org${type}ShortName`]})`
// : "-";
formData.agencyName = data[`org${type}orgName`] ? data[`org${type}orgName`] : '-';
// range != "DEPARTMENT"
// ? data[`org${type}Name`] + ` (${data[`org${type}ShortName`]})`
// : "-";
formData.orgType = range != "DEPARTMENT" ? "ส่วนราชการ" : "หน่วยงาน"; formData.orgType = range != "DEPARTMENT" ? "ส่วนราชการ" : "หน่วยงาน";
formData.orgLevel = store.convertType(range); formData.orgLevel = store.convertType(range);
formData.status = formData.status =

View file

@ -65,9 +65,9 @@ const listAdd = ref<ListMenu[]>([
}, },
{ {
label: "จัดลำดับ", label: "จัดลำดับ",
icon: "filter_list", icon: "mdi-sort",
type: "SORT", type: "SORT",
color: "green-7", color: "blue-6",
}, },
// { // {
// label: "", // label: "",
@ -166,17 +166,18 @@ async function deleteUpdate(rootId: string, treeId: string) {
if (breakLoop.value) break; if (breakLoop.value) break;
} }
} else { } else {
console.log("rootId===>", rootId);
console.log("treeId===>", treeId);
nodes.value = nodes.value.filter((x: any) => x.orgTreeId != treeId); nodes.value = nodes.value.filter((x: any) => x.orgTreeId != treeId);
} }
} }
function deleteNode(treeNode: any, rootId: string, treeId: string): boolean { function deleteNode(treeNode: any, rootId: string, treeId: string): boolean {
if (treeNode.orgTreeId === rootId) { if (treeNode.orgTreeId === rootId) {
const childrenNew = treeNode.children.filter(
(x: any) => x.orgTreeId != treeId
);
let newData = { let newData = {
...treeNode, ...treeNode,
children: [], children: childrenNew,
}; };
Object.assign(treeNode, newData); Object.assign(treeNode, newData);
@ -239,7 +240,8 @@ async function onClickDel(type: number, id: string, rootId: string) {
}); });
} }
async function onClickSort(id: string) { async function onClickSort(id: string, level: number) {
type.value = level;
modalSortAgency.value = true; modalSortAgency.value = true;
if (id) { if (id) {
breakLoop.value = false; breakLoop.value = false;
@ -293,9 +295,9 @@ onMounted(async () => {});
</script> </script>
<template> <template>
<div class="col-12 q-py-md q-px-lg"> <div class="col-12 q-py-md q-px-sm">
<div class="q-gutter-md"> <div class="q-gutter-sm">
<div class="row q-col-gutter-sm"> <div class="row q-col-gutter-sm q-pl-sm">
<div class="col-2" v-if="store.typeOrganizational === 'draft'"> <div class="col-2" v-if="store.typeOrganizational === 'draft'">
<q-btn <q-btn
dense dense
@ -312,7 +314,13 @@ onMounted(async () => {});
<div <div
:class="store.typeOrganizational === 'draft' ? 'col-10' : 'col-12'" :class="store.typeOrganizational === 'draft' ? 'col-10' : 'col-12'"
> >
<q-input dense outlined v-model="filter" label="ค้นหา"> <q-input
dense
outlined
v-model="filter"
label="ค้นหา"
class="bg-white"
>
<template v-slot:append> <template v-slot:append>
<q-icon <q-icon
v-if="filter !== ''" v-if="filter !== ''"
@ -324,14 +332,7 @@ onMounted(async () => {});
</q-input> </q-input>
</div> </div>
</div> </div>
<div <div class="bg-white tree-container">
class="bg-white"
style="
height: 60vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 10px;
"
>
<q-tree <q-tree
class="q-pa-md q-gutter-sm" class="q-pa-md q-gutter-sm"
dense dense
@ -403,7 +404,7 @@ onMounted(async () => {});
prop.node.orgRootId prop.node.orgRootId
) )
: item.type === 'SORT' : item.type === 'SORT'
? onClickSort(prop.node.orgRootId) ? onClickSort(prop.node.orgRootId, prop.node.orgLevel)
: item.type === 'HISTORY' : item.type === 'HISTORY'
? onClickHistory( ? onClickHistory(
prop.node.orgLevel, prop.node.orgLevel,
@ -420,14 +421,16 @@ onMounted(async () => {});
v-if=" v-if="
item.type === 'EDIT' || item.type === 'EDIT' ||
item.type === 'DEL' || item.type === 'DEL' ||
item.type === 'HISTORY' item.type === 'HISTORY' ||
item.type === 'SORT'
" "
>{{ item.label }}หนวยงาน</q-item-section
> >
<q-item-section v-else-if="item.type === 'ADD'" {{ item.label }}หนวยงาน
>{{ item.label }}วนราชการ</q-item-section </q-item-section>
> <q-item-section v-else-if="item.type === 'ADD'">
<q-item-section v-else>{{ item.label }}</q-item-section> {{ item.label }}วนราชการ
</q-item-section>
<q-item-section v-else> {{ item.label }} </q-item-section>
</div> </div>
<div v-else> <div v-else>
@ -436,7 +439,8 @@ onMounted(async () => {});
item.type === 'ADD' || item.type === 'ADD' ||
item.type === 'EDIT' || item.type === 'EDIT' ||
item.type === 'DEL' || item.type === 'DEL' ||
item.type === 'HISTORY' item.type === 'HISTORY' ||
item.type === 'SORT'
" "
>{{ item.label }}วนราชการ</q-item-section >{{ item.label }}วนราชการ</q-item-section
> >
@ -466,19 +470,7 @@ onMounted(async () => {});
clickable clickable
v-close-popup v-close-popup
@click=" @click="
item.type === 'EDIT' onClickDetail(prop.node.orgTreeId, prop.node.orgLevel)
? 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,
prop.node.orgRootId
)
: null
" "
> >
<q-item-section avatar> <q-item-section avatar>
@ -490,31 +482,7 @@ onMounted(async () => {});
</q-menu> </q-menu>
</q-btn> </q-btn>
</template> </template>
<!-- <template v-slot:default-body="prop">
<div v-if="prop.node.orgCode">
<span class="text-grey-13"
>{{ prop.node.orgCode }} {{ prop.node.orgTreeShortName }}</span
>
</div>
</template> -->
</q-tree> </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> </div>
</div> </div>
@ -540,6 +508,8 @@ onMounted(async () => {});
<DialogSortAgency <DialogSortAgency
v-model:sort-agency="modalSortAgency" v-model:sort-agency="modalSortAgency"
v-model:data="dataSort" v-model:data="dataSort"
:fetchDataTree="props.fetchDataTree"
v-model:type="type"
/> />
<DialogHistory <DialogHistory
v-model:history="modalHistory" v-model:history="modalHistory"
@ -548,4 +518,11 @@ onMounted(async () => {});
/> />
</template> </template>
<style scoped></style> <style scoped>
.tree-container {
overflow: auto;
height: 60vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 10px;
}
</style>