leaderInfoList.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. var pageSize = 6;
  4. var searchParam = $("#searchForm").serializeJSON();
  5. var flow ;
  6. $(document).ready(function() {
  7. /*$('#leaderInfoTable').bootstrapTable({
  8. //请求方法
  9. method: 'post',
  10. //类型json
  11. dataType: "json",
  12. contentType: "application/x-www-form-urlencoded",
  13. //显示检索按钮
  14. showSearch: true,
  15. //显示刷新按钮
  16. showRefresh: true,
  17. //显示切换手机试图按钮
  18. showToggle: true,
  19. //显示 内容列下拉框
  20. showColumns: true,
  21. //显示到处按钮
  22. showExport: true,
  23. //显示切换分页按钮
  24. showPaginationSwitch: true,
  25. //最低显示2行
  26. minimumCountColumns: 2,
  27. //是否显示行间隔色
  28. striped: true,
  29. //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  30. cache: false,
  31. //是否显示分页(*)
  32. pagination: true,
  33. //排序方式
  34. sortOrder: "asc",
  35. //初始化加载第一页,默认第一页
  36. pageNumber:1,
  37. //每页的记录行数(*)
  38. pageSize: 10,
  39. //可供选择的每页的行数(*)
  40. pageList: [10, 25, 50, 100],
  41. //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
  42. url: "${ctx}/leader/info/leaderInfo/data",
  43. //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
  44. //queryParamsType:'',
  45. ////查询参数,每次调用是会带上这个参数,可自定义
  46. queryParams : function(params) {
  47. var searchParam = $("#searchForm").serializeJSON();
  48. searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
  49. searchParam.pageSize = params.limit === undefined? -1 : params.limit;
  50. searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+ params.order;
  51. return searchParam;
  52. },
  53. //分页方式:client客户端分页,server服务端分页(*)
  54. sidePagination: "server",
  55. contextMenuTrigger:"right",//pc端 按右键弹出菜单
  56. contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
  57. contextMenu: '#context-menu',
  58. onContextMenuItem: function(row, $el){
  59. if($el.data("item") == "edit"){
  60. edit(row.id);
  61. }else if($el.data("item") == "view"){
  62. view(row.id);
  63. } else if($el.data("item") == "delete"){
  64. jp.confirm('确认要删除该党员信息记录吗?', function(){
  65. jp.loading();
  66. jp.get("${ctx}/leader/info/leaderInfo/delete?id="+row.id, function(data){
  67. if(data.success){
  68. $('#leaderInfoTable').bootstrapTable('refresh');
  69. jp.success(data.msg);
  70. }else{
  71. jp.error(data.msg);
  72. }
  73. })
  74. });
  75. }
  76. },
  77. onClickRow: function(row, $el){
  78. },
  79. onShowSearch: function () {
  80. $("#search-collapse").slideToggle();
  81. },
  82. columns: [{
  83. checkbox: true
  84. }
  85. ,{
  86. field: 'name',
  87. title: '姓名',
  88. sortable: true,
  89. sortName: 'name'
  90. ,formatter:function(value, row , index){
  91. value = jp.unescapeHTML(value);
  92. <c:choose>
  93. <c:when test="${fns:hasPermission('leader:info:leaderInfo:edit')}">
  94. return "<a href='javascript:edit(\""+row.id+"\")'>"+value+"</a>";
  95. </c:when>
  96. <c:when test="${fns:hasPermission('leader:info:leaderInfo:view')}">
  97. return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
  98. </c:when>
  99. <c:otherwise>
  100. return value;
  101. </c:otherwise>
  102. </c:choose>
  103. }
  104. }
  105. ,{
  106. field: 'sex',
  107. title: '性别',
  108. sortable: true,
  109. sortName: 'sex',
  110. formatter:function(value, row , index){
  111. return jp.getDictLabel(${fns:toJson(fns:getDictList('sex'))}, value, "-");
  112. }
  113. }
  114. ,{
  115. field: 'nation',
  116. title: '民族',
  117. sortable: true,
  118. sortName: 'nation',
  119. formatter:function(value, row , index){
  120. return jp.getDictLabel(${fns:toJson(fns:getDictList('nation'))}, value, "-");
  121. }
  122. }
  123. ,{
  124. field: 'degree',
  125. title: '学历',
  126. sortable: true,
  127. sortName: 'degree',
  128. formatter:function(value, row , index){
  129. return jp.getDictLabel(${fns:toJson(fns:getDictList('degree'))}, value, "-");
  130. }
  131. }
  132. ,{
  133. field: 'lead',
  134. title: '所在党支部',
  135. sortable: true,
  136. sortName: 'lead'
  137. }
  138. ,{
  139. field: 'phone',
  140. title: '联系电话(手机号)',
  141. sortable: true,
  142. sortName: 'phone'
  143. }
  144. ,{
  145. field: 'leaderStatus',
  146. title: '党籍状态',
  147. sortable: true,
  148. sortName: 'leaderStatus',
  149. formatter:function(value, row , index){
  150. return jp.getDictLabel(${fns:toJson(fns:getDictList(''))}, value, "-");
  151. }
  152. }
  153. ,{
  154. field: 'updateDate',
  155. title: '更新时间',
  156. sortable: true,
  157. sortName: 'updateDate'
  158. }
  159. ]
  160. });*/
  161. $("#export").click(function(){//导出Excel文件
  162. jp.downloadFile('${ctx}/leader/info/leaderInfo/export');
  163. });
  164. layui.use('flow', function(){
  165. flow = layui.flow;
  166. loadData();
  167. });
  168. $("#search").click("click", function() {// 绑定查询按扭
  169. $('#lay_local').html('');
  170. searchParam = $("#searchForm").serializeJSON();
  171. loadData();
  172. });
  173. $("#reset").click("click", function() {// 绑定查询按扭
  174. $("#searchForm input").val("");
  175. $("#searchForm select").val("");
  176. $("#searchForm .select-item").html("");
  177. $("#search").click();
  178. });
  179. });
  180. function loadData() {
  181. flow.load({
  182. elem: '#lay_local' //流加载容器
  183. ,scrollElem: '#lay_local' //滚动条所在元素,一般不用填,此处只是演示需要。
  184. ,done: function(page, next){ //执行下一页的回调
  185. var photo = "${ctxStatic}/common/images/default.jpg";
  186. var lis = [];
  187. $.post("${ctx}/leader/info/leaderInfo/data",
  188. {
  189. 'pageNo':page,
  190. 'pageSize':pageSize,
  191. 'name':searchParam.name,
  192. 'sex':searchParam.sex,
  193. 'lead':searchParam.lead,
  194. 'nation':searchParam.nation
  195. },function(res){
  196. //假设你的列表返回在data集合中
  197. layui.each(res.rows, function(index, item){
  198. //console.log();
  199. if(item.photo!=undefined && item.photo !=''){
  200. photo = item.photo;
  201. }else{
  202. if(item.sex == '1'){
  203. photo = "${ctxStatic}/common/images/default.jpg";
  204. }else{
  205. photo = "${ctxStatic}/common/images/default.jpg";
  206. }
  207. }
  208. var html = '<li><table class="table" width="100%" >'+
  209. '<tr>'+
  210. '<td width="18%" rowspan="3" align="center" valign="center"><img name="img" src="'+photo+'" height="180" width="152" /></td>'+
  211. '<td width="68%" align="left" style="vertical-align:middle;" colspan="2"><font size="4"><b>'+ item.name +'</b></font>' +
  212. '&nbsp;&nbsp;&nbsp;'+jp.getDictLabel(${fns:toJson(fns:getDictList('sex'))}, item.sex, "-")+
  213. '&nbsp;&nbsp;&nbsp;'+jp.getDictLabel(${fns:toJson(fns:getDictList('nation'))}, item.nation, "-")+' </td>'+
  214. '</tr>'+
  215. '<tr>'+
  216. '<td align="left" style="vertical-align:middle;">出生年月:'+ item.birth +'</td>'+
  217. '<td>&nbsp;</td>'+
  218. '</tr>'+
  219. '<tr>'+
  220. '<td align="left" style="vertical-align:middle;" >所在党组织:'+ item.allName +'</td>'+
  221. '<td>&nbsp;</td>'+
  222. '</tr>'+
  223. '<tr>'+
  224. '<td colspan="2" align="right" style="vertical-align:bottom;">';
  225. <c:if test="${fns:hasPermission('leader:info:leaderInfo:edit')}">
  226. html += '<a href="javascript:edit(\''+ item.id +'\')" style="margin:4px; line-height:24px;">' +
  227. '<img src="${ctxStatic}/common/images/xg.png" width="16" height="16" />修改</a>';
  228. </c:if>
  229. <c:if test="${fns:hasPermission('leader:info:leaderInfo:del')}">
  230. html += '<a href="javascript:del(\''+ item.id +'\')" style="margin:4px;line-height:24px;">' +
  231. '<img src="${ctxStatic}/common/images/delete.png" width="16" height="16" />删除</a>';
  232. </c:if>
  233. html +='<a href="javascript:view(\''+ item.id +'\')" style="margin:4px;line-height:24px;">' +
  234. '<img src="${ctxStatic}/common/images/look.png" width="16" height="16" />查看</a>';
  235. html += '</td></tr></table></li>';
  236. lis.push(html);
  237. });
  238. //执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
  239. //pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
  240. next(lis.join(''), page < res.pagesize);
  241. });
  242. }
  243. });
  244. }
  245. function del(id){
  246. jp.confirm('确认要删除该党员信息记录吗?', function(){
  247. jp.loading();
  248. jp.get("${ctx}/leader/info/leaderInfo/deleteAll?ids=" + id, function(data){
  249. if(data.success){
  250. loadData();
  251. jp.success(data.msg);
  252. }else{
  253. jp.error(data.msg);
  254. }
  255. })
  256. })
  257. }
  258. function add(){
  259. jp.go("${ctx}/leader/info/leaderInfo/form/add");
  260. }
  261. function edit(id){
  262. jp.go("${ctx}/leader/info/leaderInfo/form/edit?id=" + id);
  263. }
  264. function view(id) {
  265. jp.go("${ctx}/leader/info/leaderInfo/form/view?oprType=view&id=" + id);
  266. }
  267. function onShowSearch() {
  268. $("#search-collapse").slideToggle();
  269. }
  270. </script>