暫無描述

evaluateManage.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. $(document).ready(function() {
  2. $('.tool_bars').authorizeButton();
  3. laydate.render({
  4. elem: '#startTime',
  5. range: '~',
  6. theme: '#249fea'
  7. });
  8. $('#sc_btns').click(function() {
  9. initTable();
  10. })
  11. initTable();
  12. })
  13. function initTable() {
  14. var $tableLeft = $('#tables');
  15. $tableLeft.bootstrapTable('destroy');
  16. //初始化表格,动态从服务器加载数据
  17. $tableLeft.bootstrapTable({
  18. method: "get", //使用get请求到服务器获取数据
  19. url: huayi.config.callcenter_url + "equipmentapi/api/worepairevaluate/getlistsbypage",
  20. striped: true, //表格显示条纹
  21. pagination: true, //启动分页
  22. pageSize: 10, //每页显示的记录数
  23. pageNumber: 1, //当前第几页
  24. fixedColumns: true,
  25. fixedNumber: 3,
  26. pageList: [5, 20, 50, 100], //记录数可选列表
  27. search: false, //是否启用查询
  28. showColumns: false, //显示下拉框勾选要显示的列
  29. showRefresh: false, //显示刷新按钮
  30. sidePagination: "server", //表示服务端请求
  31. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  32. //设置为limit可以获取limit, offset, search, sort, order
  33. queryParamsType: "undefined",
  34. queryParams: function queryParams(params) { //设置查询参数
  35. var param = {
  36. pageindex: params.pageNumber,
  37. pagesize: params.pageSize,
  38. stime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[0],
  39. etime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[1]
  40. };
  41. return param;
  42. },
  43. onLoadSuccess: function (data) { //加载成功时执行
  44. var newDataL = {};
  45. newDataL.state = data.state;
  46. newDataL.message = data.message;
  47. newDataL.rows = data.data.rows;
  48. newDataL.total = data.data.total;
  49. $tableLeft.bootstrapTable('load', newDataL);
  50. $('.tool_downs').authorizeOperateButton();
  51. },
  52. onLoadError: function() { //加载失败时执行
  53. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  54. }
  55. });
  56. }
  57. //格式化操作
  58. function formatterOperate(val, row) {
  59. var str = '<ul class="tool_downs">' +
  60. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id + '\')">删除</a><li>' +
  61. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id + '\')">详情</a><li>' +
  62. '</ul>';
  63. return str
  64. }
  65. //评价内容
  66. function content(val, row) {
  67. if(val) {
  68. var codeContent = decodeURIComponent(val);
  69. var str = '<div '
  70. if(codeContent.length > 10) {
  71. codeContent = codeContent.substr(0, 10) + "...";
  72. str = str + ' title="' + codeContent + '" ';
  73. }
  74. return str + '>' + codeContent + '</div>';
  75. } else {
  76. return '-';
  77. }
  78. }
  79. function btn_deletes() {
  80. var ids = $.map($('#tables').bootstrapTable('getSelections'),
  81. function(row) {
  82. return row.id;
  83. });
  84. /*判断长度*/
  85. if(ids.length <= 0) {
  86. layer.confirm('没有可删除的选项?', {
  87. btn: ['确定'] //按钮
  88. });
  89. return;
  90. }
  91. btn_delete(ids);
  92. }
  93. function btn_delete(ids) {
  94. layer.confirm('确定删除当前记录?', {
  95. btn: ['是', '否'] //按钮
  96. }, function() {
  97. /*发送请求*/
  98. $.ajax({
  99. type: "post",
  100. url: huayi.config.callcenter_url + "equipmentapi/api/worepairevaluate/delete",
  101. async: true,
  102. dataType: 'json',
  103. data: {
  104. ids: ids
  105. },
  106. success: function(data) {
  107. if(data.state.toLowerCase() == 'success') {
  108. layer.msg("删除成功!");
  109. initTable();
  110. }
  111. }
  112. });
  113. });
  114. }
  115. function btn_details(ids) {
  116. layer.open({
  117. type: 2,
  118. content: "template/evaluateDetail.html?ids=" + ids, //iframe的url,no代表不显示滚动条
  119. title: '查看评价详情',
  120. area: ['80%', '60%'], //宽高
  121. });
  122. }