s-gj.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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='gjTypes' class="layui-form-item">
  8. <label class="layui-form-label">选择管径</label>
  9. <div class="layui-input-block"></div>
  10. </div>
  11. <div class="layui-form-item">
  12. <div class="layui-input-block" style="text-align: right;">
  13. <button id="query" type="button" class="layui-btn layui-btn-normal">查&nbsp;&nbsp;询</button>
  14. <button type="reset" class="layui-btn layui-btn-primary">重&nbsp;&nbsp;置</button>
  15. </div>
  16. </div>
  17. </form>
  18. <script type="text/javascript">
  19. let lyrs = CONST_VALUES.GX_Datas;
  20. //debugger;
  21. let checkboxStr = "<input type='radio' lay-filter='layer' name='THENAME' title='THETITLE' value='THEVALUE' id='THEID' lay-skin='primary' datatype='THETYPE' dataSetName='THEDATASETNAME' dataSourceName='THEWS'>";
  22. for (let index = 0; index < lyrs.length; index++) {
  23. const lyr = lyrs[index];
  24. //debugger;
  25. if (lyr.name.indexOf("管线") < 0)
  26. continue;
  27. var dom = checkboxStr.replace('THETITLE', lyr.name);
  28. dom = dom.replace('THEID', lyr.id);
  29. dom = dom.replace('THEVALUE', lyr.tableName);
  30. dom = dom.replace('THETYPE', lyr.dataType);
  31. dom = dom.replace('THEWS', lyr.dataSourceName);
  32. dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
  33. //debugger;
  34. $("#layers .layui-input-block").append(dom);
  35. }
  36. layui.use('form', function () {
  37. var form = layui.form;
  38. //监听多选框点击事件 主要是通过 lay-filter="sex" 来监听
  39. form.on('radio(layer)', function (data) {
  40. $("#gjTypes .layui-input-block").html("");
  41. layui.layer.close(panels.lastResultPanelIndex);
  42. layui.layer.closeAll();
  43. var value = data.value; // 当前选中的value值
  44. $.ajax({
  45. url: "statistics/spatialstatistics/allGj?tbNames=" + value,
  46. success: function(result) {
  47. let checkboxStr = "<input type='checkbox' lay-filter='gjType' name='THENAME' title='THETITLE' id='THEID' lay-skin='primary'dataSetName='THEDATASETNAME' dataSourceName='THEWS'>";
  48. for (let i = 0; i < result.length; i++) {
  49. let dom = checkboxStr.replace('THENAME', result[i]["gj"]);
  50. dom = dom.replace('THETITLE', result[i]["gj"]);
  51. dom = dom.replace('THEID', i+1);
  52. //debugger;
  53. $("#gjTypes .layui-input-block").append(dom);
  54. }
  55. form.render();
  56. layui.use('form', function () {
  57. var form = layui.form;
  58. form.on('checkbox(gjType)', function (data) {
  59. layui.layer.close(panels.lastResultPanelIndex);
  60. layui.layer.closeAll();
  61. });
  62. });
  63. },
  64. error: function() {
  65. layer.msg('查询管径报错!', {
  66. icon: 7
  67. });
  68. }
  69. });
  70. });
  71. });
  72. // const czs = CONST_VALUES.GX_GJ;
  73. // let radioStr = "<input type='radio' name='GUANJING' title='THETITLE' id='THEID'>";
  74. // for (let index = 0; index < czs.length; index++) {
  75. // const cz = czs[index];
  76. // let dom = radioStr.replace('THETITLE', cz);
  77. // dom = dom.replace('THEID', cz);
  78. //
  79. // $("#gjTypes .layui-input-block").append(dom);
  80. // }
  81. $("#s_cz_div #query").click(function(obj) {
  82. //debugger;
  83. // let cz = $('input[name="GUANJING"]:checked').val();
  84. //
  85. // if (cz == undefined) {
  86. // layer.msg('请选择一种管径!', {
  87. // icon: 7
  88. // });
  89. // return;
  90. // }
  91. // cz = $('input[name="GUANJING"]:checked')[0].id;
  92. // let layers = $("#layers input:checked");
  93. // if (layers.length == 0) {
  94. // layer.msg('请至少选择一个图层!', {
  95. // icon: 7
  96. // });
  97. // return;
  98. // }
  99. // for (let index = 0; index < layers.length; index++) {
  100. // let checked = layers[index].checked;
  101. // if (!checked)
  102. // continue;
  103. // let ws = layers[index].attributes.dataSourceName.value;
  104. // let dataSetName = layers[index].attributes.dataSetName.value;
  105. //
  106. // //debugger;
  107. // let sql = "SmID > 0"
  108. // if (cz !== "全部") {
  109. // sql += " AND GJ = '" + cz + "'";
  110. // }
  111. // query(layers[index].title, dataSetName, ws, sql);
  112. // }
  113. let cz = $('input[name="THENAME"]:checked').val();
  114. if (cz == undefined) {
  115. layer.msg('请选择一个图层!', {
  116. icon: 7
  117. });
  118. return;
  119. }
  120. var ws = $('input[name="THENAME"]:checked')[0].attributes.dataSourceName.value;
  121. var dataSetName = $('input[name="THENAME"]:checked')[0].attributes.dataSetName.value;
  122. var title = $('input[name="THENAME"]:checked')[0].attributes.title.value;
  123. var czTypes = $("#gjTypes input:checked");
  124. if (czTypes.length == 0) {
  125. layer.msg('请至少选择一种管径!', {
  126. icon: 7
  127. });
  128. return;
  129. }
  130. var czs = "";
  131. for (let index = 0; index < czTypes.length; index++) {
  132. var checked = czTypes[index].checked;
  133. if (!checked)
  134. continue;
  135. //console.log(czTypes[index]);
  136. var czType = czTypes[index].attributes.name.value;
  137. if(index < czTypes.length -1 ){
  138. czs += "'" + czType + "',";
  139. }
  140. else{
  141. czs += "'" + czType + "'";
  142. }
  143. }
  144. let sql = "SmID > 0"
  145. if (czs != "") {
  146. sql += " AND GJ in (" + czs + ")";
  147. }
  148. query(title, dataSetName, ws, sql);
  149. });
  150. let query = function(subtitleP, dataSetNameP, wsP, sqlP) {
  151. let thatsubtitleP = subtitleP;
  152. let dataSource = wsP;
  153. let urlTmp = URL_CONFIG.GX_Datas_BaseUrl + "/datasources/" + wsP +
  154. "/datasets/" + dataSetNameP + "/features.json";
  155. // $.get(urlTmp, function(e) {
  156. // const count = e.featureCount;
  157. //console.info("e.featureCount" + e.featureCount);
  158. Q.queryBySql(dataSetNameP, wsP, sqlP, 0, 2000000, "", function(rs) {
  159. if (rs.result == undefined) return;
  160. panels.createResultPanelWithDataGrid({
  161. subTitle: thatsubtitleP,
  162. features: rs.result.features.features,
  163. title: "按管径查询结果",
  164. //count: count,
  165. dataSetName: dataSetNameP,
  166. dataSourceName: dataSource
  167. }, function() {
  168. //debugger;
  169. });
  170. });
  171. // });
  172. }
  173. </script>