將前端整合進來
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
var selectedDate = document.getElementById("queryDate");
|
||||
|
||||
let table = document.createElement("table");
|
||||
let thead = document.createElement("thead");
|
||||
let tbody = document.createElement("tbody");
|
||||
|
||||
table.appendChild(thead);
|
||||
table.appendChild(tbody);
|
||||
|
||||
// Adding the entire table to the body tag
|
||||
document.getElementById("body").appendChild(table);
|
||||
|
||||
// Creating and adding data to first row of the table
|
||||
let row_1 = document.createElement("tr");
|
||||
/*let heading_1 = document.createElement("th");
|
||||
heading_1.innerHTML = "<h4>成員名稱</h4>";*/
|
||||
let heading_2 = document.createElement("th");
|
||||
heading_2.innerHTML = "<h4>角色暱稱</h4>";
|
||||
heading_2.setAttribute('style', 'width: 54%;')
|
||||
let heading_3 = document.createElement("th");
|
||||
heading_3.innerHTML = "<h4>角色UID</h4>";
|
||||
heading_3.setAttribute('style', 'width: 34%;')
|
||||
/*let heading_4 = document.createElement("th");
|
||||
heading_4.innerHTML = "<h4>DC ID</h4>";*/
|
||||
let heading_5 = document.createElement("th");
|
||||
heading_5.innerHTML = "<h4>離開</h4>";
|
||||
heading_5.setAttribute('style', 'width: 12%;')
|
||||
|
||||
//row_1.appendChild(heading_1);
|
||||
row_1.appendChild(heading_2);
|
||||
row_1.appendChild(heading_3);
|
||||
//row_1.appendChild(heading_4);
|
||||
row_1.appendChild(heading_5);
|
||||
thead.appendChild(row_1);
|
||||
// 取得刀表
|
||||
axios.get("./api/member", {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
const data = response.data;
|
||||
console.log(data);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
// Creating and adding data to second row of the table
|
||||
let row_2 = document.createElement("tr");
|
||||
//let row_2_data_1 = document.createElement("td");
|
||||
let row_2_data_2 = document.createElement("td");
|
||||
let row_2_data_3 = document.createElement("td");
|
||||
//let row_2_data_4 = document.createElement("td");
|
||||
let row_2_data_5 = document.createElement("td");
|
||||
|
||||
const item = data[i];
|
||||
|
||||
//row_2_data_1.innerHTML = "<a href=\"edit.html?id=" + item._id + "\">" + item.nickName + "</a>";
|
||||
row_2_data_2.innerHTML = "<h4><a href=\"edit.html?id=" + item._id + "\">" + item.playerName + "</a></h4>";
|
||||
row_2_data_3.innerHTML = "<h4>" + item.uid + "</h4>";
|
||||
//row_2_data_4.innerHTML = item.discordID;
|
||||
if (item.leave) {
|
||||
row_2_data_5.innerHTML = "<h4>O</h4>";
|
||||
} else {
|
||||
row_2_data_5.innerHTML = "<h4>X</h4>";
|
||||
}
|
||||
|
||||
//row_2.appendChild(row_2_data_1);
|
||||
row_2.appendChild(row_2_data_2);
|
||||
row_2.appendChild(row_2_data_3);
|
||||
//row_2.appendChild(row_2_data_4);
|
||||
row_2.appendChild(row_2_data_5);
|
||||
tbody.appendChild(row_2);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
//const message = error.response.data.message;
|
||||
//alert("資料取得失敗");
|
||||
console.error('資料取得失敗:', error);
|
||||
});
|
||||
Reference in New Issue
Block a user