diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index 6dc129465..b497f4431 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -20,8 +20,10 @@ export default { /** position*/ orgPosPosition: `${orgPos}/position`, orgPosPositionById: (id: string) => `${orgPos}/position/${id}`, + orgPosPositionExecutive : () => `${orgPos}/position/executive`, 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/components/position/DialogAddPosition.vue b/src/modules/01_metadataNew/components/position/DialogAddPosition.vue index 8b3f1579b..7fa58c25f 100644 --- a/src/modules/01_metadataNew/components/position/DialogAddPosition.vue +++ b/src/modules/01_metadataNew/components/position/DialogAddPosition.vue @@ -288,19 +288,6 @@ function close() { :rules="[(val) => !!val || `${'กรุณากรอกตำแหน่งในสายงาน'}`]" />
-
- -
-
-
+
+ +
- +
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 { diff --git a/src/modules/02_organizationalNew/components/DialogAddPosition.vue b/src/modules/02_organizationalNew/components/DialogAddPosition.vue index d28cd7d03..7547f7d90 100644 --- a/src/modules/02_organizationalNew/components/DialogAddPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogAddPosition.vue @@ -23,7 +23,9 @@ import type { DataPosition, } from "@/modules/02_organizationalNew/interface/response/organizational"; +const posExecutive = ref(""); const isSpecial = ref(false); +const shape = ref("false"); const props = defineProps({ emitSearch: Function, getData: Function, @@ -109,19 +111,33 @@ function saveSelectEdit() { dialogConfirm( $q, async () => { + const dataExecutive = shape.value == "false" ? formPositionSelect.positionExecutive:posExecutive.value + const url = + shape.value == "false" + ? config.API.orgPosPositionById(formPositionSelect.positionId) + : config.API.orgPosPositionExecutive()+`/${formPositionSelect.positionId}`; showLoader(); - const body = { + const body = shape.value == "false" ?{ posDictName: formPositionSelect.positionName, posDictField: formPositionSelect.positionField, //สายงาน posTypeId: formPositionSelect.positionType, //*ประเภทตำแหน่ง posLevelId: formPositionSelect.positionLevel, //*ระดับตำแหน่ง - posExecutiveId: formPositionSelect.positionExecutive, //ตำแหน่งทางการบริหาร + posExecutiveId: dataExecutive, //ตำแหน่งทางการบริหาร posDictExecutiveField: formPositionSelect.positionExecutiveField, //ด้านทางการบริหาร posDictArea: formPositionSelect.positionArea, //ด้าน/สาขา isSpecial: isSpecial.value, - }; + }:{ + posDictName: formPositionSelect.positionName, + posDictField: formPositionSelect.positionField, //สายงาน + posTypeId: formPositionSelect.positionType, //*ประเภทตำแหน่ง + posLevelId: formPositionSelect.positionLevel, //*ระดับตำแหน่ง + posExecutive: dataExecutive, //ตำแหน่งทางการบริหาร + posDictExecutiveField: formPositionSelect.positionExecutiveField, //ด้านทางการบริหาร + posDictArea: formPositionSelect.positionArea, //ด้าน/สาขา + isSpecial: isSpecial.value, + } await http - .put(config.API.orgPosPositionById(formPositionSelect.positionId), body) + .put(url, body) .then(() => { success($q, "เพิ่มข้อมูลสำเร็จ"); @@ -145,19 +161,33 @@ function onSubmitSelectEdit() { dialogConfirm( $q, async () => { + const dataExecutive = shape.value == "false" ? formPositionSelect.positionExecutive:posExecutive.value + const url = + shape.value == "false" + ? config.API.orgPosPosition + : config.API.orgPosPositionExecutive(); showLoader(); - const body = { + const body = shape.value == "false" ?{ posDictName: formPositionSelect.positionName, posDictField: formPositionSelect.positionField, //สายงาน posTypeId: formPositionSelect.positionType, //*ประเภทตำแหน่ง posLevelId: formPositionSelect.positionLevel, //*ระดับตำแหน่ง - posExecutiveId: formPositionSelect.positionExecutive, //ตำแหน่งทางการบริหาร + posExecutiveId: dataExecutive, //ตำแหน่งทางการบริหาร posDictExecutiveField: formPositionSelect.positionExecutiveField, //ด้านทางการบริหาร posDictArea: formPositionSelect.positionArea, //ด้าน/สาขา isSpecial: isSpecial.value, - }; + }:{ + posDictName: formPositionSelect.positionName, + posDictField: formPositionSelect.positionField, //สายงาน + posTypeId: formPositionSelect.positionType, //*ประเภทตำแหน่ง + posLevelId: formPositionSelect.positionLevel, //*ระดับตำแหน่ง + posExecutive: dataExecutive, //ตำแหน่งทางการบริหาร + posDictExecutiveField: formPositionSelect.positionExecutiveField, //ด้านทางการบริหาร + posDictArea: formPositionSelect.positionArea, //ด้าน/สาขา + isSpecial: isSpecial.value, + } await http - .post(config.API.orgPosPosition, body) + .post(url, body) .then(() => { success($q, "เพิ่มข้อมูลสำเร็จ"); @@ -314,20 +344,6 @@ watch( " /> -
- -
-
-
+
+ + +
+ +
+
+
- +
diff --git a/src/modules/02_organizationalNew/components/DialogFormPosition.vue b/src/modules/02_organizationalNew/components/DialogFormPosition.vue index f74c1b2ed..7ec039b5e 100644 --- a/src/modules/02_organizationalNew/components/DialogFormPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogFormPosition.vue @@ -377,7 +377,7 @@ function onSubmit() { }; showLoader(); - props.actionType === "ADD" + props.actionType === "ADD" || props.actionType === "COPY" ? await http .post(config.API.orgPosMaster, body) .then(() => { diff --git a/src/modules/02_organizationalNew/components/TreeTable.vue b/src/modules/02_organizationalNew/components/TreeTable.vue index 005c7af5a..37946bc5c 100644 --- a/src/modules/02_organizationalNew/components/TreeTable.vue +++ b/src/modules/02_organizationalNew/components/TreeTable.vue @@ -74,6 +74,12 @@ const listMenu = ref([ type: "EDIT", color: "edit", }, + { + label: "คัดลอก", + icon: "content_copy", + type: "COPY", + color: "blue-6", + }, { label: "ลบ", icon: "delete", @@ -259,6 +265,12 @@ function onClickPosition(type: string, id: string) { dialogPosition.value = !dialogPosition.value; } +function onClickCopyPosition(type: string, id: string) { + rowId.value = id ? id : ""; + actionType.value = type; + dialogPosition.value = !dialogPosition.value; +} + const dialogDetail = ref(false); const dataDetailPos = ref([]); /** @@ -650,6 +662,8 @@ async function onClickDownloadReport(val: string, name: string) { ? onClickHistoryPos(props.row.id) : item.type === 'INHERIT' ? onClickInherit(props.row.id) + : item.type === 'COPY' + ? onClickCopyPosition('COPY', props.row.id) : null " >