|
|
@@ -1,4 +1,4 @@
|
|
|
-$(document).ready(function() {
|
|
|
+$(document).ready(function () {
|
|
|
const types = ["工程概要", "工程計算書", "設計圖", "數量計算書", "工程預算書", "施工規範及特定條款", "設計報告書"];
|
|
|
var path = '';
|
|
|
var category = '';
|
|
|
@@ -75,7 +75,7 @@ $(document).ready(function() {
|
|
|
]
|
|
|
],
|
|
|
|
|
|
- drawCallback: function() {
|
|
|
+ drawCallback: function () {
|
|
|
if (!start) {
|
|
|
var api = this.api();
|
|
|
var rowCount = api.rows({
|
|
|
@@ -98,10 +98,10 @@ $(document).ready(function() {
|
|
|
type: "GET",
|
|
|
async: false
|
|
|
})
|
|
|
- .success(function(response) {
|
|
|
+ .success(function (response) {
|
|
|
tree_data = response;
|
|
|
|
|
|
- }).error(function(error) {
|
|
|
+ }).error(function (error) {
|
|
|
console.log(error);
|
|
|
});
|
|
|
|
|
|
@@ -109,6 +109,7 @@ $(document).ready(function() {
|
|
|
displayDetail(false);
|
|
|
|
|
|
|
|
|
+
|
|
|
$('#treeAjaxHTML').jstree({
|
|
|
'core': {
|
|
|
'themes': {
|
|
|
@@ -128,7 +129,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
},
|
|
|
'plugins': ['types', 'search', 'wholerow']
|
|
|
- }).bind("loaded.jstree", function(event, data) {
|
|
|
+ }).bind("loaded.jstree", function (event, data) {
|
|
|
var searchURL = window.location.search;
|
|
|
searchURL = searchURL.substring(1, searchURL.length);
|
|
|
if (searchURL.includes("=")) {
|
|
|
@@ -136,18 +137,9 @@ $(document).ready(function() {
|
|
|
$(this).jstree("open_all");
|
|
|
}
|
|
|
|
|
|
- /*var typeNode = $(".jstree-anchor").filter(function() {
|
|
|
- return $(this).text() == type;
|
|
|
- });
|
|
|
-
|
|
|
- var typeId = typeNode[0].attributes.id.value;
|
|
|
-
|
|
|
- $(this).jstree("select_node", typeId);*/
|
|
|
-
|
|
|
-
|
|
|
}).on(
|
|
|
'select_node.jstree',
|
|
|
- function(event, data) {
|
|
|
+ function (event, data) {
|
|
|
if (data.node.text.includes("-")) {
|
|
|
$("#folderPath").empty();
|
|
|
displayDetail(false);
|
|
|
@@ -160,7 +152,7 @@ $(document).ready(function() {
|
|
|
let i = 1;
|
|
|
table.clear().draw();
|
|
|
tempTable = [];
|
|
|
- types.forEach(function(data) {
|
|
|
+ types.forEach(function (data) {
|
|
|
|
|
|
let temp = [
|
|
|
i,
|
|
|
@@ -182,7 +174,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $('#btn-search').click(function() {
|
|
|
+ $('#btn-search').click(function () {
|
|
|
$("#folderPath").empty();
|
|
|
$("#header").text("搜尋結果");
|
|
|
$.ajax({
|
|
|
@@ -195,11 +187,11 @@ $(document).ready(function() {
|
|
|
dataType: "json",
|
|
|
type: "GET",
|
|
|
})
|
|
|
- .success(function(response) {
|
|
|
+ .success(function (response) {
|
|
|
displayDetail(true);
|
|
|
table.clear().draw();
|
|
|
$("#tableDetail td").empty();
|
|
|
- response.forEach(function(data) {
|
|
|
+ response.forEach(function (data) {
|
|
|
let temp = [
|
|
|
data["SN"],
|
|
|
data["original_name"].slice(6),
|
|
|
@@ -217,46 +209,46 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
})
|
|
|
- .error(function(error) {
|
|
|
+ .error(function (error) {
|
|
|
console.log(error);
|
|
|
})
|
|
|
- .complete(function() {});
|
|
|
+ .complete(function () {});
|
|
|
|
|
|
});
|
|
|
- $('#search').keyup(function(e) {
|
|
|
+ $('#search').keyup(function (e) {
|
|
|
if (e.keyCode == 13) {
|
|
|
$('#btn-search').click();
|
|
|
}
|
|
|
});
|
|
|
- $('#reset').click(function() {
|
|
|
- $("#folderPath").empty();
|
|
|
- folderPath.splice(folderPath.length - 2, 1);
|
|
|
- if (folderPath[0] != " ") {
|
|
|
- $("#folderPath").text(folderPath.join(">"));
|
|
|
- }
|
|
|
+
|
|
|
+ $('#reset').click(function () {
|
|
|
+
|
|
|
+ folderPath.pop();
|
|
|
+ let index = folderPath.length;
|
|
|
+
|
|
|
+ $("#folderPath").children().eq(index).remove();
|
|
|
+
|
|
|
table.clear().draw();
|
|
|
- if (!is_blueprint2) {
|
|
|
- tempTable.forEach(function(data) {
|
|
|
- table.row.add(data).draw();
|
|
|
- });
|
|
|
- } else {
|
|
|
+ if(is_blueprint2){
|
|
|
tempTable2.forEach(function(data) {
|
|
|
table.row.add(data).draw();
|
|
|
});
|
|
|
is_blueprint2 = false;
|
|
|
+ }else{
|
|
|
+ tempTable.forEach(function(data) {
|
|
|
+ table.row.add(data).draw();
|
|
|
+ });
|
|
|
}
|
|
|
$("#tableDetail td").empty();
|
|
|
displayDetail(false);
|
|
|
-
|
|
|
});
|
|
|
|
|
|
var is_blueprint2 = false;
|
|
|
- $('#datatable-ajax tbody').on('click', 'tr', function() {
|
|
|
+ $('#datatable-ajax tbody').on('click', 'tr', function () {
|
|
|
$(this).parent().find("tr").css('background-color', '');
|
|
|
$(this).css("background-color", "#cccccc");
|
|
|
$("#tableDetail td").empty();
|
|
|
var data = table.row(this).data();
|
|
|
- console.log(data);
|
|
|
if (data == null) {
|
|
|
data = ["", "", "null", "", "", "", "", "", "", ""];
|
|
|
}
|
|
|
@@ -282,65 +274,30 @@ $(document).ready(function() {
|
|
|
dataType: "json",
|
|
|
type: "GET",
|
|
|
})
|
|
|
- .success(function(response) {
|
|
|
-
|
|
|
- table.clear().draw();
|
|
|
-
|
|
|
- $("#folderPath").text($("#folderPath").text() + data[1] + " > ");
|
|
|
- folderPath = $("#folderPath").text().split(">");
|
|
|
-
|
|
|
- if (data[1] != "設計圖") {
|
|
|
- displayDetail(true);
|
|
|
-
|
|
|
- if (notes.includes(data[1])) {
|
|
|
- is_blueprint2 = true;
|
|
|
- }
|
|
|
- for (i = 0; i < response.length; i++) {
|
|
|
- table.row.add([
|
|
|
- response[i]["SN"],
|
|
|
- response[i]["original_name"].slice(6),
|
|
|
- response[i]["keyword"],
|
|
|
- '1.0.0',
|
|
|
- response[i]["project_id"],
|
|
|
- response[i]["project_name"],
|
|
|
- response[i]["type_id"],
|
|
|
- response[i]["category_name"],
|
|
|
- response[i]["notes"],
|
|
|
- response[i]["filename"],
|
|
|
- ])
|
|
|
- table.draw();
|
|
|
+ .success(function (response) {
|
|
|
+
|
|
|
+ var span = $('<span>' + data[1] + ' > </span>');
|
|
|
+ span.on("click", function (e) {
|
|
|
+ let clicked = $(e.target).text().split(" > ")[0];
|
|
|
+ let index = folderPath.indexOf(clicked);
|
|
|
+ for(k = index+1; k < folderPath.length; k++){
|
|
|
+ $("#folderPath").children().eq(k).remove();
|
|
|
+ folderPath.pop();
|
|
|
}
|
|
|
+ addTable(data, notes, response, SN, path);
|
|
|
+ is_blueprint2 = false;
|
|
|
+ });
|
|
|
+ $("#folderPath").append(span);
|
|
|
+ folderPath = $("#folderPath").text().split(" > ");
|
|
|
+ folderPath.pop();
|
|
|
|
|
|
- } else {
|
|
|
- blueprint_SN = SN;
|
|
|
- blueprint_path = path;
|
|
|
- tempTable2 = [];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for (i = 0; i < response.length; i++) {
|
|
|
- notes[i] = response[i]['notes'];
|
|
|
-
|
|
|
- let temp = [
|
|
|
- i + 1,
|
|
|
- response[i]['notes'],
|
|
|
- '',
|
|
|
- '',
|
|
|
- data[4],
|
|
|
- ];
|
|
|
- table.row.add(temp);
|
|
|
- tempTable2.push(temp);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- table.draw();
|
|
|
- }
|
|
|
+ addTable(data, notes, response, SN, path);
|
|
|
|
|
|
})
|
|
|
- .error(function(error) {
|
|
|
+ .error(function (error) {
|
|
|
console.log(error);
|
|
|
})
|
|
|
- .complete(function() {});
|
|
|
+ .complete(function () {});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
@@ -380,4 +337,51 @@ $(document).ready(function() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function addTable(data, notes, response, SN, path) {
|
|
|
+
|
|
|
+ table.clear().draw();
|
|
|
+ if (data[1] != "設計圖") {
|
|
|
+ displayDetail(true);
|
|
|
+
|
|
|
+ if (notes.includes(data[1])) {
|
|
|
+ is_blueprint2 = true;
|
|
|
+ }
|
|
|
+ for (i = 0; i < response.length; i++) {
|
|
|
+ table.row.add([
|
|
|
+ response[i]["SN"],
|
|
|
+ response[i]["original_name"].slice(6),
|
|
|
+ response[i]["keyword"],
|
|
|
+ '1.0.0',
|
|
|
+ response[i]["project_id"],
|
|
|
+ response[i]["project_name"],
|
|
|
+ response[i]["type_id"],
|
|
|
+ response[i]["category_name"],
|
|
|
+ response[i]["notes"],
|
|
|
+ response[i]["filename"],
|
|
|
+ ])
|
|
|
+ table.draw();
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ blueprint_SN = SN;
|
|
|
+ blueprint_path = path;
|
|
|
+ tempTable2 = [];
|
|
|
+
|
|
|
+ for (i = 0; i < response.length; i++) {
|
|
|
+ notes[i] = response[i]['notes'];
|
|
|
+ let temp = [
|
|
|
+ i + 1,
|
|
|
+ response[i]['notes'],
|
|
|
+ '',
|
|
|
+ '',
|
|
|
+ data[4],
|
|
|
+ ];
|
|
|
+ table.row.add(temp);
|
|
|
+ tempTable2.push(temp);
|
|
|
+ }
|
|
|
+ table.draw();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
});
|