|
|
@@ -107,6 +107,7 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
margin-top: 13px;
|
|
|
border-bottom: 4px solid #0088cc;
|
|
|
height: 41px;
|
|
|
+ padding-left: 40px;
|
|
|
}
|
|
|
|
|
|
.sidebar-left {
|
|
|
@@ -144,8 +145,12 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- th {
|
|
|
- width: 30%;
|
|
|
+ #tablepage0>thead>tr>th {
|
|
|
+ width: 25%;
|
|
|
+ }
|
|
|
+
|
|
|
+ #tableform>thead>tr>th {
|
|
|
+ width: 50%;
|
|
|
}
|
|
|
|
|
|
.nav-main {
|
|
|
@@ -168,10 +173,6 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
width: 0px;
|
|
|
}
|
|
|
|
|
|
- #datatable-ajax tr:hover {
|
|
|
- background-color: #e8e8e8;
|
|
|
- }
|
|
|
-
|
|
|
#viewDiv {
|
|
|
height: 100%;
|
|
|
width: 100%;
|
|
|
@@ -281,6 +282,10 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
color: white;
|
|
|
}
|
|
|
|
|
|
+ table.dataTable tbody tr td.NullClass {
|
|
|
+ background-color: #ed9c28;
|
|
|
+ }
|
|
|
+
|
|
|
.submit {
|
|
|
display: inline-block;
|
|
|
margin-left: auto;
|
|
|
@@ -319,7 +324,9 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
color: #d2322d;
|
|
|
}
|
|
|
|
|
|
- a.error.text-center,i.error {
|
|
|
+ a.error.text-center,
|
|
|
+ i.error,
|
|
|
+ td.error {
|
|
|
color: #d2322d;
|
|
|
}
|
|
|
|
|
|
@@ -331,7 +338,9 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
color: #ed9c28;
|
|
|
}
|
|
|
|
|
|
- a.warning.text-center,i.warning {
|
|
|
+ a.warning.text-center,
|
|
|
+ i.warning,
|
|
|
+ td.warning {
|
|
|
color: #ed9c28;
|
|
|
}
|
|
|
|
|
|
@@ -343,7 +352,8 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
color: #0088cc;
|
|
|
}
|
|
|
|
|
|
- a.info.text-center,i.info {
|
|
|
+ a.info.text-center,
|
|
|
+ i.info {
|
|
|
color: #0088cc;
|
|
|
}
|
|
|
|
|
|
@@ -355,9 +365,18 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
color: #4a934a;
|
|
|
}
|
|
|
|
|
|
- a.success.text-center,i.success {
|
|
|
+ a.success.text-center,
|
|
|
+ i.success {
|
|
|
color: #4a934a;
|
|
|
}
|
|
|
+
|
|
|
+ .dataTables_wrapper .dataTables_filter label {
|
|
|
+ width: initial;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dataTables_wrapper .dataTables_filter input {
|
|
|
+ width: initial;
|
|
|
+ }
|
|
|
</style>
|
|
|
|
|
|
|
|
|
@@ -445,14 +464,15 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
|
|
|
</section>
|
|
|
<script type="text/javascript">
|
|
|
-
|
|
|
+ var error;
|
|
|
+ var tables;
|
|
|
const icons = {
|
|
|
- 'info':'fa fa-info-circle',
|
|
|
- 'success':'fa fa-check-circle',
|
|
|
- 'error':'fa fa-times-circle',
|
|
|
- 'warning':'fa fa-exclamation-circle',
|
|
|
- };
|
|
|
- // TODO: 1.頁籤依據選擇變色 2.偵測null欄位資料
|
|
|
+ 'info': 'fa fa-info-circle',
|
|
|
+ 'success': 'fa fa-check-circle',
|
|
|
+ 'error': 'fa fa-times-circle',
|
|
|
+ 'warning': 'fa fa-exclamation-circle',
|
|
|
+ };
|
|
|
+
|
|
|
$(document).ready(function() {
|
|
|
const queryString = window.location.search;
|
|
|
const urlParams = new URLSearchParams(queryString);
|
|
|
@@ -479,26 +499,29 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
type: "GET",
|
|
|
})
|
|
|
.success(function(response) {
|
|
|
- var table = response.table;
|
|
|
+ tables = response.table;
|
|
|
var info = response.info;
|
|
|
var statuses = response.statuses;
|
|
|
- console.log(response.test);
|
|
|
+ errors = response.errorLists;
|
|
|
+ var projectInfo = tables["匯入資訊"];
|
|
|
+ $("#header").append(projectInfo[1][0] + "-" + projectInfo[1][1]); // 16019-促進民間參與高雄市鳳山溪污水處理廠放流水回收再利用案之興建、移轉、營運
|
|
|
+
|
|
|
let i = 0;
|
|
|
- for (var tab in table) {
|
|
|
+ console.log(errors);
|
|
|
+ for (var tab in tables) {
|
|
|
let status = statuses[i];
|
|
|
let active = '';
|
|
|
if (i == 0) {
|
|
|
active = 'class="active"';
|
|
|
- }
|
|
|
+ }
|
|
|
let icon = icons[status];
|
|
|
$('#tabs').append(`<li ${active}><a href="#page${i}" data-toggle="tab" class="text-center ${status}"><i class="${icon}"></i> ${tab}</a></li>`);
|
|
|
$("#tab-content").append(`<div id="page${i}" class="tab-pane fade"></div>`);
|
|
|
-
|
|
|
- appendTable(table[tab], `#page${i}`);
|
|
|
+ appendTable(tables[tab], `page${i}`);
|
|
|
i++;
|
|
|
}
|
|
|
$(`#page${0}`).append("<form id='form' method='post' action='./insertExcel.php'></form>");
|
|
|
- appendTable(info, "#form");
|
|
|
+ appendTable(info, "form");
|
|
|
// TODO: add confirm message
|
|
|
$("#form").append(`<div class='center'><input class='submit' type='submit' value='開始匯入'><button type='button' class='submit' onClick=\"location.href='/DataBase/upload.html'\" >重新選擇檔案</button></div>`);
|
|
|
$("#form").append(`<input id='projectId' name='projectId' type='hidden' value='${projectId}'><input id='projectName' name='projectName' type='hidden' value='${projectName}'><input id='file' name='file' type='hidden' value='${file}'><input id='categoryId' name='categoryId' style='display:none;' value='${categoryId}'>`);
|
|
|
@@ -508,29 +531,104 @@ if (0 < $_FILES['excel']['error']) {
|
|
|
})
|
|
|
.complete(function() {
|
|
|
$('#page0').addClass('in active')
|
|
|
+ let i = 1;
|
|
|
+
|
|
|
+ for (var tab in tables) {
|
|
|
+ var errorList = [];
|
|
|
+
|
|
|
+ if (errors[tab] != "" && errors[tab] != undefined) {
|
|
|
+ errorList = errors[tab].split(',');
|
|
|
+ errorList.shift();
|
|
|
+ }
|
|
|
+
|
|
|
+ /*$('#tablepage'+i).dataTable({
|
|
|
+ "createdRow": function(row, data, dataIndex) {
|
|
|
+ for (j = 0; j < data.length; j++) {
|
|
|
+ if (data[j] == `null`) {
|
|
|
+ $(row).addClass('NullClass');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });*/
|
|
|
+ $('#tablepage' + i).dataTable({
|
|
|
+ "language": {
|
|
|
+ "processing": "處理中...",
|
|
|
+ "loadingRecords": "載入中...",
|
|
|
+ "lengthMenu": "顯示 _MENU_ 項結果",
|
|
|
+ "zeroRecords": "沒有符合的結果或是沒有資料",
|
|
|
+ "info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
|
|
+ "infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
|
|
+ "infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
|
|
+ "infoPostFix": "",
|
|
|
+ "search": "搜尋:",
|
|
|
+ "paginate": {
|
|
|
+ "first": '<i class="fa fa-step-backward"></i>',
|
|
|
+ "previous": '<i class="fa fa-backward"></i>',
|
|
|
+ "next": '<i class="fa fa-forward"></i>',
|
|
|
+ "last": '<i class="fa fa-step-forward"></i>'
|
|
|
+ },
|
|
|
+ "aria": {
|
|
|
+ "sortAscending": ": 升冪排列",
|
|
|
+ "sortDescending": ": 降冪排列"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "columnDefs": [{
|
|
|
+ "targets": -1,
|
|
|
+ "createdCell": function(td, cellData, rowData, row, col) {
|
|
|
+
|
|
|
+ if(cellData == "03-厭氧儲氣槽結構計算書"){
|
|
|
+ console.log("row:" + row + " col: " + col)
|
|
|
+ }
|
|
|
+ if(errorList.length > 0 ){
|
|
|
+ for(var error in errorList){
|
|
|
+ if(error == row){
|
|
|
+ console.log(cellData)
|
|
|
+ $(td).addClass('NullClass');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },{
|
|
|
+ "targets": '_all',
|
|
|
+ "createdCell": function(td, cellData, rowData, row, col) {
|
|
|
+ if (cellData == "null") {
|
|
|
+ $(td).addClass('NullClass');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ });
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function appendTable(data, id) {
|
|
|
let i = 0;
|
|
|
- table = "<table class='excel'>";
|
|
|
+ table = `<table id='table${id}' class='excel'><thead>`;
|
|
|
for (var tab in data) {
|
|
|
table += "<tr>";
|
|
|
|
|
|
for (j = 0; j < data[tab].length; j++) {
|
|
|
if (i == 0)
|
|
|
- table += `<th style="width:33%;">${data[tab][j]}</th>`
|
|
|
+ table += `<th>${data[tab][j]}</th>` //style="width:33%;"
|
|
|
else
|
|
|
table += `<td>${data[tab][j]}</td>`
|
|
|
}
|
|
|
- i++;
|
|
|
+
|
|
|
table += "</tr>";
|
|
|
+ if (i == 0) {
|
|
|
+ table += "</thead><tbody>";
|
|
|
+ }
|
|
|
+ i++;
|
|
|
}
|
|
|
|
|
|
|
|
|
- table += "</table>";
|
|
|
+ table += "</tbody></table>";
|
|
|
|
|
|
- $(id).append(table);
|
|
|
+ $('#' + id).append(table);
|
|
|
}
|
|
|
</script>
|
|
|
|