browsegroup.html.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /**
  3. * The browsegroup view file of chart module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2022 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @license ZPL (http://zpl.pub/page/zplv12.html)
  7. * @author Mengyi Liu <liumengyi@easycorp.ltd>
  8. * @package chart
  9. * @version $Id: browsegroup.html.php 4129 2013-01-18 01:58:14Z wwccss $
  10. * @link https://www.zentao.net
  11. */
  12. ?>
  13. <?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
  14. <?php $dataType = $type == 'report' ? 'custom' : $type;?>
  15. <?php js::set('dataType', $dataType);?>
  16. <div id="mainMenu" class="clearfix">
  17. <div class="btn-toolbar pull-left">
  18. <?php echo html::a($gobackLink, $lang->goback, '', 'class="btn btn-secondary"');?>
  19. <div class="divider"></div>
  20. <div class="page-title">
  21. <span class='text' title='<?php echo $lang->chart->manageGroup;?>'><?php echo $lang->chart->manageGroup;?></span>
  22. </div>
  23. </div>
  24. </div>
  25. <div id="mainContent" class="main-row">
  26. <div class="side-col col-4">
  27. <div class='panel'>
  28. <div class='panel-heading'>
  29. <div class='panel-title'><?php echo !empty($group) ? $group->name : $lang->chart->allGroup;?></div>
  30. </div>
  31. <div class='panel-body'>
  32. <ul id='modulesTree' data-name='tree-chart'></ul>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="main-col col-8">
  37. <div class="panel">
  38. <div class="panel-heading">
  39. <div class="panel-title">
  40. <?php echo $lang->chart->manageGroup;?>
  41. </div>
  42. </div>
  43. <div class="panel-body">
  44. <form id='childrenForm' method='post' target='hiddenwin' action='<?php echo $this->createLink('tree', 'manageChild', "rootID=$dimensionID&viewType=$type&oldPage=yes");?>'>
  45. <table class='table table-form table-auto'>
  46. <tr>
  47. <td class="text-middle text-right with-padding">
  48. <?php
  49. echo "<span>" . html::a($this->createLink('tree', 'browsegroup', "dimensionID=$dimensionID&groupID=0&type=$type"), $lang->chart->allGroup, '', "data-app='bi'") . "<i class='icon icon-angle-right muted'></i></span>";
  50. if(!empty($groupID))
  51. {
  52. foreach($parentGroups as $parentGroup)
  53. {
  54. echo "<span>" . html::a($this->createLink('tree', 'browsegroup', "dimensionID=$dimensionID&groupID=$parentGroup->id&type=$type"), $parentGroup->name, '', "data-app='bi'") . " <i class='icon icon-angle-right muted'></i></span>";
  55. }
  56. }
  57. ?>
  58. </td>
  59. <td>
  60. <div id='sonGroup'>
  61. <?php $maxOrder = 0;?>
  62. <?php foreach($sonGroups as $sonGroup):?>
  63. <?php if($sonGroup->order > $maxOrder) $maxOrder = $sonGroup->order;?>
  64. <?php $disabled = $sonGroup->owner == 'system' ? 'disabled' : '';?>
  65. <div class="table-row row-module">
  66. <div class="table-col col-module"><?php echo html::input("modules[id$sonGroup->id]", $sonGroup->name, 'class="form-control"' . $disabled);?></div>
  67. <div class="table-col col-shorts"><?php echo html::input("shorts[id$sonGroup->id]", $sonGroup->short, "class='form-control' placeholder='{$lang->tree->short}' $disabled") . html::hidden("order[id$sonGroup->id]", $sonGroup->order);?></div>
  68. <div class="table-col col-actions"> </div>
  69. </div>
  70. <?php endforeach;?>
  71. <?php for($i = 0; $i < 5 ; $i ++):?>
  72. <div class="table-row row-module row-module-new">
  73. <div class="table-col col-module"><?php echo html::input("modules[]", '', "class='form-control' placeholder='{$lang->chart->groupName}'");?></div>
  74. <div class="table-col col-shorts"><?php echo html::input("shorts[]", '', "class='form-control' placeholder='{$lang->tree->short}'");?></div>
  75. <div class="table-col col-actions">
  76. <button type="button" class="btn btn-link btn-icon btn-add" onclick="addItem(this)"><i class="icon icon-plus"></i></button>
  77. <button type="button" class="btn btn-link btn-icon btn-delete" onclick="deleteItem(this)"><i class="icon icon-close"></i></button>
  78. </div>
  79. </div>
  80. <?php endfor;?>
  81. <div id="insertItemBox" class="template">
  82. <div class="table-row row-module row-module-new">
  83. <div class="table-col col-module"><?php echo html::input("modules[]", '', "class='form-control' placeholder='{$lang->chart->groupName}'");?></div>
  84. <div class="table-col col-shorts"><?php echo html::input("shorts[]", '', "class='form-control' placeholder='{$lang->tree->short}'");?></div>
  85. <div class="table-col col-actions">
  86. <button type="button" class="btn btn-link btn-icon btn-add" onclick="addItem(this)"><i class="icon icon-plus"></i></button>
  87. <button type="button" class="btn btn-link btn-icon btn-delete" onclick="deleteItem(this)"><i class="icon icon-close"></i></button>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </td>
  93. </tr>
  94. <tr>
  95. <td></td>
  96. <td colspan="2" class="form-actions">
  97. <?php
  98. echo html::submitButton();
  99. if(!isonlybody()) echo html::a($gobackLink, $lang->goback, '', 'class="btn btn-wide"');
  100. echo html::hidden('parentModuleID', $groupID);
  101. echo html::hidden('maxOrder', $maxOrder);
  102. ?>
  103. </td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. </form>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <script>
  113. $(function()
  114. {
  115. var data = $.parseJSON('<?php echo helper::jsonEncode4Parse($groupStructure);?>');
  116. var orderModule = 0;
  117. var options =
  118. {
  119. initialState: 'preserve',
  120. data: data,
  121. sortable:
  122. {
  123. lazy: true,
  124. nested: true,
  125. canMoveHere: function($ele, $target)
  126. {
  127. if($ele && $target && $ele.parent().closest('li').attr('data-id') !== $target.parent().closest('li').attr('data-id')) return false;
  128. },
  129. start: function(e)
  130. {
  131. orderModule = e.element.data('id');
  132. }
  133. },
  134. itemCreator: function($li, item)
  135. {
  136. var link = '<a href="' + createLink('tree', 'browseGroup', 'dimensionID=<?php echo $dimensionID ?>&moduleID={0}&type=<?php echo $type;?>'.format(item.id)) + '" data-app="bi" title="' + item.name + '">' + item.name + '</a>';
  137. /* Disable link when item.grade != 1. */
  138. if(item.grade != 1) link = item.name;
  139. $li.append($('<span class="module-name" data-id="' + item.id + '">' + link + '</span>'));
  140. if(item.owner == 'system') $li.addClass('system');
  141. if(item.nodeType || item.type) $li.addClass('tree-item-' + (item.nodeType || item.type));
  142. $li.toggleClass('active', '<?php echo $groupID ?>' === item.id);
  143. return true;
  144. },
  145. actions:
  146. {
  147. sort:
  148. {
  149. title: '<?php echo $lang->tree->dragAndSort ?>',
  150. template: '<a class="sort-handler"><i class="icon-move"></i></a>'
  151. },
  152. edit:
  153. {
  154. linkTemplate: '<?php echo helper::createLink('tree', 'edit', "moduleID={0}&type=$type"); ?>',
  155. title: '<?php echo $lang->chart->editGroup;?>',
  156. template: '<a><i class="icon-edit"></i></a>'
  157. },
  158. "delete":
  159. {
  160. linkTemplate: '<?php echo helper::createLink('tree', 'delete', "rootID=$dimensionID&moduleID={0}"); ?>',
  161. title: '<?php echo $lang->chart->deleteGroup;?>',
  162. template: '<a><i class="icon-trash"></i></a>'
  163. },
  164. subModules:
  165. {
  166. linkTemplate: '<?php echo helper::createLink('tree', 'browsegroup', "dimensionID=$dimensionID&moduleID={0}&type=$type"); ?>',
  167. title: '<?php echo $lang->chart->childTitle;?>',
  168. template: '<a><?php echo '<i class="icon-split"></i>';?></a>',
  169. }
  170. },
  171. action: function(event)
  172. {
  173. var action = event.action, $target = $(event.target), item = event.item;
  174. if(action.type === 'edit')
  175. {
  176. new $.zui.ModalTrigger({
  177. type: 'iframe',
  178. height: '320px',
  179. url: action.linkTemplate.format(item.id),
  180. keyboard: true
  181. }).show();
  182. }
  183. else if(action.type === 'delete')
  184. {
  185. hiddenwin.location.href = action.linkTemplate.format(item.id);
  186. }
  187. else if(action.type === 'sort' && event.item == null)
  188. {
  189. var orders = {};
  190. $('#modulesTree').find('li:not(.tree-action-item)').each(function()
  191. {
  192. var $li = $(this);
  193. if($li.hasClass('tree-item-branch')) return;
  194. var item = $li.data();
  195. orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
  196. });
  197. $.post(createLink('tree', 'updateOrder', 'rootID=<?php echo $dimensionID;?>&viewType=chart&moduleID=' + orderModule), orders, function(data)
  198. {
  199. $('.main-col').load(location.href + ' .main-col .panel');
  200. }).error(function()
  201. {
  202. bootbox.alert(lang.timeout);
  203. });
  204. }
  205. else if(action.type === 'subModules')
  206. {
  207. window.location.href = action.linkTemplate.format(item.id);
  208. }
  209. }
  210. };
  211. if(<?php echo (common::hasPriv('tree', 'updateorder')) ? 'false' : 'true' ?>) options.actions["sort"] = false;
  212. if(<?php echo (common::hasPriv('tree', 'edit')) ? 'false' : 'true' ?>) options.actions["edit"] = false;
  213. if(<?php echo (common::hasPriv('tree', 'delete')) ? 'false' : 'true' ?>) options.actions["delete"] = false;
  214. var $tree = $('#modulesTree').tree(options);
  215. var tree = $tree.data('zui.tree');
  216. if(<?php echo $groupID ?>)
  217. {
  218. var $currentLi = $tree.find('.module-name[data-id=' + <?php echo $groupID ?> + ']').closest('li');
  219. if($currentLi.length) tree.show($currentLi);
  220. }
  221. $tree.on('mouseenter', 'li:not(.tree-action-item)', function(e)
  222. {
  223. $('#modulesTree').find('li.hover').removeClass('hover');
  224. $(this).addClass('hover');
  225. e.stopPropagation();
  226. });
  227. $('#subNavbar > ul > li > a[href*=tree][href*=browse]').not('[href*=<?php echo 'chart';?>]').parent().removeClass('active');
  228. $("#modulesTree > li.system > .tree-actions > a[data-type='delete']").remove();
  229. $("#modulesTree > li.system > .tree-actions > a[data-type='edit']").remove();
  230. $("#modulesTree > li > ul .tree-actions > a[data-type='subModules']").remove();
  231. });
  232. </script>
  233. <?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>