123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <form id="s_cz_div" class="layui-form">
- <div id='layers' class="layui-form-item">
- <label class="layui-form-label">选择图层</label>
- <div class="layui-input-block"></div>
- </div>
- <div id='czTypes' class="layui-form-item">
- <label class="layui-form-label">选择材质</label>
- <div class="layui-input-block"></div>
- </div>
- <div class="layui-form-item">
- <div class="layui-input-block" style="text-align: right;">
- <button id="query" type="button" class="layui-btn layui-btn-normal">查 询</button>
- <button type="reset" class="layui-btn layui-btn-primary">重 置</button>
- </div>
- </div>
- </form>
- <script type="text/javascript">
- let lyrs = CONST_VALUES.GX_Datas;
- //debugger;
- 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'>";
- for (let index = 0; index < lyrs.length; index++) {
- const lyr = lyrs[index];
- var dom = checkboxStr.replace('THETITLE', lyr.name);
- dom = dom.replace('THEID', lyr.id);
- dom = dom.replace('THEVALUE', lyr.tableName);
- dom = dom.replace('THETYPE', lyr.dataType);
- dom = dom.replace('THEWS', lyr.dataSourceName);
- dom = dom.replace('THEDATASETNAME', lyr.dataSetName);
- //debugger;
- $("#layers .layui-input-block").append(dom);
- }
- layui.use('form', function () {
- var form = layui.form;
- //监听多选框点击事件 主要是通过 lay-filter="sex" 来监听
- form.on('radio(layer)', function (data) {
- $("#czTypes .layui-input-block").html("");
- layui.layer.close(panels.lastResultPanelIndex);
- layui.layer.closeAll();
- var value = data.value; // 当前选中的value值
- $.ajax({
- url: "statistics/spatialstatistics/allCz?tbNames=" + value,
- success: function(result) {
- let checkboxStr = "<input type='checkbox' lay-filter='czType' name='THENAME' title='THETITLE' id='THEID' lay-skin='primary'dataSetName='THEDATASETNAME' dataSourceName='THEWS'>";
- for (let i = 0; i < result.length; i++) {
- let dom = checkboxStr.replace('THENAME', result[i]["cz"]);
- dom = dom.replace('THETITLE', result[i]["cz"]);
- dom = dom.replace('THEID', i+1);
- //debugger;
- $("#czTypes .layui-input-block").append(dom);
- }
- form.render();
- layui.use('form', function () {
- var form = layui.form;
- form.on('checkbox(czType)', function (data) {
- layui.layer.close(panels.lastResultPanelIndex);
- layui.layer.closeAll();
- });
- });
- },
- error: function() {
- layer.msg('查询材质报错!', {
- icon: 7
- });
- }
- });
- });
- });
- $("#s_cz_div #query").click(function(obj) {
- let cz = $('input[name="THENAME"]:checked').val();
- if (cz == undefined) {
- layer.msg('请选择一个图层!', {
- icon: 7
- });
- return;
- }
- var ws = $('input[name="THENAME"]:checked')[0].attributes.dataSourceName.value;
- var dataSetName = $('input[name="THENAME"]:checked')[0].attributes.dataSetName.value;
- var title = $('input[name="THENAME"]:checked')[0].attributes.title.value;
- var czTypes = $("#czTypes input:checked");
- // if (czTypes.length == 0) {
- // layer.msg('请至少选择一种材质!', {
- // icon: 7
- // });
- // return;
- // }
- var czs = "";
- for (let index = 0; index < czTypes.length; index++) {
- var checked = czTypes[index].checked;
- if (!checked)
- continue;
- //console.log(czTypes[index]);
- var czType = czTypes[index].attributes.name.value;
- if(index < czTypes.length -1 ){
- czs += "'" + czType + "',";
- }
- else{
- czs += "'" + czType + "'";
- }
- }
- let sql = "SmID > 0"
- if (czs != "") {
- sql += " AND CZ in (" + czs + ")";
- }
- query(title, dataSetName, ws, sql);
- });
- var query = function(subtitleP, dataSetNameP, wsP, sqlP) {
- Q.queryBySql(dataSetNameP, wsP, sqlP, 0, 2000000, "", function(rs) {
- if (rs.result == undefined) return;
- panels.createResultPanelWithDataGrid({
- subTitle: subtitleP,
- features: rs.result.features.features,
- title: "按材质查询结果",
- //count: count,
- dataSetName: dataSetNameP,
- dataSourceName: wsP
- }, function() {
- });
- });
- }
- </script>
|