Refactoring code module 02_organization

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-11 17:00:27 +07:00
parent 63b9aafbaf
commit 0f5d772e53
24 changed files with 805 additions and 1033 deletions

View file

@ -1,18 +1,18 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { reactive, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useOrganizational } from "@/modules/02_organization/store/organizational";
import DialogHeader from "@/components/DialogHeader.vue";
const $q = useQuasar();
const mixin = useCounterMixin();
const store = useOrganizational();
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
const { showLoader, hideLoader, messageError } = mixin;
const modal = defineModel<boolean>("structureDetail", { required: true });
const treeId = defineModel<string>("treeId", { required: true });
@ -30,12 +30,17 @@ const formData = reactive<any>({
orgShortName: "",
});
/**
* function งขอมลรายละเอยดโหนดขอโครงสรางตาม ID โหนดโครงสราง
* @param id id โหนดโครงสราง
* @param type ระดบโหนดของโครงอสราง
*/
async function fetchDetailTree(id: string, type: string) {
showLoader();
await http
.get(config.API.orgLevelByid(type.toLocaleLowerCase(), id))
.then((res) => {
const data = res.data.result;
.then(async (res) => {
const data = await res.data.result;
const range = data[`org${type}Rank`];
formData.orgName = data.orgRootName ? data.orgRootName : "-";
formData.agencyName = data.orgName ? data.orgName : "-";
@ -60,10 +65,19 @@ async function fetchDetailTree(id: string, type: string) {
});
}
/**
* function popup
*/
function close() {
modal.value = false;
}
/**
* การเปลยนแปลงของ modal
*
* เม modal เป true จะสงระดบของโหนดไปเช
* และจะดงขอมลรายละเอยดโหนดขอโครงสรางตาม ID และ ระด โหนดโครงสราง
*/
watch(
() => modal.value,
async () => {