From ce8fa1afb261773fea79824b37f89c87f52ae1d8 Mon Sep 17 00:00:00 2001 From: oat_dev Date: Mon, 18 Mar 2024 12:05:34 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A0=E0=B8=97?= =?UTF-8?q?=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= =?UTF-8?q?:=20=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=E0=B9=81=E0=B8=81?= =?UTF-8?q?=E0=B9=89=E0=B9=84=E0=B8=82=E0=B8=AA=E0=B9=88=E0=B8=87=E0=B8=84?= =?UTF-8?q?=E0=B9=88=E0=B8=B2=E0=B8=9C=E0=B8=B4=E0=B8=94,=E0=B9=81?= =?UTF-8?q?=E0=B8=81=E0=B9=89Get?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 1 + .../components/position/05ListLevelDetail.vue | 43 ++++++++----------- .../stores/positionListStore.ts | 4 +- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 6dc129465..713897f19 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -22,6 +22,7 @@ export default { orgPosPositionById: (id: string) => `${orgPos}/position/${id}`, orgPosExecutive: `${orgPos}/executive`, orgPosType: `${orgPos}/type`, + orgPosTypeId: (id: string) => `${orgPos}/type/${id}`, orgPosLevel: `${orgPos}/level`, orgPosMaster: `${orgPos}/master`, orgPosMasterById: (id: string) => `${orgPos}/master/${id}`, diff --git a/src/modules/01_metadataNew/components/position/05ListLevelDetail.vue b/src/modules/01_metadataNew/components/position/05ListLevelDetail.vue index 318976a30..514d7f5ee 100644 --- a/src/modules/01_metadataNew/components/position/05ListLevelDetail.vue +++ b/src/modules/01_metadataNew/components/position/05ListLevelDetail.vue @@ -2,7 +2,7 @@ import { ref, onMounted } from "vue"; import type { QInput, QTableProps } from "quasar"; import { useCounterMixin } from "@/stores/mixin"; -import { useRouter, useRoute } from "vue-router"; +import { useRoute } from "vue-router"; import { usePositionDataStore } from "@/modules/01_metadataNew/stores/positionListStore"; import { useMainOptionDataStore } from "@/modules/01_metadataNew/stores/main"; import { usePositionTypeDataStore } from "@/modules/01_metadataNew/stores/positionTypeStore"; @@ -133,6 +133,7 @@ const posLevelAuthority = ref(""); const posLevelNameRef = ref(null); const posLevelRankRef = ref(null); const posTypeIdRef = ref(null); +const posLevelAuthorityRef = ref(null); const visibleColumns = ref([ "no", "posTypeName", @@ -144,9 +145,10 @@ const visibleColumns = ref([ async function fetchData() { showLoader(); await http - .get(config.API.orgPosLevel) + .get(config.API.orgPosTypeId(id.value)) .then(async (res) => { - store.save(res.data.result, id.value); + posName.value = res.data.result.posTypeName; + store.save(res.data.result.posLevels); }) .catch((err) => { messageError($q, err); @@ -221,6 +223,7 @@ function validateForm() { posLevelNameRef.value?.validate(); posLevelRankRef.value?.validate(); posTypeIdRef.value?.validate(); + posLevelAuthorityRef.value?.validate(); onSubmit(); } @@ -238,28 +241,7 @@ async function onSubmit() { } } -async function fetchName() { - showLoader(); - await http - .get(config.API.orgPosType) - .then(async (res) => { - storeName.save(res.data.result); - storeName.row.forEach((e) => { - if (e.id === id.value) { - posName.value = e.posTypeName ? e.posTypeName : ""; - } - }); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} - onMounted(async () => { - fetchName(); fetchData(); }); @@ -348,11 +330,18 @@ onMounted(async () => { @click.stop=" () => { dialogStatus = 'edit'; - dialog = true; editId = props.row.id; posLevelName = props.row.posLevelName; posLevelRank = props.row.posLevelRank; - posLevelAuthority = props.row.posLevelAuthority; + if (props.row.posLevelAuthority === 'หัวหน้าหน่วยงาน') { + posLevelAuthority = 'HEAD'; + } else if (props.row.posLevelAuthority === 'ปลัด') { + posLevelAuthority = 'DEPUTY'; + } else { + posLevelAuthority = 'GOVERNOR'; + } + + dialog = true; } " > @@ -424,6 +413,7 @@ onMounted(async () => {
{ label="ผู้มีอำนาจสั่งบรรจุ" dense lazy-rules + :rules="[(val) => !!val || 'กรุณาเลือกผู้มีอำนาจสั่งบรรจุ']" borderless bg-color="white" hide-bottom-space diff --git a/src/modules/01_metadataNew/stores/positionListStore.ts b/src/modules/01_metadataNew/stores/positionListStore.ts index c61f8ac74..8c039313c 100644 --- a/src/modules/01_metadataNew/stores/positionListStore.ts +++ b/src/modules/01_metadataNew/stores/positionListStore.ts @@ -13,7 +13,7 @@ const { date2Thai } = useCounterMixin(); export const usePositionDataStore = defineStore("PositionData", () => { const pathLocation = ref("list_position"); const row = ref([]); - function save(data: DataResponse[], id: string) { + function save(data: DataResponse[]) { const list = data.map((e) => ({ ...e, posTypes: undefined, @@ -26,7 +26,7 @@ export const usePositionDataStore = defineStore("PositionData", () => { ? storeOption.posLevelAuthorityConvert(e.posLevelAuthority) : "-", })) satisfies DataRow[]; - row.value = list.filter((e) => e.posTypeId === id); + row.value = list; } return {