notify_addPush.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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="@{/government/notify/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);" type="checkbox">街道</label>
  29. </dt>
  30. <dd class="pushStreetsList">
  31. <label class="" th:each="street,iterStat:${streetList}" th:object="${street}">
  32. <input type="checkbox" th:value="*{id}" th:id="*{id}" th:streetName="*{name}" th:text="*{name}"
  33. th:checked="*{isChecked}" onchange="getStreet_ids();getBuilds();">
  34. <span class="c-red" th:if="*{isPush}">已推送</span>
  35. </label>
  36. </dd>
  37. </dl>
  38. </div>
  39. <div class="row cl">
  40. <input type="hidden" name="build_ids" id="build_ids"/>
  41. <dl class="cl permission-list" th:if="${userType}=='0'">
  42. <dt>
  43. <label class=""><input type="checkbox" onchange="setTimeout(function(){getBuild_ids();getCompanys();},200);">园区</label>
  44. </dt>
  45. <dd class="pushBuildsList">
  46. <label class="" th:each="build,iterStat:${buildList}" th:object="${build}">
  47. <input type="checkbox" th:value="*{id}" th:buildName="*{name}" th:name="builds" th:id="*{id}"
  48. th:text="*{name}"
  49. th:checked="*{isChecked}" onchange="getBuild_ids();getCompanys();">
  50. <span class="c-red" th:if="*{isPush}">已推送</span>
  51. </label>
  52. </dd>
  53. </dl>
  54. <dl class="cl permission-list" th:if="${userType}=='4'">
  55. <dt>
  56. <label class=""><input type="checkbox" onchange="getBuild_ids();getCompanys();">园区</label>
  57. </dt>
  58. <dd class="pushBuildsList">
  59. <label class="" th:each="build,iterStat:${buildList}" th:object="${build}">
  60. <input type="checkbox" th:value="*{id}" th:buildName="*{name}" th:name="builds" th:id="*{id}"
  61. th:text="*{name}"
  62. th:checked="*{isChecked}" onchange="getBuild_ids();getCompanys();">
  63. <span class="c-red" th:if="*{isPush}">已推送</span>
  64. </label>
  65. </dd>
  66. </dl>
  67. </div>
  68. <div class="row cl">
  69. <input type="hidden" name="company_ids" id="company_ids" th:value="${searchCompany.company_ids}"/>
  70. <input type="hidden" name="company_names" id="company_names" th:value="${searchCompany.company_names}"/>
  71. <div style="margin:10px;">
  72. <input th:name="company_name" th:value="${searchCompany.company_name}" type="text" class="input-text"
  73. style="width:250px" placeholder="输入企业名称"/>
  74. <label>企业性质:</label>
  75. <span class="select-box" style="width:250px">
  76. <select class="select" th:name="type" >
  77. <option value="">--请选择--</option>
  78. <option th:selected ="${searchCompany.type}==*{value}" th:each="type,iterStat:${companyTypeList}" th:object="${type}"
  79. th:value="*{value}" th:text="*{name}"></option>
  80. </select>
  81. </span>
  82. <button class="btn btn-success" type="submit">
  83. <i class="Hui-iconfont">&#xe665;</i>搜索
  84. </button>
  85. </div>
  86. <table id="companyTb" class="table table-border table-bordered table-bg table-hover">
  87. <thead>
  88. <tr class="text-c">
  89. <th><input type="checkbox" id="all" name="" value=""/></th>
  90. <th>企业名称</th>
  91. </tr>
  92. </thead>
  93. <tbody>
  94. </tbody>
  95. <tbody class="pushCompanyList" id="pushCompanyList">
  96. <tr class="text-c" th:each="company,iterStat:${companyList}"
  97. th:object="${company}">
  98. <td><input type="checkbox" th:companyName="*{company_name}" th:checked="*{isChecked}" th:id="*{id}" th:value="*{id}" onchange="getCompany_ids()"/></td>
  99. <td>
  100. <span th:name="company_name" th:text="*{company_name}"></span>
  101. <span class="c-red" th:if="*{isPush}">已推送</span>
  102. </td>
  103. </tr>
  104. </tbody>
  105. </table>
  106. <div th:replace="admin/common/page :: page"></div>
  107. </div>
  108. <div class="row cl">
  109. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" th:if="${directPush}">
  110. <a class="btn btn-primary radius" title="推送" href="javascript:;" onclick="send()"
  111. style="text-decoration:none;padding: 4px 16px">推送</a>
  112. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  113. </div>
  114. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" th:unless="*{directPush}">
  115. <button class="btn btn-primary radius" type="submit" onClick="savePush();"><i class="Hui-iconfont">&#xe632;</i>
  116. 保存
  117. </button>
  118. <button onClick="removeIframe();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
  119. </div>
  120. </div>
  121. </form>
  122. </article>
  123. <script type="text/javascript" th:src="@{/js/government/notify/notify_addPush.js}"></script>
  124. <script type="text/javascript" th:src="@{/js/common/page.js}"></script>
  125. <script th:inline="javascript">
  126. $(function () {
  127. $(".permission-list dt input:checkbox").click(function () {
  128. $(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
  129. //$(this).trigger('change');
  130. });
  131. $(".permission-list dd input:checkbox").click(function () {
  132. var l = $(this).parent().parent().find("input:checked").length;
  133. if ($(this).prop("checked")) {
  134. $(this).closest("dl").find("dt input:checkbox").prop("checked", true);
  135. if(l == $(this).parent().parent().find("input").length){
  136. //$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", true);
  137. $(this).closest("dl").find("dt input:checkbox").prop("checked", true);
  138. }
  139. else{
  140. $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  141. }
  142. }
  143. else {
  144. $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  145. //if (l == 0) {
  146. // $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  147. //}
  148. }
  149. });
  150. //
  151. $(".permission-list").find("dt input:checkbox").each(function(){
  152. var length = $(this).parents(".permission-list").find("dd input:checkbox").length;
  153. var checkedLength = $(this).parents(".permission-list").find("dd input:checked").length;
  154. if(length >0 && length==checkedLength){
  155. $(this).prop("checked", true);
  156. }
  157. });
  158. //添加页面根据父页面数据回显
  159. if($('input[name="directPush"]').val()=="false" && $('input[name="firstAdd"]').val()=="true" ){
  160. loadSelectedItems();
  161. }
  162. //
  163. getStreet_ids();
  164. getBuild_ids();
  165. getCompany_ids();
  166. });
  167. /**
  168. * 取消
  169. */
  170. function removeIframe() {
  171. var index = parent.layer.getFrameIndex(window.name);
  172. parent.layer.close(index);
  173. }
  174. function getBuilds() {
  175. var chlength = $('.pushStreetsList').find('input[type="checkbox"]:checked').length;
  176. var street_ids = '';
  177. $('.pushStreetsList').find('input[type="checkbox"]:checked').each(function (i, item) {
  178. street_ids = street_ids + $(this).attr("value") + ",";
  179. });
  180. street_ids = street_ids.substring(0, street_ids.length - 1);
  181. if (street_ids.length > 0) {
  182. $.ajax({
  183. url: pagePath + "/government/notify/getBuildsByStreetIds",
  184. type: "post",
  185. data: {
  186. 'street_ids': street_ids,
  187. 'notify_id' : $("#notify_id").val()
  188. },
  189. dataType: "json",
  190. success: function (result) {
  191. if (result.success) {
  192. //smileMessage(result.message)
  193. var buildList = result.obj;
  194. bindBuild(buildList);
  195. getCompanys();
  196. } else {
  197. errorMessage(result.message);
  198. }
  199. },
  200. error: function () {
  201. errorMessage('系统错误!');
  202. }
  203. });
  204. } else {
  205. $(".pushBuildsList").empty();
  206. $("#companyTb").find("tbody tr").remove();
  207. $("#paging").hide();
  208. }
  209. }
  210. function bindBuild(buildList) {
  211. $(".pushBuildsList").empty();
  212. for (var i = 0; i < buildList.length; i++) {
  213. var label = '<label class="">';
  214. label += '<input type="checkbox" value="' + buildList[i].id + '" buildName="' + buildList[i].name + '" id="' + buildList[i].id + '" onchange="getBuild_ids();getCompanys();">';
  215. label += buildList[i].name;
  216. //label += '<span class="c-red" th:if="*{isPush}">已推送</span>';
  217. label += '</label>';
  218. if(buildList[i].isPush){
  219. label +='<span class="c-red" >已推送</span>';
  220. }
  221. $(".pushBuildsList").append(label);
  222. }
  223. getBuild_ids();
  224. }
  225. function getCompanys(){
  226. $("#form-notify-addPush").submit();
  227. }
  228. </script>
  229. </body>
  230. </html>