diff --git a/src/modules/00_support/interface/index/Main.ts b/src/modules/00_support/interface/index/Main.ts new file mode 100644 index 000000000..6fbe82ee1 --- /dev/null +++ b/src/modules/00_support/interface/index/Main.ts @@ -0,0 +1,8 @@ +interface DataOption { + id: string; + name: string; +} + +export type { + DataOption, +}; diff --git a/src/modules/00_support/interface/request/index.ts b/src/modules/00_support/interface/request/index.ts new file mode 100644 index 000000000..e4ea7770c --- /dev/null +++ b/src/modules/00_support/interface/request/index.ts @@ -0,0 +1 @@ +export type {}; diff --git a/src/modules/00_support/interface/response/index.ts b/src/modules/00_support/interface/response/index.ts new file mode 100644 index 000000000..e4ea7770c --- /dev/null +++ b/src/modules/00_support/interface/response/index.ts @@ -0,0 +1 @@ +export type {}; diff --git a/src/modules/00_support/router.ts b/src/modules/00_support/router.ts new file mode 100644 index 000000000..518b05c6c --- /dev/null +++ b/src/modules/00_support/router.ts @@ -0,0 +1,14 @@ +const supportMain = () => import("@/modules/00_support/views/MainPage.vue"); + +export default [ + { + path: "/support", + name: "supportMain", + component: supportMain, + meta: { + Auth: true, + Key: [1.1], + Role: "evaluate", + }, + }, +]; diff --git a/src/modules/00_support/store/Main.ts b/src/modules/00_support/store/Main.ts new file mode 100644 index 000000000..d01c30064 --- /dev/null +++ b/src/modules/00_support/store/Main.ts @@ -0,0 +1,10 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; + +export const useEvalutuonStore = defineStore("supportServiceStore", () => { + const index = ref(0); + + return { + index, + }; +}); diff --git a/src/modules/00_support/views/MainPage.vue b/src/modules/00_support/views/MainPage.vue new file mode 100644 index 000000000..ad5a46655 --- /dev/null +++ b/src/modules/00_support/views/MainPage.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/src/modules/02_organizationalNew/components/DialogFormAgency.vue b/src/modules/02_organizationalNew/components/DialogFormAgency.vue index 0d569ccf0..84660ee43 100644 --- a/src/modules/02_organizationalNew/components/DialogFormAgency.vue +++ b/src/modules/02_organizationalNew/components/DialogFormAgency.vue @@ -9,6 +9,7 @@ import type { DataOption, } from "@/modules/02_organizationalNew/interface/index/Main"; +const level = defineModel("orgLevel", { required: true }); const props = defineProps({ modal: Boolean, close: Function, @@ -18,35 +19,46 @@ const $q = useQuasar(); const mixin = useCounterMixin(); const { dialogConfirm } = mixin; -const ocLevelOp = ref([]); +const orgLevelOptionMain = ref([ + { name: "ระดับสำนัก", id: "DEPARTMENT" }, + { + name: "ระดับกอง/สำนักงาน/ส่วนราชการ/โรงพยาบาล/เทียบเท่ากอง", + id: "OFFICE", + }, + { name: "ระดับส่วน/กลุ่มภารกิจ", id: "DIVISION" }, + { name: "ระดับฝ่าย/กลุ่มงาน", id: "SECTION" }, +]); -const ocNameRef = ref(null); -const shortNameRef = ref(null); -const ocNoRef = ref(null); -const ocLevelRef = ref(null); -const telOutRef = ref(null); -const telInRef = ref(null); -const telRef = ref(null); +const orgLevelOption = ref([]); + +const orgNameRef = ref(null); +const orgShortNameRef = ref(null); +const orgCodeRef = ref(null); +const orgPhoneExRef = ref(null); +const orgPhoneInRef = ref(null); +const orgFaxRef = ref(null); +const orgLevelRef = ref(null); const formData = reactive({ - ocName: "", - shortName: "", - ocNo: "", - ocLevel: "", - telOut: "", - telIn: "", - tel: "", + orgName: "", + orgShortName: "", + orgCode: "", + orgPhoneEx: "", + orgPhoneIn: "", + orgFax: "", + orgRevisionId: "", + orgLevel: "", }); /** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */ const objectComplaintsRef: FormAgencyRef = { - ocName: ocNameRef, - shortName: shortNameRef, - ocNo: ocNoRef, - ocLevel: ocLevelRef, - telOut: telOutRef, - telIn: telInRef, - tel: telRef, + orgName: orgNameRef, + orgShortName: orgShortNameRef, + orgCode: orgCodeRef, + orgPhoneEx: orgPhoneExRef, + orgPhoneIn: orgPhoneInRef, + orgFax: orgFaxRef, + orgLevel: orgLevelRef, }; /** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */ @@ -70,7 +82,7 @@ function validateForm() { /** ฟังชั่น บันทึก */ function onSubmit() { dialogConfirm($q, () => { - console.log(formData) + console.log(formData); }); } @@ -78,16 +90,13 @@ watch( () => props.modal, () => { if (props.modal === true) { - ocLevelOp.value = [ - { - id: "id1", - name: "id1", - }, - { - id: "id2", - name: "id2", - }, - ]; + if (level.value === "DEPARTMENT") { + formData.orgLevel = level.value; + orgLevelOption.value = orgLevelOptionMain.value; + } else { + orgLevelOption.value = orgLevelOptionMain.value.splice(1, 4); + formData.orgLevel = ""; + } } } ); @@ -104,8 +113,8 @@ watch(
("newStructure", { required: true }); const status = defineModel("status", { required: true }); +const type = defineModel("type", { default: "NEW" }); const typeOp = ref([ { @@ -41,19 +43,25 @@ const typeOp = ref([ name: "ทำสำเนาโครงสร้าง ตำแหน่ง และคนครอง", }, ]); +const orgRevisionId = ref(""); +const orgRevisionOpMain = ref([]); +const orgRevisionOp = ref([]); const orgRevisionNameRef = ref(null); const typeRef = ref(null); +const orgRevisionIdRef = ref(null); const formData = reactive({ + orgRevisionId: "", orgRevisionName: "", - type: "", + typeDraft: "", }); /** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */ const objectRef: FormNewStructureRef = { orgRevisionName: orgRevisionNameRef, type: typeRef, + orgRevisionId: orgRevisionIdRef, }; /** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */ @@ -77,31 +85,75 @@ function validateForm() { /** ฟังชั่น บันทึก */ function onSubmit() { dialogConfirm($q, () => { - // http - // .post(config.API.createOrganization, formData) - // .then(() => { - status.value = true; - store.typeOrganizational = "draft"; - success($q, "บันทึกข้อมูลสำเร็จ"); - // }) - // .catch((err) => { - // messageError($q, err); - // }) - // .finally(() => {}); - - console.log(formData); + showLoader(); + http + .post(config.API.createOrganization, formData) + .then(() => { + status.value = true; + store.typeOrganizational = "draft"; + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(async () => { + modal.value = await false; + await close(); + await hideLoader(); + }); }); - modal.value = false; } function close() { modal.value = false; + formData.orgRevisionId = ""; + formData.orgRevisionName = ""; + formData.typeDraft = ""; +} + +async function fetchOrgRevision() { + showLoader(); + await http + .get(config.API.organizationHistoryNew) + .then((res) => { + const data = res.data.result.filter( + (e: HistoryType) => e.orgRevisionIsDraft === false + ); + if (data) { + const listOption = data.map((e: HistoryType) => ({ + id: e.orgRevisionId, + name: e.orgRevisionName, + })); + orgRevisionOpMain.value = listOption; + } + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +function filterSelector(val: any, update: Function, refData: string) { + switch (refData) { + case "orgRevisionId": + update(() => { + orgRevisionOp.value = orgRevisionOpMain.value.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + default: + break; + } } watch( () => modal.value, () => { - modal.value && !status.value && (formData.type = "NEW"); + modal.value && (formData.typeDraft = type.value); + modal.value && type.value !== "NEW" && fetchOrgRevision(); } ); @@ -131,7 +183,7 @@ watch( +
+ + + +
diff --git a/src/modules/02_organizationalNew/components/mainTree.vue b/src/modules/02_organizationalNew/components/mainTree.vue index 1ad991898..4846cb152 100644 --- a/src/modules/02_organizationalNew/components/mainTree.vue +++ b/src/modules/02_organizationalNew/components/mainTree.vue @@ -64,6 +64,7 @@ const expanded = ref>([]); const notFound = ref("ไม่พบข้อมูลที่ค้นหา"); const noData = ref("ไม่มีข้อมูล"); const selected = ref(""); +const orgLevel = ref(""); const filterData = (node: any, filter: string) => { // ให้ทาง API ค้นหาให้ @@ -225,8 +226,9 @@ function searchAndReplace( } const dialogAgency = ref(false); -function onClickAgency() { +function onClickAgency(level: string) { dialogAgency.value = !dialogAgency.value; + orgLevel.value = level; } watch( @@ -277,7 +279,7 @@ onMounted(async () => { round color="primary" icon="add" - @click="onClickAgency" + @click="onClickAgency('DEPARTMENT')" > เพิ่มหน่วยงาน @@ -347,6 +349,8 @@ onMounted(async () => { @click=" item.val === 'EDIT' ? edit(prop.node.organizationId) + : item.val === 'ADD' + ? onClickAgency('TEST') : null " > @@ -370,7 +374,12 @@ onMounted(async () => { - + + diff --git a/src/modules/02_organizationalNew/interface/index/Main.ts b/src/modules/02_organizationalNew/interface/index/Main.ts index 37302deba..b5f3da8a3 100644 --- a/src/modules/02_organizationalNew/interface/index/Main.ts +++ b/src/modules/02_organizationalNew/interface/index/Main.ts @@ -8,36 +8,37 @@ interface DataOption { } interface FormDataAgency { - ocName: string - shortName: string - ocNo: string - ocLevel: string - telOut: string - telIn: string - tel: string + orgName: string; + orgShortName: string; + orgCode: string; + orgPhoneEx: string; + orgPhoneIn: string; + orgFax: string; + orgRevisionId: string; + orgLevel: string; } interface FormDataPosition { - prefixNo: string - positionNo: string - suffixNo: string - confirm: boolean + prefixNo: string; + positionNo: string; + suffixNo: string; + confirm: boolean; } interface FormDataNewStructure { - orgRevisionName: string - type: string - + orgRevisionId: string; + orgRevisionName: string; + typeDraft: string; } interface FormAgencyRef { - ocName: object | null; - shortName: object | null; - ocNo: object | null; - ocLevel: object | null; - telOut: object | null; - telIn: object | null; - tel: object | null; + orgName: object | null; + orgShortName: object | null; + orgCode: object | null; + orgPhoneEx: object | null; + orgPhoneIn: object | null; + orgFax: object | null; + orgLevel: object | null; [key: string]: any; } @@ -54,26 +55,27 @@ interface FormDateTimeRef { interface FormNewStructureRef { orgRevisionName: object | null; + orgRevisionId: object | null; type: object | null; [key: string]: any; } interface HistoryType { - orgRevisionId: string - orgRevisionName: string - orgRevisionIsCurrent: boolean - orgRevisionIsDraft: boolean - orgRevisionCreatedAt: any + orgRevisionId: string; + orgRevisionName: string; + orgRevisionIsCurrent: boolean; + orgRevisionIsDraft: boolean; + orgRevisionCreatedAt: any; } -export type { - Pagination, - DataOption, - FormDataAgency, - FormDataPosition, - FormAgencyRef, - FormPositionRef, - FormDateTimeRef, - FormDataNewStructure, - FormNewStructureRef, - HistoryType +export type { + Pagination, + DataOption, + FormDataAgency, + FormDataPosition, + FormAgencyRef, + FormPositionRef, + FormDateTimeRef, + FormDataNewStructure, + FormNewStructureRef, + HistoryType, }; diff --git a/src/modules/02_organizationalNew/store/organizational.ts b/src/modules/02_organizationalNew/store/organizational.ts index 303455ecb..efa6b313b 100644 --- a/src/modules/02_organizationalNew/store/organizational.ts +++ b/src/modules/02_organizationalNew/store/organizational.ts @@ -1,12 +1,27 @@ import { defineStore } from "pinia"; import { ref } from "vue"; +/** importType*/ +import type { DataActive } from "@/modules/02_organizationalNew/interface/response/organizational"; + export const useOrganizational = defineStore("organizationalStore", () => { const typeOrganizational = ref("current"); const statusView = ref("list"); + const dataActive = ref(); + const activeId = ref(); + const draftId = ref(); + function fetchDataActive(data: DataActive) { + activeId.value = data.activeId; + draftId.value = data.draftId; + dataActive.value = data; + } + return { typeOrganizational, statusView, + + // + fetchDataActive, }; }); diff --git a/src/modules/02_organizationalNew/views/main.vue b/src/modules/02_organizationalNew/views/main.vue index 9efce0243..0e4525231 100644 --- a/src/modules/02_organizationalNew/views/main.vue +++ b/src/modules/02_organizationalNew/views/main.vue @@ -5,7 +5,6 @@ import http from "@/plugins/http"; import config from "@/app.config"; /** importType*/ -import type { DataActive } from "@/modules/02_organizationalNew/interface/response/organizational"; /** importComponents*/ import ListView from "@/modules/02_organizationalNew/components/listView.vue"; @@ -37,62 +36,57 @@ const itemStructure = ref([ name: "สร้างใหม่", }, { - val: "STRUCTURE", + val: "ORG", name: "ทำสำเนาเฉพาะโครงสร้าง", }, { - val: "STRUCTUREANDPOSITION", + val: "ORG_POSITION", name: "ทำสำเนาโครงสร้างและตำแหน่ง", }, { - val: "STRUCTUREANDPOSITION", + val: "ORG_POSITION_PERSON", name: "ทำสำเนาโครงสร้าง ตำแหน่งและคนครอง", }, ]); -const dataActive = ref(); async function fetchOrganizationActive() { - const data = { - activeId: null, - activeName: "null", - draftId: null, - draftName: null, - }; - - // dataActive.value = data; - showLoader(); await http .get(config.API.activeOrganization) .then((res) => { - console.log(res); - // if (data) { - // if (data.activeName === null && data.draftName === null) { - // isStatusData.value = false; - // } else { - // isStatusData.value = true; - // } - // if (isStatusData.value) { - // if (data.activeName === null) { - // ishasActive.value = true; - // stroe.typeOrganizational = "draft"; - // } else if (data.draftName === null) { - // ishasDraft.value = true; - // stroe.typeOrganizational = "current"; - // } - - // } - // } + const data = res.data.result; + if (data) { + stroe.fetchDataActive(data); + if (data.activeName === null && data.draftName === null) { + isStatusData.value = false; + } else { + isStatusData.value = true; + if (isStatusData.value) { + if (data.activeName === null) { + ishasActive.value = true; + stroe.typeOrganizational = "draft"; + } else if (data.draftName === null) { + ishasDraft.value = true; + stroe.typeOrganizational = "current"; + } + } + } + } }) .catch((err) => { messageError($q, err); - console.log(err); }) .finally(() => { hideLoader(); }); } +const typeStructure = ref(""); +function ocClickAddStructure(type: string) { + modalNewStructure.value = !modalNewStructure.value; + typeStructure.value = type; +} + const modalDateTime = ref(false); function onClickDateTime() { modalDateTime.value = !modalDateTime.value; @@ -151,7 +145,7 @@ onMounted(async () => { color="primary" size="lg" icon="add" - @click="modalNewStructure = true" + @click="ocClickAddStructure('NEW')" > เพิ่มโครงสร้าง @@ -189,6 +183,7 @@ onMounted(async () => { v-close-popup v-for="(item, index) in itemStructure" :key="index" + @click="ocClickAddStructure(item.val)" > {{ item.name }} @@ -236,10 +231,13 @@ onMounted(async () => { + + diff --git a/src/router/index.ts b/src/router/index.ts index 79f5de822..c5c42cd98 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -19,6 +19,7 @@ import ModuleOrder from "@/modules/10_order/router"; import ModuleLeave from "@/modules/09_leave/router"; import ModuleDiscipline from "@/modules/11_discipline/router"; import ModuleEvaluate from "@/modules/12_evaluatePersonal/router"; +import ModuleSupport from "@/modules/00_support/router"; // TODO: ใช้หรือไม่? import keycloak from "@/plugins/keycloak"; @@ -56,6 +57,7 @@ const router = createRouter({ ...ModuleLeave, ...ModuleDiscipline, ...ModuleEvaluate, + ...ModuleSupport, ], }, /**