s-cz.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <form id="s_cz_div" class="layui-form">
  2. <div id='layers' class="layui-form-item">
  3. <label class="layui-form-label">选择图层</label>
  4. <div class="layui-input-block"></div>
  5. </div>
  6. <div id='czTypes' class="layui-form-item">
  7. <label class="layui-form-label">选择材质</label>
  8. <div class="layui-input-block"></div>
  9. </div>
  10. <div class="layui-form-item">
  11. <div class="layui-input-block" style="text-align: right;">
  12. <button id="query" type="button" class="layui-btn layui-btn-normal">查&nbsp;&nbsp;询</button>
  13. <button type="reset" class="layui-btn layui-btn-primary">重&nbsp;&nbsp;置</button>
  14. </div>
  15. </div>
  16. </form>
  17. <script type="text/javascript">
  18. let lyrs = CONST_VALUES.GX_Datas;
  19. //debugger;
  20. 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'>";
  21. for (let index = 0; index < lyrs.length; index++) {
  22. const lyr = lyrs[index];
  23. var dom = checkboxStr.replace('THETITLE', lyr.name);
  24. dom = dom.replace('THEID', lyr.id);
  25. dom = dom.replace('THEVALUE', lyr.tableName);
  26. dom = dom.replace('THETYPE', lyr.dataType);
  27. dom = dom.replace('THEWS', lyr.dataSourceName);
  28. dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
  29. //debugger;
  30. $("#layers .layui-input-block").append(dom);
  31. }
  32. layui.use('form', function () {
  33. var form = layui.form;
  34. //监听多选框点击事件 主要是通过 lay-filter="sex" 来监听
  35. form.on('radio(layer)', function (data) {
  36. $("#czTypes .layui-input-block").html("");
  37. layui.layer.close(panels.lastResultPanelIndex);
  38. layui.layer.closeAll();
  39. var value = data.value; // 当前选中的value值
  40. $.ajax({
  41. url: "statistics/spatialstatistics/allCz?tbNames=" + value,
  42. success: function(result) {
  43. let checkboxStr = "<input type='checkbox' lay-filter='czType' name='THENAME' title='THETITLE' id='THEID' lay-skin='primary'dataSetName='THEDATASETNAME' dataSourceName='THEWS'>";
  44. for (let i = 0; i < result.length; i++) {
  45. let dom = checkboxStr.replace('THENAME', result[i]["cz"]);
  46. dom = dom.replace('THETITLE', result[i]["cz"]);
  47. dom = dom.replace('THEID', i+1);
  48. //debugger;
  49. $("#czTypes .layui-input-block").append(dom);
  50. }
  51. form.render();
  52. layui.use('form', function () {
  53. var form = layui.form;
  54. form.on('checkbox(czType)', function (data) {
  55. layui.layer.close(panels.lastResultPanelIndex);
  56. layui.layer.closeAll();
  57. });
  58. });
  59. },
  60. error: function() {
  61. layer.msg('查询材质报错!', {
  62. icon: 7
  63. });
  64. }
  65. });
  66. });
  67. });
  68. $("#s_cz_div #query").click(function(obj) {
  69. let cz = $('input[name="THENAME"]:checked').val();
  70. if (cz == undefined) {
  71. layer.msg('请选择一个图层!', {
  72. icon: 7
  73. });
  74. return;
  75. }
  76. var ws = $('input[name="THENAME"]:checked')[0].attributes.dataSourceName.value;
  77. var dataSetName = $('input[name="THENAME"]:checked')[0].attributes.dataSetName.value;
  78. var title = $('input[name="THENAME"]:checked')[0].attributes.title.value;
  79. var czTypes = $("#czTypes input:checked");
  80. // if (czTypes.length == 0) {
  81. // layer.msg('请至少选择一种材质!', {
  82. // icon: 7
  83. // });
  84. // return;
  85. // }
  86. var czs = "";
  87. for (let index = 0; index < czTypes.length; index++) {
  88. var checked = czTypes[index].checked;
  89. if (!checked)
  90. continue;
  91. //console.log(czTypes[index]);
  92. var czType = czTypes[index].attributes.name.value;
  93. if(index < czTypes.length -1 ){
  94. czs += "'" + czType + "',";
  95. }
  96. else{
  97. czs += "'" + czType + "'";
  98. }
  99. }
  100. let sql = "SmID > 0"
  101. if (czs != "") {
  102. sql += " AND CZ in (" + czs + ")";
  103. }
  104. query(title, dataSetName, ws, sql);
  105. });
  106. var query = function(subtitleP, dataSetNameP, wsP, sqlP) {
  107. Q.queryBySql(dataSetNameP, wsP, sqlP, 0, 2000000, "", function(rs) {
  108. if (rs.result == undefined) return;
  109. panels.createResultPanelWithDataGrid({
  110. subTitle: subtitleP,
  111. features: rs.result.features.features,
  112. title: "按材质查询结果",
  113. //count: count,
  114. dataSetName: dataSetNameP,
  115. dataSourceName: wsP
  116. }, function() {
  117. });
  118. });
  119. }
  120. </script>