person_list.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. var Person = {
  2. id: "table", //表格id
  3. seItem: null, //选中的条目
  4. table: null,
  5. layerIndex: -1
  6. };
  7. Person.initColumn = function(){
  8. return [
  9. {field: 'selectItem', radio: true},
  10. {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
  11. {title: '用户名/账号', field: 'username', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip'},
  12. {title: '姓名', field: 'name', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip'},
  13. {title: '性别', field: 'sex', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip',
  14. formatter: function (value, row, index){
  15. if (value==null || value==''){
  16. return "";
  17. } else if (value == 1){
  18. return "男";
  19. }else if(value == 2){
  20. return "女";
  21. } else {
  22. return "";
  23. }
  24. }
  25. },
  26. {title: '证件号码', field: 'idCard', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip'},
  27. {title: '电话号码', field: 'phone', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip'},
  28. {title: '联系地址', field: 'address', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip'},
  29. {title: '账号状态', field: 'active', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip',
  30. formatter: function (value, row, index){
  31. if (value==null || value==''){
  32. return "";
  33. } else if (value == 1){
  34. return "账号有效";
  35. }else if(value == 2){
  36. return "被冻结/拉黑";
  37. } else {
  38. return "";
  39. }
  40. },
  41. cellStyle: function(value, row, index) {
  42. if (value==null || value==''){
  43. return {css:{}};
  44. } else if (value == 1){
  45. return {css:{'background-color':'LightGreen'}};
  46. }else if(value == 2){
  47. return {css:{"background-color":"Orange"}};
  48. } else {
  49. return {css:{}};
  50. }
  51. }
  52. },
  53. {title: '注册时间', field: 'createTime', align: 'center', width:120, valign: 'middle', 'class': 'uitd_showTip'}
  54. ];
  55. };
  56. Person.search = function() {
  57. var queryData = {};
  58. queryData['username'] = $("#username").val();
  59. queryData['name'] = $("#name").val();
  60. queryData['sex'] = $("#sex").val();
  61. queryData['idCard'] = $("#idCard").val();
  62. queryData['phone'] = $("#phone").val();
  63. Person.table.refresh({"query": queryData});
  64. };
  65. Person.reset = function() {
  66. $("#username").val("");
  67. $("#name").val("");
  68. $("#sex").val("");
  69. $("#idCard").val("");
  70. $("#phone").val("");
  71. };
  72. Person.check = function () {
  73. var selected = $('#' + Person.id).bootstrapTable('getSelections');
  74. if(selected.length == 0){
  75. Feng.info("请先选中表格中的某一记录!");
  76. return false;
  77. }else{
  78. Person.seItem = selected[0];
  79. return true;
  80. }
  81. };
  82. Person.gotoPersonDetailPage = function() {
  83. if (!Person.check()) {
  84. return;
  85. }
  86. var index = layer.open({
  87. type: 2,
  88. title: '查看详情',
  89. area: ['830px', '450px'], //宽高
  90. fix: false, //不固定
  91. maxmin: true,
  92. content: Feng.ctxPath + '/person/gotoPersonDetailPage?id='+Person.seItem.id,
  93. btn: ['<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
  94. yes: function (index, layero) {
  95. layer.close(index);
  96. }
  97. });
  98. layer.full(index);
  99. Person.layerIndex = index;
  100. };
  101. Person.setActive = function() {
  102. if (!Person.check()) {
  103. return;
  104. }
  105. var index = layer.open({
  106. type: 2,
  107. title: '设置冻结',
  108. area: ['830px', '580px'], //宽高
  109. fix: false, //不固定
  110. maxmin: true,
  111. content: Feng.ctxPath + '/person/gotoActivePage?id='+Person.seItem.id,
  112. btn: ['<i class="fa fa-check"></i>&nbsp;&nbsp;确定', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;取消'],
  113. yes: function (index, layero) {
  114. //按钮【按钮一】的回调
  115. var iframeWin = window[layero.find('iframe')[0]['name']];
  116. iframeWin.PsActive.addSubmit();
  117. }
  118. });
  119. // layer.full(index);
  120. this.layerIndex = index;
  121. };
  122. Person.resetPassword = function() {
  123. if (!Person.check()) {
  124. return;
  125. }
  126. Feng.confirm(
  127. "确定要重置吗?",
  128. function(){
  129. var ajax = new $ax(Feng.ctxPath + "/person/resetPassword?id="+Person.seItem.id, function(data){
  130. Feng.info(data.msg);
  131. if(data.code == 200){
  132. Person.table.refresh();
  133. }
  134. },function(data){
  135. Feng.error("操作失败!");
  136. });
  137. ajax.set(null);
  138. ajax.start();
  139. }
  140. );
  141. };
  142. $(function () {
  143. var defaultColunms = Person.initColumn();
  144. var table = new BSTable(Person.id, "/person/findPersonByPage", defaultColunms);
  145. table.setPaginationType("server");
  146. Person.table = table.init();
  147. });