park-list.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>列表页面</title>
  5. <!--#include file="common/_header.html"-->
  6. <style>
  7. .table .center{
  8. text-align:center;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <nav class="breadcrumb">
  14. <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 列表
  15. <a class="btn btn-success radius r"
  16. style="line-height: 1.6em; margin-top: 3px"
  17. href="javascript:location.replace(location.href);" title="刷新">
  18. <i class="Hui-iconfont">&#xe68f;</i></a>
  19. </nav>
  20. <div class="page-container">
  21. <div class="container mb-10">
  22. <form>
  23. <div class="row mb-10">
  24. <input type="text" class="input-text" style="width: 250px" placeholder="输入园区名称" id="selTitle">
  25. <select class="select" style="width:250px" id="selAdminName" name="selAdminName"></select>
  26. <!-- <input type="text" class="input-text" style="width: 250px" placeholder="输入包联领导" id="selAdminName"> -->
  27. <button type="submit" class="btn btn-success" id="btnSearch">
  28. <i class="Hui-iconfont">&#xe665;</i> 查询
  29. </button>
  30. <button type="reset" class="btn btn-success" id="btnReset">
  31. <i class="Hui-iconfont">&#xe665;</i> 重置
  32. </button>
  33. </div>
  34. </form>
  35. </div>
  36. <div class="cl pd-5 bg-1 bk-gray">
  37. <span class="l">
  38. <a href="javascript:batch_del();" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>批量删除</a>
  39. <a href="javascript:item_add();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>添加</a>
  40. </span>
  41. </div>
  42. <div class="mt-20">
  43. <table id="grid1" class="table table-border table-bordered table-bg">
  44. <thead>
  45. <tr class="text-c">
  46. <th width="25"><input id="checkAll" type="checkbox" value=""></th>
  47. <th width="100">园区名称</th>
  48. <th width="100">园区办公室</th>
  49. <th width="100">顺序编号</th>
  50. <th width="100">创建人</th>
  51. <th width="100">创建时间</th>
  52. <th width="100">更新人</th>
  53. <th width="100">更新时间</th>
  54. <th width="100">操作</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. </tbody>
  59. </table>
  60. </div>
  61. </div>
  62. <!--_footer 作为公共模版分离出去-->
  63. <!--#include file="common/_footer.html"-->
  64. <!--/_footer 作为公共模版分离出去-->
  65. <!--请在下方写此页面业务相关的脚本-->
  66. <script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
  67. <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
  68. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  69. <script id="rowTmpl" type="text/template">
  70. <a href="javascript:item_edit('{{id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
  71. <a href="javascript:item_del('{{id}}','{{name}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
  72. </script>
  73. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  74. <script type="text/javascript" src="scripts/global.js"></script>
  75. <!-- select2 start-->
  76. <link rel="stylesheet" type="text/css" href="lib/select2/select2.min.css" />
  77. <script src="lib/select2/select2.full.js" type="text/javascript"></script>
  78. <script src="lib/select2/select2.zh-CN.js" type="text/javascript"></script>
  79. <!-- select2 end -->
  80. <script type="text/javascript">
  81. var path = global_backend_url;
  82. $(document).ready(function(){
  83. $('#grid1').dataTable({
  84. ajax: {
  85. url: path + "/park/list",
  86. type: 'post',
  87. dataFilter: function(responseText){
  88. var jsonData = JSON.parse(responseText);
  89. // 处理返回json
  90. if(jsonData.result){
  91. return JSON.stringify(jsonData.data);
  92. }
  93. else{
  94. processError(jsonData);
  95. return null;
  96. }
  97. },
  98. data: function(searchParams){
  99. // 查询json
  100. searchParams["selTitle"] = $("#selTitle").val();
  101. searchParams["selAdminName"] = $("#selAdminName").val();
  102. }
  103. },
  104. serverSide: true,
  105. searching : false,
  106. ordering: false,
  107. columns: [
  108. {data:'parkId'},
  109. {data:'title'},
  110. {"title":"园区办公室","render":function(data, type, row, meta){
  111. var json = row.parkAdminList;
  112. var result = "";
  113. $.each(json,function(index,obj){
  114. if(json != null){
  115. if(json.length-1 == index){
  116. result = result + obj.adminName;
  117. }
  118. else{
  119. result = result + obj.adminName+",";
  120. }
  121. }
  122. })
  123. return result;
  124. }},
  125. {data:'orderId'},
  126. {data:'createByAdmin.realName'},
  127. {data:'createDate'},
  128. {data:'updateByAdmin.realName'},
  129. {data:'updateDate'},
  130. {"data":null}
  131. ],
  132. columnDefs: [
  133. {
  134. targets:0,
  135. sClass:'center',
  136. bSortable:false,
  137. render: function (data, type, row) {
  138. return '<input type="checkbox" name="checkItems" value="'+ data + '">';
  139. }
  140. },{
  141. targets:8,
  142. sClass:'center',
  143. bSortable:false,
  144. render: function (data, type, row) {
  145. return template("rowTmpl",{
  146. id: row.parkId
  147. });
  148. }
  149. }
  150. ]
  151. });
  152. $("#checkAll").change(function(){
  153. var checked = $(this).is(':checked');
  154. $("input[name='checkItems']").each(function(){
  155. $(this).attr("checked",checked);
  156. });
  157. });
  158. $("#btnSearch").click(function(){
  159. event.preventDefault();
  160. var table = $('#grid1').DataTable();
  161. table.ajax.reload();
  162. });
  163. $("#btnReset").click(function(){
  164. $("#selAdminName").empty();
  165. });
  166. strTitle = "输入园区办公室";
  167. getSelect("selAdminName",null);
  168. });
  169. var strTitle = "";
  170. function getSelect(id,value){
  171. if(value != null){
  172. var Html = "<option value='"+value.id+"' selected>" + value.realName + "</option>";
  173. $('#' + id).append(Html);
  174. $('#' + id).select2();
  175. }
  176. $("#" + id).select2({
  177. language: "zh-CN",
  178. placeholder:strTitle,//文本框的提示信息
  179. minimumInputLength:0, //至少输入n个字符,才去加载数据
  180. allowClear: true, //是否允许用户清除文本信息
  181. ajax:{
  182. url:path + "/jpAdmin/selectUserForPark", //地址
  183. type: "POST",
  184. dataType:'json', //接收的数据类型
  185. delay:250,
  186. cache: true,
  187. processResults: function (data) {
  188. var results = data.map(function(item){
  189. return {
  190. id : item.userId,
  191. text : item.realName,
  192. userName: item.userName,
  193. orgName : item.orgName
  194. }
  195. });
  196. return {
  197. results: results
  198. }
  199. }
  200. },
  201. language: "zh-CN",
  202. templateResult: function (state) {
  203. var html = "<div>";
  204. html += "<strong>姓名:" + state.text + "</strong>(" + state.userName + ")<br/>";
  205. html += "单位:" + state.orgName;
  206. html += "</div>";
  207. return $(html);
  208. }
  209. });
  210. }
  211. function item_add(){
  212. layer_show("添加园区信息","park-detail.html",850,600);
  213. }
  214. function item_edit(id){
  215. layer_show("编辑园区信息","park-detail.html?id=" + id,850,600);
  216. }
  217. function item_del(id){
  218. layer.confirm("是否删除?",{
  219. btns:["是","否"]
  220. },function(){
  221. $.post(path + "/park/forgedDelete/" + id,null,function(json){
  222. if(json.result){
  223. layer.msg("删除成功!",{icon:1,time:2000});
  224. reloadList();
  225. }
  226. else{
  227. layer.msg("删除失败!" + json.message);
  228. }
  229. });
  230. });
  231. }
  232. function reloadList(){
  233. $('#grid1').DataTable().ajax.reload(null,false);
  234. }
  235. function batch_del(){
  236. layer.confirm("是否删除选中项?",{
  237. btns:["是","否"]
  238. },function(){
  239. var arr = $("input[name='checkItems']:checked").map(function(){
  240. return $(this).val();
  241. }).get();
  242. $.post(path + "/park/batchDelete",{
  243. ids:arr.join(",")
  244. },function(json){
  245. if(json.result){
  246. layer.msg("删除成功!",{icon:1,time:2000});
  247. reloadList();
  248. }
  249. else{
  250. layer.msg("删除失败!" + json.message);
  251. }
  252. });
  253. })
  254. }
  255. </script>
  256. </body>
  257. </html>