ปรับโครงสร้าง

This commit is contained in:
Warunee Tamkoo 2024-02-01 10:32:34 +07:00
parent dd9239ac25
commit ea1f76125a
4 changed files with 40 additions and 72 deletions

View file

@ -108,7 +108,7 @@ function validateForm() {
/** ฟังชั่น บันทึก */
function onSubmit() {
dialogConfirm($q, async () => {
// showLoader();
showLoader();
const type = store.checkLevel(level.value);
const nameId =
level.value === 0
@ -142,14 +142,14 @@ function onSubmit() {
await http
.post(config.API.createOrgLevel(type.toLocaleLowerCase()), body)
.then(() => {
props.fetchDataTree(store.draftId);
success($q, "บันทึกข้อมูลสำเร็จ");
closeClear();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
props.fetchDataTree(store.draftId);
closeClear();
hideLoader();
});
} else {
@ -170,15 +170,14 @@ function onSubmit() {
body,
props.dataNode?.orgRootCode
);
closeClear();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
console.log(err);
messageError($q, err);
})
.finally(async () => {
// await props.fetchDataTree?.();
closeClear();
hideLoader();
}));
}

View file

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

View file

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

View file

@ -65,9 +65,9 @@ const listAdd = ref<ListMenu[]>([
},
{
label: "จัดลำดับ",
icon: "filter_list",
icon: "mdi-sort",
type: "SORT",
color: "green-7",
color: "blue-6",
},
// {
// label: "",
@ -164,8 +164,6 @@ async function deleteUpdate(rootId: string, treeId: string) {
if (breakLoop.value) break;
}
} else {
console.log("rootId===>", rootId);
console.log("treeId===>", treeId);
nodes.value = nodes.value.filter((x: any) => x.orgTreeId != treeId);
}
}
@ -237,7 +235,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;
if (id) {
breakLoop.value = false;
@ -401,7 +400,7 @@ onMounted(async () => {});
prop.node.orgRootId
)
: item.type === 'SORT'
? onClickSort(prop.node.orgRootId)
? onClickSort(prop.node.orgRootId, prop.node.orgLevel)
: item.type === 'HISTORY'
? onClickHistory(
prop.node.orgLevel,
@ -418,14 +417,16 @@ onMounted(async () => {});
v-if="
item.type === 'EDIT' ||
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 }}วนราชการ</q-item-section
>
<q-item-section v-else>{{ 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>
</div>
<div v-else>
@ -434,7 +435,8 @@ onMounted(async () => {});
item.type === 'ADD' ||
item.type === 'EDIT' ||
item.type === 'DEL' ||
item.type === 'HISTORY'
item.type === 'HISTORY' ||
item.type === 'SORT'
"
>{{ item.label }}วนราชการ</q-item-section
>
@ -464,19 +466,7 @@ onMounted(async () => {});
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,
prop.node.orgRootId
)
: null
onClickDetail(prop.node.orgTreeId, prop.node.orgLevel)
"
>
<q-item-section avatar>
@ -488,31 +478,7 @@ onMounted(async () => {});
</q-menu>
</q-btn>
</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>
<!-- <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>
@ -538,6 +504,8 @@ onMounted(async () => {});
<DialogSortAgency
v-model:sort-agency="modalSortAgency"
v-model:data="dataSort"
:fetchDataTree="props.fetchDataTree"
v-model:type="type"
/>
<DialogHistory
v-model:history="modalHistory"