diff --git a/src/modules/02_organizationalNew/components/DialogFormPosition.vue b/src/modules/02_organizationalNew/components/DialogFormPosition.vue index 301a281c7..094eaac52 100644 --- a/src/modules/02_organizationalNew/components/DialogFormPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogFormPosition.vue @@ -351,7 +351,7 @@ function onSubmit() { posTypeId: e.posTypeId, //*ประเภทตำแหน่ง posLevelId: e.posLevelId, //*ระดับตำแหน่ง posExecutiveId: e.posExecutiveId, //ตำแหน่งทางการบริหาร - posDictExecutiveField: e.positionName, //ด้านทางการบริหาร + posDictExecutiveField: e.positionExecutiveField, //ด้านทางการบริหาร posDictArea: e.positionArea, //ด้าน/สาขา })); const body = { @@ -366,6 +366,7 @@ function onSubmit() { positions: positionsData, // succession: succession.value, }; + showLoader(); props.actionType === "ADD" ? await http @@ -446,7 +447,6 @@ function onSubmit() { /** input ค้นหา */ const searchRef = ref(null); async function searchInput() { - console.log(1); searchRef.value.validate(); if (!searchRef.value.hasError) { showLoader(); @@ -524,7 +524,8 @@ function addPosition(data: RowDetailPositions) { const isIdExist = rows.value.some((item: any) => item.id === data.id); if (!isIdExist) { - rows.value = [data, ...rows.value]; + // rows.value = [data, ...rows.value]; + rows.value.push(data); } } @@ -635,6 +636,7 @@ async function emitSearch(keyword: string, typeSelect: string) { lazy-rules hide-bottom-space :rules="[(val) => !!val || `${'กรุณากรอกเลขที่ตำแหน่ง'}`]" + mask="########################" />
diff --git a/src/modules/02_organizationalNew/components/DialogMovePos.vue b/src/modules/02_organizationalNew/components/DialogMovePos.vue index 4fb410553..4feda6af2 100644 --- a/src/modules/02_organizationalNew/components/DialogMovePos.vue +++ b/src/modules/02_organizationalNew/components/DialogMovePos.vue @@ -51,9 +51,13 @@ const props = defineProps({ type: String, required: true, }, + mainTree: { + type: Object, + required: true, + }, }); -const title = ref("ย้ายตำแหน่ง"); +const title = ref("ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน"); const filterTree = ref(""); const filterRef = ref(); const selectedTree = ref(""); @@ -116,60 +120,11 @@ function onClickMovePos() { } } -/** - * function fetch ข้อรายการตำแหน่ง - * @param id idTree - * @param level levelTree - */ -async function fetchDataTable(id: string, level: number, action: boolean) { - // orgLevel.value = level; - // reqMaster.id = id; - // reqMaster.type = level; - // action1.value = action; - // if (action) { - // setTimeout(() => { - // action1.value = false; - // }, 1000); - // reqMaster.isAll = false; - // reqMaster.page = 1; - // reqMaster.pageSize = 10; - // reqMaster.keyword = ""; - // } - // if (action === true) { - // isLoad.value = true; - // } - // await http - // .post(config.API.orgPosMasterList, reqMaster) - // .then((res) => { - // posMaster.value = []; - // const dataMain: PosMaster[] = []; - // totalPage.value = Math.ceil(res.data.result.total / reqMaster.pageSize); - // res.data.result.data.forEach((e: PosMaster) => { - // const p = e.positions; - // if (p.length !== 0) { - // const a = p.find((el: Position) => el.positionIsSelected === true); - // const { id, ...rest } = a ? a : p[0]; - // const test = { ...e, ...rest }; - // dataMain.push(test); - // } - // }); - // posMaster.value = store.fetchPosMaster(dataMain); - // }) - // .catch((err) => { - // messageError($q, err); - // posMaster.value = []; - // }) - // .finally(() => { - // setTimeout(() => { - // isLoad.value = false; - // }, 500); - // }); -} - watch( () => modal.value, () => { reqMaster.value.page = 1; + title.value = `ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน ${props.mainTree.orgName}`; if (modal.value && props.type === "SINGER") { const data = rows.value.filter((e: PosMaster2) => e.id === props.rowId); selectedFilter.value = data; diff --git a/src/modules/02_organizationalNew/components/TreeTable.vue b/src/modules/02_organizationalNew/components/TreeTable.vue index 327ae0d14..419afb5ae 100644 --- a/src/modules/02_organizationalNew/components/TreeTable.vue +++ b/src/modules/02_organizationalNew/components/TreeTable.vue @@ -3,7 +3,7 @@ import { ref } from "vue"; import { useQuasar } from "quasar"; import config from "@/app.config"; import http from "@/plugins/http"; -import genReport from "@/plugins/genreport"; +import genreport from "@/plugins/genreportxlsx"; /** importType*/ import type { QTableProps } from "quasar"; @@ -12,7 +12,10 @@ import type { NewPagination, } from "@/modules/02_organizationalNew/interface/index/Main"; import type { FilterMaster } from "@/modules/02_organizationalNew/interface/request/organizational"; -import type { PosMaster2 } from "@/modules/02_organizationalNew/interface/response/organizational"; +import type { + PosMaster2, + OrgTree, +} from "@/modules/02_organizationalNew/interface/response/organizational"; import type { DataPosition } from "@/modules/02_organizationalNew/interface/index/organizational"; /** importComponents*/ @@ -52,6 +55,10 @@ const props = defineProps({ require: true, default: () => {}, }, + mainTree: { + type: Object, + require: true, + }, }); const modalSelectPerson = ref(false); @@ -396,14 +403,14 @@ function getSummary() { } /** function DownloadReport*/ -async function onClickDownloadReport(val: string) { +async function onClickDownloadReport(val: string, name: string) { showLoader(); await http .get(config.API.orgReport(val)) .then((res) => { const data = res.data.result; if (data) { - genReport(data, "name"); + genreport(data, name); } }) .catch((err) => { @@ -462,7 +469,7 @@ async function onClickDownloadReport(val: string) { {{ item.name }} @@ -774,6 +781,7 @@ async function onClickDownloadReport(val: string) { :fetchDataTree="props.fetchDataTree" :type="typeMove" :rowId="rowId" + :mainTree="props.mainTree ? props.mainTree : []" /> diff --git a/src/modules/02_organizationalNew/components/TreeView.vue b/src/modules/02_organizationalNew/components/TreeView.vue index 770e778a1..3f6f42ec5 100644 --- a/src/modules/02_organizationalNew/components/TreeView.vue +++ b/src/modules/02_organizationalNew/components/TreeView.vue @@ -35,6 +35,7 @@ const nodeId = ref(""); // id ของ Tree const orgLevel = ref(0); // levelTree const isLoad = ref(false); // loadTable const isLoadTree = ref(false); // loadTable +const mainTree = ref(); const selected = ref(""); @@ -79,6 +80,7 @@ async function fetchDataTree(id: string) { * @param level levelTree */ async function fetchDataTable(id: string, level: number, action: boolean) { + mainTree.value = nodeTree.value?.find((e) => e.orgTreeId === id); orgLevel.value = level; reqMaster.id = id; reqMaster.type = level; @@ -291,6 +293,7 @@ watch( v-model:reqMaster="reqMaster" v-model:totalPage="totalPage" v-model:posMaster="posMaster" + :mainTree="mainTree" :fetchDataTable="fetchDataTable" :filterKeyword="filterKeyword" :fetchDataTree="fetchDataTree" diff --git a/src/plugins/genreportxlsx.ts b/src/plugins/genreportxlsx.ts new file mode 100644 index 000000000..ed37490c8 --- /dev/null +++ b/src/plugins/genreportxlsx.ts @@ -0,0 +1,55 @@ +import axios from "axios"; +import config from "@/app.config"; + +import { useQuasar } from "quasar"; +import { useCounterMixin } from "@/stores/mixin"; + +const $q = useQuasar(); + +const mixin = useCounterMixin(); +const { showLoader, hideLoader, messageError } = mixin; + +async function genReportXLSX( + data: any, + fileName: string, + type: string = "xlsx" +) { + showLoader(); + await axios + .post(`${config.API.reportTemplate}/xlsx`, data, { + headers: { + accept: + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "content-Type": "application/json", + }, + responseType: "blob", + }) + .then((res) => { + const data = res.data; + if (data) { + // สร้าง Blob จาก array buffer + const blob = new Blob([data]); + + // สร้าง URL สำหรับไฟล์ Blob + const url = URL.createObjectURL(blob); + + // สร้างลิงก์เพื่อดาวน์โหลดไฟล์ + const link = document.createElement("a"); + link.href = url; + link.download = `${fileName}.${type}`; // กำหนดชื่อไฟล์ที่จะดาวน์โหลด + document.body.appendChild(link); + link.click(); + + // ลบ URL ที่สร้างขึ้นหลังจากใช้งาน + URL.revokeObjectURL(url); + } + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + +export default genReportXLSX;