push.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <!DOCTYPE HTML>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  4. layout:decorate="~{admin/common/common}">
  5. <head>
  6. <title>推送</title>
  7. <style>
  8. .site-title {
  9. background: #5a98de;
  10. color: #fff;
  11. line-height: 36px;
  12. padding: 0 15px;
  13. }
  14. .site-box {
  15. border: solid 1px #dadada;
  16. padding: 0 15px;
  17. }
  18. .site-box ul li {
  19. margin: 10px 0;
  20. }
  21. .right-line {
  22. border-right: solid 1px #dadada;
  23. }
  24. </style>
  25. </head>
  26. <body layout:fragment="content">
  27. <article class="page-container">
  28. <div class="row cl" style="margin-bottom: 40px;">
  29. <div class="col-xs-4 col-sm-4"></div>
  30. <div class="formControls col-xs-4 col-sm-4">
  31. <input id="searchContent" type="text" class="input-text" placeholder="请输入街道或园区或企业名称" name="search"/>
  32. </div>
  33. <div class="col-xs-2 col-sm-2"><a class="btn btn-primary radius" id="searchBtn">搜索</a></div>
  34. </div>
  35. <div class="row clearfix">
  36. <div class="col-xs-4 col-sm-4">
  37. <div class="site-title">
  38. <input type="checkbox" name="streetAll" onchange="setTimeout(function(){getBuilds();checkIds();},200);">
  39. <span>街道</span>
  40. </div>
  41. <div class="site-box streetListPre">
  42. <ul th:each="street,iterStat:${streetList}" th:object="${street}" class="streetList">
  43. <li>
  44. <input type="checkbox" th:value="*{id}" th:id="*{id}" name="street" th:streetName="*{name}"
  45. onchange="setTimeout(function(){getBuilds();checkIds();},200);">
  46. <span th:text="*{name}"></span>
  47. </li>
  48. </ul>
  49. </div>
  50. </div>
  51. <div class="col-xs-4 col-sm-4">
  52. <div class="site-title">
  53. <input type="checkbox" name="buildAll"
  54. onchange="setTimeout(function(){getCompanys();checkIds();},200);">
  55. <span>园区</span>
  56. </div>
  57. <div class="site-box">
  58. <ul class="buildList">
  59. <!--<li>
  60. <input type="checkbox" value="" id="" name="build" onchange="setTimeout(function(){getCompanys()},200);">
  61. <span>name</span>
  62. </li>-->
  63. </ul>
  64. </div>
  65. </div>
  66. <div class="col-xs-4 col-sm-4">
  67. <div class="row site-title clearfix">
  68. <div class="col-sx-5 col-sm-5" style="padding: 0;">
  69. <input type="checkbox" name="companyAll" onchange="setTimeout(function(){checkIds();},200);">
  70. <select class="select" style="width: 70px;" id="type_id">
  71. <option value="">性质</option>
  72. <option value="1">工业</option>
  73. <option value="0">非工业</option>
  74. </select>
  75. </div>
  76. <div class="col-sx-7 col-sm-7">
  77. <span>企业</span>
  78. </div>
  79. </div>
  80. <div class="row site-box clearfix companyList">
  81. <!--<div class="col-sx-3 col-sm-3 right-line" style="padding: 0;">
  82. <ul>
  83. <li>
  84. <input type="checkbox">
  85. <span>工业</span>
  86. </li>
  87. </ul>
  88. </div>
  89. <div class="col-sx-9 col-sm-9">
  90. <ul>
  91. <li>
  92. <span>企业A</span>
  93. </li>
  94. </ul>
  95. </div>-->
  96. </div>
  97. </div>
  98. </div>
  99. <div class="row" style="margin-top: 40px; text-align: center;">
  100. <button onclick="saveItems();" class="btn btn-primary radius">保存</button>
  101. <button onclick="removeIframe();" class="btn btn-default radius">取消</button>
  102. </div>
  103. </article>
  104. <script th:inline="javascript">
  105. /**
  106. * 取消
  107. */
  108. function removeIframe() {
  109. var index = parent.layer.getFrameIndex(window.name);
  110. parent.layer.close(index);
  111. }
  112. var selectedObj, streetIds = '', BuildIds = '', CompanyIds = '', Names = '';
  113. $('input[name="streetAll"]').click(function () {
  114. //alert(this.checked);
  115. if ($(this).is(':checked')) {
  116. $('input[name="street"]').each(function () {
  117. //此处如果用attr,会出现第三次失效的情况
  118. $(this).prop("checked", true);
  119. });
  120. } else {
  121. $('input[name="street"]').each(function () {
  122. $(this).removeAttr("checked", false);
  123. });
  124. //$(this).removeAttr("checked");
  125. }
  126. });
  127. $('input[name="buildAll"]').click(function () {
  128. //alert(this.checked);
  129. if ($(this).is(':checked')) {
  130. $('input[name="build"]').each(function () {
  131. //此处如果用attr,会出现第三次失效的情况
  132. $(this).prop("checked", true);
  133. });
  134. } else {
  135. $('input[name="build"]').each(function () {
  136. $(this).removeAttr("checked", false);
  137. });
  138. //$(this).removeAttr("checked");
  139. }
  140. });
  141. $('input[name="companyAll"]').click(function () {
  142. //alert(this.checked);
  143. if ($(this).is(':checked')) {
  144. $('input[name="company"]').each(function () {
  145. //此处如果用attr,会出现第三次失效的情况
  146. $(this).prop("checked", true);
  147. });
  148. } else {
  149. $('input[name="company"]').each(function () {
  150. $(this).removeAttr("checked", false);
  151. });
  152. //$(this).removeAttr("checked");
  153. }
  154. });
  155. $("#type_id").change(function () {
  156. getCompanys();
  157. checkIds();
  158. });
  159. function getBuilds() {
  160. var ids = new Array();
  161. $("input:checkbox[name='street']:checked").each(function (i) {
  162. var val = $(this).val() + ',';
  163. ids += val;
  164. });
  165. console.log(ids);
  166. if (ids.length > 0) {
  167. $.ajax({
  168. url: pagePath + "/government/activity/getBuildsByStreetIds",
  169. type: "post",
  170. data: {
  171. 'streetIds': ids
  172. },
  173. dataType: "json",
  174. success: function (result) {
  175. if (result.success) {
  176. //smileMessage(result.message)
  177. console.log(result.obj);
  178. bindBuild(result.obj);
  179. } else {
  180. errorMessage(result.message);
  181. }
  182. },
  183. error: function () {
  184. errorMessage('系统错误!');
  185. }
  186. });
  187. } else {
  188. $(".buildList").empty();
  189. }
  190. }
  191. function bindStreet(streetList) {
  192. $(".streetListPre").empty();
  193. $(".streetListPre").append('<ul class="streetList"></ul>');
  194. $(".streetList").empty();
  195. var str = '';
  196. for (var i = 0; i < streetList.length; i++) {
  197. str += '<li>';
  198. str += '<input type="checkbox" value="' + streetList[i].id + '" id="' + streetList[i].id + '" name="street" streetName="' + streetList[i].name + '" onchange="setTimeout(function(){getCompanys();checkIds()},200);">';
  199. str += '<span>' + streetList[i].name + '</span>';
  200. str += '</li>';
  201. }
  202. $(".streetList").append(str);
  203. }
  204. function bindBuild(buildList) {
  205. $(".buildList").empty();
  206. var str = '';
  207. for (var i = 0; i < buildList.length; i++) {
  208. str += '<li>';
  209. str += '<input type="checkbox" value="' + buildList[i].id + '" id="' + buildList[i].id + '" name="build" buildName="' + buildList[i].name + '" onchange="setTimeout(function(){getCompanys();checkIds()},200);">';
  210. str += '<span>' + buildList[i].name + '</span>';
  211. str += '</li>';
  212. }
  213. $(".buildList").append(str);
  214. }
  215. function getCompanys() {
  216. var ids = new Array();
  217. $("input:checkbox[name='build']:checked").each(function (i) {
  218. var val = $(this).val() + ',';
  219. ids += val;
  220. });
  221. console.log(ids);
  222. if (ids.length > 0) {
  223. $.ajax({
  224. url: pagePath + "/government/activity/getCompanysByBuildIds",
  225. type: "post",
  226. data: {
  227. 'buildIds': ids,
  228. 'type_id': $('#type_id').val()
  229. },
  230. dataType: "json",
  231. success: function (result) {
  232. if (result.success) {
  233. //smileMessage(result.message)
  234. console.log(result.obj);
  235. bindCompany(result.obj);
  236. } else {
  237. errorMessage(result.message);
  238. }
  239. },
  240. error: function () {
  241. errorMessage('系统错误!');
  242. }
  243. });
  244. } else {
  245. $(".companyList").empty();
  246. }
  247. }
  248. function bindCompany(companyList) {
  249. $(".companyList").empty();
  250. var str = '';
  251. for (var i = 0; i < companyList.length; i++) {
  252. str += '<div class="col-sx-3 col-sm-3 right-line" style="padding: 0;">'
  253. str += '<ul>'
  254. str += '<li>'
  255. str += '<input type="checkbox" value="' + companyList[i].id + '" name="company" companyName="' + companyList[i].company_name + '" onchange="setTimeout(function(){checkIds()},200);">'
  256. if (companyList[i].type_id == '1') {
  257. str += '<span>工业</span>'
  258. } else if (companyList[i].type_id == '0') {
  259. str += '<span>非工业</span>'
  260. } else {
  261. str += '<span></span>'
  262. }
  263. str += '</li>'
  264. str += '</ul>'
  265. str += '</div>'
  266. str += '<div class="col-sx-9 col-sm-9">'
  267. str += '<ul>'
  268. str += '<li>'
  269. str += '<span>' + companyList[i].company_name + '</span>'
  270. str += '</li>'
  271. str += '</ul>'
  272. str += '</div>'
  273. }
  274. $(".companyList").append(str);
  275. }
  276. function checkIds() {
  277. var ids = new Array();
  278. streetIds = '', BuildIds = '', CompanyIds = '', Names = '';
  279. $("input:checkbox[name='street']:checked").each(function (i) {
  280. var val = $(this).val();
  281. streetIds += val + ',';
  282. //Names += $(this).attr("streetName") + ",";
  283. ids.push({id: val, type: 4});
  284. });
  285. $("input:checkbox[name='build']:checked").each(function (i) {
  286. var val = $(this).val();
  287. BuildIds += val + ',';
  288. //Names += $(this).attr("buildName") + ",";
  289. ids.push({id: val, type: 1});
  290. });
  291. $("input:checkbox[name='company']:checked").each(function (i) {
  292. var val = $(this).val();
  293. CompanyIds += val + ',';
  294. Names += $(this).attr("companyName") + ",";
  295. ids.push({id: val, type: 3});
  296. });
  297. selectedObj = ids;
  298. }
  299. $("body").keydown(function (event) {
  300. if (event.keyCode == "13") {//keyCode=13是回车键
  301. $('#searchBtn').trigger("click");
  302. }
  303. });
  304. $('#searchBtn').click(function () {
  305. var name = $("input[ name='search']").val();
  306. $.ajax({
  307. url: pagePath + "/government/activity/findStreetBuildCompanyByName",
  308. type: "post",
  309. data: {
  310. 'name': name
  311. },
  312. dataType: "json",
  313. success: function (result) {
  314. if (result.success) {
  315. //smileMessage(result.message)
  316. console.log(result.obj);
  317. var list = result.obj;
  318. var streetList = new Array();
  319. var buildList = new Array();
  320. var companyList = new Array();
  321. for (var i = 0; i < list.length; i++) {
  322. if (list[i].type == '4') {
  323. streetList.push(list[i]);
  324. } else if (list[i].type == '1') {
  325. buildList.push(list[i]);
  326. } else if (list[i].type == '3') {
  327. companyList.push({id: list[i].id, company_name: list[i].name});
  328. }
  329. }
  330. console.log(streetList)
  331. console.log(buildList)
  332. console.log(companyList)
  333. bindStreet(streetList);
  334. bindBuild(buildList);
  335. bindCompany(companyList);
  336. } else {
  337. errorMessage(result.message);
  338. }
  339. },
  340. error: function () {
  341. errorMessage('系统错误!');
  342. }
  343. });
  344. });
  345. function saveItems() {
  346. parent.$("#pushStreetIds").val(streetIds);
  347. parent.$("#pushBuildIds").val(BuildIds);
  348. parent.$("#pushCompanyIds").val(CompanyIds);
  349. parent.$("#pushNames").text(Names);
  350. var index = parent.layer.getFrameIndex(window.name);
  351. parent.layer.close(index);
  352. }
  353. </script>
  354. </body>
  355. </html>