| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- 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;
- });
- if (ids.length > 0) {
- $.ajax({
- url: pagePath + "/government/activity/getBuildsByStreetIds",
- type: "post",
- data: {
- 'streetIds': ids
- },
- dataType: "json",
- success: function (result) {
- if (result.success) {
- 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;
- });
- 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) {
- 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 += "<span>"+$(this).attr("streetName") + "</span>";
- ids.push({id: val, type: 4});
- });
- $("input:checkbox[name='build']:checked").each(function (i) {
- var val = $(this).val();
- BuildIds += val + ',';
- Names += "<span>"+$(this).attr("buildName") + "</span>";
- ids.push({id: val, type: 1});
- });
- $("input:checkbox[name='company']:checked").each(function (i) {
- var val = $(this).val();
- CompanyIds += val + ',';
- Names += "<span>"+$(this).attr("companyName") + "</span>";
- 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) {
- 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});
- }
- }
- 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").html(Names);
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- }
|