รักษาการในตำแหน่ง ==> ปรับโครงสร้าง
This commit is contained in:
parent
115b41c922
commit
0da3f425a7
3 changed files with 94 additions and 40 deletions
|
|
@ -54,4 +54,39 @@ interface DataStructureTree {
|
|||
children: DataStructureTree[];
|
||||
}
|
||||
|
||||
export type { DataOption, FormProfile, RoleData, DataStructureTree };
|
||||
interface DataStrategy {
|
||||
id: string;
|
||||
level: number;
|
||||
name: string;
|
||||
children: DataStrategy[];
|
||||
}
|
||||
|
||||
interface DataActing {
|
||||
labelName: string;
|
||||
orgCode: string;
|
||||
orgLevel: 0;
|
||||
orgName: string;
|
||||
orgRootName: string;
|
||||
orgTreeCode: string;
|
||||
orgTreeId: string;
|
||||
orgTreeName: string;
|
||||
orgTreeShortName: string;
|
||||
children: DataActing[];
|
||||
posMaster: PosMaster[];
|
||||
}
|
||||
|
||||
interface PosMaster {
|
||||
fullNameCurrentHolder: string;
|
||||
orgLevel: number;
|
||||
orgTreeId: string;
|
||||
posmasterId: string;
|
||||
}
|
||||
|
||||
export type {
|
||||
DataOption,
|
||||
FormProfile,
|
||||
RoleData,
|
||||
DataStructureTree,
|
||||
DataActing,
|
||||
DataStrategy,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useStructureTree } from "@/stores/structureTree";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
|
|
@ -14,10 +17,12 @@ import type {
|
|||
} from "@/modules/17_acting/interface/response/Main";
|
||||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/** use*/
|
||||
const $q = useQuasar();
|
||||
const { fetchTreeActing } = useStructureTree();
|
||||
const storeTree = useStructureTree();
|
||||
|
||||
const { showLoader, hideLoader, messageError, dialogRemove } =
|
||||
useCounterMixin();
|
||||
|
||||
|
|
@ -31,40 +36,26 @@ const isAll = ref<boolean>(false);
|
|||
/**
|
||||
* function เรียกข้อมูลโครงสร้าง แบบปัจุบัน
|
||||
*/
|
||||
function fetchOrganizationActive() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
if (data) {
|
||||
fetchOrganization(data.activeId);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูลโครงสร้าาง
|
||||
* @param id id โครงสร้างปัจุบัน
|
||||
*/
|
||||
function fetchOrganization(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.orgAct + `/${id}`)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
nodeTree.value = data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
async function fetchOrganizationActive() {
|
||||
if (storeTree.dataActing.length > 0) {
|
||||
nodeTree.value = await fetchTreeActing("");
|
||||
} else {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.activeOrganization)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
if (data) {
|
||||
nodeTree.value = await fetchTreeActing(data.activeId);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@ import http from "@/plugins/http";
|
|||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type { DataStructureTree } from "@/interface/main";
|
||||
import type {
|
||||
DataStructureTree,
|
||||
DataStrategy,
|
||||
DataActing,
|
||||
} from "@/interface/main";
|
||||
|
||||
const $q = useQuasar();
|
||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||
|
|
@ -14,7 +18,8 @@ const { showLoader, hideLoader, messageError } = useCounterMixin();
|
|||
export const useStructureTree = defineStore("structureTree", () => {
|
||||
const activeId = ref<string>("");
|
||||
const dataStore = ref<{ [key: string]: DataStructureTree[] }>({});
|
||||
const dataStrategy = ref<any[]>([]);
|
||||
const dataStrategy = ref<DataStrategy[]>([]);
|
||||
const dataActing = ref<DataActing[]>([]);
|
||||
|
||||
/**
|
||||
* fetch ข้อมูลโครงสร้างตามคีย์ของระบบ
|
||||
|
|
@ -74,11 +79,11 @@ export const useStructureTree = defineStore("structureTree", () => {
|
|||
|
||||
/** function fetchTree ยุทธศาสตร์ / แผน*/
|
||||
async function fetchTreeStrategy() {
|
||||
dataStrategy.value;
|
||||
if (dataStrategy.value.length > 0) {
|
||||
return dataStrategy.value;
|
||||
} else {
|
||||
try {
|
||||
showLoader();
|
||||
const res = await http.get(config.API.devStrategy + `/edit/indicator`);
|
||||
const data = res.data.result;
|
||||
dataStrategy.value = data;
|
||||
|
|
@ -91,9 +96,32 @@ export const useStructureTree = defineStore("structureTree", () => {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetchTree รักษาการในตำแหน่ง
|
||||
*/
|
||||
async function fetchTreeActing(id: string) {
|
||||
if (dataActing.value.length > 0) {
|
||||
return dataActing.value;
|
||||
} else {
|
||||
try {
|
||||
showLoader();
|
||||
const res = await http.get(config.API.orgAct + `/${id}`);
|
||||
const data = res.data.result;
|
||||
dataActing.value = data;
|
||||
return data;
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
activeId,
|
||||
fetchStructureTree,
|
||||
fetchTreeStrategy,
|
||||
fetchTreeActing,
|
||||
dataActing,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue