Нет описания

inspectionMatters.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * 检查事项
  3. * */
  4. $(function() {
  5. $('.tool_bars').authorizeButton();
  6. //项目下拉
  7. helper.getDropList.getProlistDrop($('#sc_pro'));
  8. initTable();
  9. //搜索
  10. $("#sc_btns").click(function() {
  11. initTable();
  12. })
  13. });
  14. function initTable() {
  15. //先销毁表格
  16. $('#table_all').bootstrapTable('destroy');
  17. //初始化表格,动态从服务器加载数据
  18. $('#table_all').bootstrapTable({
  19. method: "get", //使用get请求到服务器获取数据
  20. url: huayi.config.callcenter_url + "equipmentapi/api/MattersMgr/getlistbypage", //获取数据的Servlet地址
  21. contentType: "application/x-www-form-urlencoded",
  22. striped: true, //表格显示条纹
  23. pagination: true, //启动分页
  24. pageSize: 10, //每页显示的记录数
  25. pageNumber: 1, //当前第几页
  26. pageList: [10, 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, //否 int 页码
  37. pagesize: params.pageSize, //否 int 条数
  38. keyword: $('#sc_keyWords').val(), //计划名称
  39. projectid: $('#sc_pro').val(),// 否 string 项目id
  40. type: $('#sc_type').val()// 否 int 检查类型 2保养,3巡检
  41. };
  42. return param;
  43. },
  44. responseHandler: function(res) {
  45. //格式化数据
  46. return {
  47. "total": res.data && res.data.total, //总页数
  48. "rows": res.data && res.data.rows,
  49. }
  50. },
  51. onLoadSuccess: function(res) { //加载成功时执行
  52. //layer.msg("加载成功");
  53. $('.table_con').popover()
  54. $('.tool_down').authorizeOperateButton();
  55. },
  56. onLoadError: function() { //加载失败时执行
  57. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  58. }
  59. });
  60. }
  61. //详情
  62. function btn_details(edit_id) {
  63. layer.open({
  64. type: 2,
  65. content: "template/seeMattersDetails.html?edit_id=" + edit_id, //iframe的url,no代表不显示滚动条
  66. title: '查看检查事项',
  67. resize: false,
  68. area: ['80%', '90%'], //宽高
  69. });
  70. }
  71. //添加
  72. function btn_add() {
  73. layer.open({
  74. type: 2,
  75. content: "template/addOrEditMatters.html", //iframe的url,no代表不显示滚动条
  76. title: '添加检查事项',
  77. resize: false,
  78. area: ['80%', '90%'], //宽高
  79. });
  80. }
  81. //编辑
  82. function btn_edit(edit_id) {
  83. layer.open({
  84. type: 2,
  85. content: "template/addOrEditMatters.html?edit_id=" + edit_id, //iframe的url,no代表不显示滚动条
  86. title: '编辑检查事项',
  87. resize: false,
  88. area: ['80%', '90%'], //宽高
  89. });
  90. }
  91. //批量删除
  92. function btn_deletes() {
  93. var ids = $.map($('#table_all').bootstrapTable('getSelections'),
  94. function(row) {
  95. return row.id;
  96. });
  97. /*判断长度*/
  98. if(ids.length <= 0) {
  99. layer.confirm('请选择要删除的选项', {
  100. icon: 7,
  101. btn: ['确定'] //按钮
  102. });
  103. return;
  104. }
  105. btn_delete(ids);
  106. }
  107. //删除
  108. function btn_delete(del_id) {
  109. layer.confirm('您确定要删除当前检查事项吗?', {
  110. icon: 7,
  111. btn: ['确定', '取消'],
  112. yes: function(index, layero) {
  113. $.post(huayi.config.callcenter_url + "equipmentapi/api/MattersMgr/delete", {
  114. ids: del_id,
  115. }, function(result) {
  116. result = JSON.parse(result);
  117. if(result.state.toLowerCase() == "success") {
  118. layer.msg("删除成功");
  119. $('#table_all').bootstrapTable('refresh');
  120. }
  121. })
  122. },
  123. });
  124. }
  125. //格式化操作
  126. function formatterOperate(val, row) {
  127. var str = '';
  128. str = '<div class="task_tools" onclick = helper.methods.taskTools(this)>' +
  129. '<a title="操作"><i class="fa fa-cogs" aria-hidden="true"></i></a>' +
  130. '<ul class="tool_down">' +
  131. '<li><a class="aBtn" authorize="yes" id="HY_details_' + row.id + '" onclick="btn_details(\'' + row.id + '\')"><i class="fa icon-detail tub"></i>详情</a><li>' +
  132. '<li><a class="aBtn" authorize="yes" id="HY_edit_' + row.id + '" onclick="btn_edit(\'' + row.id + '\')"><i class="fa icon-edit tub"></i>编辑</a><li>' +
  133. '<li><a class="aBtn" authorize="yes" id="HY_delete_' + row.id + '" onclick="btn_delete(\'' + row.id + '\')"><i class="fa icon-delete tub"></i>删除</a><li>' +
  134. '</ul></div>'
  135. return str;
  136. }
  137. //格式化检查类型
  138. function formatterChecktype(val, row) {
  139. //计划状态 2保养,3巡检
  140. var stateClass, stateName;
  141. switch(val) {
  142. case 3:
  143. stateClass = 'state_audit_done';
  144. stateName = '巡检';
  145. break;
  146. case 2:
  147. stateClass = 'state_audit_doned';
  148. stateName = '保养';
  149. break;
  150. default:
  151. stateClass = 'text-block';
  152. stateName = '-';
  153. break;
  154. }
  155. return '<a class="state_audit ' + stateClass + '" href="javascript:;">' + stateName + '</a>';
  156. }
  157. //格式化内容
  158. function formatterCountent(val, row){
  159. if(val && val.length === 0){
  160. return '-'
  161. }
  162. if(val && val.length > 5){
  163. return '<span class="table_con" data-container="body" data-toggle="popover" data-placement="top" data-content="'+ val +'">'+ val.splice(0,5) +'...</span>';
  164. }else{
  165. return '<span style="color: #249fea">'+ val +'</span>';
  166. }
  167. }
  168. //格式化创建人
  169. function formatterUser(val, row) {
  170. return val + '-' + row.createusername;
  171. }