รักษาการในตำแหน่ง ==> ปรับโครงสร้าง
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[];
|
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">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import { checkPermission } from "@/utils/permissions";
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
import { checkPermission } from "@/utils/permissions";
|
||||||
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useStructureTree } from "@/stores/structureTree";
|
||||||
|
|
||||||
/** importType*/
|
/** importType*/
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
|
|
@ -14,10 +17,12 @@ import type {
|
||||||
} from "@/modules/17_acting/interface/response/Main";
|
} from "@/modules/17_acting/interface/response/Main";
|
||||||
|
|
||||||
/** importStore*/
|
/** importStore*/
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
|
||||||
|
|
||||||
/** use*/
|
/** use*/
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
const { fetchTreeActing } = useStructureTree();
|
||||||
|
const storeTree = useStructureTree();
|
||||||
|
|
||||||
const { showLoader, hideLoader, messageError, dialogRemove } =
|
const { showLoader, hideLoader, messageError, dialogRemove } =
|
||||||
useCounterMixin();
|
useCounterMixin();
|
||||||
|
|
||||||
|
|
@ -31,40 +36,26 @@ const isAll = ref<boolean>(false);
|
||||||
/**
|
/**
|
||||||
* function เรียกข้อมูลโครงสร้าง แบบปัจุบัน
|
* function เรียกข้อมูลโครงสร้าง แบบปัจุบัน
|
||||||
*/
|
*/
|
||||||
function fetchOrganizationActive() {
|
async function fetchOrganizationActive() {
|
||||||
showLoader();
|
if (storeTree.dataActing.length > 0) {
|
||||||
http
|
nodeTree.value = await fetchTreeActing("");
|
||||||
.get(config.API.activeOrganization)
|
} else {
|
||||||
.then((res) => {
|
showLoader();
|
||||||
const data = res.data.result;
|
http
|
||||||
if (data) {
|
.get(config.API.activeOrganization)
|
||||||
fetchOrganization(data.activeId);
|
.then(async (res) => {
|
||||||
}
|
const data = res.data.result;
|
||||||
})
|
if (data) {
|
||||||
.catch((err) => {
|
nodeTree.value = await fetchTreeActing(data.activeId);
|
||||||
messageError($q, err);
|
}
|
||||||
hideLoader();
|
})
|
||||||
});
|
.catch((err) => {
|
||||||
}
|
messageError($q, err);
|
||||||
|
})
|
||||||
/**
|
.finally(() => {
|
||||||
* function fetch ข้อมูลโครงสร้าาง
|
hideLoader();
|
||||||
* @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();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
|
||||||
import type { DataStructureTree } from "@/interface/main";
|
import type {
|
||||||
|
DataStructureTree,
|
||||||
|
DataStrategy,
|
||||||
|
DataActing,
|
||||||
|
} from "@/interface/main";
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||||
|
|
@ -14,7 +18,8 @@ const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||||
export const useStructureTree = defineStore("structureTree", () => {
|
export const useStructureTree = defineStore("structureTree", () => {
|
||||||
const activeId = ref<string>("");
|
const activeId = ref<string>("");
|
||||||
const dataStore = ref<{ [key: string]: DataStructureTree[] }>({});
|
const dataStore = ref<{ [key: string]: DataStructureTree[] }>({});
|
||||||
const dataStrategy = ref<any[]>([]);
|
const dataStrategy = ref<DataStrategy[]>([]);
|
||||||
|
const dataActing = ref<DataActing[]>([]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch ข้อมูลโครงสร้างตามคีย์ของระบบ
|
* fetch ข้อมูลโครงสร้างตามคีย์ของระบบ
|
||||||
|
|
@ -74,11 +79,11 @@ export const useStructureTree = defineStore("structureTree", () => {
|
||||||
|
|
||||||
/** function fetchTree ยุทธศาสตร์ / แผน*/
|
/** function fetchTree ยุทธศาสตร์ / แผน*/
|
||||||
async function fetchTreeStrategy() {
|
async function fetchTreeStrategy() {
|
||||||
dataStrategy.value;
|
|
||||||
if (dataStrategy.value.length > 0) {
|
if (dataStrategy.value.length > 0) {
|
||||||
return dataStrategy.value;
|
return dataStrategy.value;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
showLoader();
|
||||||
const res = await http.get(config.API.devStrategy + `/edit/indicator`);
|
const res = await http.get(config.API.devStrategy + `/edit/indicator`);
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
dataStrategy.value = data;
|
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 {
|
return {
|
||||||
activeId,
|
activeId,
|
||||||
fetchStructureTree,
|
fetchStructureTree,
|
||||||
fetchTreeStrategy,
|
fetchTreeStrategy,
|
||||||
|
fetchTreeActing,
|
||||||
|
dataActing,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue