s-rq.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!--日期查询-->
  2. <form id="s_cz_div" class="layui-form">
  3. <div id='layers' class="layui-form-item">
  4. <label class="layui-form-label">选择图层</label>
  5. <div class="layui-input-block"></div>
  6. </div>
  7. <div id='czTypes' class="layui-form-item">
  8. <label class="layui-form-label">日期范围</label>
  9. <div class="layui-input-block">
  10. <input type="text" autocomplete="off" id="startDate" class="layui-input layui-input-inline" style="width: 99px;" placeholder="开始日期">
  11. <input type="text" autocomplete="off" id="endDate" class="layui-input layui-input-inline" style="width: 99px;" placeholder="结束日期">
  12. </div>
  13. </div>
  14. <div class="layui-form-item">
  15. <div class="layui-input-block" style="text-align: right;">
  16. <button id="query" type="button" class="layui-btn layui-btn-normal">查&nbsp;&nbsp;询</button>
  17. <button type="reset" class="layui-btn layui-btn-primary">重&nbsp;&nbsp;置</button>
  18. </div>
  19. </div>
  20. </form>
  21. <script type="text/javascript">
  22. layui.use('laydate', function() {
  23. let laydate = layui.laydate;
  24. //执行一个laydate实例
  25. laydate.render({
  26. elem: '#startDate' //指定元素
  27. });
  28. laydate.render({
  29. elem: '#endDate' //指定元素
  30. });
  31. });
  32. let lyrs = CONST_VALUES.GX_Datas;
  33. //debugger;
  34. let checkboxStr = "<input type='checkbox' name='THENAME' title='THETITLE' id='THEID' lay-skin='primary' dataSetName='THEDATASETNAME' dataSourceName='THEWS'>";
  35. for (let index = 0; index < lyrs.length; index++) {
  36. const lyr = lyrs[index];
  37. //debugger;
  38. // if (lyr.name.indexOf("管线") < 0)
  39. // continue;
  40. let dom = checkboxStr.replace('THENAME', lyr.name);
  41. dom = dom.replace('THETITLE', lyr.name);
  42. dom = dom.replace('THEID', lyr.id);
  43. dom = dom.replace('THEWS', lyr.dataSourceName);
  44. dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
  45. //debugger;
  46. $("#layers .layui-input-block").append(dom);
  47. }
  48. $("#s_cz_div #query").click(function(obj) {
  49. let layers = $("#layers input:checked");
  50. if (layers.length == 0) {
  51. layer.msg('请至少选择一个图层!', {
  52. icon: 7
  53. });
  54. return;
  55. }
  56. let startDate = $("#startDate").val();
  57. let endDate = $("#endDate").val();
  58. for (let index = 0; index < layers.length; index++) {
  59. let checked = layers[index].checked;
  60. if (!checked)
  61. continue;
  62. let ws = layers[index].attributes.dataSourceName.value;
  63. let dataSetName = layers[index].attributes.dataSetName.value;
  64. //debugger;
  65. let sql = "SmID > 0"
  66. if (startDate != undefined && startDate.length > 0) {
  67. sql += " AND MSRQ >= '" + startDate + "'";
  68. }
  69. if (endDate != undefined && endDate.length > 0) {
  70. sql += " AND MSRQ <= '" + endDate + "'";
  71. }
  72. query(layers[index].title, dataSetName, ws, sql);
  73. }
  74. });
  75. let query = function(subtitleP, dataSetNameP, wsP, sqlP) {
  76. let thatsubtitleP = subtitleP;
  77. let dataSource = wsP;
  78. let urlTmp = CONST_VALUES.GX_Datas_BaseUrl + "/datasources/" + wsP +
  79. "/datasets/" + dataSetNameP + "/features.json";
  80. // $.get(urlTmp, function(e) {
  81. // const count = e.featureCount;
  82. //console.info("e.featureCount" + e.featureCount);
  83. Q.queryBySql(dataSetNameP, wsP, sqlP, 0, 2000000, "", function(rs) {
  84. if (rs.result == undefined) return;
  85. panels.createResultPanelWithDataGrid({
  86. subTitle: thatsubtitleP,
  87. features: rs.result.features.features,
  88. title: "按日期查询结果",
  89. //count: count,
  90. dataSetName: dataSetNameP,
  91. dataSourceName: dataSource
  92. },
  93. function() {
  94. //debugger;
  95. });
  96. });
  97. // });
  98. }
  99. </script>