diff --git a/package.json b/package.json
index d84d6c4..fc5a6bd 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,6 @@
"@tato30/vue-pdf": "^1.5.1",
"@vuepic/vue-datepicker": "^3.6.3",
"bma-org-chart": "^0.0.7",
- "exceljs": "^4.4.0",
"html-to-image": "^1.11.13",
"keycloak-js": "^20.0.2",
"moment": "^2.29.4",
diff --git a/src/components/DialogDebug.vue b/src/components/DialogDebug.vue
index 401d641..d51100e 100644
--- a/src/components/DialogDebug.vue
+++ b/src/components/DialogDebug.vue
@@ -316,9 +316,6 @@ function onClose() {
-
- ผู้ดูแลระบบจะติดต่อกลับผ่านทางอีเมลที่ท่านระบุ กรุณาตรวจสอบอีเมลของท่านเป็นระยะ
-
@@ -345,6 +341,12 @@ function onClose() {
v-model="formData.phone"
class="inputgreen"
hide-bottom-space
+ :rules="[
+ () =>
+ !!formData.email ||
+ !!formData.phone ||
+ 'กรุณากรอกอีเมลหรือเบอร์โทรติดต่อกลับ',
+ ]"
/>
diff --git a/src/modules/05_leave/components/DialogDetail.vue b/src/modules/05_leave/components/DialogDetail.vue
index 7874515..2c05ebd 100644
--- a/src/modules/05_leave/components/DialogDetail.vue
+++ b/src/modules/05_leave/components/DialogDetail.vue
@@ -6,7 +6,7 @@ import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useLeaveStore } from "@/modules/05_leave/store";
-import genReport from "@/plugins/genreport";
+import { useDataStore } from "@/stores/data";
/** import type*/
import type {
@@ -16,6 +16,8 @@ import type {
FromCancelDetail,
} from "@/modules/05_leave/interface/response/leave";
+import DialogHeader from "@/components/DialogHeader.vue";
+import Workflow from "@/components/Workflow/Main.vue";
import FormLeave from "@/modules/05_leave/components/formDetail/01_SickForm.vue";
import FormChildbirth from "@/modules/05_leave/components/formDetail/04_HelpWifeBirthForm.vue";
import FormHoliday from "@/modules/05_leave/components/formDetail/05_VacationForm.vue";
@@ -31,6 +33,7 @@ import FormCancel from "@/modules/05_leave/components/formDetail/formCancel.vue"
const $q = useQuasar();
const dataStore = useLeaveStore();
+const mainStore = useDataStore();
const { convertStatud } = dataStore;
const mixin = useCounterMixin();
const {
@@ -203,7 +206,7 @@ async function fetchDataDetail(id: string) {
formData.leaveDateEnd = data.leaveEndDate && date2Thai(data.leaveEndDate);
formData.leaveCount = calculateDurationYmd(
data.leaveStartDate,
- data.leaveEndDate,
+ data.leaveEndDate
);
formData.leaveWrote = data.leaveWrote ?? "-";
formData.leaveAddress = data.leaveAddress ?? "-";
@@ -252,7 +255,8 @@ async function fetchDataDetail(id: string) {
formData.studyDaySubject = data.studyDaySubject ?? "-";
formData.studyDayDegreeLevel = data.studyDayDegreeLevel ?? "-";
formData.studyDayUniversityName = data.studyDayUniversityName ?? "-";
- formData.studyDayTrainingSubject = data.studyDayTrainingSubject ?? "-";
+ formData.studyDayTrainingSubject =
+ data.studyDayTrainingSubject ?? "-" ?? "-";
formData.studyDayTrainingName = data.studyDayTrainingName ?? "-";
formData.studyDayCountry = data.studyDayCountry ?? "-";
formData.studyDayScholarship = data.studyDayScholarship ?? "-";
@@ -379,7 +383,7 @@ async function onClickSave() {
onSubmit();
},
"ยืนยันการบันทึกข้อมูล",
- "ต้องการยินยันการบันทึกข้อมูลนี้หรือไม่ ?",
+ "ต้องการยินยันการบันทึกข้อมูลนี้หรือไม่ ?"
);
} else {
}
@@ -408,28 +412,6 @@ async function onSubmit() {
});
}
-/**
- * ฟังก์ชันดาวน์โหลดไฟล์
- * @param id รหัสการลา
- * @param fileName ชื่อไฟล์
- * @param type ประเภทไฟล์
- */
-async function onClickDownloadFile(id: string, fileName: string, type: string) {
- showLoader();
- await http
- .get(config.API.leaveReport(id))
- .then(async (res) => {
- const data = res.data.result;
- await genReport(data, fileName, type);
- })
- .catch((err) => {
- messageError($q, err);
- })
- .finally(() => {
- hideLoader();
- });
-}
-
/**** ตรวจสอบว่ามีการส่งข้อมูลเข้ามาแล้วเปิด modal */
watch(
() => props.modal,
@@ -443,7 +425,7 @@ watch(
? props.leaveId && fetchDataCancelDetail(props.leaveId)
: props.leaveId && fetchDataDetail(props.leaveId);
}
- },
+ }
);
@@ -453,62 +435,10 @@ watch(
v-if="props.leaveStatus != 'DELETE'"
style="width: 900px; max-width: 80vw"
>
-
-
- {{ ` ${titleMain} ${titleName}` }}
-
- ดาวน์โหลดไฟล์
-
-
-
-
-
-
- ไฟล์ .DOCX
-
-
-
-
-
- ไฟล์ .pdf
-
-
-
-
-
-
-
+
@@ -651,62 +581,10 @@ watch(
-
-
- {{ ` ${titleMainCancle} ${titleName}` }}
-
- ดาวน์โหลดไฟล์
-
-
-
-
-
-
- ไฟล์ .DOCX
-
-
-
-
-
- ไฟล์ .pdf
-
-
-
-
-
-
-
+
diff --git a/src/modules/05_leave/components/FormLeave/01_SickForm.vue b/src/modules/05_leave/components/FormLeave/01_SickForm.vue
index 9b6df27..f1e754e 100644
--- a/src/modules/05_leave/components/FormLeave/01_SickForm.vue
+++ b/src/modules/05_leave/components/FormLeave/01_SickForm.vue
@@ -131,11 +131,11 @@ function onValidate() {
formData.append("leaveRangeEnd", formDataSick.leaveRangeEnd);
formData.append(
"leaveStartDate",
- convertDateToAPI(formDataSick.leaveStartDate) ?? "",
+ convertDateToAPI(formDataSick.leaveStartDate) ?? ""
);
formData.append(
"leaveEndDate",
- convertDateToAPI(formDataSick.leaveEndDate) ?? "",
+ convertDateToAPI(formDataSick.leaveEndDate) ?? ""
);
formData.append("leaveWrote", formDataSick.leaveWrote);
formData.append("leaveAddress", dataStore.currentAddress);
@@ -202,6 +202,7 @@ function mapPropsToFormData() {
statusCheck.value = props.data.status;
leaveId.value = props.data.id;
formDataSick.leaveDocument = [];
+ console.log(props.data.leaveDocument);
}
}
@@ -210,7 +211,7 @@ watch(
() => {
mapPropsToFormData();
},
- { deep: true },
+ { deep: true }
);
/** Hook */
diff --git a/src/modules/05_leave/components/FormLeave/Form.vue b/src/modules/05_leave/components/FormLeave/Form.vue
index d5fd5fe..d80b64b 100644
--- a/src/modules/05_leave/components/FormLeave/Form.vue
+++ b/src/modules/05_leave/components/FormLeave/Form.vue
@@ -293,7 +293,7 @@ function getSearch() {
/>
-
diff --git a/src/modules/05_leave/components/ListView.vue b/src/modules/05_leave/components/ListView.vue
index 294c302..37aea58 100644
--- a/src/modules/05_leave/components/ListView.vue
+++ b/src/modules/05_leave/components/ListView.vue
@@ -163,7 +163,7 @@ async function updatePagination(p: number, ps: number, s: string, d: boolean) {
function convert(val: any) {
if (leaveType.value) {
const filtertype = leaveType.value.find(
- (e: any) => e.id === val.leaveTypeId,
+ (e: any) => e.id === val.leaveTypeId
);
const type = filtertype?.code;
if (type == "LV-006" && val.hajjDayStatus == false) {
@@ -242,7 +242,7 @@ onMounted(async () => {
:props="props"
@click="onClickView(props.row.id, props.row.status)"
>
- {{ props.row.status === "DRAFT" ? "-" : props.row.dateSendLeave }}
+ {{ props.row.dateSendLeave }}
@@ -419,7 +419,7 @@ onMounted(async () => {
{{ (page - 1) * pageSize + props.rowIndex + 1 }}
-
+
{
{{ props.row.statusConvert }}
-
- {{
- props.row.status === "DRAFT" ? "-" : props.row.dateSendLeave
- }}
-
- {{ col.value }}
+ {{ col.value }}
diff --git a/src/modules/05_leave/components/formDetail/01_SickForm.vue b/src/modules/05_leave/components/formDetail/01_SickForm.vue
index 43530d7..d186c94 100644
--- a/src/modules/05_leave/components/formDetail/01_SickForm.vue
+++ b/src/modules/05_leave/components/formDetail/01_SickForm.vue
@@ -18,9 +18,7 @@ const props = defineProps({
วันที่ยื่นใบลา
-
- {{ props.data.status === "DRAFT" ? "-" : props.data.dateSendLeave }}
-
+
{{ props.data.dateSendLeave }}
เรื่อง
@@ -32,33 +30,11 @@ const props = defineProps({
ลาตั้งแต่วันที่
-
- {{ props.data.leaveDateStart }}
- {{
- `${
- props.data.leaveRange && props.data.leaveRange !== "ALL"
- ? `(${converstType(props.data.leaveRange)})`
- : ""
- }`
- }}
-
+
{{ props.data.leaveDateStart }} {{ `${props.data.leaveRange && props.data.leaveRange !== 'ALL' ? `(${converstType(props.data.leaveRange)})`:''}` }}
ลาถึงวันที่
-
- {{ props.data.leaveDateEnd }}
- {{
- `${
- props.data.leaveDateStart !== props.data.leaveDateEnd
- ? `${
- props.data.leaveRangeEnd && props.data.leaveRangeEnd !== "ALL"
- ? `(${converstType(props.data.leaveRangeEnd)})`
- : ""
- }`
- : ""
- }`
- }}
-
+
{{ props.data.leaveDateEnd }} {{ `${props.data.leaveDateStart !== props.data.leaveDateEnd ? `${props.data.leaveRangeEnd && props.data.leaveRangeEnd !== 'ALL' ? `(${converstType(props.data.leaveRangeEnd)})`:''}` :''}` }}
จำนวนวันที่ลา
@@ -111,12 +87,10 @@ const props = defineProps({
target="_blank"
outline
color="blue"
- :label="`ดาวน์โหลดเอกสารแนบที่ ${Number(index) + 1}`"
+ :label="`ดาวน์โหลดเอกสารแนบที่ ${index + 1}`"
size="12px"
>
-
ดาวน์โหลดเอกสารแนบที่ {{ Number(index) + 1 }}
+
ดาวน์โหลดเอกสารแนบที่ {{ index + 1 }}
diff --git a/src/modules/05_leave/components/formDetail/04_HelpWifeBirthForm.vue b/src/modules/05_leave/components/formDetail/04_HelpWifeBirthForm.vue
index 52d358c..80ec85d 100644
--- a/src/modules/05_leave/components/formDetail/04_HelpWifeBirthForm.vue
+++ b/src/modules/05_leave/components/formDetail/04_HelpWifeBirthForm.vue
@@ -1,8 +1,8 @@
diff --git a/src/modules/10_registry/05_Other/03_FileOther.vue b/src/modules/10_registry/05_Other/03_FileOther.vue
index 585e68c..585997b 100644
--- a/src/modules/10_registry/05_Other/03_FileOther.vue
+++ b/src/modules/10_registry/05_Other/03_FileOther.vue
@@ -1,12 +1,11 @@
diff --git a/src/modules/10_registry/components/PositionReview/Table.vue b/src/modules/10_registry/components/PositionReview/Table.vue
index 4523be3..d2b7712 100644
--- a/src/modules/10_registry/components/PositionReview/Table.vue
+++ b/src/modules/10_registry/components/PositionReview/Table.vue
@@ -24,8 +24,6 @@ import type { DataPosition } from "@/modules/10_registry/interface/review/Edit";
// import DialogSort from "@/modules/04_registryPerson/views/edit/components/DialogSort.vue";
// import CurruncyInput from "@/components/CurruncyInput.vue";
-import { exportToExcelPosition } from "@/modules/10_registry/utils/exportPosition";
-
const dataStore = useDataStore();
const store = useGovernmentPosDataStore();
const $q = useQuasar();
@@ -325,23 +323,20 @@ async function fetchData() {
// .get(
// `${config.API.profileSalaryTemp}/${empType.value}/done/${profileId.value}`,
// )
- try {
- await http.get(
- `${config.API.profileSalaryTemp}/${empType.value}/${profileId.value}`,
- );
-
- const res = await http.get(
- `${config.API.profileSalaryTemp}/${empType.value}/done/${profileId.value}`,
- );
- const data = res.data.result;
- rowsMain.value = data;
- rows.value = data;
- serchDataTable();
- } catch (err) {
- messageError($q, err);
- } finally {
- isLoad.value = false;
- }
+ http
+ .get(`${config.API.profileSalaryTemp}/${empType.value}/${profileId.value}`)
+ .then((res) => {
+ const data = res.data.result;
+ rowsMain.value = data;
+ rows.value = data;
+ serchDataTable();
+ })
+ .catch((err) => {
+ messageError($q, err);
+ })
+ .finally(() => {
+ isLoad.value = false;
+ });
}
/** function ค้นหาข้อมูลรายการในตาราง*/
@@ -447,68 +442,67 @@ function classColorRow(isDelete: boolean, isEdit: boolean, isEntry: boolean) {
/** ฟังก์ชันดาวน์โหลดไฟล Excel */
function exportToExcel() {
- exportToExcelPosition(rows.value);
- // const newData = rows.value.map((e: DataPosition, index: number) => {
- // return {
- // no: index + 1,
- // commandDateAffect: date2Thai(e.commandDateAffect),
- // positionName: e.positionName,
- // positionType: e.positionType,
- // positionLevel: e.positionLevel
- // ? e.positionLevel
- // : e.positionCee
- // ? e.positionCee
- // : "",
- // positionExecutive: e.positionExecutive,
- // amount: e.amount,
- // mouthSalaryAmount: e.mouthSalaryAmount,
- // positionSalaryAmount: e.positionSalaryAmount,
- // organization: findOrgName({
- // root: e.orgRoot,
- // child1: e.orgChild1,
- // child2: e.orgChild2,
- // child3: e.orgChild3,
- // child4: e.orgChild4,
- // }),
- // posNo:
- // e.posNoAbb && e.posNo
- // ? `${e.posNoAbb} ${e.posNo}`
- // : e.posNo
- // ? e.posNo
- // : "",
- // posNumCodeSit:
- // e.posNumCodeSitAbb && e.posNumCodeSit
- // ? `${e.posNumCodeSit} (${e.posNumCodeSitAbb})`
- // : e.posNumCodeSit
- // ? e.posNumCodeSit
- // : "",
- // commandNo:
- // e.commandNo && e.commandYear
- // ? `${e.commandNo}/${Number(e.commandYear) + 543}`
- // : "",
- // commandDateSign: date2Thai(e.commandDateSign),
- // commandCode: store.convertCommandCodeName(e.commandCode),
- // remark: e.remark,
- // };
- // });
+ const newData = rows.value.map((e: DataPosition, index: number) => {
+ return {
+ no: index + 1,
+ commandDateAffect: date2Thai(e.commandDateAffect),
+ positionName: e.positionName,
+ positionType: e.positionType,
+ positionLevel: e.positionLevel
+ ? e.positionLevel
+ : e.positionCee
+ ? e.positionCee
+ : "",
+ positionExecutive: e.positionExecutive,
+ amount: e.amount,
+ mouthSalaryAmount: e.mouthSalaryAmount,
+ positionSalaryAmount: e.positionSalaryAmount,
+ organization: findOrgName({
+ root: e.orgRoot,
+ child1: e.orgChild1,
+ child2: e.orgChild2,
+ child3: e.orgChild3,
+ child4: e.orgChild4,
+ }),
+ posNo:
+ e.posNoAbb && e.posNo
+ ? `${e.posNoAbb} ${e.posNo}`
+ : e.posNo
+ ? e.posNo
+ : "",
+ posNumCodeSit:
+ e.posNumCodeSitAbb && e.posNumCodeSit
+ ? `${e.posNumCodeSit} (${e.posNumCodeSitAbb})`
+ : e.posNumCodeSit
+ ? e.posNumCodeSit
+ : "",
+ commandNo:
+ e.commandNo && e.commandYear
+ ? `${e.commandNo}/${Number(e.commandYear) + 543}`
+ : "",
+ commandDateSign: date2Thai(e.commandDateSign),
+ commandCode: store.convertCommandCodeName(e.commandCode),
+ remark: e.remark,
+ };
+ });
- // const headers = columns.value.map((item: any) => item.label) || []; // หัวคอลัมน์ภาษาไทย
- // const worksheet = XLSX.utils.json_to_sheet(newData, {
- // header: visibleColumns.value,
- // });
+ const headers = columns.value.map((item: any) => item.label) || []; // หัวคอลัมน์ภาษาไทย
+ const worksheet = XLSX.utils.json_to_sheet(newData, {
+ header: visibleColumns.value,
+ });
//แทรกหัวคอลัมน์ภาษาไทย (ใช้ A1, B1, C1 แทน)
- // XLSX.utils.sheet_add_aoa(worksheet, [headers], { origin: "A1" });
+ XLSX.utils.sheet_add_aoa(worksheet, [headers], { origin: "A1" });
// Create a new workbook and append the worksheet
- // const workbook = XLSX.utils.book_new();
+ const workbook = XLSX.utils.book_new();
- // XLSX.utils.book_append_sheet(
- // workbook,
- // worksheet,
- // `รายการประวัติตำแหน่งเงินเดือน`,
- // );
- // XLSX.writeFile(workbook, "รายการประวัติตำแหน่งเงินเดือน.xlsx");
+ XLSX.utils.book_append_sheet(
+ workbook,
+ worksheet,
+ `รายการประวัติตำแหน่งเงินเดือน`,
+ );
+ XLSX.writeFile(workbook, "รายการประวัติตำแหน่งเงินเดือน.xlsx");
}
// const commandCodeOptions = ref(store.commandCodeData); //รายการปรเภทคำสั่ง
@@ -886,20 +880,12 @@ async function fetchDataCommandCode() {
// }
onMounted(async () => {
+ // เพิ่ม delay เล็กน้อยเพื่อรอให้ dataStore fetch ข้อมูล position เสร็จก่อน
+ await new Promise((resolve) => setTimeout(resolve, 800));
if (dataStore.officerType && dataStore.profileId) {
await Promise.all([fetchData(), fetchDataCommandCode()]);
}
});
-
-watch(
- () => [dataStore.officerType, dataStore.profileId],
- async ([officerType, profileId]) => {
- if (officerType && profileId) {
- await Promise.all([fetchData(), fetchDataCommandCode()]);
- }
- },
- { immediate: true },
-);
diff --git a/src/modules/10_registry/interface/review/Edit.ts b/src/modules/10_registry/interface/review/Edit.ts
index 545dc35..04041b2 100644
--- a/src/modules/10_registry/interface/review/Edit.ts
+++ b/src/modules/10_registry/interface/review/Edit.ts
@@ -71,7 +71,6 @@ interface DataPosition {
status: string;
posNumCodeSitAbb: string;
posNumCodeSit: string;
- positionExecutiveField: string;
}
export type { DataSalaryPos, DataPosition };
diff --git a/src/modules/10_registry/utils/downloadFile.ts b/src/modules/10_registry/utils/downloadFile.ts
deleted file mode 100644
index 99c06c5..0000000
--- a/src/modules/10_registry/utils/downloadFile.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-export interface DownloadFileOptions {
- downloadUrl: string;
- fileName: string;
-}
-
-const isMobile =
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
- navigator.userAgent,
- );
-
-export async function downloadBlobFile({
- downloadUrl,
- fileName,
-}: DownloadFileOptions): Promise {
- // Use window.open for desktop, blob download for mobile
- if (!isMobile) {
- window.open(downloadUrl, "_blank");
- return;
- }
-
- const response = await fetch(downloadUrl);
- const blob = await response.blob();
-
- const contentType: string | null = response.headers.get("Content-Type");
-
- const extensionMap: Record = {
- "application/pdf": "pdf",
- "image/jpeg": "jpg",
- "image/png": "png",
- "image/gif": "gif",
- "application/zip": "zip",
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
- "docx",
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
- };
-
- let extension = contentType ? extensionMap[contentType] : undefined;
-
- if (!extension) {
- const urlWithoutQuery = downloadUrl.split("?")[0];
- extension = urlWithoutQuery.includes(".")
- ? urlWithoutQuery.split(".").pop()
- : "pdf";
- }
-
- const blobForDownload = new Blob([blob], {
- type: "application/octet-stream",
- });
- const url = URL.createObjectURL(blobForDownload);
- const link = document.createElement("a");
- link.href = url;
- const downloadFileName = fileName.includes(".") ? fileName : `${fileName}.${extension}`;
- link.download = downloadFileName;
- document.body.appendChild(link);
- link.click();
- setTimeout(() => {
- document.body.removeChild(link);
- URL.revokeObjectURL(url);
- }, 100);
-}
diff --git a/src/modules/10_registry/utils/exportPosition.ts b/src/modules/10_registry/utils/exportPosition.ts
deleted file mode 100644
index 1761408..0000000
--- a/src/modules/10_registry/utils/exportPosition.ts
+++ /dev/null
@@ -1,157 +0,0 @@
-import ExcelJS from "exceljs";
-import { useGovernmentPosDataStore } from "@/modules/10_registry/store/Position";
-
-import type { DataPosition } from "@/modules/10_registry/interface/review/Edit";
-
-const store = useGovernmentPosDataStore();
-
-// ฟังก์ชันแปลงวันที่จาก ISO format เป็นรูปแบบ dd/mm/yyyy (เช่น 18/05/2564)
-function formatDateToDDMMYYYY(dateString: string | null | Date): string {
- if (!dateString) return "";
-
- const date = new Date(dateString);
- if (isNaN(date.getTime())) return "";
-
- const day = String(date.getDate()).padStart(2, "0");
- const month = String(date.getMonth() + 1).padStart(2, "0");
- const year = date.getFullYear() + 543; // แปลงเป็นปีพุทธศักราช
-
- return `${day}/${month}/${year}`;
-}
-
-export async function exportToExcelPosition(data: DataPosition[]) {
- const workbook = new ExcelJS.Workbook();
- const worksheet = workbook.addWorksheet("รายการประวัติตำแหน่งเงินเดือน");
-
- // --- ส่วนที่ 1: สร้าง Master Data Sheet สำหรับอ้างอิง ID ---
- // เราจะซ่อนแผ่นงานนี้ไว้ (hidden) เพื่อใช้ทำ Dropdown และ VLOOKUP
- const masterSheet = workbook.addWorksheet("MasterData", { state: "hidden" });
- const masterData = store.commandCodeData; // [{id: 1, name: "ย้าย"}, ...]
-
- masterData.forEach((item, index) => {
- masterSheet.getCell(`A${index + 1}`).value = item.name;
- masterSheet.getCell(`B${index + 1}`).value = item.id;
- });
-
- // --- ส่วนที่ 2: กำหนด Columns ---
- worksheet.columns = [
- { header: "ลำดับ", key: "no", width: 8 },
- { header: "วันที่คำสั่งมีผล", key: "commandDateAffect", width: 18 },
- { header: "ตำแหน่งในสายงาน", key: "positionName", width: 25 },
- { header: "ตำแหน่งประเภท", key: "positionType", width: 18 },
- { header: "ระดับ", key: "positionLevel", width: 12 },
- { header: "ระดับซี", key: "positionCee", width: 12 },
- { header: "สายงาน", key: "positionLine", width: 20 },
- { header: "ด้าน/สาขา", key: "positionPathSide", width: 15 },
- { header: "ตำแหน่งทางการบริหาร", key: "positionExecutive", width: 20 },
- { header: "ด้านทางการบริหาร", key: "positionExecutiveField", width: 20 },
- { header: "เงินเดือน", key: "amount", width: 15 },
- { header: "เงินค่าตอบแทนรายเดือน", key: "mouthSalaryAmount", width: 15 },
- { header: "เงินประจำตำแหน่ง", key: "positionSalaryAmount", width: 15 },
- { header: "เงินค่าตอบแทนพิเศษ", key: "amountSpecial", width: 15 },
- { header: "หน่วยงาน", key: "organization", width: 30 },
- { header: "ส่วนราชการระดับ 1", key: "orgChild1", width: 20 },
- { header: "ส่วนราชการระดับ 2", key: "orgChild2", width: 20 },
- { header: "ส่วนราชการระดับ 3", key: "orgChild3", width: 20 },
- { header: "ส่วนราชการระดับ 4", key: "orgChild4", width: 20 },
- { header: "ตัวย่อเลขที่ตำแหน่ง", key: "posNoAbb", width: 15 },
- { header: "เลขที่ตำแหน่ง", key: "posNo", width: 15 },
- { header: "หน่วยงานที่ออกคำสั่ง", key: "posNumCodeSit", width: 20 },
- {
- header: "ตัวย่อหน่วยงานที่ออกคำสั่ง",
- key: "posNumCodeSitAbb",
- width: 15,
- },
- { header: "เลขที่คำสั่ง", key: "commandNo", width: 15 },
- { header: "ปีเลขที่คำสั่ง", key: "commandYear", width: 12 },
- { header: "วันที่ลงนาม", key: "commandDateSign", width: 18 },
- { header: "ประเภทคำสั่ง", key: "commandCodeName", width: 25 }, // AA
- { header: "หมายเหตุ", key: "remark", width: 20 },
- { header: "commandId", key: "commandId", width: 20 }, // AC (ลำดับที่ 29)
- { header: "commandCode", key: "commandCode", width: 20 }, // AD (ลำดับที่ 30)
- ];
-
- // 3. Map ข้อมูล
- const newData = data.map((e, index) => ({
- no: index + 1,
- commandDateAffect: e.commandDateAffect
- ? formatDateToDDMMYYYY(e.commandDateAffect)
- : "",
- positionName: e.positionName,
- positionType: e.positionType,
- positionLevel: e.positionLevel,
- positionCee: e.positionCee,
- positionLine: e.positionLine || "",
- positionPathSide: e.positionPathSide || "",
- positionExecutive: e.positionExecutive,
- positionExecutiveField: e.positionExecutiveField || "",
- amount: e.amount || 0,
- mouthSalaryAmount: e.mouthSalaryAmount || 0,
- positionSalaryAmount: e.positionSalaryAmount || 0,
- amountSpecial: e.amountSpecial || 0,
- organization: e.orgRoot,
- orgChild1: e.orgChild1,
- orgChild2: e.orgChild2,
- orgChild3: e.orgChild3,
- orgChild4: e.orgChild4,
- posNoAbb: e.posNoAbb,
- posNo: e.posNo,
- posNumCodeSit: e.posNumCodeSit,
- posNumCodeSitAbb: e.posNumCodeSitAbb,
- commandNo: e.commandNo,
- commandYear: e.commandYear ? Number(e.commandYear) + 543 : "",
- commandDateSign: e.commandDateSign
- ? formatDateToDDMMYYYY(e.commandDateSign)
- : "",
- commandCodeName: store.convertCommandCodeName(e.commandCode),
- remark: e.remark,
- commandId: e.commandId || "",
- commandCode: e.commandCode || "", // ใส่ค่าเริ่มต้นไว้
- }));
-
- worksheet.addRows(newData);
-
- // 4. ตกแต่งสี, Dropdown และ สูตร VLOOKUP
- newData.forEach((_, index) => {
- const rowIndex = index + 2;
-
- // --- ตั้งค่า Format สำหรับเซลล์วันที่ ---
- // เซลล์ B (commandDateAffect) และ Z (commandDateSign)
- const dateAffectCell = worksheet.getCell(`B${rowIndex}`);
- const dateSignCell = worksheet.getCell(`Z${rowIndex}`);
-
- [dateAffectCell, dateSignCell].forEach((cell) => {
- cell.numFmt = "dd/mm/yyyy";
- });
-
- // --- ทำ Dropdown คอลัมน์ AA ---
- // อ้างอิงรายการจาก MasterData Sheet จะทำให้ Excel ทำงานได้เสถียรกว่า (กรณีรายการเยอะ)
- worksheet.getCell(`AA${rowIndex}`).dataValidation = {
- type: "list",
- allowBlank: true,
- formulae: [`MasterData!$A$1:$A$${masterData.length}`],
- };
-
- // --- ผูกสูตรให้ commandCode (AD) เปลี่ยนตามการเลือกใน AA ---
- // AA คือประเภทคำสั่ง, AD คือ commandCode
- worksheet.getCell(`AD${rowIndex}`).value = {
- formula: `=IFERROR(VLOOKUP(AA${rowIndex}, MasterData!$A$1:$B$${masterData.length}, 2, FALSE), "")`,
- };
- });
-
- // 5. สไตล์ Header
- worksheet.getRow(1).font = { bold: true };
- worksheet.getRow(1).alignment = { vertical: "middle", horizontal: "center" };
-
- // 6. เขียนไฟล์
- const buffer = await workbook.xlsx.writeBuffer();
- const blob = new Blob([buffer], {
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
- });
- const url = window.URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = "รายการประวัติตำแหน่งเงินเดือน.xlsx";
- a.click();
- window.URL.revokeObjectURL(url);
-}
diff --git a/src/modules/11_probation/views/mainDetail.vue b/src/modules/11_probation/views/mainDetail.vue
index a4584c0..cd6b60c 100644
--- a/src/modules/11_probation/views/mainDetail.vue
+++ b/src/modules/11_probation/views/mainDetail.vue
@@ -151,7 +151,6 @@ async function getAvatar(id: string) {
})
.catch((e) => {
messageError($q, e);
- profileImg.value = avatar;
});
}
@@ -169,15 +168,14 @@ function getList(id: string) {
});
}
-function getImg(id: string, pathName: string) {
- http
+async function getImg(id: string, pathName: string) {
+ await http
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName))
.then((res) => {
profileImg.value = res.data.downloadUrl;
})
.catch((e) => {
- profileImg.value = avatar;
- // messageError($q, e);
+ messageError($q, e);
hideLoader();
});
}
@@ -190,7 +188,7 @@ function onSearch() {
rows.value = onSearchDataTable(
filter.value,
rowsData.value,
- columns.value ? columns.value : [],
+ columns.value ? columns.value : []
);
}
diff --git a/src/plugins/genreport.ts b/src/plugins/genreport.ts
index 500dca4..520ec00 100644
--- a/src/plugins/genreport.ts
+++ b/src/plugins/genreport.ts
@@ -19,7 +19,7 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
},
responseType: "arraybuffer",
})
- .then(async (res) => {
+ .then((res) => {
const responseData = res.data;
if (responseData) {
const mimeType =
@@ -32,11 +32,13 @@ async function genReport(data: any, fileName: string, type: string = "docx") {
const baseName = fileName.trim();
const extension = type === "docx" ? "docx" : "pdf";
+
const link = document.createElement("a");
link.href = url;
link.download = `${baseName}.${extension}`;
document.body.appendChild(link);
link.click();
+
setTimeout(() => {
document.body.removeChild(link);
URL.revokeObjectURL(url);
diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts
index 02981bb..41c7161 100644
--- a/src/stores/mixin.ts
+++ b/src/stores/mixin.ts
@@ -14,7 +14,7 @@ export const useCounterMixin = defineStore("mixin", () => {
const calAge = (
srcDate: Date,
birthCal: Date = new Date(),
- eng: boolean = false,
+ eng: boolean = false
) => {
const year = eng ? "years" : "ปี";
const month = eng ? "months" : "เดือน";
@@ -82,7 +82,7 @@ export const useCounterMixin = defineStore("mixin", () => {
function date2Thai(
srcDate: Date | null,
isFullMonth: boolean = false,
- isTime: boolean = false,
+ isTime: boolean = false
) {
if (srcDate == null || !moment(srcDate).isValid()) return "";
@@ -98,7 +98,7 @@ export const useCounterMixin = defineStore("mixin", () => {
function dateThai(
srcDate: Date,
isFullMonth: boolean = true,
- isTime: boolean = false,
+ isTime: boolean = false
) {
if (srcDate == null) {
return null;
@@ -490,7 +490,7 @@ export const useCounterMixin = defineStore("mixin", () => {
color: string | undefined,
ok?: Function | undefined,
cancel?: Function | undefined,
- onlycancel: Boolean = false,
+ onlycancel: Boolean = false
) => {
q.dialog({
component: CustomComponent,
@@ -529,7 +529,7 @@ export const useCounterMixin = defineStore("mixin", () => {
title: string,
message: string,
ok: Function,
- cancel?: Function,
+ cancel?: Function
) {
q.dialog({
title: `${title}`,
@@ -559,7 +559,7 @@ export const useCounterMixin = defineStore("mixin", () => {
title: string,
message: string,
ok: Function,
- cancel?: Function,
+ cancel?: Function
) {
q.dialog({
title: `${title}`,
@@ -795,7 +795,7 @@ export const useCounterMixin = defineStore("mixin", () => {
ok?: Function,
title?: string, // ถ้ามี cancel action ใส่เป็น null
desc?: string, // ถ้ามี cancel action ใส่เป็น null
- cancel?: Function,
+ cancel?: Function
) => {
q.dialog({
component: CustomComponent,
@@ -824,7 +824,7 @@ export const useCounterMixin = defineStore("mixin", () => {
ok?: Function,
title?: string, // ถ้ามี cancel action ใส่เป็น null
desc?: string, // ถ้ามี cancel action ใส่เป็น null
- cancel?: Function,
+ cancel?: Function
) => {
q.dialog({
component: CustomComponent,
@@ -851,7 +851,7 @@ export const useCounterMixin = defineStore("mixin", () => {
const dialogMessageNotify = (
q: any,
desc?: string, // ถ้ามี cancel action ใส่เป็น null
- cancel?: Function,
+ cancel?: Function
) => {
q.dialog({
component: CustomComponent,
@@ -973,7 +973,7 @@ export const useCounterMixin = defineStore("mixin", () => {
* @returns ผลการคำนวน ปี เดือน วัน ในรูปแบบ 1 ปี 10 เดือน 5 วัน
*/
function calculateDurationYmd(startDate: any, endDate: any) {
- if (!startDate || !endDate) return "";
+ if (!startDate || !endDate) return "";
let start = moment(startDate).startOf("day");
let end = moment(endDate).startOf("day").add(1, "day");
@@ -1252,15 +1252,9 @@ export const useCounterMixin = defineStore("mixin", () => {
// กรณีมีเฉพาะ date
function convertDateToAPI(date: Date | null) {
- if (!date) return null;
-
- const parsedDate = new Date(date);
-
- if (parsedDate) {
- return format(parsedDate, "yyyy-MM-dd");
- } else {
- return null;
- }
+ return date
+ ? format(utcToZonedTime(date, "Asia/Bangkok"), "yyyy-MM-dd")
+ : null;
}
// กรณี datetime
diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue
index 331dbe8..f14d08e 100644
--- a/src/views/MainLayout.vue
+++ b/src/views/MainLayout.vue
@@ -74,7 +74,7 @@ async function checkUser() {
await dataStore.getProFileType();
kpiDataStore.dataProfile = data; // Set dataProfile in kpiDataStore
if (data.avatarName) {
- getImg(data.profileId, data.avatarName);
+ await getImg(data.profileId, data.avatarName);
} else {
dataStore.profileImg = avatar;
}
@@ -106,9 +106,6 @@ function getImg(id: string, pathName: string) {
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName))
.then((res) => {
dataStore.profileImg = res.data.downloadUrl;
- })
- .catch(() => {
- dataStore.profileImg = avatar;
});
}
@@ -175,13 +172,13 @@ const doLogout = () => {
);
};
-const clickDelete = async (id: string, index: number | string) => {
+const clickDelete = async (id: string, index: number) => {
dialogRemove($q, async () => {
// showLoader();
await http
.delete(config.API.msgId(id))
.then(() => {
- notiList.value.splice(Number(index), 1);
+ notiList.value.splice(index, 1);
totalInbox.value--;
totalNoti.value--;
success($q, "ลบข้อมูลสำเร็จ");
@@ -775,10 +772,10 @@ watch(
-
-
-
+
+
+