record.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. Global.Ztree.Init(cleardataele.find("#tree"), {
  27. url: Global.AccessUrl + "/api/area/children/list",
  28. idKey: "id",
  29. pidKey: "pid",
  30. nameKey: "title",
  31. callback: {
  32. onClick: function(event, treeId, treeNode) {
  33. if (treeNode.id != "0") {
  34. } else {
  35. layer.msg("请先选择变电站!")
  36. }
  37. ruleCrud_syntax.GetList({"stationid":treeNode.id});
  38. },
  39. onInitLoad:function(firstnode){
  40. //console.log(firstnode)
  41. ruleCrud_syntax.GetList({"stationid":""});
  42. }
  43. }
  44. });
  45. var ruleCrud_syntax=new CurdObj();
  46. ruleCrud_syntax.Init({
  47. "module_name":"cleardata",
  48. "list_table_id":"table_ruleCrud_dataclear",
  49. "window_size": ['60rem', '55rem'],
  50. "nameColKey":"scd_name",
  51. "idColKey":"id",
  52. "height": ($(".main-body").height()-$("#table_datalist_control").offset().top -(20*hRate)),
  53. //默认的数据table ID
  54. "table_datalist_control": "table_datalist_control",
  55. //默认的数据table工具栏ID
  56. "table_tools_bar": "none",
  57. //默认的数据table查询条件元素ID
  58. "table_search_panel": "table_search_panel",
  59. //默认的数据table操作模板ID
  60. "table_row_operator": "table_row_operator",
  61. "apiUrl": {
  62. "delete_url": "/api/screen/scd/delete",
  63. "list_url": "/api/screen/scd/list"
  64. },
  65. "data":{},
  66. "columns":[
  67. [
  68. {
  69. field: 'id',
  70. title: "SCD编号",
  71. width: 100
  72. }, {
  73. field: 'scd_name',
  74. title: "SCD名称",
  75. width: 260
  76. },{
  77. field: 'is_parse',
  78. title: "解析状态",
  79. width: 160,
  80. templet:function(data){
  81. var breaker=0;
  82. //解析时间超过30分钟时,解析又可能中断了
  83. if(data.is_parse==0 && (new Date()- new Date(data.CREATED_TIME)>(1000*60*30))){
  84. return "<b style='color:red'>解析可能已中断</b>"
  85. }
  86. return data.is_parse==1?"解析完成":"<b style='color:red'>解析中...</b>";
  87. }
  88. }, {
  89. field: '',
  90. title: "可用状态",
  91. width: 120,
  92. templet:function(data){
  93. return data.enable==1?"启用":"<b style='color:red'>不可用</b>";
  94. }
  95. }, {
  96. field: 'version',
  97. title: "版本",
  98. width: 90
  99. },{
  100. field:"CREATED_TIME",
  101. title: "创建日期",
  102. width: 180
  103. },{
  104. fixed: 'right',
  105. title: "操作",
  106. width: 120,
  107. align: 'center',
  108. templet:function(data){
  109. return template('table_row_operator',data);
  110. }
  111. }
  112. ]
  113. ]
  114. });
  115. function agin_parse(data){
  116. 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) {
  117. $.post(Global.AccessUrl+"/api/screen/scd/agin_parse",{"scd_id":data.id},function(r){
  118. if(r.code!=0){
  119. layer.msg("操作失败:"+r.msg);
  120. return;
  121. }
  122. layer.msg("正在重新解析中,等耐心等待解析完成",{time:5000});
  123. setTimeout(function(){
  124. autoRefresh();
  125. },3000);
  126. })
  127. });
  128. }
  129. function autoRefresh(){
  130. if($("#cleardata").length==0){
  131. return;
  132. }
  133. ruleCrud_syntax.Reset();
  134. setTimeout(function(){
  135. autoRefresh();
  136. },5000);
  137. }
  138. </script>