addPush.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. </head>
  8. <body layout:fragment="content">
  9. <style>
  10. dl dd label {
  11. display: inline-block;
  12. padding: 5px 20px;
  13. }
  14. input[type="checkbox"] {
  15. margin-right: 5px;
  16. }
  17. </style>
  18. <article class="page-container">
  19. <form class="form form-horizontal" id="form-notify-addPush" th:action="@{/projectDeclaration/addPushSearch}">
  20. <input type="hidden" id="notify_id" th:name="id" th:value="${id}"/>
  21. <input type="hidden" id="notify_detail_id" th:name="notify_detail_id" th:value="${notify_detail_id}"/>
  22. <input type="hidden" name="directPush" th:name="directPush" th:value="${directPush}"/>
  23. <input type="hidden" name="firstAdd" th:name="firstAdd" th:value="${firstAdd}"/>
  24. <div class="row cl">
  25. <input type="hidden" name="street_ids" id="street_ids"/>
  26. <dl class="cl permission-list" th:if="${userType}=='0'">
  27. <dt>
  28. <label class=""><input onchange="setTimeout(function(){getStreet_ids();getBuilds();},200);"
  29. type="checkbox">街道</label>
  30. </dt>
  31. <dd class="pushStreetsList">
  32. <label class="" th:each="street,iterStat:${streetList}" th:object="${street}">
  33. <input type="checkbox" th:value="*{id}" th:id="*{id}" th:streetName="*{name}" th:text="*{name}"
  34. th:checked="*{isChecked}" onchange="getStreet_ids();getBuilds();">
  35. <span class="c-red" th:if="*{isPush}">已推送</span>
  36. </label>
  37. </dd>
  38. </dl>
  39. </div>
  40. <div class="row cl">
  41. <input type="hidden" name="build_ids" id="build_ids"/>
  42. <dl class="cl permission-list" th:if="${userType}=='0'">
  43. <dt>
  44. <label class=""><input type="checkbox"
  45. onchange="setTimeout(function(){getBuild_ids();getCompanys();},200);">园区</label>
  46. </dt>
  47. <dd class="pushBuildsList">
  48. <label class="" th:each="build,iterStat:${buildList}" th:object="${build}">
  49. <input type="checkbox" th:value="*{id}" th:buildName="*{name}" th:name="builds" th:id="*{id}"
  50. th:text="*{name}"
  51. th:checked="*{isChecked}" onchange="getBuild_ids();getCompanys();">
  52. <span class="c-red" th:if="*{isPush}">已推送</span>
  53. </label>
  54. </dd>
  55. </dl>
  56. <dl class="cl permission-list" th:if="${userType}=='4'">
  57. <dt>
  58. <label class=""><input type="checkbox" onchange="getBuild_ids();getCompanys();">园区</label>
  59. </dt>
  60. <dd class="pushBuildsList">
  61. <label class="" th:each="build,iterStat:${buildList}" th:object="${build}">
  62. <input type="checkbox" th:value="*{id}" th:buildName="*{name}" th:name="builds" th:id="*{id}"
  63. th:text="*{name}"
  64. th:checked="*{isChecked}" onchange="getBuild_ids();getCompanys();">
  65. <span class="c-red" th:if="*{isPush}">已推送</span>
  66. </label>
  67. </dd>
  68. </dl>
  69. </div>
  70. <div class="row cl">
  71. <input type="hidden" name="company_ids" id="company_ids"/>
  72. <div style="margin:10px;">
  73. <input th:name="company_name" th:value="${searchCompany.company_name}" type="text" class="input-text"
  74. style="width:250px" placeholder="输入企业名称"/>
  75. <label>企业性质:</label>
  76. <span class="select-box" style="width:250px">
  77. <select class="select" th:name="type">
  78. <option value="">--请选择--</option>
  79. <option th:selected="${searchCompany.type}==*{value}"
  80. th:each="type,iterStat:${companyTypeList}" th:object="${type}"
  81. th:value="*{value}" th:text="*{name}"></option>
  82. </select>
  83. </span>
  84. <button class="btn btn-success" type="submit">
  85. <i class="Hui-iconfont">&#xe665;</i>搜索
  86. </button>
  87. </div>
  88. <table id="companyTb" class="table table-border table-bordered table-bg table-hover">
  89. <thead>
  90. <tr class="text-c">
  91. <th><input type="checkbox" id="all" name="" value=""/></th>
  92. <th>企业名称</th>
  93. </tr>
  94. </thead>
  95. <tbody>
  96. </tbody>
  97. <tbody class="pushCompanyList" id="pushCompanyList">
  98. <tr class="text-c" th:each="company,iterStat:${companyList}"
  99. th:object="${company}">
  100. <td><input type="checkbox" th:companyName="*{company_name}" th:checked="*{isChecked}" th:id="*{id}"
  101. th:value="*{id}" onchange="getCompany_ids()"/></td>
  102. <td>
  103. <span th:name="company_name" th:text="*{company_name}"></span>
  104. <span class="c-red" th:if="*{isPush}">已推送</span>
  105. </td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. <div th:replace="admin/common/page :: page"></div>
  110. </div>
  111. <div class="row cl">
  112. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" th:if="${directPush}">
  113. <a class="btn btn-primary radius" title="推送" href="javascript:;" onclick="send()"
  114. style="text-decoration:none;padding: 4px 16px">推送</a>
  115. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  116. </div>
  117. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" th:unless="*{directPush}">
  118. <button class="btn btn-primary radius" type="submit" onClick="savePush();"><i class="Hui-iconfont">&#xe632;</i>
  119. 保存
  120. </button>
  121. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  122. </div>
  123. </div>
  124. </form>
  125. </article>
  126. <script type="text/javascript" th:src="@{/js/common/page.js}"></script>
  127. <script th:inline="javascript">
  128. $(function () {
  129. $(".permission-list dt input:checkbox").click(function () {
  130. $(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
  131. //$(this).trigger('change');
  132. });
  133. $(".permission-list dd input:checkbox").click(function () {
  134. var l = $(this).parent().parent().find("input:checked").length;
  135. if ($(this).prop("checked")) {
  136. $(this).closest("dl").find("dt input:checkbox").prop("checked", true);
  137. if (l == $(this).parent().parent().find("input").length) {
  138. //$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", true);
  139. $(this).closest("dl").find("dt input:checkbox").prop("checked", true);
  140. }
  141. else {
  142. $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  143. }
  144. }
  145. else {
  146. $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  147. //if (l == 0) {
  148. // $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  149. //}
  150. }
  151. });
  152. //
  153. $(".permission-list").find("dt input:checkbox").each(function () {
  154. var length = $(this).parents(".permission-list").find("dd input:checkbox").length;
  155. var checkedLength = $(this).parents(".permission-list").find("dd input:checked").length;
  156. if (length > 0 && length == checkedLength) {
  157. $(this).prop("checked", true);
  158. }
  159. });
  160. //添加页面根据父页面数据回显
  161. if ($('input[name="directPush"]').val() == "false" && $('input[name="firstAdd"]').val() == "true") {
  162. loadSelectedItems();
  163. }
  164. //
  165. getStreet_ids();
  166. getBuild_ids();
  167. getCompany_ids();
  168. });
  169. /**
  170. * 取消
  171. */
  172. function removeIframe() {
  173. var index = parent.layer.getFrameIndex(window.name);
  174. parent.layer.close(index);
  175. }
  176. function getBuilds() {
  177. var chlength = $('.pushStreetsList').find('input[type="checkbox"]:checked').length;
  178. var street_ids = '';
  179. $('.pushStreetsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  180. street_ids = street_ids + $(this).attr("value") + ",";
  181. });
  182. street_ids = street_ids.substring(0, street_ids.length - 1);
  183. if (street_ids.length > 0) {
  184. $.ajax({
  185. url: pagePath + "/projectDeclaration/getBuildsByStreetIds",
  186. type: "post",
  187. data: {
  188. 'street_ids': street_ids,
  189. 'id': $("#notify_id").val()
  190. },
  191. dataType: "json",
  192. success: function (result) {
  193. if (result.success) {
  194. //smileMessage(result.message)
  195. var buildList = result.obj;
  196. bindBuild(buildList);
  197. getCompanys();
  198. } else {
  199. errorMessage(result.message);
  200. }
  201. },
  202. error: function () {
  203. errorMessage('系统错误!');
  204. }
  205. });
  206. } else {
  207. $(".pushBuildsList").empty();
  208. $("#companyTb").find("tbody tr").remove();
  209. $("#paging").hide();
  210. }
  211. }
  212. function bindBuild(buildList) {
  213. $(".pushBuildsList").empty();
  214. for (var i = 0; i < buildList.length; i++) {
  215. var label = '<label class="">';
  216. label += '<input type="checkbox" value="' + buildList[i].id + '" buildName="' + buildList[i].name + '" id="' + buildList[i].id + '" onchange="getBuild_ids();getCompanys();">';
  217. label += buildList[i].name;
  218. //label += '<span class="c-red" th:if="*{isPush}">已推送</span>';
  219. label += '</label>';
  220. if (buildList[i].isPush) {
  221. label += '<span class="c-red" >已推送</span>';
  222. }
  223. $(".pushBuildsList").append(label);
  224. }
  225. getBuild_ids();
  226. }
  227. function getCompanys() {
  228. $("#form-notify-addPush").submit();
  229. }
  230. function getStreet_ids() {
  231. var street_ids = '';
  232. $('.pushStreetsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  233. street_ids = street_ids + $(this).attr("value") + ",";
  234. });
  235. street_ids = street_ids.substring(0, street_ids.length - 1);
  236. $("#street_ids").val(street_ids);
  237. return street_ids;
  238. }
  239. function getBuild_ids() {
  240. var build_ids = '';
  241. $('.pushBuildsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  242. build_ids = build_ids + $(this).attr("value") + ",";
  243. });
  244. build_ids = build_ids.substring(0, build_ids.length - 1);
  245. $("#build_ids").val(build_ids);
  246. return build_ids;
  247. }
  248. function getCompany_ids() {
  249. var company_ids = '';
  250. $('.pushCompanyList').find('input[type="checkbox"]:checked').each(function (i, item) {
  251. company_ids = company_ids + $(this).attr("value") + ",";
  252. });
  253. company_ids = company_ids.substring(0, company_ids.length - 1);
  254. $("#company_ids").val(company_ids);
  255. return company_ids;
  256. }
  257. /**
  258. * 保存推送单位
  259. * */
  260. function savePush() {
  261. var chlength = $('.pushStreetsList').find('input[type="checkbox"]:checked').length;
  262. var street_ids = '';
  263. var street_names = '';
  264. $('.pushStreetsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  265. street_ids = street_ids + $(this).attr("value") + ",";
  266. street_names = street_names += $(this).attr("streetName") + ",";
  267. });
  268. street_ids = street_ids.substring(0, street_ids.length - 1);
  269. street_names = street_names.substring(0, street_names.length - 1);
  270. var chlength = $('.pushBuildsList').find('input[type="checkbox"]:checked').length;
  271. var build_ids = '';
  272. var build_names = '';
  273. $('.pushBuildsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  274. build_ids = build_ids + $(this).attr("value") + ",";
  275. build_names = build_names + $(this).attr("buildName") + ",";
  276. });
  277. build_ids = build_ids.substring(0, build_ids.length - 1);
  278. build_names = build_names.substring(0, build_names.length - 1);
  279. var chlength = $('.pushCompanyList').find('input[type="checkbox"]:checked').length;
  280. var company_ids = '';
  281. var company_names = '';
  282. $('.pushCompanyList').find('input[type="checkbox"]:checked').each(function (i, item) {
  283. company_ids = company_ids + $(this).attr("value") + ",";
  284. company_names = company_names + $(this).attr("companyName") + ",";
  285. });
  286. company_ids = company_ids.substring(0, company_ids.length - 1);
  287. company_names = company_names.substring(0, company_names.length - 1);
  288. parent.$("#pushStreetIds").val(street_ids);
  289. parent.$("#pushBuildIds").val(build_ids);
  290. parent.$("#pushCompanyIds").val(company_ids);
  291. parent.$("#pushStreetNames").val(street_names);
  292. parent.$("#pushBuildNames").val(build_names);
  293. parent.$("#pushCompanyNames").val(company_names);
  294. /*parent.$("#pushNames").text(street_names+" "+build_names+" "+company_names);*/
  295. parent.$("#pushNames").text(company_names);
  296. var index = parent.layer.getFrameIndex(window.name);
  297. parent.layer.close(index);
  298. }
  299. /***
  300. * 直接推送
  301. * */
  302. function send() {
  303. var chlength = $('.pushStreetsList').find('input[type="checkbox"]:checked').length;
  304. var street_ids = '';
  305. var street_names = '';
  306. $('.pushStreetsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  307. street_ids = street_ids + $(this).attr("value") + ",";
  308. street_names = street_names += $(this).attr("streetName") + ",";
  309. });
  310. street_ids = street_ids.substring(0, street_ids.length - 1);
  311. street_names = street_names.substring(0, street_names.length - 1);
  312. var chlength = $('.pushBuildsList').find('input[type="checkbox"]:checked').length;
  313. var build_ids = '';
  314. var build_names = '';
  315. $('.pushBuildsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  316. build_ids = build_ids + $(this).attr("value") + ",";
  317. build_names = build_names + $(this).attr("buildName") + ",";
  318. });
  319. build_ids = build_ids.substring(0, build_ids.length - 1);
  320. build_names = build_names.substring(0, build_names.length - 1);
  321. var chlength = $('.pushCompanyList').find('input[type="checkbox"]:checked').length;
  322. var company_ids = '';
  323. var company_names = '';
  324. $('.pushCompanyList').find('input[type="checkbox"]:checked').each(function (i, item) {
  325. company_ids = company_ids + $(this).attr("value") + ",";
  326. company_names = company_names + $(this).attr("companyName") + ",";
  327. });
  328. company_ids = company_ids.substring(0, company_ids.length - 1);
  329. company_names = company_names.substring(0, company_names.length - 1);
  330. if (street_ids == '' && build_ids == '' && company_ids == '') {
  331. sadMessage("请选择推送单位!");
  332. return false;
  333. }
  334. $.ajax({
  335. url: pagePath + "/projectDeclaration/send",
  336. type: "post",
  337. data: {
  338. 'id': $("#notify_id").val(),
  339. 'notify_detail_id': $("#notify_detail_id").val(),
  340. 'street_ids': street_ids,
  341. 'street_names': street_names,
  342. 'build_ids': build_ids,
  343. 'build_names': build_names,
  344. 'company_ids': company_ids,
  345. 'company_names': company_names,
  346. },
  347. dataType: "json",
  348. success: function (result) {
  349. if (result.success) {
  350. smileMessage(result.message)
  351. setTimeClose();
  352. } else {
  353. errorMessage(result.message);
  354. }
  355. },
  356. error: function () {
  357. errorMessage('系统错误!');
  358. }
  359. });
  360. }
  361. function loadSelectedItems() {
  362. var selectedStreets = parent.$("#pushStreetIds").val();
  363. var selectedBuilds = parent.$("#pushBuildIds").val();
  364. var selectedCompanys = parent.$("#pushCompanyIds").val();
  365. $("#street_ids").val(selectedStreets);
  366. $("#build_ids").val(selectedBuilds);
  367. $("#company_ids").val(selectedCompanys);
  368. $("#form-notify-addPush").submit();
  369. }
  370. </script>
  371. </body>
  372. </html>