feat: complete all tables in audit page
This commit is contained in:
parent
256c64dcf5
commit
d93bfe172b
83
api/audit.js
83
api/audit.js
@ -4,6 +4,9 @@ const util = require("./../utilities/utilities_main.js");
|
||||
const moment = require("moment");
|
||||
|
||||
router.get("/", async function(req, res) {
|
||||
|
||||
const is_audited = req.query.is_audited == 1;
|
||||
|
||||
try {
|
||||
let conn;
|
||||
try {
|
||||
@ -11,22 +14,49 @@ router.get("/", async function(req, res) {
|
||||
const query =
|
||||
`
|
||||
SELECT item_form.application_id, item_form.item_info_id, item_info.item_content,
|
||||
item_form.application_unit,
|
||||
item_form.application_unit,
|
||||
item_form.subsidy,
|
||||
scholarship_application.application_date,
|
||||
scholarship_application.student_id,
|
||||
student.student_name
|
||||
FROM
|
||||
scholarship_application.student_id,
|
||||
student.student_name,
|
||||
audit_form.committee_review,
|
||||
advisor.advisor_name,
|
||||
student.departmant_and_grade,
|
||||
assistant.assistant_name,
|
||||
audit_form.documents_ready,
|
||||
audit_form.meeting_name,
|
||||
audit_form.passed_date,
|
||||
audit_form.scholarship_amount
|
||||
FROM
|
||||
item_form
|
||||
RIGHT JOIN
|
||||
JOIN
|
||||
scholarship_application ON item_form.application_id = scholarship_application.application_id
|
||||
LEFT JOIN
|
||||
LEFT JOIN
|
||||
student ON scholarship_application.student_id = student.student_id
|
||||
JOIN
|
||||
advisor ON student.advisor_id = advisor.advisor_id
|
||||
LEFT JOIN
|
||||
item_info ON item_form.item_info_id = item_info.item_info_id
|
||||
LEFT JOIN
|
||||
audit_form ON item_form.application_id = audit_form.application_id
|
||||
LEFT JOIN
|
||||
assistant ON audit_form.assistant_username = assistant.username;
|
||||
;
|
||||
`;
|
||||
const result = await conn.query(query);
|
||||
const db_result = await conn.query(query);
|
||||
let result = [];
|
||||
for(let i=0; i<db_result.length; i++) {
|
||||
if (is_audited) {
|
||||
if (db_result[i].committee_review != null) {
|
||||
result.push(db_result[i]);
|
||||
}
|
||||
} else {
|
||||
if (db_result[i].committee_review == null) {
|
||||
result.push(db_result[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ success: true, data: result });
|
||||
}
|
||||
catch(e) {
|
||||
@ -77,43 +107,4 @@ router.post("/", async function(req, res) {
|
||||
}
|
||||
})
|
||||
|
||||
router.get("/log", async function (req, res) {
|
||||
try {
|
||||
let conn;
|
||||
try {
|
||||
conn = await util.getDBConnection(); // get connection from db
|
||||
const query =
|
||||
`
|
||||
SELECT item_form.application_id, item_form.item_info_id, item_info.item_content,
|
||||
item_form.application_unit,
|
||||
item_form.subsidy,
|
||||
scholarship_application.application_date,
|
||||
scholarship_application.student_id,
|
||||
student.student_name
|
||||
FROM
|
||||
item_form
|
||||
RIGHT JOIN
|
||||
scholarship_application ON item_form.application_id = scholarship_application.application_id
|
||||
LEFT JOIN
|
||||
student ON scholarship_application.student_id = student.student_id
|
||||
LEFT JOIN
|
||||
item_info ON item_form.item_info_id = item_info.item_info_id
|
||||
;
|
||||
`;
|
||||
const result = await conn.query(query);
|
||||
res.json({ success: true, data: result });
|
||||
}
|
||||
catch(e) {
|
||||
console.error(e);
|
||||
res.json({suc : false});
|
||||
}
|
||||
finally {
|
||||
util.closeDBConnection(conn); // close db connection
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router;
|
||||
|
||||
192
js/audit.js
192
js/audit.js
@ -9,7 +9,19 @@ let assistant_name;
|
||||
async function getItemInfo() {
|
||||
// get the data from table : item_info
|
||||
try {
|
||||
let result = await axios.get('/api/audit');
|
||||
let result = await axios.get('/api/audit?is_audited=0');
|
||||
result = result.data;
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async function getAuditedItemInfo() {
|
||||
// get the data from table : item_info
|
||||
try {
|
||||
let result = await axios.get('/api/audit?is_audited=1');
|
||||
result = result.data;
|
||||
return result;
|
||||
}
|
||||
@ -23,6 +35,8 @@ function combineSameAppData(data) {
|
||||
// combine the same application id data in a same record
|
||||
let n_data = {};
|
||||
let next_record = true;
|
||||
console.log("data:");
|
||||
console.log(data);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (i > 0 && data[i].application_id != data[i-1].application_id) {
|
||||
// this record is different from the last
|
||||
@ -35,8 +49,16 @@ function combineSameAppData(data) {
|
||||
n_data[data[i].application_id] = {};
|
||||
n_data[data[i].application_id].application_id = data[i].application_id;
|
||||
n_data[data[i].application_id].application_date = data[i].application_date;
|
||||
n_data[data[i].application_id].advisor_name = data[i].advisor_name;
|
||||
n_data[data[i].application_id].assistant_name = data[i].assistant_name;
|
||||
n_data[data[i].application_id].student_id = data[i].student_id;
|
||||
n_data[data[i].application_id].departmant_and_grade = data[i].departmant_and_grade;
|
||||
n_data[data[i].application_id].documents_ready = data[i].documents_ready;
|
||||
n_data[data[i].application_id].meeting_name = data[i].meeting_name;
|
||||
n_data[data[i].application_id].passed_date = data[i].passed_date;
|
||||
n_data[data[i].application_id].scholarship_amount = data[i].scholarship_amount;
|
||||
n_data[data[i].application_id].student_name = data[i].student_name;
|
||||
n_data[data[i].application_id].committee_review = data[i].committee_review;
|
||||
n_data[data[i].application_id].application_units = [data[i].application_unit];
|
||||
n_data[data[i].application_id].item_contents = [data[i].item_content];
|
||||
n_data[data[i].application_id].subsidys = [data[i].subsidy];
|
||||
@ -52,6 +74,7 @@ function combineSameAppData(data) {
|
||||
}
|
||||
|
||||
function auditCase(application_id) {
|
||||
console.log(`set application_id = ${application_id}`);
|
||||
current_review_apllication_id = application_id;
|
||||
|
||||
// add item content
|
||||
@ -59,6 +82,7 @@ function auditCase(application_id) {
|
||||
document.getElementById(table_id).innerHTML = application_detail_init_table_content;
|
||||
let table_content = document.getElementById(table_id).innerHTML;
|
||||
const data = all_audit_data[application_id];
|
||||
console.log(all_audit_data);
|
||||
console.log(data);
|
||||
table_content += "<tr>";
|
||||
for (let i = 0;i < data.item_contents.length;i++) {
|
||||
@ -118,51 +142,6 @@ async function putDataInTable(table_id) {
|
||||
`
|
||||
;
|
||||
}
|
||||
/*
|
||||
`<h2>證明文件是否備齊</h2>
|
||||
<div>
|
||||
<label>
|
||||
<input type="radio" id="checkbox_yes_${i}" value="yes"/> 是
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" id="checkbox_no_${i}" value="no"/> 否
|
||||
</label>
|
||||
,尚須補繳:<input type="text" id="unit_${i}"/>
|
||||
</div>
|
||||
|
||||
<h2>學生事務委員會審核結果</h2>
|
||||
<div>
|
||||
|
||||
<input type="radio" id="passed" value="passed">
|
||||
<label >經</label>
|
||||
會議名稱("學期-次數"):<input type="text" id="passedTimes" style="width: 50px;">,核發獎學金
|
||||
<input type="number" id="scholarshipAmount" style="width: 100px;">元
|
||||
<br>
|
||||
|
||||
|
||||
|
||||
<blockquote>
|
||||
<div >
|
||||
<label>通過日期:</label>
|
||||
<input type="date" id="passed_date">
|
||||
</div>
|
||||
</blockquote>
|
||||
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" id="notPassed" value="notPassed">
|
||||
<label>未通過</label>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label for="noSupportProof"> 未獲補助證明檔案繳交處:</label>
|
||||
<input type="file" id="noSupportProof" accept=".pdf, .doc, .docx, .jpg, .jpeg, .png">
|
||||
|
||||
</div>
|
||||
<br></br>
|
||||
`
|
||||
*/
|
||||
// write back data into table
|
||||
document.getElementById(table_id).innerHTML = table_content;
|
||||
// set info length
|
||||
@ -173,6 +152,124 @@ async function putDataInTable(table_id) {
|
||||
}
|
||||
}
|
||||
|
||||
async function putDataInAuditedTable(table_id) {
|
||||
// get data
|
||||
const result = await getAuditedItemInfo();
|
||||
const data = combineSameAppData(result.data);
|
||||
const suc = result.success;
|
||||
if (suc && data != null && table_id != null) {
|
||||
// insert data into table
|
||||
let table_content = document.getElementById(table_id).innerHTML;
|
||||
|
||||
const keys = (Object.keys(data));
|
||||
let next_record = false;
|
||||
let this_application_info = {};
|
||||
console.log(data);
|
||||
table_content += `
|
||||
<h3>已通過審核</h3>
|
||||
<table border='1'>
|
||||
`
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (data[keys[i]].committee_review == 1) {
|
||||
table_content +=
|
||||
`
|
||||
<tr>
|
||||
<td>${data[keys[i]].application_id}</td>
|
||||
<td>${data[keys[i]].application_date}</td>
|
||||
<td>${data[keys[i]].student_id}</td>
|
||||
<td>${data[keys[i]].departmant_and_grade}</td>
|
||||
<td>${data[keys[i]].student_name}</td>
|
||||
<td>${data[keys[i]].advisor_name}</td>
|
||||
<td> <ul>
|
||||
`;
|
||||
for (let j=0; j<data[keys[i]].item_contents.length; j++) {
|
||||
table_content += `<li>${data[keys[i]].item_contents[j]}`
|
||||
if (data[keys[i]].application_units[j]) {
|
||||
table_content += `(${data[keys[i]].application_units[j]}`
|
||||
if (data[keys[i]].subsidys[j]) {
|
||||
table_content += `, NT \$${data[keys[i]].subsidys[j]}`;
|
||||
}
|
||||
table_content += `)`;
|
||||
}
|
||||
table_content += `</li>`;
|
||||
}
|
||||
|
||||
table_content += `
|
||||
</ul></td>
|
||||
<td>${data[keys[i]].assistant_name}</td>
|
||||
`;
|
||||
if (data[keys[i]].documents_ready) {
|
||||
table_content += `<td>仍需補交 ${data[keys[i]].documents_ready}</td>`
|
||||
} else {
|
||||
table_content += `<td>不需補交文件</td>`
|
||||
}
|
||||
|
||||
table_content += `
|
||||
<td>於${data[keys[i]].passed_date} ${data[keys[i]].meeting_name}會議通過,核發獎學金 ${data[keys[i]].scholarship_amount}</td>
|
||||
</tr>
|
||||
`
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
table_content += `
|
||||
</table>
|
||||
<h3>審核未通過</h3>
|
||||
<table border='1'>
|
||||
`
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (data[keys[i]].committee_review == 0) {
|
||||
table_content +=
|
||||
`
|
||||
<tr>
|
||||
<td>${data[keys[i]].application_id}</td>
|
||||
<td>${data[keys[i]].application_date}</td>
|
||||
<td>${data[keys[i]].student_id}</td>
|
||||
<td>${data[keys[i]].departmant_and_grade}</td>
|
||||
<td>${data[keys[i]].student_name}</td>
|
||||
<td>${data[keys[i]].advisor_name}</td>
|
||||
<td> <ul>
|
||||
`;
|
||||
for (let j=0; j<data[keys[i]].item_contents.length; j++) {
|
||||
table_content += `<li>${data[keys[i]].item_contents[j]}`
|
||||
if (data[keys[i]].application_units[j]) {
|
||||
table_content += `(${data[keys[i]].application_units[j]}`
|
||||
if (data[keys[i]].subsidys[j]) {
|
||||
table_content += `, NT \$${data[keys[i]].subsidys[j]}`;
|
||||
}
|
||||
table_content += `)`;
|
||||
}
|
||||
table_content += `</li>`;
|
||||
}
|
||||
|
||||
table_content += `
|
||||
</ul></td>
|
||||
<td>${data[keys[i]].assistant_name}</td>
|
||||
`;
|
||||
if (data[keys[i]].documents_ready) {
|
||||
table_content += `<td>仍需補交 ${data[keys[i]].documents_ready}</td>`
|
||||
} else {
|
||||
table_content += `<td>不需補交文件</td>`
|
||||
}
|
||||
|
||||
table_content += `
|
||||
</tr>
|
||||
`
|
||||
;
|
||||
}
|
||||
}
|
||||
table_content += `
|
||||
</table>
|
||||
`
|
||||
// write back data into table
|
||||
document.getElementById(table_id).innerHTML = table_content;
|
||||
// set info length
|
||||
item_info_len = data.length;
|
||||
}
|
||||
else {
|
||||
console.error("data and table id can not be null");
|
||||
}
|
||||
}
|
||||
async function setAssistantName() {
|
||||
// get student name, and show on page
|
||||
const queryString = window.location.search;
|
||||
@ -242,8 +339,9 @@ async function sendReviewResult() {
|
||||
else {
|
||||
alert("審核失敗!", result.data.msg);
|
||||
}
|
||||
window.location.reload();
|
||||
// window.location.reload();
|
||||
}
|
||||
|
||||
setAssistantName();
|
||||
putDataInTable("application_table");
|
||||
putDataInAuditedTable("audit_block");
|
||||
|
||||
@ -87,8 +87,7 @@
|
||||
<br>
|
||||
<fieldset>
|
||||
<h2 align="center">審核區</h2>
|
||||
<table id="audit_table" border="1">
|
||||
</table>
|
||||
<div id='audit_block'></div>
|
||||
<form id="audit_item" border="1">
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user