exportSelected.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 search-collapse">
  10. <form id="export-form">
  11. <div class="select-list">
  12. <ul>
  13. <li>
  14. 用户姓名:<input type="text" name="userName" value=""/>
  15. </li>
  16. <li>
  17. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  18. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  19. </li>
  20. </ul>
  21. </div>
  22. </form>
  23. </div>
  24. <div class="btn-group-sm" id="toolbar" role="group">
  25. <i class="fa fa-info-circle" style="color: red;"></i> 勾选数据导出指定列,否则为全部
  26. <a class="btn btn-warning" onclick="exportSelected()">
  27. <i class="fa fa-download"></i> 导出
  28. </a>
  29. </div>
  30. <div class="col-sm-12 select-table table-striped">
  31. <table id="bootstrap-table"></table>
  32. </div>
  33. </div>
  34. </div>
  35. <div th:include="include :: footer"></div>
  36. <script th:inline="javascript">
  37. var prefix = ctx + "demo/table";
  38. var datas = [[${@dict.getType('sys_normal_disable')}]];
  39. $(function() {
  40. var options = {
  41. url: prefix + "/list",
  42. showSearch: false,
  43. showRefresh: false,
  44. showToggle: false,
  45. showColumns: false,
  46. clickToSelect: true,
  47. rememberSelected: true,
  48. columns: [{
  49. field: 'state',
  50. checkbox: true
  51. },
  52. {
  53. field : 'userId',
  54. title : '用户ID'
  55. },
  56. {
  57. field : 'userCode',
  58. title : '用户编号'
  59. },
  60. {
  61. field : 'userName',
  62. title : '用户姓名'
  63. },
  64. {
  65. field : 'userPhone',
  66. title : '用户手机'
  67. },
  68. {
  69. field : 'userEmail',
  70. title : '用户邮箱'
  71. },
  72. {
  73. field : 'userBalance',
  74. title : '用户余额'
  75. },
  76. {
  77. field: 'status',
  78. title: '用户状态',
  79. align: 'center',
  80. formatter: function(value, row, index) {
  81. return $.table.selectDictLabel(datas, value);
  82. }
  83. },
  84. {
  85. title: '操作',
  86. align: 'center',
  87. formatter: function(value, row, index) {
  88. var actions = [];
  89. actions.push('<a class="btn btn-success btn-xs" href="#"><i class="fa fa-edit"></i>编辑</a> ');
  90. actions.push('<a class="btn btn-danger btn-xs" href="#"><i class="fa fa-remove"></i>删除</a>');
  91. return actions.join('');
  92. }
  93. }]
  94. };
  95. $.table.init(options);
  96. });
  97. // 导出数据
  98. function exportSelected() {
  99. var userIds = $.table.selectColumns("userId");
  100. var dataParam = $("#export-form").serializeArray();
  101. var tipMsg = "确定导出所有数据吗?";
  102. if($.common.isNotEmpty(userIds)){
  103. tipMsg = "确定导出勾选" + userIds.length + "条数据吗?";
  104. dataParam.push({ "name": "userIds", "value": userIds });
  105. }
  106. $.modal.confirm(tipMsg, function() {
  107. $.post(prefix + "/exportData", dataParam, function(result) {
  108. if (result.code == web_status.SUCCESS) {
  109. window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
  110. } else {
  111. $.modal.alertError(result.msg);
  112. }
  113. });
  114. });
  115. }
  116. </script>
  117. </body>
  118. </html>