main.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <script type="text/javascript" src="/static/js/layui_crud.js"></script>
  2. <div class="children-content" id="cleardata">
  3. <blockquote class="layui-elem-quote" style="padding:1rem;line-height:2.5rem;">
  4. 系统管理 / SCD清理
  5. </blockquote>
  6. <div id="tree_area" style="float:left;width:22%;overflow: auto;background-color: #fafafa;">
  7. <div id="tree" class="ztree tree"></div>
  8. </div>
  9. <div style="float:right;width:77%;">
  10. <table id="table_datalist_control" lay-filter="table_row_operator">
  11. </table>
  12. </div>
  13. </div>
  14. <!--语法规则-->
  15. <script type="text/html" id="table_row_operator">
  16. {{if is_parse=="1" || (is_parse=="0" && date_sub_sencond(CREATED_TIME))}}
  17. <i class="layui-icon layui-icon-delete" title="删除SCD并清除相关数据" style="margin-left:10px;cursor:pointer;" lay-event="delete"></i>
  18. <i class="layui-icon layui-icon-refresh" title="重新解析" style="margin-left:10px;cursor:pointer;" lay-event="agin_parse"></i>
  19. {{/if}}
  20. </script>
  21. <script type="text/javascript">
  22. template.helper("date_sub_sencond",function(dt){
  23. return new Date()- new Date(dt)
  24. })
  25. var cleardataele=$("#cleardata");
  26. cleardataele.find("#tree").height($(".main-body").height() - $(".layui-elem-quote:first").height());
  27. Global.Ztree.Init(cleardataele.find("#tree"), {
  28. url: Global.AccessUrl + "/api/area/children/list",
  29. idKey: "id",
  30. pidKey: "pid",
  31. nameKey: "title",
  32. callback: {
  33. onClick: function(event, treeId, treeNode) {
  34. if (treeNode.id != "0") {
  35. } else {
  36. layer.msg("请先选择变电站!")
  37. }
  38. ruleCrud_syntax.GetList({"stationid":treeNode.id});
  39. },
  40. onInitLoad:function(firstnode){
  41. //console.log(firstnode)
  42. ruleCrud_syntax.GetList({"stationid":""});
  43. }
  44. }
  45. });
  46. var ruleCrud_syntax=new CurdObj();
  47. ruleCrud_syntax.Init({
  48. "module_name":"cleardata",
  49. "list_table_id":"table_ruleCrud_dataclear",
  50. "window_size": ['60rem', '55rem'],
  51. "nameColKey":"scd_name",
  52. "idColKey":"id",
  53. "height": ($(".main-body").height()-$("#header").height()-$(".layui-elem-quote:first").height()),
  54. //默认的数据table ID
  55. "table_datalist_control": "table_datalist_control",
  56. //默认的数据table工具栏ID
  57. "table_tools_bar": "none",
  58. //默认的数据table查询条件元素ID
  59. "table_search_panel": "table_search_panel",
  60. //默认的数据table操作模板ID
  61. "table_row_operator": "table_row_operator",
  62. "apiUrl": {
  63. "delete_url": "/api/screen/scd/delete",
  64. "list_url": "/api/screen/scd/list"
  65. },
  66. "data":{},
  67. "columns":[
  68. [
  69. {
  70. field: 'id',
  71. title: "SCD编号",
  72. width: 100
  73. }, {
  74. field: 'scd_name',
  75. title: "SCD名称",
  76. width: 260
  77. },{
  78. field: 'is_parse',
  79. title: "解析状态",
  80. width: 160,
  81. templet:function(data){
  82. var breaker=0;
  83. //解析时间超过30分钟时,解析又可能中断了
  84. if(data.is_parse==0 && (new Date()- new Date(data.CREATED_TIME)>(1000*60*30))){
  85. return "<b style='color:red'>解析可能已中断</b>"
  86. }
  87. return data.is_parse==1?"解析完成":"<b style='color:red'>解析中...</b>";
  88. }
  89. }, {
  90. field: '',
  91. title: "可用状态",
  92. width: 120,
  93. templet:function(data){
  94. return data.enable==1?"启用":"<b style='color:red'>不可用</b>";
  95. }
  96. }, {
  97. field: 'version',
  98. title: "版本",
  99. width: 90
  100. },{
  101. field:"CREATED_TIME",
  102. title: "创建日期",
  103. width: 180
  104. },{
  105. fixed: 'right',
  106. title: "操作",
  107. width: 120,
  108. align: 'center',
  109. templet:function(data){
  110. return template('table_row_operator',data);
  111. }
  112. }
  113. ]
  114. ]
  115. });
  116. function agin_parse(data){
  117. layer.confirm('<div style="text-align:center;">重新解析会清除原来的数据,确定要重新解析SCD文件<span style="color:red;font-weight:700;padding:0 2px;">' + data.scd_name + "</span>吗?</div>", function(index) {
  118. $.post(Global.AccessUrl+"/api/screen/scd/agin_parse",{"scd_id":data.id},function(r){
  119. if(r.code!=0){
  120. layer.msg("操作失败:"+r.msg);
  121. return;
  122. }
  123. layer.msg("正在重新解析中,等耐心等待解析完成",{time:5000});
  124. setTimeout(function(){
  125. autoRefresh();
  126. },3000);
  127. })
  128. });
  129. }
  130. function autoRefresh(){
  131. if($("#cleardata").length==0){
  132. return;
  133. }
  134. ruleCrud_syntax.Reset();
  135. setTimeout(function(){
  136. autoRefresh();
  137. },5000);
  138. }
  139. </script>