รายการโครงการ => ปรับ interface

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-04-22 09:55:17 +07:00
parent 854ee54396
commit 1757de73ff
4 changed files with 141 additions and 290 deletions

View file

@ -2,30 +2,22 @@
import { reactive, ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import type { FormBasicinfo } from "@/modules/15_development/interface/request/Main";
import DialogSelectAgency from "@/modules/15_development/components/DialogSelectAgency.vue";
import { useCounterMixin } from "@/stores/mixin";
import { useDevelopmentDataStore } from "@/modules/15_development/store/developmentStore";
import http from "@/plugins/http";
import config from "@/app.config";
const $q = useQuasar();
const store = useDevelopmentDataStore();
const mixin = useCounterMixin();
/** importType*/
import type { FormBasicinfo } from "@/modules/15_development/interface/request/Main";
import type { DataTree } from "@/modules/15_development/interface/response/Main";
const {
dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
date2Thai,
} = mixin;
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();
const { dialogConfirm, showLoader, hideLoader, messageError, success } = mixin;
const projectId = ref<string>(route.params.id.toLocaleString());
const formData = reactive<FormBasicinfo>({
@ -41,8 +33,12 @@ const formData = reactive<FormBasicinfo>({
const orgName = ref<string>("");
const node = ref<any>([]);
const filter = ref<string>("");
const expanded = ref<any>([]);
const expanded = ref<string[]>([]);
/**
* function fetch อมลเบองต
* @param id ProjectId
*/
function fetchData(id: string) {
showLoader();
http
@ -76,29 +72,26 @@ function fetchData(id: string) {
});
}
async function editData(id: string) {
await http
.put(config.API.developmentMainTab("tab1", id), formData)
.then(() => {
fetchData(id);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/** function บันทึกข้อมูล*/
function onSubmit() {
dialogConfirm($q, async () => {
dialogConfirm($q, () => {
showLoader();
editData(projectId.value);
hideLoader();
http
.put(config.API.developmentMainTab("tab1", projectId.value), formData)
.then(() => {
fetchData(projectId.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
/** function fetch หา Id หน่วยงานที่ Active*/
function fetchActive() {
showLoader();
http
@ -113,11 +106,15 @@ function fetchActive() {
});
}
async function fetchTree(id: string) {
/**
* function fetch โครงสรางปจ
* @param id โครงสรางปจ
*/
function fetchTree(id: string) {
showLoader();
http
.get(config.API.orgByid(id.toString()))
.then(async (res) => {
.then((res) => {
const data = res.data.result;
node.value = data;
fetchData(projectId.value);
@ -130,13 +127,19 @@ async function fetchTree(id: string) {
});
}
function updateSelected(data: any) {
/** function เลือกหน่วยงาน*/
function updateSelected(data: DataTree) {
orgName.value = data.orgTreeName;
formData.node = data.orgLevel;
formData.nodeId = data.orgTreeId;
formData.orgRevisionId = data.orgRevisionId;
}
/**
* function หาหนวยงานทบผดชอบ
* @param orgTreeData อม nodeTree
* @param treeId tree ID
*/
async function searchAndReplace(orgTreeData: any, treeId: string | null) {
if (orgTreeData) {
for (let orgTree of orgTreeData) {
@ -154,9 +157,6 @@ async function searchAndReplace(orgTreeData: any, treeId: string | null) {
onMounted(async () => {
fetchActive();
// setTimeout(() => {
// fetchData(projectId.value);
// }, 500);
});
</script>