No Description

repairWorkloadStatistics.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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=$("#deptname").val();
  58. var usercode=$("#usercode").val();
  59. var stime=$('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  60. var etime=$('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  61. if(deptname==undefined){
  62. deptname='';
  63. }
  64. if(usercode==undefined){
  65. usercode='';
  66. }
  67. if(stime==undefined){
  68. stime='';
  69. }
  70. if(etime==undefined){
  71. etime='';
  72. }
  73. console.log(huayi.config.callcenter_url + "/equipmentapi/api/WoRepairBase/excelwxrygzllist?deptname=" + deptname+
  74. "&usercode=" + usercode+"&stime=" + stime+"&etime="+etime)
  75. window.location.href=huayi.config.callcenter_url + "/equipmentapi/api/WoRepairBase/excelwxrygzllist?deptname=" + deptname+
  76. "&usercode=" + usercode+"&stime=" + stime+"&etime="+etime;
  77. })
  78. })
  79. //初始化表格
  80. function initTable() {
  81. var $tableLeft = $('#tables');
  82. $tableLeft.bootstrapTable('destroy');
  83. //初始化表格,动态从服务器加载数据
  84. $tableLeft.bootstrapTable({
  85. method: "get", //使用get请求到服务器获取数据
  86. url: huayi.config.callcenter_url + "equipmentapi/api/WoRepairBase/gettjlistbytouser",
  87. striped: true, //表格显示条纹
  88. pagination: false, //启动分页
  89. pageSize: 10, //每页显示的记录数
  90. pageNumber: 1, //当前第几页
  91. fixedColumns: true,
  92. fixedNumber: 3,
  93. pageList: [5, 10, 20, 50, 100], //记录数可选列表
  94. search: false, //是否启用查询
  95. showColumns: false, //显示下拉框勾选要显示的列
  96. showRefresh: false, //显示刷新按钮
  97. sidePagination: "server", //表示服务端请求
  98. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  99. //设置为limit可以获取limit, offset, search, sort, order
  100. queryParamsType: "undefined",
  101. queryParams: function queryParams(params) { //设置查询参数
  102. console.log(params)
  103. var param = {
  104. // PageIndex: params.pageNumber,
  105. // PageSize: params.pageSize,
  106. // usercode: 8000, //维修工账号
  107. deptname: $("#deptname").val(),
  108. usercode:$('#usercode').val(),
  109. stime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[0], //开始时间
  110. etime: $('#startTime').val() && $('#startTime').val().split(' ~ ')[1], //结束时间
  111. // ckorrk: f_State
  112. };
  113. return param;
  114. },
  115. onLoadSuccess: function(data) { //加载成功时执行
  116. var newDataL = {};
  117. newDataL.state = data.state;
  118. newDataL.message = data.message;
  119. newDataL.rows = data.data;
  120. $tableLeft.bootstrapTable('load', newDataL);
  121. $('.tool_downs').authorizeOperateButton();
  122. },
  123. onLoadError: function() { //加载失败时执行
  124. layer.msg("加载数据失败", {
  125. time: 1500,
  126. icon: 2
  127. });
  128. }
  129. });
  130. }
  131. //获取科室名
  132. function getdepartment(obj) {
  133. obj.empty();
  134. obj.append('<option value="">请选择班组名称</option>');
  135. $(QdepartmentList).each(function(i, n) {
  136. obj.append('<option value="' + n.role_name + '">' + n.role_name + '</option>');
  137. })
  138. }
  139. //获取科室名
  140. function getUsercode(obj) {
  141. obj.empty();
  142. obj.append('<option value="">请选择维修人员编号</option>');
  143. $(usercodeList).each(function(i, n) {
  144. obj.append('<option value="' + n.usercode + '">' + n.username + '</option>');
  145. })
  146. }
  147. //显示时间
  148. function getPreDatetime(pdate) {
  149. var start = new Date()
  150. start.setTime(start.getTime() - pdate)
  151. start.getYear(); // 获取当前年份(2位)
  152. var YY = start.getFullYear() // 获取完整的年份(4位,1970-????)
  153. var MM = start.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
  154. MM = MM > 9 ? MM : ('0' + MM);
  155. var DD = start.getDate() // 获取当前日(1-31)
  156. DD = DD > 9 ? DD : ('0' + DD)
  157. var lastmonth = YY + '-' + MM + '-' + DD;
  158. return lastmonth;
  159. }