diff --git a/src/api/KPI/api.kpis.ts b/src/api/KPI/api.kpis.ts index 6d701d1..1c3bc01 100644 --- a/src/api/KPI/api.kpis.ts +++ b/src/api/KPI/api.kpis.ts @@ -15,7 +15,7 @@ const Kpi = `${env.API_URI}/kpi`; const KpiUser = `${env.API_URI}/kpi/user`; const kpiAchievement = `${env.API_URI}/kpi/user/achievement`; const kpiReason = `${env.API_URI}/kpi/reason`; - +const development = `${env.API_URI}/development`; // const placementKeycloak = `${env.API_URI}/placement/officer/keycloak`; const placementKeycloak = `${env.API_URI}/placement/officer/profileId`; // const orgPosition = `${env.API_URI}/org/profile/keycloak/position `; @@ -62,4 +62,6 @@ export default { updatePoint: (id: string) => `${kpiEvaluation}/point/${id}`, openPoint: (id: string) => `${kpiEvaluation}/open/${id}`, kpiReport: (id: string) => `${Kpi}/report/kpi-user/${id}`, + + developmentMain: `${development}/main`, }; diff --git a/src/modules/08_KPI/components/Tab/Dialog/DialogDevelop.vue b/src/modules/08_KPI/components/Tab/Dialog/DialogDevelop.vue index a980da7..cfd25ee 100644 --- a/src/modules/08_KPI/components/Tab/Dialog/DialogDevelop.vue +++ b/src/modules/08_KPI/components/Tab/Dialog/DialogDevelop.vue @@ -8,7 +8,7 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useRoute } from "vue-router"; -import type { DataOptionTechnique } from "@/modules/08_KPI/interface/index/Main"; +import type { DataOptionTechnique,ProjectYearOp } from "@/modules/08_KPI/interface/index/Main"; const props = defineProps({ getAll: Function, @@ -20,6 +20,15 @@ const reasonDevelopment70 = ref(""); const reasonDevelopment20 = ref(""); const reasonDevelopment10 = ref(""); +const choice = ref("MANUAL"); +const projectName = ref(""); +const projectOp = ref([]); +const projectOpMain = ref([]); +const choiceOp = ref([ + { value: "PROJECT", label: "เลือกจากโครงการ/หลักสูตรการฝึกอบรม" }, + { value: "MANUAL", label: "กรอกเอง" }, +]); + const checkOtherBox11 = computed(() => { return development.value.includes("other1"); }); @@ -60,7 +69,19 @@ const { const modal = defineModel("modal", { required: true }); const id = defineModel("id", { required: true }); -const formData = reactive({ +const formData = reactive<{ + year: number | null; + name: string; + group: any[]; + target: string; + isDevelopment70: boolean; + isDevelopment20: boolean; + isDevelopment10: boolean; + achievement10: string; + achievement5: string; + achievement0: string; +}>({ + year: null, name: "", group: [], target: "", @@ -152,6 +173,15 @@ function close() { "มีผลการพัฒนาแต่ยังไม่ได้ดำเนินการตามเป้าหมายการนำไปพัฒนางาน"; formData.achievement0 = "ไม่ได้ดำเนินการพัฒนา"; + choice.value = "MANUAL"; + formData.year = null; + projectName.value = ""; + reasonDevelopment70.value = ""; + reasonDevelopment20.value = ""; + reasonDevelopment10.value = ""; + development.value = []; + + props.getAll?.(); } @@ -181,6 +211,9 @@ function onSubmit() { reasonDevelopment70: checkOtherBox11 ? reasonDevelopment70.value : "", reasonDevelopment20: checkOtherBox12 ? reasonDevelopment20.value : "", reasonDevelopment10: checkOtherBox13 ? reasonDevelopment10.value : "", + selectType: choice.value, + selectTypeYear: formData.year ? formData.year.toString() : null, + selectTypeId: projectName.value.id ? projectName.value.id : null, }; showLoader(); http[id.value ? "put" : "post"](url, body) @@ -206,19 +239,39 @@ watch( .get(config.API.kpiAchievementDevelop + `/${id.value}`) .then(async(res) => { const data = res.data.result; - formData.name = data.name; - formData.group = data.group; - formData.target = data.target; - formData.isDevelopment70 = data.isDevelopment70; - formData.isDevelopment20 = data.isDevelopment20; - formData.isDevelopment10 = data.isDevelopment10; - formData.achievement10 = data.achievement10; - formData.achievement5 = data.achievement5; - formData.achievement0 = data.achievement0; - development.value = data.developmentProjects; - reasonDevelopment70.value = data.developmentProjects.includes("other1") ? data.reasonDevelopment70:''; - reasonDevelopment20.value = data.developmentProjects.includes("other2") ? data.reasonDevelopment20:''; - reasonDevelopment10.value = data.developmentProjects.includes("other3") ? data.reasonDevelopment10:''; + formData.year = data.selectTypeYear; + await getDataByYear(); + setTimeout(() => { + choice.value = data.selectType; + projectName.value = projectOpMain.value.find( + (i: any) => i.id == data.selectTypeId + ); + formData.name = data.name; + formData.group = data.group; + formData.target = data.target; + formData.isDevelopment70 = data.isDevelopment70; + formData.isDevelopment20 = data.isDevelopment20; + formData.isDevelopment10 = data.isDevelopment10; + formData.achievement10 = data.achievement10; + formData.achievement5 = data.achievement5; + formData.achievement0 = data.achievement0; + development.value = data.developmentProjects; + reasonDevelopment70.value = data.developmentProjects.includes( + "other1" + ) + ? data.reasonDevelopment70 + : ""; + reasonDevelopment20.value = data.developmentProjects.includes( + "other2" + ) + ? data.reasonDevelopment20 + : ""; + reasonDevelopment10.value = data.developmentProjects.includes( + "other3" + ) + ? data.reasonDevelopment10 + : ""; + }, 500); }) .catch((e) => { messageError($q, e); @@ -229,6 +282,77 @@ watch( } } ); + +const customPosition = () => ({ top: "490px", left: "410px" }); +async function getDataByYear() { + if (formData.year) { + showLoader(); + http + .get(config.API.developmentMain + `/done?year=${formData.year}`) + .then(async(res) => { + const data = await res.data.result.data; + projectOpMain.value = data; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + } +} + +function getProjectDetail(val: any) { + showLoader(); + http + .get(config.API.developmentMain + `/tab3_1/${val.id}`) + .then((res) => { + const data = res.data.result; + formData.name = val.projectName; + formData.group = data.group; + formData.target = data.target; + formData.isDevelopment70 = data.isDevelopment70; + formData.isDevelopment20 = data.isDevelopment20; + formData.isDevelopment10 = data.isDevelopment10; + formData.achievement10 = data.achievement10; + formData.achievement5 = data.achievement5; + formData.achievement0 = data.achievement0; + development.value = data.developmentProjectTechniqueActuals; + reasonDevelopment70.value = + data.developmentProjectTechniqueActuals.includes("other1") + ? data.reasonDevelopment70 + : ""; + reasonDevelopment20.value = + data.developmentProjectTechniqueActuals.includes("other2") + ? data.reasonDevelopment20 + : ""; + reasonDevelopment10.value = + data.developmentProjectTechniqueActuals.includes("other3") + ? data.reasonDevelopment10 + : ""; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + +/** + * function ค้นหาข้อมูลใน option + * @param val คำค้นหา + * @param update function + */ + function filterOptionFn(val: string, update: Function) { + projectName.value = ""; + update(() => { + projectOp.value = projectOpMain.value.filter( + (e: any) => e.projectName.search(val) !== -1 + ); + }); +} +