refactor(position-condition): fetchStructureTree
This commit is contained in:
parent
b083bcb0ca
commit
55ca5d64a7
3 changed files with 13 additions and 44 deletions
|
|
@ -47,8 +47,8 @@ function onSubmit() {
|
|||
formData
|
||||
)
|
||||
.then(async () => {
|
||||
await props.fetchData?.();
|
||||
onCloseDialog();
|
||||
await props.fetchData?.();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export default [
|
|||
component: mainView,
|
||||
meta: {
|
||||
Auth: true,
|
||||
Key: "COMMAND",
|
||||
Key: "SYS_POS_CONDITION",
|
||||
Role: "STAFF",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useStructureTree } from "@/stores/structureTree";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
|
|
@ -17,12 +20,15 @@ import LoadView from "@/components/LoadView.vue";
|
|||
import DialogCondition from "@/modules/19_condition/components/DialogCondition.vue";
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const { showLoader, hideLoader, messageError } = useCounterMixin();
|
||||
const { fetchStructureTree, fetchTreeStrategy } = useStructureTree();
|
||||
const { activeId } = storeToRefs(useStructureTree());
|
||||
|
||||
const isLoadTable = ref<boolean>(false);
|
||||
|
||||
//Tree
|
||||
const activeId = ref<string>("");
|
||||
// const activeId = ref<string>("");
|
||||
const filter = ref<string>("");
|
||||
const orgTreeId = ref<string>("");
|
||||
const nodeTree = ref<OrgTree[]>([]);
|
||||
|
|
@ -193,46 +199,9 @@ const columnsExpand = ref<QTableProps["columns"]>([
|
|||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลโครงสร้าง แบบปัจุบัน
|
||||
*/
|
||||
async function fetchOrgActive() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.activeOrganization)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
if (data) {
|
||||
activeId.value = data.activeId;
|
||||
await fetchDataTree(data.activeId);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูลของ Tree
|
||||
* @param id id โครงสร้าง
|
||||
*/
|
||||
async function fetchDataTree(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByid(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
nodeTree.value = data.data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
/** function fetch ข้อมูลของ Tree*/
|
||||
async function fetchDataTree() {
|
||||
nodeTree.value = await fetchStructureTree(route.meta.Key as string, true);
|
||||
}
|
||||
|
||||
function onSelectedOrgTree(data: OrgTree) {
|
||||
|
|
@ -302,7 +271,7 @@ watch(pageSize, () => {
|
|||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchOrgActive();
|
||||
await fetchDataTree();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue