component-list.php 6.9 KB

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