component-detail.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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>
  10. var isFavorite = false;
  11. var revitVersion = "";
  12. var url_href = window.location.href;
  13. var url = new URL(url_href);
  14. name = url.searchParams.get("object");
  15. type = url.searchParams.get("type");
  16. parent = url.searchParams.get("parent");
  17. var userName = "<?php echo $_SESSION['name'] ?>";
  18. var role = "<?php echo ($groupName); ?>";
  19. var right = <?php echo ($right); ?>;
  20. var header = [];
  21. var sizeHeader = [];
  22. var value = [];
  23. var sizeValue = [];
  24. pageHeader = "元件庫";
  25. </script>
  26. <style>
  27. .hide-image {
  28. display: none;
  29. }
  30. .preview:hover .hide-image {
  31. display: block;
  32. position: absolute;
  33. padding: 8px;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <section class="body">
  39. <!-- start: header -->
  40. <header-menu></header-menu>
  41. <!-- end: header -->
  42. <div class="inner-wrapper">
  43. <!-- start: sidebar -->
  44. <side-bar></side-bar>
  45. <!-- end: sidebar -->
  46. <section role="main" class="content-body">
  47. <header class="page-header">
  48. <h2>{{pageHeader}}</h2>
  49. </header>
  50. <!-- start: page -->
  51. <section class="content-with-menu content-with-menu-has-toolbar media-gallery">
  52. <div class="content-with-menu-container">
  53. <inner-menu>
  54. <template v-slot:inner-equipment>
  55. <equipment-list></equipment-list>
  56. </template>
  57. </inner-menu>
  58. <div class="inner-body mg-main">
  59. <div class="inner-toolbar">
  60. <ul>
  61. <li>
  62. <label>
  63. <span id="insertComponentName" style="font-size: 30px; color: white;"></span>
  64. </label>
  65. </li>
  66. <li class="right">
  67. <a href="#" onclick="window.history.go(-1); return false;"><i class="fa fa-undo"></i> 返回</a>
  68. </li>
  69. <li class="right">
  70. <div style="cursor: pointer;" onclick="AddFavorite();"><i id="heart" class="fa fa-heart"></i><span id="favorite"> 加入清單</span></div>
  71. </li>
  72. </ul>
  73. </div>
  74. <div class="row">
  75. <div class="col-md-6">
  76. <div class="tabs">
  77. <ul class="nav nav-tabs nav-justified">
  78. <li class="active">
  79. <a href="#content" data-toggle="tab" class="text-center">3D元件模型</a>
  80. </li>
  81. <li>
  82. <a href="#2DImage" data-toggle="tab" class="text-center">2D圖例</a>
  83. </li>
  84. </ul>
  85. <div class="tab-content">
  86. <div id="content" class="tab-pane active" style="width:100%; position: relative; padding: 0 0 0;">
  87. </div>
  88. <div id="2DImage" class="tab-pane" style="overflow: auto;">
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="col-md-6">
  94. <section class="panel">
  95. <div class="panel-body" style="padding: 0px;">
  96. <div class="table-responsive">
  97. <table class="table table-bordered mb-none">
  98. <tbody id="table">
  99. </tbody>
  100. </table>
  101. </div>
  102. </div>
  103. </section>
  104. <h3>尺寸:</h3>
  105. <section class="panel">
  106. <div class="panel-body" style="padding: 0px;">
  107. <div class="table-responsive">
  108. <table class="table table-bordered mb-none">
  109. <tbody id="sizeTable">
  110. </tbody>
  111. </table>
  112. </div>
  113. </div>
  114. </section>
  115. </div>
  116. </div>
  117. </div>
  118. </section>
  119. <!-- end: page -->
  120. </section>
  121. </div>
  122. </section>
  123. <script>
  124. /*Vue */
  125. vm.mount('.body');
  126. addUserImage(userName.charAt(0), role);
  127. </script>
  128. <?php include("bim-support-body.html"); ?>
  129. <script>
  130. $(document).ready(function() {
  131. $.ajax({
  132. url: "./script/php/equipment_group_detail.php",
  133. type: "GET",
  134. data: {
  135. type: type,
  136. object: name,
  137. parent: parent
  138. },
  139. contentType: "application/json",
  140. dataType: "json"
  141. }).done(function(data) {
  142. header = data.header;
  143. value = data.value;
  144. sizeHeader = data.sizeHeader;
  145. sizeValue = data.sizeValue;
  146. for (var i = 0; i < header.length; i++) {
  147. if (value[i] == null)
  148. value[i] = "";
  149. if (header[i] == "元件版本")
  150. revitVersion = value[i];
  151. if (data.header[i] == "族群品類" || data.header[i] == "族群名稱" || data.header[i] == "類型名稱") {
  152. $('#table').append("<tr><td><div class='preview'>" + data.header[i] + "<img src='/Common/assets/images/" + data.header[i] + ".jpg' class='hide-image'></div></td><td><div>" + data.value[i] + "</div></td></tr>");
  153. } else {
  154. $('#table').append("<tr><td><div>" + data.header[i] + "</div></td><td><div>" + data.value[i] + "</div></td></tr>");
  155. }
  156. }
  157. for (var i = 0; i < sizeHeader.length; i++) {
  158. if (value[i] == null)
  159. value[i] = "";
  160. if (data.sizeHeader[i] != 0 && data.sizeValue[i] != 0) {
  161. $('#sizeTable').append("<tr><td>" + data.sizeHeader[i] + "</td><td>" + data.sizeValue[i] + "</td></tr>");
  162. } else
  163. $('#sizeTable').append("<tr><td>無資料</td><td>無資料</td></tr>");
  164. }
  165. $("#insertComponentName").text(name);
  166. $.ajax({
  167. url: "./assets/glb/Revit元件/Components/" + parent + "/" + type + "/" + name + ".PNG",
  168. success: function() {
  169. $("#2DImage").append("<img src='./assets/glb/Revit元件/Components/" + parent + "/" + type + "/" + name + ".PNG' style='width: 100%; aspect-ratio: 1 / 1;'>")
  170. },
  171. error: function() {
  172. $("#2DImage").append("<span>此元件沒有2D圖例</span>");
  173. }
  174. });
  175. }).error(function(error) {
  176. console.log(error.responseText);
  177. });
  178. $.ajax({
  179. url: "./script/php/addFavorite.php",
  180. type: "GET",
  181. data: {
  182. CheckFavorite: parent + "/" + type + "/" + name
  183. },
  184. contentType: "application/json",
  185. dataType: "json"
  186. }).done(function(data) {
  187. isFavorite = data;
  188. if (isFavorite) {
  189. $("#heart").css("color", "Tomato");
  190. $("#favorite").html('移出清單');
  191. } else {
  192. $("#heart").css("color", "white");
  193. $("#favorite").html('加入清單');
  194. }
  195. }).error(function(error) {
  196. console.log(error.responseText);
  197. });
  198. });
  199. for (var i = 0; i < jsonData.length; i++) {
  200. for (var j = 0; j < jsonData[i].children.length; j++) {
  201. $("a").each(function() {
  202. if (jsonData[i].category_name == parent) {
  203. if (jsonData[i].children[j].component_name == type) {
  204. var searchText = jsonData[i].children[j].component_name;
  205. var found;
  206. if ($(this).context.innerText == searchText && $(this).context.name == jsonData[i].category_name) {
  207. $(this).context.classList.add("highlight");
  208. $(this).context.parentNode.parentNode.parentNode.classList.add("nav-expanded");
  209. }
  210. }
  211. }
  212. });
  213. }
  214. }
  215. function AddFavorite() {
  216. var stack_bar_top = {
  217. "dir1": "down",
  218. "dir2": "right",
  219. "push": "top",
  220. "spacing1": 0,
  221. "spacing2": 0
  222. };
  223. if (isFavorite) {
  224. $.ajax({
  225. url: "./script/php/addFavorite.php",
  226. type: "POST",
  227. data: {
  228. DelFavorite: parent + "/" + type + "/" + name,
  229. username: userName
  230. }
  231. }).done(function(data) {
  232. var notice = new PNotify({
  233. title: '通知',
  234. text: '移出清單成功!',
  235. type: 'success',
  236. addclass: 'stack-bar-top',
  237. stack: stack_bar_top,
  238. width: "100%"
  239. });
  240. isFavorite = false;
  241. $("#heart").css("color", "white");
  242. $("#favorite").html('加入清單');
  243. }).error(function(error) {
  244. var notice = new PNotify({
  245. title: '通知',
  246. text: '移出清單失敗!',
  247. type: 'error',
  248. addclass: 'stack-bar-top',
  249. stack: stack_bar_top,
  250. width: "100%"
  251. });
  252. console.log(error);
  253. });
  254. } else {
  255. $.ajax({
  256. url: "./script/php/addFavorite.php",
  257. type: "POST",
  258. data: {
  259. AddFavorite: parent + "/" + type + "/" + name,
  260. username: userName,
  261. revitVersion: revitVersion
  262. }
  263. }).done(function(data) {
  264. var notice = new PNotify({
  265. title: '通知',
  266. text: '加入清單成功!',
  267. type: 'success',
  268. addclass: 'stack-bar-top',
  269. stack: stack_bar_top,
  270. width: "100%"
  271. });
  272. isFavorite = true;
  273. $("#heart").css("color", "Tomato");
  274. $("#favorite").html('移出清單');
  275. }).error(function() {
  276. var notice = new PNotify({
  277. title: '通知',
  278. text: '加入清單失敗!',
  279. type: 'error',
  280. addclass: 'stack-bar-top',
  281. stack: stack_bar_top,
  282. width: "100%"
  283. });
  284. });
  285. }
  286. }
  287. </script>
  288. <!-- Vendor -->
  289. <script src="script/js/3Dpic-detail.js" type="module" async></script>
  290. </body>
  291. </html>