Merge branch 'nice_dev' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-31 10:34:17 +07:00
commit 531b5a33db
4 changed files with 143 additions and 39 deletions

View file

@ -19,38 +19,50 @@ const { showLoader, hideLoader, messageError } = useCounterMixin();
const showData = ref<boolean>(false); const showData = ref<boolean>(false);
const nodeTree = ref<OrgTree[]>(); 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

@ -149,9 +149,6 @@ function deleteNode(treeNode: any, organizationId: any): boolean {
// console.log("tttttttttttttt", treeNode.orgTreeId, organizationId); // console.log("tttttttttttttt", treeNode.orgTreeId, organizationId);
if (treeNode.orgTreeId === organizationId) { if (treeNode.orgTreeId === organizationId) {
console.log(treeNode);
// Node Node
treeNode.children = []; treeNode.children = [];
breakLoop.value = true; breakLoop.value = true;
@ -351,6 +348,45 @@ 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">

View file

@ -5,7 +5,7 @@ interface DataActive {
draftName: string; draftName: string;
} }
interface nodes { interface OrgTree {
orgTreeId: string; orgTreeId: string;
orgRootId: string; orgRootId: string;
orgLevel: number; orgLevel: number;
@ -23,4 +23,12 @@ interface nodes {
children: OrgTree[]; children: OrgTree[];
} }
export type { DataActive, OrgTree }; interface OrgRevision {
orgRevisionCreatedAt: string | null;
orgRevisionId: string;
orgRevisionIsCurrent: boolean;
orgRevisionIsDraft: boolean;
orgRevisionName: string;
}
export type { DataActive, OrgTree, OrgRevision };

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,16 @@ function onClickDateTime() {
} }
const modalHistory = ref<boolean>(false); const modalHistory = ref<boolean>(false);
function onClickHistory() { const count = ref<number>(0);
modalHistory.value = !modalHistory.value; function onClickHistory(id: string) {
historyId.value = id;
count.value++;
// modalHistory.value = !modalHistory.value;
} }
onMounted(async () => { onMounted(async () => {
await fetchOrganizationActive(); await fetchOrganizationActive();
await fetchHistory();
}); });
</script> </script>
<template> <template>
@ -174,9 +203,30 @@ onMounted(async () => {
@click="stroe.typeOrganizational = 'draft'" @click="stroe.typeOrganizational = 'draft'"
:disable="ishasDraft" :disable="ishasDraft"
/> />
<q-btn-dropdown
color="blue"
label="โครงสร้างแบบเก่า"
@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)"
>
<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 +243,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 +265,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 +291,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" />