customView.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('自定义视图分页')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="container-div">
  8. <div class="row">
  9. <div class="col-sm-12 select-table table-striped">
  10. <table id="bootstrap-table" data-page-size="10"
  11. data-show-custom-view="true" data-custom-view="customViewFormatter"
  12. data-show-custom-view-button="true">
  13. </table>
  14. </div>
  15. </div>
  16. </div>
  17. <template id="profileTemplate">
  18. <div class="col-sm-4">
  19. <div class="contact-box">
  20. <a href="profile.html">
  21. <div class="col-sm-4">
  22. <div class="text-center">
  23. <img alt="image" class="img-circle m-t-xs img-responsive" src="%IMAGE%">
  24. <div class="m-t-xs font-bold">%userName%</div>
  25. </div>
  26. </div>
  27. <div class="col-sm-8">
  28. <h3><strong>%userCode%</strong></h3>
  29. <p><i class="fa fa-jpy"></i> %userBalance%</p>
  30. <address>
  31. <strong>RuoYi, Inc.</strong><br>
  32. E-mail: %userEmail%<br>
  33. <abbr title="Phone">Tel:</abbr> %userPhone%
  34. </address>
  35. </div>
  36. <div class="clearfix"></div>
  37. </a>
  38. </div>
  39. </div>
  40. </template>
  41. <div th:include="include :: footer"></div>
  42. <th:block th:include="include :: bootstrap-table-custom-view-js" />
  43. <script th:inline="javascript">
  44. var prefix = ctx + "demo/table";
  45. var datas = [[${@dict.getType('sys_normal_disable')}]];
  46. $(function() {
  47. var options = {
  48. url: prefix + "/list",
  49. showSearch: false,
  50. showRefresh: false,
  51. showToggle: false,
  52. showColumns: false,
  53. showExport: true,
  54. columns: [{
  55. checkbox: true
  56. },
  57. {
  58. field : 'userId',
  59. title : '用户ID'
  60. },
  61. {
  62. field : 'userCode',
  63. title : '用户编号'
  64. },
  65. {
  66. field : 'userName',
  67. title : '用户姓名'
  68. },
  69. {
  70. field : 'userPhone',
  71. title : '用户手机'
  72. },
  73. {
  74. field : 'userEmail',
  75. title : '用户邮箱'
  76. },
  77. {
  78. field : 'userBalance',
  79. title : '用户余额'
  80. },
  81. {
  82. field: 'status',
  83. title: '用户状态',
  84. align: 'center',
  85. formatter: function(value, row, index) {
  86. return $.table.selectDictLabel(datas, value);
  87. }
  88. },
  89. {
  90. title: '操作',
  91. align: 'center',
  92. formatter: function(value, row, index) {
  93. var actions = [];
  94. actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
  95. actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
  96. return actions.join('');
  97. }
  98. }]
  99. };
  100. $.table.init(options);
  101. });
  102. function customViewFormatter (data) {
  103. var template = $('#profileTemplate').html()
  104. var view = ''
  105. $.each(data, function (i, row) {
  106. view += template.replace('%userCode%', row.userCode)
  107. .replace('%IMAGE%', "http://demo.ruoyi.vip/img/profile.jpg")
  108. .replace('%userName%', row.userName)
  109. .replace('%userEmail%', row.userEmail)
  110. .replace('%userPhone%', row.userPhone)
  111. .replace('%userBalance%', row.userBalance);
  112. })
  113. return `<div class="row mx-0">${view}</div>`
  114. }
  115. </script>
  116. </body>
  117. </html>