push.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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. </ul>
  60. </div>
  61. </div>
  62. <div class="col-xs-4 col-sm-4">
  63. <div class="row site-title clearfix">
  64. <div class="col-sx-5 col-sm-5" style="padding: 0;">
  65. <input type="checkbox" name="companyAll" onchange="setTimeout(function(){checkIds();},200);">
  66. <select class="select" style="width: 70px;" id="type_id">
  67. <option value="">性质</option>
  68. <option value="1">工业</option>
  69. <option value="0">非工业</option>
  70. </select>
  71. </div>
  72. <div class="col-sx-7 col-sm-7">
  73. <span>企业</span>
  74. </div>
  75. </div>
  76. <div class="row site-box clearfix companyList">
  77. </div>
  78. </div>
  79. </div>
  80. <div class="row" style="margin-top: 40px; text-align: center;">
  81. <button onclick="send();" class="btn btn-primary radius">推送</button>
  82. <button onclick="removeIframe();" class="btn btn-default radius">取消</button>
  83. </div>
  84. <input type="hidden" id="notify_id" th:name="id" th:value="${id}"/>
  85. </article>
  86. <script type="text/javascript" th:src="@{/js/government/activity/activityMessagepush_add.js}"></script>
  87. <script th:inline="javascript">
  88. /**
  89. * 取消
  90. */
  91. function removeIframe() {
  92. var index = parent.layer.getFrameIndex(window.name);
  93. parent.layer.close(index);
  94. }
  95. var selectedObj, StreetIds = '', BuildIds = '', CompanyIds = '', StreetNames = '', BuildNames = '',
  96. CompanyNames = '', Names = '';
  97. var sids = [[${pushedStreetIds}]], bids = [[${pushedBuildIds}]], cids = [[${pushedCompanyIds}]];
  98. var sarray = sids.split(",");
  99. var barray = bids.split(",");
  100. var carray = cids.split(",");
  101. var d = [[${streetList}]]
  102. bindStreet(d);
  103. $('input[name="streetAll"]').click(function () {
  104. //alert(this.checked);
  105. if ($(this).is(':checked')) {
  106. $('input[name="street"]').each(function () {
  107. //此处如果用attr,会出现第三次失效的情况
  108. $(this).prop("checked", true);
  109. });
  110. } else {
  111. $('input[name="street"]').each(function () {
  112. $(this).removeAttr("checked", false);
  113. });
  114. //$(this).removeAttr("checked");
  115. }
  116. });
  117. $('input[name="buildAll"]').click(function () {
  118. //alert(this.checked);
  119. if ($(this).is(':checked')) {
  120. $('input[name="build"]').each(function () {
  121. //此处如果用attr,会出现第三次失效的情况
  122. $(this).prop("checked", true);
  123. });
  124. } else {
  125. $('input[name="build"]').each(function () {
  126. $(this).removeAttr("checked", false);
  127. });
  128. //$(this).removeAttr("checked");
  129. }
  130. });
  131. $('input[name="companyAll"]').click(function () {
  132. //alert(this.checked);
  133. if ($(this).is(':checked')) {
  134. $('input[name="company"]').each(function () {
  135. //此处如果用attr,会出现第三次失效的情况
  136. $(this).prop("checked", true);
  137. });
  138. } else {
  139. $('input[name="company"]').each(function () {
  140. $(this).removeAttr("checked", false);
  141. });
  142. //$(this).removeAttr("checked");
  143. }
  144. });
  145. $("#type_id").change(function () {
  146. getCompanys();
  147. checkIds();
  148. });
  149. function getBuilds() {
  150. var ids = new Array();
  151. $("input:checkbox[name='street']:checked").each(function (i) {
  152. var val = $(this).val() + ',';
  153. ids += val;
  154. });
  155. if (ids.length > 0) {
  156. $.ajax({
  157. url: pagePath + "/government/activity/getBuildsByStreetIds",
  158. type: "post",
  159. data: {
  160. 'streetIds': ids
  161. },
  162. dataType: "json",
  163. success: function (result) {
  164. if (result.success) {
  165. bindBuild(result.obj);
  166. } else {
  167. errorMessage(result.message);
  168. }
  169. },
  170. error: function () {
  171. errorMessage('系统错误!');
  172. }
  173. });
  174. } else {
  175. $(".buildList").empty();
  176. }
  177. }
  178. function bindStreet(streetList) {
  179. $(".streetListPre").empty();
  180. $(".streetListPre").append('<ul class="streetList"></ul>');
  181. $(".streetList").empty();
  182. var str = '';
  183. for (var i = 0; i < streetList.length; i++) {
  184. str += '<li>';
  185. str += '<input type="checkbox" value="' + streetList[i].id + '" id="' + streetList[i].id + '" name="street" streetName="' + streetList[i].name + '" onchange="setTimeout(function(){getBuilds();checkIds()},200);">';
  186. str += '<span>' + streetList[i].name + '</span>';
  187. for (var j = 0; j < sarray.length; j++) {
  188. if (sarray[j] == streetList[i].id) {
  189. str += '<span style="color:red">(已推送)</span>';
  190. }
  191. }
  192. str += '</li>';
  193. }
  194. $(".streetList").append(str);
  195. }
  196. function bindBuild(buildList) {
  197. $(".buildList").empty();
  198. var str = '';
  199. for (var i = 0; i < buildList.length; i++) {
  200. str += '<li>';
  201. str += '<input type="checkbox" value="' + buildList[i].id + '" id="' + buildList[i].id + '" name="build" buildName="' + buildList[i].name + '" onchange="setTimeout(function(){getCompanys();checkIds()},200);">';
  202. str += '<span>' + buildList[i].name + '</span>';
  203. for (var j = 0; j < barray.length; j++) {
  204. if (barray[j] == buildList[i].id) {
  205. str += '<span style="color:red">(已推送)</span>';
  206. }
  207. }
  208. str += '</li>';
  209. }
  210. $(".buildList").append(str);
  211. }
  212. function getCompanys() {
  213. var ids = new Array();
  214. $("input:checkbox[name='build']:checked").each(function (i) {
  215. var val = $(this).val() + ',';
  216. ids += val;
  217. });
  218. if (ids.length > 0) {
  219. $.ajax({
  220. url: pagePath + "/government/activity/getCompanysByBuildIds",
  221. type: "post",
  222. data: {
  223. 'buildIds': ids,
  224. 'type_id': $('#type_id').val()
  225. },
  226. dataType: "json",
  227. success: function (result) {
  228. if (result.success) {
  229. bindCompany(result.obj);
  230. } else {
  231. errorMessage(result.message);
  232. }
  233. },
  234. error: function () {
  235. errorMessage('系统错误!');
  236. }
  237. });
  238. } else {
  239. $(".companyList").empty();
  240. }
  241. }
  242. function bindCompany(companyList) {
  243. $(".companyList").empty();
  244. var str = '';
  245. for (var i = 0; i < companyList.length; i++) {
  246. str += '<div class="col-sx-3 col-sm-3 right-line" style="padding: 0;">'
  247. str += '<ul>'
  248. str += '<li>'
  249. str += '<input type="checkbox" value="' + companyList[i].id + '" name="company" companyName="' + companyList[i].company_name + '" onchange="setTimeout(function(){checkIds()},200);">'
  250. if (companyList[i].type_id == '1') {
  251. str += '<span>工业</span>'
  252. } else if (companyList[i].type_id == '0') {
  253. str += '<span>非工业</span>'
  254. } else {
  255. str += '<span></span>'
  256. }
  257. str += '</li>'
  258. str += '</ul>'
  259. str += '</div>'
  260. str += '<div class="col-sx-9 col-sm-9">'
  261. str += '<ul>'
  262. str += '<li>'
  263. str += '<span>' + companyList[i].company_name + '</span>'
  264. for (var j = 0; j < carray.length; j++) {
  265. if (carray[j] == companyList[i].id) {
  266. str += '<span style="color:red">(已推送)</span>';
  267. }
  268. }
  269. str += '</li>'
  270. str += '</ul>'
  271. str += '</div>'
  272. }
  273. $(".companyList").append(str);
  274. }
  275. function checkIds() {
  276. var ids = new Array();
  277. StreetIds = '', BuildIds = '', CompanyIds = '', Names = '';
  278. $("input:checkbox[name='street']:checked").each(function (i) {
  279. var val = $(this).val();
  280. StreetIds += val + ',';
  281. StreetNames += "<span>" + $(this).attr("streetName") + "</span>";
  282. Names += "<span>" + $(this).attr("streetName") + "</span>";
  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. BuildNames += "<span>" + $(this).attr("buildName") + "</span>";
  289. Names += "<span>" + $(this).attr("buildName") + "</span>";
  290. ids.push({id: val, type: 1});
  291. });
  292. $("input:checkbox[name='company']:checked").each(function (i) {
  293. var val = $(this).val();
  294. CompanyIds += val + ',';
  295. CompanyNames += "<span>" + $(this).attr("companyName") + "</span>";
  296. Names += "<span>" + $(this).attr("companyName") + "</span>";
  297. ids.push({id: val, type: 3});
  298. });
  299. selectedObj = ids;
  300. }
  301. $("body").keydown(function (event) {
  302. if (event.keyCode == "13") {//keyCode=13是回车键
  303. $('#searchBtn').trigger("click");
  304. }
  305. });
  306. $('#searchBtn').click(function () {
  307. var name = $("input[ name='search']").val();
  308. $.ajax({
  309. url: pagePath + "/government/activity/findStreetBuildCompanyByName",
  310. type: "post",
  311. data: {
  312. 'name': name
  313. },
  314. dataType: "json",
  315. success: function (result) {
  316. if (result.success) {
  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. bindStreet(streetList);
  331. bindBuild(buildList);
  332. bindCompany(companyList);
  333. } else {
  334. errorMessage(result.message);
  335. }
  336. },
  337. error: function () {
  338. errorMessage('系统错误!');
  339. }
  340. });
  341. });
  342. function send() {
  343. $.ajax({
  344. url: pagePath + "/projectFilling/send",
  345. type: "post",
  346. data: {
  347. 'id': $("#notify_id").val(),
  348. 'street_ids': StreetIds,
  349. 'street_names': StreetNames,
  350. 'build_ids': BuildIds,
  351. 'build_names': BuildNames,
  352. 'company_ids': CompanyIds,
  353. 'company_names': CompanyNames,
  354. },
  355. dataType: "json",
  356. success: function (result) {
  357. if (result.success) {
  358. smileMessage(result.message)
  359. setTimeClose();
  360. } else {
  361. errorMessage(result.message);
  362. }
  363. },
  364. error: function () {
  365. errorMessage('系统错误!');
  366. }
  367. });
  368. }
  369. </script>
  370. </body>
  371. </html>