refactor(registry): exportToExcelPosition

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-04-23 09:13:05 +07:00
parent 3cedcddbac
commit 573a76448e
4 changed files with 208 additions and 55 deletions

View file

@ -24,6 +24,8 @@ 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();
@ -445,67 +447,68 @@ function classColorRow(isDelete: boolean, isEdit: boolean, isEntry: boolean) {
/** ฟังก์ชันดาวน์โหลดไฟล Excel */
function exportToExcel() {
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,
};
});
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 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<DataOption[]>(store.commandCodeData); //