-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from chienniman/issue-26
Issue-26
- Loading branch information
Showing
16 changed files
with
1,716 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$(document).ready(function () { | ||
function createBaseElement() { | ||
$("body").append(` | ||
<div class="bg"></div> | ||
<div class="bg bg2"></div> | ||
<div class="bg bg3"></div> | ||
<div class="content"> | ||
<h1>全聯報表生成器</h1> | ||
</div> | ||
<div id="uploadedFiles"></div> | ||
<div class="top-row"></div> | ||
<table id="resultTable" border="1"></table> | ||
`); | ||
} | ||
|
||
createBaseElement(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(() => { | ||
// helpers/mergeStyleString.js | ||
function mergeStyleString(fixedStyles, styles) { | ||
const mergedStyles = { ...fixedStyles, ...styles }; | ||
return Object.keys(mergedStyles).map((key) => `${key}: ${mergedStyles[key]};`).join(" "); | ||
} | ||
|
||
// components/shared/buttons/button.js | ||
function button({ id, text, styles }) { | ||
const fixedStyles = { | ||
"max-width": "80px", | ||
cursor: "pointer" | ||
}; | ||
return `<button id="${id}" class="button" style="${mergeStyleString( | ||
fixedStyles, | ||
styles | ||
)}">${text}</button>`; | ||
} | ||
|
||
// utils/dataProcessing.js | ||
function getData(key) { | ||
var storedData = sessionStorage.getItem(key); | ||
return storedData ? JSON.parse(storedData) : null; | ||
} | ||
|
||
// components/actionButtons/dailySummary.js | ||
$(document).ready(function() { | ||
$(".top-row").append( | ||
button({ | ||
id: "dailySummary", | ||
text: "\u7E3D\u7D50", | ||
styles: { display: "none" } | ||
}) | ||
); | ||
$("#dailySummary").on("click", async function() { | ||
function generateSummary() { | ||
const visitedAreas = getData("visitedAreas"); | ||
const visitedAreasText = visitedAreas.join("\uFF0C"); | ||
const summaryData = getData("summaryData"); | ||
const areaSummaries = summaryData.filter((e) => visitedAreas.includes(e["C"])).map((e) => { | ||
const F = Math.ceil(e["F"]); | ||
const G = Math.ceil(e["G"]); | ||
const E = (e["E"] * 100).toFixed(2) + "%"; | ||
const H = (e["H"] * 100).toFixed(2) + "%"; | ||
return `${e["C"]}\u7684\u696D\u7E3E\u76EE\u6A19\u662F ${F}\uFF0C\u696D\u7E3E\u9054\u6210\u662F ${G}\uFF0C\u696D\u7E3E\u5360\u6BD4\u662F ${E}\uFF0C\u9054\u6210\u767E\u5206\u6BD4\u662F ${H}`; | ||
}); | ||
let base = `\u4ECA\u65E5\u62DC\u8A2A\u4E86${visitedAreasText},\u56DE\u9867\u4ECA\u65E5\u696D\u7E3E\u9054\u6210\uFF0C`; | ||
if (areaSummaries.length > 0) { | ||
base += areaSummaries.join(";"); | ||
} | ||
Swal.fire({ | ||
title: "\u6BCF\u65E5\u7E3D\u7D50", | ||
text: base, | ||
icon: "success" | ||
}); | ||
} | ||
generateSummary(); | ||
}); | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(() => { | ||
// helpers/mergeStyleString.js | ||
function mergeStyleString(fixedStyles, styles) { | ||
const mergedStyles = { ...fixedStyles, ...styles }; | ||
return Object.keys(mergedStyles).map((key) => `${key}: ${mergedStyles[key]};`).join(" "); | ||
} | ||
|
||
// components/shared/buttons/button.js | ||
function button({ id, text, styles }) { | ||
const fixedStyles = { | ||
"max-width": "80px", | ||
cursor: "pointer" | ||
}; | ||
return `<button id="${id}" class="button" style="${mergeStyleString( | ||
fixedStyles, | ||
styles | ||
)}">${text}</button>`; | ||
} | ||
|
||
// components/actionButtons/exportToExcel.js | ||
$(document).ready(function() { | ||
$(".top-row").append( | ||
button({ | ||
id: "exportToExcel", | ||
text: "\u5C0E\u51FA", | ||
styles: { display: "none" } | ||
}) | ||
); | ||
$("#exportToExcel").on("click", async function() { | ||
function isTableEmpty(table) { | ||
return table.children().length === 0; | ||
} | ||
function downloadDate() { | ||
const today = /* @__PURE__ */ new Date(); | ||
const month = today.getMonth() + 1; | ||
const day = today.getDate(); | ||
return `${month}\u6708_${day}\u65E5`; | ||
} | ||
function exportToExcel() { | ||
const htmlTable = $("#resultTable"); | ||
if (isTableEmpty(htmlTable)) { | ||
Swal.fire({ title: "\u7121\u6CD5\u5C0E\u51FA\u7A7A\u8868\u683C!", icon: "error" }); | ||
} | ||
new Table2Excel().export(htmlTable, `PX\u53F0\u4E2D\u65E5\u92B7\u5EAB\u5B58\u8868_${downloadDate()}`); | ||
} | ||
exportToExcel(); | ||
}); | ||
}); | ||
})(); |
Oops, something went wrong.