| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <!DOCTYPE HTML>
- <html xmlns:th="http://www.thymeleaf.org"
- xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
- layout:decorate="~{admin/common/common}">
- <head>
- <title>推送</title>
- <style>
- .site-title {
- background: #5a98de;
- color: #fff;
- line-height: 36px;
- padding: 0 15px;
- }
- .site-box {
- border: solid 1px #dadada;
- padding: 0 15px;
- }
- .site-box ul li {
- margin: 10px 0;
- }
- .right-line {
- border-right: solid 1px #dadada;
- }
- </style>
- </head>
- <body layout:fragment="content">
- <article class="page-container">
- <div class="row cl" style="margin-bottom: 40px;">
- <div class="col-xs-4 col-sm-4"></div>
- <div class="formControls col-xs-4 col-sm-4">
- <input id="searchContent" type="text" class="input-text" placeholder="请输入街道或园区或企业名称" name="search"/>
- </div>
- <div class="col-xs-2 col-sm-2"><a class="btn btn-primary radius" id="searchBtn">搜索</a></div>
- </div>
- <div class="row clearfix">
- <div class="col-xs-4 col-sm-4">
- <div class="site-title">
- <input type="checkbox" name="streetAll" onchange="setTimeout(function(){getBuilds();checkIds();},200);">
- <span>街道</span>
- </div>
- <div class="site-box streetListPre">
- <ul th:each="street,iterStat:${streetList}" th:object="${street}" class="streetList">
- <li>
- <input type="checkbox" th:value="*{id}" th:id="*{id}" name="street" th:streetName="*{name}"
- onchange="setTimeout(function(){getBuilds();checkIds();},200);">
- <span th:text="*{name}"></span>
- </li>
- </ul>
- </div>
- </div>
- <div class="col-xs-4 col-sm-4">
- <div class="site-title">
- <input type="checkbox" name="buildAll"
- onchange="setTimeout(function(){getCompanys();checkIds();},200);">
- <span>园区</span>
- </div>
- <div class="site-box">
- <ul class="buildList">
- <!--<li>
- <input type="checkbox" value="" id="" name="build" onchange="setTimeout(function(){getCompanys()},200);">
- <span>name</span>
- </li>-->
- </ul>
- </div>
- </div>
- <div class="col-xs-4 col-sm-4">
- <div class="row site-title clearfix">
- <div class="col-sx-5 col-sm-5" style="padding: 0;">
- <input type="checkbox" name="companyAll" onchange="setTimeout(function(){checkIds();},200);">
- <select class="select" style="width: 70px;" id="type_id">
- <option value="">性质</option>
- <option value="1">工业</option>
- <option value="0">非工业</option>
- </select>
- </div>
- <div class="col-sx-7 col-sm-7">
- <span>企业</span>
- </div>
- </div>
- <div class="row site-box clearfix companyList">
- <!--<div class="col-sx-3 col-sm-3 right-line" style="padding: 0;">
- <ul>
- <li>
- <input type="checkbox">
- <span>工业</span>
- </li>
- </ul>
- </div>
- <div class="col-sx-9 col-sm-9">
- <ul>
- <li>
- <span>企业A</span>
- </li>
- </ul>
- </div>-->
- </div>
- </div>
- </div>
- <div class="row" style="margin-top: 40px; text-align: center;">
- <button onclick="saveItems();" class="btn btn-primary radius">保存</button>
- <button onclick="removeIframe();" class="btn btn-default radius">取消</button>
- </div>
- </article>
- <script th:inline="javascript">
- /**
- * 取消
- */
- function removeIframe() {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
- var selectedObj, streetIds = '', BuildIds = '', CompanyIds = '', Names = '';
- $('input[name="streetAll"]').click(function () {
- //alert(this.checked);
- if ($(this).is(':checked')) {
- $('input[name="street"]').each(function () {
- //此处如果用attr,会出现第三次失效的情况
- $(this).prop("checked", true);
- });
- } else {
- $('input[name="street"]').each(function () {
- $(this).removeAttr("checked", false);
- });
- //$(this).removeAttr("checked");
- }
- });
- $('input[name="buildAll"]').click(function () {
- //alert(this.checked);
- if ($(this).is(':checked')) {
- $('input[name="build"]').each(function () {
- //此处如果用attr,会出现第三次失效的情况
- $(this).prop("checked", true);
- });
- } else {
- $('input[name="build"]').each(function () {
- $(this).removeAttr("checked", false);
- });
- //$(this).removeAttr("checked");
- }
- });
- $('input[name="companyAll"]').click(function () {
- //alert(this.checked);
- if ($(this).is(':checked')) {
- $('input[name="company"]').each(function () {
- //此处如果用attr,会出现第三次失效的情况
- $(this).prop("checked", true);
- });
- } else {
- $('input[name="company"]').each(function () {
- $(this).removeAttr("checked", false);
- });
- //$(this).removeAttr("checked");
- }
- });
- $("#type_id").change(function () {
- getCompanys();
- checkIds();
- });
- function getBuilds() {
- var ids = new Array();
- $("input:checkbox[name='street']:checked").each(function (i) {
- var val = $(this).val() + ',';
- ids += val;
- });
- console.log(ids);
- if (ids.length > 0) {
- $.ajax({
- url: pagePath + "/government/activity/getBuildsByStreetIds",
- type: "post",
- data: {
- 'streetIds': ids
- },
- dataType: "json",
- success: function (result) {
- if (result.success) {
- //smileMessage(result.message)
- console.log(result.obj);
- bindBuild(result.obj);
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- } else {
- $(".buildList").empty();
- }
- }
- function bindStreet(streetList) {
- $(".streetListPre").empty();
- $(".streetListPre").append('<ul class="streetList"></ul>');
- $(".streetList").empty();
- var str = '';
- for (var i = 0; i < streetList.length; i++) {
- str += '<li>';
- str += '<input type="checkbox" value="' + streetList[i].id + '" id="' + streetList[i].id + '" name="street" streetName="' + streetList[i].name + '" onchange="setTimeout(function(){getCompanys();checkIds()},200);">';
- str += '<span>' + streetList[i].name + '</span>';
- str += '</li>';
- }
- $(".streetList").append(str);
- }
- function bindBuild(buildList) {
- $(".buildList").empty();
- var str = '';
- for (var i = 0; i < buildList.length; i++) {
- str += '<li>';
- str += '<input type="checkbox" value="' + buildList[i].id + '" id="' + buildList[i].id + '" name="build" buildName="' + buildList[i].name + '" onchange="setTimeout(function(){getCompanys();checkIds()},200);">';
- str += '<span>' + buildList[i].name + '</span>';
- str += '</li>';
- }
- $(".buildList").append(str);
- }
- function getCompanys() {
- var ids = new Array();
- $("input:checkbox[name='build']:checked").each(function (i) {
- var val = $(this).val() + ',';
- ids += val;
- });
- console.log(ids);
- if (ids.length > 0) {
- $.ajax({
- url: pagePath + "/government/activity/getCompanysByBuildIds",
- type: "post",
- data: {
- 'buildIds': ids,
- 'type_id': $('#type_id').val()
- },
- dataType: "json",
- success: function (result) {
- if (result.success) {
- //smileMessage(result.message)
- console.log(result.obj);
- bindCompany(result.obj);
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- } else {
- $(".companyList").empty();
- }
- }
- function bindCompany(companyList) {
- $(".companyList").empty();
- var str = '';
- for (var i = 0; i < companyList.length; i++) {
- str += '<div class="col-sx-3 col-sm-3 right-line" style="padding: 0;">'
- str += '<ul>'
- str += '<li>'
- str += '<input type="checkbox" value="' + companyList[i].id + '" name="company" companyName="' + companyList[i].company_name + '" onchange="setTimeout(function(){checkIds()},200);">'
- if (companyList[i].type_id == '1') {
- str += '<span>工业</span>'
- } else if (companyList[i].type_id == '0') {
- str += '<span>非工业</span>'
- } else {
- str += '<span></span>'
- }
- str += '</li>'
- str += '</ul>'
- str += '</div>'
- str += '<div class="col-sx-9 col-sm-9">'
- str += '<ul>'
- str += '<li>'
- str += '<span>' + companyList[i].company_name + '</span>'
- str += '</li>'
- str += '</ul>'
- str += '</div>'
- }
- $(".companyList").append(str);
- }
- function checkIds() {
- var ids = new Array();
- streetIds = '', BuildIds = '', CompanyIds = '', Names = '';
- $("input:checkbox[name='street']:checked").each(function (i) {
- var val = $(this).val();
- streetIds += val + ',';
- //Names += $(this).attr("streetName") + ",";
- ids.push({id: val, type: 4});
- });
- $("input:checkbox[name='build']:checked").each(function (i) {
- var val = $(this).val();
- BuildIds += val + ',';
- //Names += $(this).attr("buildName") + ",";
- ids.push({id: val, type: 1});
- });
- $("input:checkbox[name='company']:checked").each(function (i) {
- var val = $(this).val();
- CompanyIds += val + ',';
- Names += $(this).attr("companyName") + ",";
- ids.push({id: val, type: 3});
- });
- selectedObj = ids;
- }
- $("body").keydown(function (event) {
- if (event.keyCode == "13") {//keyCode=13是回车键
- $('#searchBtn').trigger("click");
- }
- });
- $('#searchBtn').click(function () {
- var name = $("input[ name='search']").val();
- $.ajax({
- url: pagePath + "/government/activity/findStreetBuildCompanyByName",
- type: "post",
- data: {
- 'name': name
- },
- dataType: "json",
- success: function (result) {
- if (result.success) {
- //smileMessage(result.message)
- console.log(result.obj);
- var list = result.obj;
- var streetList = new Array();
- var buildList = new Array();
- var companyList = new Array();
- for (var i = 0; i < list.length; i++) {
- if (list[i].type == '4') {
- streetList.push(list[i]);
- } else if (list[i].type == '1') {
- buildList.push(list[i]);
- } else if (list[i].type == '3') {
- companyList.push({id: list[i].id, company_name: list[i].name});
- }
- }
- console.log(streetList)
- console.log(buildList)
- console.log(companyList)
- bindStreet(streetList);
- bindBuild(buildList);
- bindCompany(companyList);
- } else {
- errorMessage(result.message);
- }
- },
- error: function () {
- errorMessage('系统错误!');
- }
- });
- });
- function saveItems() {
- parent.$("#pushStreetIds").val(streetIds);
- parent.$("#pushBuildIds").val(BuildIds);
- parent.$("#pushCompanyIds").val(CompanyIds);
- parent.$("#pushNames").text(Names);
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
- </script>
- </body>
- </html>
|