component-list.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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("<h1 style='color: red;'>注意!BIM元件庫需配合BIM程式庫中的拖放元件API使用!</h1>");
  141. $("#content").append("<h3>請選擇左方類別以搜尋元件,搜尋到需要的元件請點擊加入清單按鈕</h3>");
  142. $("#content").append("<h3>到BIM程式庫下載拖放元件API,並參考操作方式以進行元件放置動作</h3>");
  143. $("#content").css("padding", "0");
  144. $("#content").css("text-align", "center");
  145. }
  146. if (!(type == "" && parent == "")) {
  147. $.when(initThreeJS()).then(function() {
  148. $grid = $("#content").isotope({
  149. itemSelector: ".isotope-item",
  150. layoutMode: 'fitRows'
  151. });
  152. //若選到細項,該細項內沒有元件檔案
  153. if ($("#content").children().length == 0 && searchURL != "") {
  154. $("#content").append("<h3>此類別沒有元件檔案</h3>");
  155. $("#content").css("padding", "0");
  156. $("#content").css("text-align", "center");
  157. }
  158. }).then(function() {
  159. //元件有時候會不排版
  160. setTimeout(function() {
  161. $grid.isotope()
  162. }, 100);
  163. });
  164. }
  165. }).error(function(error) {
  166. console.log(error);
  167. });
  168. $.ajax({
  169. url: "./script/php/equipment_revitVersion.php",
  170. type: "GET",
  171. data: {
  172. type: type,
  173. parent: parent
  174. },
  175. contentType: "application/json",
  176. dataType: "json"
  177. }).done(function(data) {
  178. //篩選內元件版本
  179. for (var i = 0; i < data.length; i++) {
  180. $("#revitVersion").append('<label><input type="checkbox" value=".' + data[i] + '" /> ' + data[i] + '</label> ');
  181. }
  182. }).error(function(error) {
  183. console.log(error);
  184. });
  185. //被選到的類別highlight起來
  186. for (var i = 0; i < jsonData.length; i++) {
  187. for (var j = 0; j < jsonData[i].children.length; j++) {
  188. $("a").each(function() {
  189. if (jsonData[i].category_code == parent) {
  190. //選到的是細項類別
  191. if (jsonData[i].children[j].component_code == type) {
  192. var searchText = jsonData[i].children[j].component_name;
  193. var found;
  194. if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
  195. $(this).context.classList.add("highlight");
  196. $(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
  197. }
  198. //選到的是大項類別
  199. } else if (type == "") {
  200. var searchText = parentInChinese;
  201. var found;
  202. if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_code) {
  203. if (!$(this).context.classList.contains("highlight")) {
  204. $(this).context.classList.add("highlight");
  205. $(this).context.setAttribute("style", "background: #0088cc");
  206. } else {
  207. $(this).context.removeAttribute("href");
  208. }
  209. }
  210. }
  211. }
  212. });
  213. }
  214. }
  215. });
  216. </script>
  217. <script src="./script/js/data-sort.js"></script>
  218. <script src="script/js/3Dpic.js" type="module"></script>
  219. </body>
  220. </html>