暫無描述

repairWorkloadStatistics.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. $(document).ready(function() {
  2. //时间
  3. laydate.render({
  4. elem: '#startTime',
  5. range: '~',
  6. theme: '#249fea'
  7. });
  8. //显示时间
  9. if ($('#startTime').val() == "") {
  10. function p(s) {
  11. return s < 10 ? '0' + s : s;
  12. }
  13. var currentYear = new Date().getFullYear();
  14. var currentMonth = new Date().getMonth() + 1;
  15. var currentDate = new Date().getDate();
  16. var prevCurrentYear = 0;
  17. var prevCurrentMonth = 0;
  18. if (currentMonth == 1) {
  19. prevCurrentYear = currentYear - 1;
  20. prevCurrentMonth = 12;
  21. } else {
  22. prevCurrentYear = currentYear;
  23. prevCurrentMonth = currentMonth - 1;
  24. }
  25. var current = currentYear + "-" + p(currentMonth) + "-" + p(currentDate);
  26. // var lastmonth = prevCurrentYear + "-" + p(prevCurrentMonth) + "-" + p(currentDate)
  27. var a = getPreDatetime(3600 * 1000 * 24 * 30);
  28. $('#startTime').val(getPreDatetime(3600 * 1000 * 24 * 30) + " ~ " + current)
  29. initTable()
  30. }
  31. //获取所有科室信息
  32. $.getJSON(huayi.config.callcenter_url + 'equipmentapi/api/WoRepairBase/getallbzcount', {
  33. deptname: $("#deptname").val()
  34. }, function(res) {
  35. if (res.state == "success") {
  36. QdepartmentList = res.data;
  37. getdepartment($("#deptname"));
  38. $('#deptname').selectpicker('refresh');
  39. }
  40. })
  41. //获取维修人员编号
  42. $.getJSON(huayi.config.callcenter_url + 'signtokenapi/api/useraccount/getprojectuser', {
  43. usercode: $("#usercode").val()
  44. }, function(res) {
  45. if (res.state == "success") {
  46. usercodeList = res.data;
  47. getUsercode($("#usercode"));
  48. $('#usercode').selectpicker('refresh');
  49. }
  50. })
  51. //搜索
  52. $("#sc_btns").click(function() {
  53. initTable();
  54. })
  55. //导出
  56. $('#HY_export').click(function() {
  57. var deptname=$("#Qdepartment").val();
  58. var stime=$('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  59. var etime=$('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  60. if(deptname==undefined){
  61. deptname='';
  62. }
  63. if(stime==undefined){
  64. stime='';
  65. }
  66. if(etime==undefined){
  67. etime='';
  68. }
  69. console.log(huayi.config.callcenter_url + "/equipmentapi/api/WoRepairBase/excelwxrygzllist?deptnames=" + deptname+
  70. "&stime=" + stime+"&etime="+etime)
  71. window.location.href=huayi.config.callcenter_url + "/equipmentapi/api/WoRepairBase/excelwxrygzllist?deptnames=" + deptname+
  72. "&stime=" + stime+"&etime="+etime;
  73. })
  74. })
  75. //初始化表格
  76. function initTable() {
  77. var $tableLeft = $('#tables');
  78. $tableLeft.bootstrapTable('destroy');
  79. //初始化表格,动态从服务器加载数据
  80. $tableLeft.bootstrapTable({
  81. method: "get", //使用get请求到服务器获取数据
  82. url: huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/gettjlistbytouser",
  83. striped: true, //表格显示条纹
  84. pagination: false, //启动分页
  85. pageSize: 10, //每页显示的记录数
  86. pageNumber: 1, //当前第几页
  87. fixedColumns: true,
  88. fixedNumber: 3,
  89. pageList: [5, 10, 20, 50, 100], //记录数可选列表
  90. search: false, //是否启用查询
  91. showColumns: false, //显示下拉框勾选要显示的列
  92. showRefresh: false, //显示刷新按钮
  93. sidePagination: "server", //表示服务端请求
  94. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  95. //设置为limit可以获取limit, offset, search, sort, order
  96. queryParamsType: "undefined",
  97. queryParams: function queryParams(params) { //设置查询参数
  98. console.log(params)
  99. var param = {
  100. // PageIndex: params.pageNumber,
  101. // PageSize: params.pageSize,
  102. // usercode: 8000, //维修工账号
  103. deptname: $("#deptname").val(),
  104. usercode:$('#usercode').val(),
  105. stime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[0], //开始时间
  106. etime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[1], //结束时间
  107. // ckorrk: f_State
  108. };
  109. return param;
  110. },
  111. onLoadSuccess: function(data) { //加载成功时执行
  112. var newDataL = {};
  113. newDataL.state = data.state;
  114. newDataL.message = data.message;
  115. newDataL.rows = data.data;
  116. $tableLeft.bootstrapTable('load', newDataL);
  117. $('.tool_downs').authorizeOperateButton();
  118. },
  119. onLoadError: function() { //加载失败时执行
  120. layer.msg("加载数据失败", {
  121. time: 1500,
  122. icon: 2
  123. });
  124. }
  125. });
  126. }
  127. //获取科室名
  128. function getdepartment(obj) {
  129. obj.empty();
  130. obj.append('<option value="">请选择班组名称</option>');
  131. $(QdepartmentList).each(function(i, n) {
  132. obj.append('<option value="' + n.role_name + '">' + n.role_name + '</option>');
  133. })
  134. }
  135. //获取科室名
  136. function getUsercode(obj) {
  137. obj.empty();
  138. obj.append('<option value="">请选择维修人员编号</option>');
  139. $(usercodeList).each(function(i, n) {
  140. obj.append('<option value="' + n.usercode + '">' + n.username + '</option>');
  141. })
  142. }
  143. //显示时间
  144. function getPreDatetime(pdate) {
  145. var start = new Date()
  146. start.setTime(start.getTime() - pdate)
  147. start.getYear(); // 获取当前年份(2位)
  148. var YY = start.getFullYear() // 获取完整的年份(4位,1970-????)
  149. var MM = start.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
  150. MM = MM > 9 ? MM : ('0' + MM);
  151. var DD = start.getDate() // 获取当前日(1-31)
  152. DD = DD > 9 ? DD : ('0' + DD)
  153. var lastmonth = YY + '-' + MM + '-' + DD;
  154. return lastmonth;
  155. }