index.ejs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <div class="panel-sidebar">
  2. <div class="panel-title">
  3. <div class="title-bar">
  4. <h2 class="">项目节 <a href="#upload" data-toggle="modal" data-target="#upload" class="pull-right mr-3" title="导入项目节"><i class="fa fa-upload"></i></a></h2>
  5. </div>
  6. </div>
  7. <div class="scrollbar-auto">
  8. <div class="nav-box">
  9. <ul id="templateNode" class="ztree"></ul>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="panel-content">
  14. <div class="panel-title">
  15. <div class="title-main">
  16. <h2>
  17. <%= selectNode.code %> <%= selectNode.name %>
  18. <a href="#add-index" data-toggle="modal" data-target="#add-index" class="btn btn-primary btn-sm pull-right">添加指标</a>
  19. </h2>
  20. </div>
  21. </div>
  22. <div class="content-wrap">
  23. <div class="c-body">
  24. <div class="sjs-height-1">
  25. <table class="table table-bordered">
  26. <tr>
  27. <th>指标编号</th>
  28. <th>指标名称</th>
  29. <th colspan="2">指标单位</th>
  30. <th>计算规则</th>
  31. <th>设置规则</th>
  32. </tr>
  33. <% for (const index of selectIndex) { %>
  34. <tr>
  35. <td><%= index.code %></td>
  36. <td><%= index.name %></td>
  37. <td><%= index.unit1 %></td>
  38. <td><%= index.unit2 %></td>
  39. <td><%= index.rule %></td>
  40. <td><%= index.rule %><a href="#set-count" data-toggle="modal" data-target="#set-count"><i class="fa fa-cog"></i></a></td>
  41. </tr>
  42. <% } %>
  43. </table>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <script type="text/javascript">
  49. const treeSetting = {
  50. treeId: 'template',
  51. view: {showIcon: false},
  52. data: {
  53. key: {
  54. name: 'text',
  55. }
  56. }
  57. };
  58. const selectNode = '<%- selectNode.node_id %>';
  59. const treeNode = '<%- nodes %>';
  60. $(document).ready(function(){
  61. const loadText = function (arr) {
  62. for (const a of arr) {
  63. a.text = a.code + ' ' + a.name;
  64. if (a.children && a.children.length > 0) {
  65. loadText(a.children);
  66. }
  67. }
  68. }
  69. const treeNodeData = treeNode !== '' ? JSON.parse(treeNode) : [];
  70. loadText(treeNodeData);
  71. const treeObj = $.fn.zTree.init($("#templateNode"), treeSetting, treeNodeData);
  72. const node = treeObj.getNodeByParam('node_id', selectNode);
  73. treeObj.selectNode(node);
  74. });
  75. </script>