โครงสร้างอัตรากำลัง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-14 17:41:32 +07:00
parent addf03eaf3
commit 131583f89f
5 changed files with 82 additions and 59 deletions

View file

@ -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<any>(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="########################"
/>
</div>
<div class="col-3">

View file

@ -51,9 +51,13 @@ const props = defineProps({
type: String,
required: true,
},
mainTree: {
type: Object,
required: true,
},
});
const title = ref<string>("ย้ายตำแหน่ง");
const title = ref<string>("ย้ายตำแหน่งจากหน่วยงาน/ส่วนราชการปัจจุบัน");
const filterTree = ref<string>("");
const filterRef = ref();
const selectedTree = ref<string>("");
@ -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;

View file

@ -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<boolean>(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) {
<q-item
clickable
v-close-popup
@click.stop="onClickDownloadReport(item.val)"
@click.stop="onClickDownloadReport(item.val, item.name)"
>
<q-item-section>{{ item.name }}</q-item-section>
</q-item>
@ -774,6 +781,7 @@ async function onClickDownloadReport(val: string) {
:fetchDataTree="props.fetchDataTree"
:type="typeMove"
:rowId="rowId"
:mainTree="props.mainTree ? props.mainTree : []"
/>
<!-- ประวตำแหน -->

View file

@ -35,6 +35,7 @@ const nodeId = ref<string>(""); // id ของ Tree
const orgLevel = ref<number>(0); // levelTree
const isLoad = ref<boolean>(false); // loadTable
const isLoadTree = ref<boolean>(false); // loadTable
const mainTree = ref<OrgTree>();
const selected = ref<string>("");
@ -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"

View file

@ -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;