diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index f63a60e0f..b5371a1f9 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -4,6 +4,8 @@ const organization = `${env.API_URI}/org`; const orgPos = `${env.API_URI}/org/pos`; const orgProfile = `${env.API_URI}/org/profile`; const orgEmployeePos = `${env.API_URI}/org/employee/pos`; +const orgAct = `${env.API_URI}/org/act`; +const orgPosAct = `${env.API_URI}/org/pos/act`; export default { keycloakPosition: () => `${organization}/profile/keycloak/position`, @@ -100,4 +102,8 @@ export default { changePositionByIdProfile: `${organization}/placement/change-position/profile`, orgProfileReport: `${orgProfile}-employee/report`, + + /** รักษาการตำแหน่ง*/ + orgAct, + orgPosAct, }; diff --git a/src/modules/17_acting/interface/index/Main.ts b/src/modules/17_acting/interface/index/Main.ts new file mode 100644 index 000000000..46133c9b9 --- /dev/null +++ b/src/modules/17_acting/interface/index/Main.ts @@ -0,0 +1,10 @@ +interface Pagination { + rowsPerPage: number; +} + +interface DataOption { + id: string; + name: string; +} + +export type { Pagination, DataOption }; diff --git a/src/modules/17_acting/interface/request/Main.ts b/src/modules/17_acting/interface/request/Main.ts new file mode 100644 index 000000000..e4ea7770c --- /dev/null +++ b/src/modules/17_acting/interface/request/Main.ts @@ -0,0 +1 @@ +export type {}; diff --git a/src/modules/17_acting/interface/response/Main.ts b/src/modules/17_acting/interface/response/Main.ts new file mode 100644 index 000000000..8a8c012be --- /dev/null +++ b/src/modules/17_acting/interface/response/Main.ts @@ -0,0 +1,35 @@ +interface DataTree { + labelName: string; + orgCode: string; + orgLevel: 0; + orgName: string; + orgRootName: string; + orgTreeCode: string; + orgTreeId: string; + orgTreeName: string; + orgTreeShortName: string; + children: DataTree[]; + posMaster: PosMaster[]; +} + +interface PosMaster { + fullNameCurrentHolder: string; + orgLevel: number; + orgTreeId: string; + posmasterId: string; +} + +interface ListPerson { + citizenId: string; + firstName: string; + id: string; + lastName: string; + posLevel: string; + posNo: string; + posType: string; + position: string; + prefix: string; + posMasterOrder?: string; +} + +export type { DataTree, PosMaster, ListPerson }; diff --git a/src/modules/17_acting/views/main.vue b/src/modules/17_acting/views/main.vue index 191a1a463..7fc257311 100644 --- a/src/modules/17_acting/views/main.vue +++ b/src/modules/17_acting/views/main.vue @@ -6,26 +6,25 @@ import config from "@/app.config"; /** importType*/ import type { QTableProps } from "quasar"; +import type { + DataTree, + PosMaster, + ListPerson, +} from "@/modules/17_acting/interface/response/Main"; /** importStore*/ import { useCounterMixin } from "@/stores/mixin"; /** use*/ const $q = useQuasar(); -const { - showLoader, - hideLoader, - messageError, - dialogConfirm, - dialogRemove, - success, -} = useCounterMixin(); +const { showLoader, hideLoader, messageError, dialogRemove } = + useCounterMixin(); /** โครงสร้าง*/ const expanded = ref>([]); const filter = ref(""); -const nodeTree = ref([]); -const nodeId = ref(""); +const nodeTree = ref([]); +const posmasterId = ref(""); /** function เรียกข้อมูลโครงสร้าง แบบปัจุบัน*/ function fetchOrganizationActive() { @@ -51,23 +50,10 @@ function fetchOrganizationActive() { function fetchOrganization(id: string) { showLoader(); http - .get(config.API.orgByid(id.toString())) + .get(config.API.orgAct + `/${id}`) .then((res) => { const data = res.data.result; - nodeTree.value = data.map((e: any) => ({ - ...e, - owner: [ - { - name: "นางอัจฉรา ศรีปริวาทิน", - pos: "หัวหน้า", - }, - { - name: "นางศรีปริวาทิน", - pos: "รองหัวหน้า", - }, - ], - })); - console.log(nodeTree.value); + nodeTree.value = data; }) .catch((err) => { messageError($q, err); @@ -77,133 +63,20 @@ function fetchOrganization(id: string) { }); } -function updateSelected(data: any) { - nodeId.value = data; +async function updateSelected(data: PosMaster) { + posmasterId.value = data.posmasterId; + await Promise.all([fetchPosMaster(), fetchListAct()]); } /** ตำแหน่ง*/ -const rowPosition = ref([ - { - id: "1", - posMasterNo: "สกก.1", - positionName: "นักบริหาร", - posTypeName: "บริหาร", - posLevelName: "สูง", - positionIsSelected: "นางอัจฉรา ศรีปริวาทิน", - }, - { - id: "2", - posMasterNo: "สกก.1", - positionName: "นักบริหาร", - posTypeName: "บริหาร", - posLevelName: "สูง", - positionIsSelected: "นางศรีปริวาทิน", - }, - { - id: "3", - posMasterNo: "สกก.1", - positionName: "นักบริหาร", - posTypeName: "บริหาร", - posLevelName: "สูง", - positionIsSelected: "นางอัจฉรา ศรีปริวาทิน", - }, -]); -const columnsPosition = ref([ +const rowPosition = ref([]); +const columns = ref([ { name: "no", align: "left", label: "ลำดับ", sortable: false, - field: (row) => rowPosition.value.indexOf(row) + 1, - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "posMasterNo", - align: "left", - label: "เลขที่ตำแหน่ง", - sortable: false, - field: "posMasterNo", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "positionName", - align: "left", - label: "ตำแหน่งในสายงาน", - field: "positionName", - sortable: false, - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "posTypeName", - align: "left", - label: "ประเภทตำแหน่ง", - sortable: false, - field: "posTypeName", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "posLevelName", - align: "left", - label: "ระดับตำแหน่ง", - sortable: false, - field: "posLevelName", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "positionIsSelected", - align: "left", - label: "คนครอง", - sortable: false, - field: "positionIsSelected", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, -]); - -const reqMaster = reactive({ - isAll: false, - keyword: "", -}); - -function selectPosition(data: any) { - const test = rowPosition.value.filter((e) => e.id !== data.id); - rowListPerson.value.push(data); - rowPosition.value = test; -} - -/** รายชื่อคนรักษาการ*/ -const rowListPerson = ref([ - { - id: "1", - citizenId: "1101700019241", - name: "เรือตรีพนัส บิณศิรวานิช", - posMasterNo: "สพข.54", - positionName: "นายแพทย์", - posTypeName: "ทั่วไป", - posLevelName: "สูง", - }, - { - id: "2", - citizenId: "1101700019241", - name: "เรือตรีพนัส บิณศิรวานิช", - posMasterNo: "สพข.54", - positionName: "นายแพทย์", - posTypeName: "ทั่วไป", - posLevelName: "สูง", - }, -]); -const columnsPerson = ref([ - { - name: "no", - align: "left", - label: "ลำดับ", - sortable: false, - field: (row) => rowListPerson.value.indexOf(row) + 1, + field: "no", headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -220,60 +93,145 @@ const columnsPerson = ref([ name: "name", align: "left", label: "ชื่อ-นามสกุล", - field: "name", + field(row) { + return `${row.prefix}${row.firstName} ${row.lastName}`; + }, sortable: false, headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "posMasterNo", + name: "posNo", align: "left", label: "ตำแหน่งเลขที่", sortable: false, - field: "posMasterNo", + field: "posNo", headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "positionName", + name: "position", align: "left", label: "ตำแหน่งในสายงาน", sortable: false, - field: "positionName", + field: "position", headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "posTypeName", + name: "posType", align: "left", label: "ตำแหน่งประเภท", sortable: false, - field: "posTypeName", + field: "posType", headerStyle: "font-size: 14px", style: "font-size: 14px", }, { - name: "posLevelName", + name: "posLevel", align: "left", label: "ระดับ", sortable: false, - field: "posLevelName", + field: "posLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", }, ]); +const keyword = ref(""); -function onSwapPerson(type: string, id: string) {} - -function onDelete(id: string) { - dialogRemove($q, () => { - const test = rowListPerson.value.filter((e: any) => e.id !== id); - rowListPerson.value = test; - }); +/** function fetch รายชื่อ*/ +function fetchPosMaster() { + showLoader(); + http + .post(config.API.orgPosAct + `/search`, { posmasterId: posmasterId.value }) + .then((res) => { + const data = res.data.result; + rowPosition.value = data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); } -function onSubmit() { - dialogConfirm($q, () => {}); +/** + * function เลือกราชชื่อรักษาการ + * @param data ข้อมูลรายชื่อ + */ +function selectPosition(data: ListPerson) { + showLoader(); + http + .post(config.API.orgPosAct, { + posMasterId: posmasterId.value, + posMasterChildId: data.id, + }) + .then(async () => { + await Promise.all([fetchPosMaster(), fetchListAct()]); + }) + .catch((err) => { + messageError($q, err); + hideLoader(); + }); +} + +/** รายชื่อคนรักษาการ*/ +const rowListPerson = ref([]); +const keywordAct = ref(""); + +/** function fetch รายชื่อรักษาการ */ +function fetchListAct() { + showLoader(); + http + .get(config.API.orgPosAct + `/${posmasterId.value}`) + .then((res) => { + const data = res.data.result; + rowListPerson.value = data; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +/** + * funcion เลือกลำดับรายชื่อรักษาการ + * @param type up,down + * @param id รายชื่อรักษาการ + */ +function onSwapPerson(type: string, id: string) { + showLoader(); + http + .get(config.API.orgPosAct + `/swap/${type}/${id}`) + .then(() => { + fetchListAct(); + }) + .catch((err) => { + messageError($q, err); + hideLoader(); + }); +} + +/** + * function ลบรายชื่อรักษาการ + * @param id ชื่อรักษาการ + */ +function onDelete(id: string) { + dialogRemove($q, () => { + showLoader(); + http + .delete(config.API.orgPosAct + `/${id}`) + .then(async () => { + await Promise.all([fetchPosMaster(), fetchListAct()]); + }) + .catch((err) => { + messageError($q, err); + hideLoader(); + }); + }); } onMounted(() => { @@ -286,99 +244,96 @@ onMounted(() => { รักษาการในตำแหน่ง - - - -
- - - -
-
- - - + + +
+
- -
-
- -
- รายชื่อ -
-
-
-
- - -
-
- -
-
- - - -
-
-
-
- - - - - -
+
-
-
-
- -
- รายชื่อรักษาการ -
-
-
-
- - -
-
- - - -
-
-
-
-
- - - - - -
-
-
-
+
+
- +
+ +
+ รายชื่อรักษาการ +
+
+
+
+ + +
+
+ + + +
+
+
+
+
+ + + + + +
+
+
+
+ - - +