ソースを参照

資料夾階層改位置、搜尋回上層bug

nate 3 年 前
コミット
a98e784def
2 ファイル変更39 行追加28 行削除
  1. 1 2
      index.php
  2. 38 26
      script/js/jstreeAJAX.js

+ 1 - 2
index.php

@@ -74,7 +74,6 @@ if (!isset($_SESSION['loggedin'])) {
 			color: #FFFFFF;
 		}
 
-
 		.page-header>ul>li.right {
 			float: right;
 			padding-right: 10px;
@@ -575,7 +574,7 @@ if (!isset($_SESSION['loggedin'])) {
 					<div class="col-md-12">
 						<section class="panel">
 							<div class="panel-body">
-								<div id="folderPath" style="float: left;"></div>
+								
 								<button id="reset" type="button" class="mb-xs mr-xs btn btn-default" style="float: right;"><i class="fa fa-reply"></i> 上一層</button>
 								<table style="width:99%;" class="table table-bordered table-striped" id="datatable-ajax">
 									<thead>

+ 38 - 26
script/js/jstreeAJAX.js

@@ -140,14 +140,18 @@ $(document).ready(function () {
     }).on(
         'select_node.jstree',
         function (event, data) {
+            
             if (data.node.text.includes("-")) {
-                $("#folderPath").empty();
+                $("#reset").prop("disabled", false);
+                $("#header").empty();
                 displayDetail(false);
                 project_id = data.node.text.split("-")[0];
                 project_name = data.node.text.split("-")[1];
                 project = data.node.text;
                 $("#project-id").val(project_id)
-                $("#header").text(project);
+                //$("#header").text(project + " > ");
+                $("#header").empty();
+                $("#header").append("<span>" + project + " > </span>");
                 category = $('#treeAjaxHTML').jstree(true).get_node(data.node.parents[0]).text;
                 let i = 1;
                 table.clear().draw();
@@ -175,8 +179,12 @@ $(document).ready(function () {
         });
 
     $('#btn-search').click(function () {
-        $("#folderPath").empty();
-        $("#header").text("搜尋結果");
+
+        $("#reset").prop("disabled", true);
+        $("#header").empty();
+        //$("#header").text("搜尋結果");
+        $("#header").empty();
+        $("#header").append("<span>搜尋結果</span>");
         $.ajax({
                 url: "./script/php/search.php",
                 data: {
@@ -223,28 +231,32 @@ $(document).ready(function () {
 
     $('#reset').click(function () {
 
-        folderPath.pop();
-        let index = folderPath.length;
-        
-        $("#folderPath").children().eq(index).remove();
-
-        table.clear().draw();
-        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();
-            });
+        if (folderPath.length != 1) {
+            folderPath.pop();
+            let index = folderPath.length;
+            $("#header").children().eq(index).remove();
+            table.clear().draw();
+            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);
         }
-        $("#tableDetail td").empty();
-        displayDetail(false);
+
+
+
     });
 
     var is_blueprint2 = false;
     $('#datatable-ajax tbody').on('click', 'tr', function () {
+        $("#reset").prop("disabled", false);
         $(this).parent().find("tr").css('background-color', '');
         $(this).css("background-color", "#cccccc");
         $("#tableDetail td").empty();
@@ -280,15 +292,15 @@ $(document).ready(function () {
                     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();
+                        for (k = index + 1; k < folderPath.length; k++) {
+                            $("#header").children().eq(k).remove();
                             folderPath.pop();
                         }
                         addTable(data, notes, response, SN, path);
                         is_blueprint2 = false;
                     });
-                    $("#folderPath").append(span);
-                    folderPath = $("#folderPath").text().split(" > ");
+                    $("#header").append(span);
+                    folderPath = $("#header").text().split(" > ");
                     folderPath.pop();
 
                     addTable(data, notes, response, SN, path);
@@ -338,7 +350,7 @@ $(document).ready(function () {
     }
 
     function addTable(data, notes, response, SN, path) {
-
+        
         table.clear().draw();
         if (data[1] != "設計圖") {
             displayDetail(true);