Refactoring code module 15_development

This commit is contained in:
STW_TTTY\stwtt 2024-09-20 14:47:35 +07:00
parent 895bfe98f2
commit 32ff7bdc96
25 changed files with 271 additions and 1440 deletions

View file

@ -2,8 +2,11 @@
import { ref, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import { useRouter, useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useDevelopmentDataStore } from "@/modules/15_development/store/developmentStore";
/** importComponents*/
import BasicInfo from "@/modules/15_development/components/BasicInfo.vue"; //
@ -13,11 +16,6 @@ import Budget from "@/modules/15_development/components/Budget.vue"; // งบ
import Risk from "@/modules/15_development/components/Risk.vue"; //
import FollowResult from "@/modules/15_development/components/FollowResult.vue"; //
import Other from "@/modules/15_development/components/Other.vue"; //
// import Record from "@/modules/15_development/components/Record.vue"; //
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
import { useDevelopmentDataStore } from "@/modules/15_development/store/developmentStore";
/** use*/
const $q = useQuasar();
@ -31,9 +29,9 @@ const checkRoutePermission = ref<boolean>(
route.name == "developmentDetailPage"
);
const title = ref<string>(route.params.id ? "แก้ไข" : "เพิ่ม");
const projectId = ref<string>(route.params.id.toLocaleString());
const tab = ref<string>("BasicInfo");
const status = ref<string>("ONGOING");
const projectId = ref<string>(route.params.id.toLocaleString()); //id route
const tab = ref<string>("BasicInfo"); //tab
const status = ref<string>("ONGOING"); //
const step = ref<string[]>([
"BasicInfo",
"Target",
@ -45,12 +43,28 @@ const step = ref<string[]>([
"Result",
]);
const isChangeData = ref<boolean>(false);
const childBasicInfoRef = ref<InstanceType<typeof BasicInfo> | null>(null);
const childProjectDetailRef = ref<InstanceType<typeof ProjectDetail> | null>(
null
);
const childBudgetRef = ref<InstanceType<typeof Budget> | null>(null);
const childRiskRef = ref<InstanceType<typeof Risk> | null>(null);
const childFollowResultRef = ref<InstanceType<typeof FollowResult> | null>(
null
);
const childOtherRef = ref<InstanceType<typeof Other> | null>(null);
//
function prevStep() {
const index = step.value.indexOf(tab.value);
if (index > 0) {
tab.value = step.value[index - 1];
}
}
//
function nextStep() {
const index = step.value.indexOf(tab.value);
if (index < step.value.length - 1) {
@ -100,12 +114,6 @@ function onFinish(id: string) {
);
}
/** hooklifecycle*/
onMounted(() => {
projectId.value && getStatus(projectId.value);
});
const isChangeData = ref<boolean>(false);
/**
* function เชคการแกไขอม
*/
@ -113,17 +121,6 @@ function onCheckChangeData() {
isChangeData.value = true;
}
const childBasicInfoRef = ref<InstanceType<typeof BasicInfo> | null>(null);
const childProjectDetailRef = ref<InstanceType<typeof ProjectDetail> | null>(
null
);
const childBudgetRef = ref<InstanceType<typeof Budget> | null>(null);
const childRiskRef = ref<InstanceType<typeof Risk> | null>(null);
const childFollowResultRef = ref<InstanceType<typeof FollowResult> | null>(
null
);
const childOtherRef = ref<InstanceType<typeof Other> | null>(null);
watch(tab, (newValue, oldValue) => {
console.log(`Count changed from ${oldValue} to ${newValue}`);
if (isChangeData.value) {
@ -143,6 +140,11 @@ watch(tab, (newValue, oldValue) => {
}
}
});
/** hooklifecycle*/
onMounted(() => {
projectId.value && getStatus(projectId.value);
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
@ -209,8 +211,8 @@ watch(tab, (newValue, oldValue) => {
<BasicInfo
ref="childBasicInfoRef"
:next-step="nextStep"
:onCheckChangeData="onCheckChangeData"
v-model:isChangeData.value="isChangeData"
:on-check-change-data="onCheckChangeData"
v-model:is-change-data.value="isChangeData"
/>
</q-tab-panel>
@ -225,8 +227,8 @@ watch(tab, (newValue, oldValue) => {
ref="childProjectDetailRef"
:prev-step="prevStep"
:next-step="nextStep"
:onCheckChangeData="onCheckChangeData"
v-model:isChangeData.value="isChangeData"
:on-check-change-data="onCheckChangeData"
v-model:is-change-data.value="isChangeData"
/>
</q-tab-panel>
@ -237,8 +239,8 @@ watch(tab, (newValue, oldValue) => {
:status="status"
:prev-step="prevStep"
:next-step="nextStep"
:onCheckChangeData="onCheckChangeData"
v-model:isChangeData.value="isChangeData"
:on-check-change-data="onCheckChangeData"
v-model:is-change-data.value="isChangeData"
/>
</q-tab-panel>
@ -248,8 +250,8 @@ watch(tab, (newValue, oldValue) => {
ref="childRiskRef"
:prev-step="prevStep"
:next-step="nextStep"
:onCheckChangeData="onCheckChangeData"
v-model:isChangeData.value="isChangeData"
:on-check-change-data="onCheckChangeData"
v-model:is-change-data.value="isChangeData"
/>
</q-tab-panel>
<q-tab-panel name="FollowResult" style="padding: 0px">
@ -258,8 +260,8 @@ watch(tab, (newValue, oldValue) => {
:status="status"
:prev-step="prevStep"
:next-step="nextStep"
:onCheckChangeData="onCheckChangeData"
v-model:isChangeData.value="isChangeData"
:on-check-change-data="onCheckChangeData"
v-model:is-change-data.value="isChangeData"
/>
</q-tab-panel>
<q-tab-panel name="Other" style="padding: 0px">
@ -267,11 +269,10 @@ watch(tab, (newValue, oldValue) => {
ref="childOtherRef"
:status="status"
:prev-step="prevStep"
:onCheckChangeData="onCheckChangeData"
v-model:isChangeData.value="isChangeData"
:on-check-change-data="onCheckChangeData"
v-model:is-change-data.value="isChangeData"
/>
</q-tab-panel>
<!-- <q-tab-panel name="Record"> <Record /> </q-tab-panel> -->
</q-tab-panels>
</div>
</q-card>