component-favorite.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 delFavoriteList = [];
  11. var i = 0;
  12. var path = [];
  13. var categoryList = [];
  14. var categoryTable = [];
  15. var id = [];
  16. var revitVersion = [];
  17. var userName = "<?php echo $_SESSION['name'] ?>";
  18. var role = "<?php echo ($groupName); ?>";
  19. var right = <?php echo ($right); ?>;
  20. var $grid;
  21. //var year = [];
  22. pageHeader = "元件庫";
  23. var parent = [];
  24. var object = [];
  25. </script>
  26. </head>
  27. <body>
  28. <canvas id="c"></canvas>
  29. <section class="body">
  30. <!-- start: header -->
  31. <header-menu></header-menu>
  32. <!-- end: header -->
  33. <div class="inner-wrapper">
  34. <!-- start: sidebar -->
  35. <side-bar></side-bar>
  36. <!-- end: sidebar -->
  37. <section role="main" class="content-body">
  38. <header class="page-header">
  39. <h2>{{pageHeader}}</h2>
  40. </header>
  41. <!-- start: page -->
  42. <section class="content-with-menu content-with-menu-has-toolbar media-gallery">
  43. <div class="content-with-menu-container">
  44. <inner-menu>
  45. <template v-slot:inner-equipment>
  46. <equipment-list></equipment-list>
  47. </template>
  48. </inner-menu>
  49. <div class="inner-body mg-main">
  50. <div class="inner-toolbar">
  51. <ul>
  52. <search-bar></search-bar>
  53. <filter-bar></filter-bar>
  54. <li class="right">
  55. <a href="#" id="mgSelectAll"><i class="fa fa-check-square"></i> <span data-all-text="選擇全部" data-none-text="取消全選">選擇全部</span></a>
  56. </li>
  57. <li class="right">
  58. <a href="#" onclick="DelFavorite();"><i class="fa fa-trash-o"></i> 移出清單</a>
  59. </li>
  60. </ul>
  61. </div>
  62. <filter-content></filter-content>
  63. <div class="row mg-files" data-sort-destination data-sort-id="media-gallery" id="content">
  64. </div>
  65. </div>
  66. </div>
  67. </section>
  68. <!-- end: page -->
  69. </section>
  70. </div>
  71. </section>
  72. <script>
  73. /*Vue */
  74. vm.mount('.body');
  75. addUserImage(userName.charAt(0), role);
  76. </script>
  77. <?php include("bim-support-body.html"); ?>
  78. <script>
  79. $(document).ready(function() {
  80. $("a").each(function() {
  81. var searchText = "清單列表";
  82. var found;
  83. if ($(this).context.innerText == searchText) {
  84. $(this).context.classList.add("highlight");
  85. }
  86. });
  87. $(".dropdown-btn").each(function(){
  88. $(this).context.href="component-list.php?parent=" + $(this).context.innerText;
  89. });
  90. //$.getJSON
  91. $.ajaxSetup({
  92. async: false
  93. });
  94. $.ajax({
  95. url: "./script/php/equipment_group_favorite.php",
  96. type: "GET",
  97. data: {
  98. userName: userName,
  99. },
  100. contentType: "application/json",
  101. dataType: "json"
  102. }).done(function(data) {
  103. id = data.id;
  104. path = data.path;
  105. for (let i = 0; i < path.length; i++) {
  106. var array = path[i].split('/');
  107. object[i] = array[array.length-1];
  108. parent[i] = path[i].replace("/" + object[i], "");
  109. }
  110. revitVersion = data.revitVersion;
  111. for (var i = 0; i < data.year.length; i++) {
  112. $("#revitVersion").append('<label><input type="checkbox" value=".' + data.year[i] + '" /> ' + data.year[i] + '</label> ');
  113. }
  114. $.when(initThreeJS()).then(function() {
  115. $grid = $("#content").isotope({
  116. itemSelector: ".isotope-item",
  117. layoutMode: 'fitRows'
  118. });
  119. }).then(function() {
  120. setTimeout(function() {
  121. $grid.isotope()
  122. }, 100);
  123. });
  124. }).error(function(error) {
  125. console.log(error);
  126. });
  127. });
  128. //刪除元件checkbox
  129. $(document).on("change", "input[name='delCheck']", function() {
  130. if ($(this).prop('checked') === true) {
  131. delFavoriteList.push($(this).attr('value'));
  132. } else {
  133. delFavoriteList.splice(delFavoriteList.indexOf($(this).attr('value')), 1);
  134. }
  135. });
  136. $('#mgSelectAll').on('click', function(ev) {
  137. ev.preventDefault();
  138. var $this = $(this),
  139. $label = $this.find('> span');
  140. $checks = $("input[name='delCheck']")
  141. if ($this.attr('data-all-selected')) {
  142. $this.removeAttr('data-all-selected');
  143. $checks.prop('checked', false).trigger('change');
  144. $label.html($label.data('all-text'));
  145. } else {
  146. $this.attr('data-all-selected', 'true');
  147. $checks.prop('checked', true).trigger('change');
  148. $label.html($label.data('none-text'));
  149. }
  150. });
  151. function DelFavorite() {
  152. $.ajax({
  153. url: "./script/php/addFavorite.php",
  154. type: "POST",
  155. data: {
  156. delFavoriteList: delFavoriteList,
  157. username: userName
  158. }
  159. }).done(function(data) {
  160. window.location.reload();
  161. }).error(function(error) {
  162. console.log(error);
  163. });
  164. }
  165. </script>
  166. <script src="./script/js/data-sort.js"></script>
  167. <script src="script/js/3Dpic-favorite.js" type="module"></script>
  168. </body>
  169. </html>