component-list.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <?php
  2. include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_right.php");
  3. ?>
  4. <!doctype html>
  5. <html class="fixed sidebar-left-collapsed">
  6. <head>
  7. <?php include("bim-support-header.html"); ?>
  8. <script src="./script/js/global.js"></script>
  9. <script type="application/javascript">
  10. var rvtName = [];
  11. var categoryTable = [];
  12. var year = [];
  13. //當選擇大項時,需要展示所有'細項分類'內的元件
  14. var category = [];
  15. var categoryInEnglish = [];
  16. //現在的細項分類
  17. var type = "";
  18. var typeInChinese = "";
  19. //現在的大項分類
  20. var parent = "";
  21. var parentInChinese = "";
  22. //類別的中英文字典,中文是為了檔案路徑
  23. var allTypeInEnglish = [];
  24. var allTypeInChinese = [];
  25. var allParentInEnglish = [];
  26. var allParentInChinese = [];
  27. var userName = '<?php echo $_SESSION['name']; ?>';
  28. var searchURL = window.location.search;
  29. searchURL = searchURL.substring(1, searchURL.length);
  30. if (searchURL != "") {
  31. //類別選擇細項
  32. if (searchURL.split("&") != undefined && searchURL.split("&")[1] != undefined) {
  33. type = searchURL.split("&")[0].split("=")[1];
  34. parent = searchURL.split("&")[1].split("=")[1];
  35. //類別選擇大項
  36. } else if (searchURL.split("&") != undefined && searchURL.split("&")[1] == undefined) {
  37. parent = searchURL.split("&")[0].split("=")[1];
  38. }
  39. }
  40. var $grid;
  41. pageHeader = "元件庫";
  42. //匯入大細項類別的中英文字典
  43. $.getJSON('./assets/equipmentTable2.json', function(data) {
  44. for (var i = 0; i < data.length; i++) {
  45. allParentInEnglish.push(data[i].category_code);
  46. allParentInChinese.push(data[i].category_name);
  47. for (var j = 0; j < data[i].children.length; j++) {
  48. allTypeInEnglish.push(data[i].children[j].component_code);
  49. allTypeInChinese.push(data[i].children[j].component_name);
  50. }
  51. }
  52. });
  53. </script>
  54. </head>
  55. <body>
  56. <canvas id="c"></canvas>
  57. <section class="body">
  58. <!-- start: header -->
  59. <header-menu></header-menu>
  60. <!-- end: header -->
  61. <div class="inner-wrapper">
  62. <!-- start: sidebar -->
  63. <side-bar></side-bar>
  64. <!-- end: sidebar -->
  65. <section role="main" class="content-body">
  66. <header class="page-header">
  67. <h2>{{pageHeader}}</h2>
  68. </header>
  69. <!-- start: page -->
  70. <section class="content-with-menu content-with-menu-has-toolbar media-gallery">
  71. <div class="content-with-menu-container">
  72. <inner-menu>
  73. <template v-slot:inner-equipment>
  74. <equipment-list></equipment-list>
  75. </template>
  76. </inner-menu>
  77. <div class="inner-body mg-main">
  78. <div class="inner-toolbar">
  79. <ul>
  80. <search-bar></search-bar>
  81. <filter-bar></filter-bar>
  82. </ul>
  83. </div>
  84. <filter-content></filter-content>
  85. <div class="row mg-files" data-sort-destination data-sort-id="media-gallery" id="content">
  86. </div>
  87. </div>
  88. </div>
  89. </section>
  90. <!-- end: page -->
  91. </section>
  92. </div>
  93. </section>
  94. <script>
  95. /*Vue */
  96. vm.mount('.body');
  97. </script>
  98. <?php include("bim-support-body.html"); ?>
  99. <script type="application/javascript">
  100. $(function() {
  101. //現在大項的中文
  102. for (var i = 0; i < allParentInEnglish.length; i++) {
  103. if (allParentInEnglish[i] == parent) {
  104. parentInChinese = allParentInChinese[i];
  105. }
  106. }
  107. //現在細項的中文
  108. for (var i = 0; i < allTypeInEnglish.length; i++) {
  109. if (allTypeInEnglish[i] == type) {
  110. typeInChinese = allTypeInChinese[i];
  111. }
  112. }
  113. //撈現在類別內的元件
  114. $.ajax({
  115. url: "./script/php/equipment_group.php",
  116. type: "GET",
  117. data: {
  118. type: typeInChinese,
  119. parent: parentInChinese
  120. },
  121. contentType: "application/json",
  122. dataType: "json"
  123. }).done(function(data) {
  124. year = data['year'];
  125. rvtName = data['rvtName'];
  126. category = data["category"];
  127. //若類別選大項,需要列所有細項的元件,因此需要所有元件的細項名稱
  128. for (var i = 0; i < category.length; i++) {
  129. for (var j = 0; j < allTypeInChinese.length; j++) {
  130. if (category[i] == allTypeInChinese[j]) {
  131. categoryInEnglish[i] = allTypeInEnglish[j];
  132. }
  133. }
  134. }
  135. //一開始進入BIM元件庫顯示
  136. if (searchURL == "") {
  137. $("#content").append("<h3>請選擇左方類別以搜尋元件</h3>");
  138. $("#content").css("padding", "0");
  139. $("#content").css("text-align", "center");
  140. }
  141. if (!(type == "" && parent == "")) {
  142. $.when(initThreeJS()).then(function() {
  143. $grid = $("#content").isotope({
  144. itemSelector: ".isotope-item",
  145. layoutMode: 'fitRows'
  146. });
  147. //若選到細項,該細項內沒有元件檔案
  148. if ($("#content").children().length == 0 && searchURL != "") {
  149. $("#content").append("<h3>此類別沒有元件檔案</h3>");
  150. $("#content").css("padding", "0");
  151. $("#content").css("text-align", "center");
  152. }
  153. }).then(function() {
  154. //元件有時候會不排版
  155. setTimeout(function() {
  156. $grid.isotope()
  157. }, 100);
  158. });
  159. }
  160. }).error(function(error) {
  161. console.log(error);
  162. });
  163. $.ajax({
  164. url: "./script/php/equipment_revitVersion.php",
  165. type: "GET",
  166. data: {
  167. type: type,
  168. parent: parent
  169. },
  170. contentType: "application/json",
  171. dataType: "json"
  172. }).done(function(data) {
  173. //篩選內元件版本
  174. for (var i = 0; i < data.length; i++) {
  175. $("#revitVersion").append('<label><input type="checkbox" value=".' + data[i] + '" /> ' + data[i] + '</label> ');
  176. }
  177. }).error(function(error) {
  178. console.log(error);
  179. });
  180. //被選到的類別highlight起來
  181. for (var i = 0; i < jsonData.length; i++) {
  182. for (var j = 0; j < jsonData[i].children.length; j++) {
  183. $("a").each(function() {
  184. if (jsonData[i].category_code == parent) {
  185. //選到的是細項類別
  186. if (jsonData[i].children[j].component_code == type) {
  187. var searchText = jsonData[i].children[j].component_name;
  188. var found;
  189. if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
  190. $(this).context.classList.add("highlight");
  191. $(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
  192. }
  193. //選到的是大項類別
  194. } else if (type == "") {
  195. var searchText = parentInChinese;
  196. var found;
  197. if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
  198. if (!$(this).context.classList.contains("highlight")) {
  199. $(this).context.classList.add("highlight");
  200. $(this).context.setAttribute("style", "background: #0088cc");
  201. } else {
  202. $(this).context.removeAttribute("href");
  203. }
  204. }
  205. }
  206. }
  207. });
  208. }
  209. }
  210. });
  211. </script>
  212. <script src="assets/javascripts/pages/examples.mediagallery.js"></script>
  213. <script src="script/js/3Dpic.js" type="module"></script>
  214. </body>
  215. </html>