datacollect.ejs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <% include ./sub_menu.ejs %>
  2. <div class="panel-content">
  3. <div class="panel-title">
  4. <div class="title-main">
  5. <h2>决策大屏
  6. <a href="#power" data-toggle="modal" data-target="#power" class="btn btn-primary btn-sm pull-right">权限管理</a>
  7. <a href="#sort" data-toggle="modal" data-target="#sort" class="btn btn-primary btn-sm pull-right mr-1">分类管理</a>
  8. </h2>
  9. </div>
  10. </div>
  11. <div class="content-wrap">
  12. <div class="c-body">
  13. <div class="sjs-height-0">
  14. <nav class="nav nav-tabs m-3" id="tablist" role="tablist">
  15. <a class="nav-item nav-link<% if (ctx.session.sessionProject.dataCollect === 0 || ctx.session.sessionProject.dataCollect === 1) { %> active<% } %>" data-datacollect="1" data-toggle="tab" href="#shujudaping-one" role="tab">决策大屏一</a>
  16. <a class="nav-item nav-link<% if (ctx.session.sessionProject.dataCollect === 2) { %> active<% } %>" data-datacollect="2" data-toggle="tab" href="#shujudaping-two" role="tab">决策大屏二</a>
  17. <a class="nav-item nav-link<% if (ctx.session.sessionProject.dataCollect === 3) { %> active<% } %>" data-datacollect="3" data-toggle="tab" href="#shujudaping-three" role="tab">决策大屏三</a>
  18. <a class="nav-item nav-link<% if (ctx.session.sessionProject.dataCollect === 4) { %> active<% } %>" data-datacollect="4" data-toggle="tab" href="#shujudaping-four" role="tab">决策大屏四</a>
  19. <div class="ml-auto">
  20. <div class="form-check form-check-inline">
  21. <input class="form-check-input" type="checkbox" id="show-datacollect" value="option1" <% if (ctx.session.sessionProject.dataCollect) { %>checked<% } %>>
  22. <label class="form-check-label" for="show-datacollect">数据大屏显示</label>
  23. </div>
  24. </div>
  25. </nav>
  26. <div class="tab-content m-3">
  27. <div id="shujudaping-one" class="tab-pane<% if (ctx.session.sessionProject.dataCollect === 0 || ctx.session.sessionProject.dataCollect === 1) { %> active<% } %>"><img src="/public/images/juecedaping01.png" width="100%"></div>
  28. <div id="shujudaping-two" class="tab-pane<% if (ctx.session.sessionProject.dataCollect === 2) { %> active<% } %>"><img src="/public/images/juecedaping02.png" width="100%"></div>
  29. <div id="shujudaping-three" class="tab-pane<% if (ctx.session.sessionProject.dataCollect === 3) { %> active<% } %>"><img src="/public/images/juecedaping03.png" width="100%"></div>
  30. <div id="shujudaping-four" class="tab-pane<% if (ctx.session.sessionProject.dataCollect === 4) { %> active<% } %>"><img src="/public/images/juecedaping04.png" width="100%"></div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <script src="/public/js/ztree/jquery.ztree.core.js"></script>
  37. <script src="/public/js/ztree/jquery.ztree.excheck.js"></script>
  38. <script src="/public/js/setting_datacollect_tender.js"></script>
  39. <script>
  40. const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
  41. console.log(category);
  42. $(function () {
  43. autoFlashHeight();
  44. $('#show-datacollect').click(function () {
  45. let data_collect = 0;
  46. if ($(this).is(':checked')) {
  47. data_collect = $('#tablist').find('.active').data('datacollect');
  48. }
  49. postData('/setting/datacollect/save', { type: 'show', data_collect }, function (result) {
  50. })
  51. });
  52. $('#tablist a').click(function () {
  53. if ($('#show-datacollect').is(':checked')) {
  54. const data_collect = $(this).data('datacollect');
  55. postData('/setting/datacollect/save', { type: 'show', data_collect }, function (result) {
  56. })
  57. }
  58. });
  59. const setting = {
  60. check: {
  61. enable: true
  62. },
  63. data: {
  64. simpleData: {
  65. enable: true
  66. }
  67. }
  68. };
  69. const zNodes = [];
  70. const newCategory = _.filter(_.orderBy(category, ['level'], ['asc']), function (item) {
  71. return item.level !== 0;
  72. });
  73. let insertid = 1;
  74. const level1Array = [];
  75. const level2Array = [];
  76. for (const c of newCategory) {
  77. if (c.level === 1) {
  78. for (const v of c.value) {
  79. level1Array.push({id: insertid});
  80. zNodes.push({id: insertid, pId: 0, name: v.value, open: true, checked:true});
  81. insertid++;
  82. }
  83. } else if (c.level === 2) {
  84. for (const l1 of level1Array) {
  85. zNodes.push({id: insertid, pId: l1.id, name: '', checked:true});
  86. insertid++;
  87. for (const v of c.value) {
  88. level2Array.push({id: insertid});
  89. zNodes.push({id: insertid, pId: l1.id, name: v.value, open: true, checked:true});
  90. insertid++;
  91. }
  92. }
  93. }
  94. else if (c.level === 3) {
  95. for (const l2 of level2Array) {
  96. zNodes.push({id: insertid, pId: l2.id, name: '', checked:true});
  97. insertid++;
  98. for (const v of c.value) {
  99. zNodes.push({id: insertid, pId: l2.id, name: v.value, checked:true});
  100. insertid++;
  101. }
  102. }
  103. }
  104. }
  105. $.fn.zTree.init($("#treeDemo"), setting, zNodes);
  106. })
  107. </script>