monthReport.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // 筛选弹框
  2. var layer = layui.layer;
  3. var layerCreateIndex = '';
  4. var layerCreateIndex2 = '';
  5. layui.use('layer', function () {
  6. layerCreateIndex = layer.open({
  7. type: 1,
  8. title: false,
  9. closeBtn: 0,
  10. // shadeClose: true,
  11. skin: 'yourclass',
  12. area: [
  13. '380px', '300px'
  14. ],
  15. content: $(".reportOut"),
  16. success: function () {
  17. $('.clsBtn,.cancel').click(function () {
  18. layer.close(layerCreateIndex);
  19. })
  20. }
  21. })
  22. })
  23. layui.use([
  24. 'form', 'layedit', 'laydate'
  25. ], function () {
  26. });
  27. //时间日期选择
  28. layui.use('laydate', function () {
  29. var laydate = layui.laydate;
  30. // 开始日期
  31. var insStart = laydate.render({
  32. elem: '#startTime',
  33. trigger: 'click',
  34. done: function (value, date) { // 更新结束日期的最小日期
  35. insEnd.config.min = lay.extend({}, date, {
  36. month: date.month - 1
  37. });
  38. // 自动弹出结束日期的选择器
  39. insEnd.config.elem[0].focus();
  40. }
  41. });
  42. // 结束日期
  43. var insEnd = laydate.render({
  44. elem: '#endTime',
  45. trigger: 'click',
  46. done: function (value, date) { // 更新开始日期的最大日期
  47. insStart.config.max = lay.extend({}, date, {
  48. month: date.month - 1
  49. });
  50. }
  51. });
  52. });
  53. getNameList()
  54. // 单位下拉 ajax请求
  55. function getNameList() {
  56. ajaxRequest(DEVICE_TYPE_COMPANYLIST, "POST", {}, function (result) {
  57. let data = result.RESULT;
  58. let items = '';
  59. data.forEach(function (item, key) {
  60. items += `<option value=''>请选择</option><option value="${
  61. item.owner_id
  62. }">${
  63. item.owner_name
  64. }</option>`
  65. })
  66. $('#getNameList').html(items);
  67. }, function (errorMsg) {
  68. alert("请求数据失败!");
  69. })
  70. }
  71. /* 筛选提交发送请求 */
  72. $('#nextStep').click(function() {
  73. //获取表单的值 并转换成对象
  74. let allParam = serializeArrayToObj($("#reportOutForm").serializeArray());
  75. //验证数据是否为空
  76. let res = validParamIsEmpty(allParam, {
  77. "startTime": "请选择开始日期",
  78. "endTime": "请选择结束日期",
  79. "companyId": "请选择建筑物",
  80. });
  81. if (res.code == -1) {
  82. alert(res.msg);
  83. return;
  84. }
  85. //验证通过 请求ajax
  86. ajaxRequest(MONTH_REPORT, "POST", allParam, function(result) {
  87. layer.close(layerCreateIndex);
  88. layer.msg('添加成功!', { icon: 6 });
  89. $('#reportOutForm')[0].reset();
  90. layui.use('layer', function () {
  91. layerCreateIndex2 = layer.open({
  92. type: 1,
  93. title: false,
  94. closeBtn: 0,
  95. skin: 'yourclass',
  96. area: [
  97. '700px', '800px'
  98. ],
  99. content: $(".reportContentOut"),
  100. success: function () {
  101. $('.clsBtn,.cancel').click(function () {
  102. window.open("./index.html");
  103. })
  104. }
  105. })
  106. })
  107. }, function(errorMsg) {
  108. alert("异常错误!");
  109. })
  110. })
  111. layui.use('layer', function () {
  112. layerCreateIndex2 = layer.open({
  113. type: 1,
  114. title: false,
  115. closeBtn: 0,
  116. skin: 'yourclass',
  117. area: [
  118. '700px', '800px'
  119. ],
  120. content: $(".reportContentOut"),
  121. success: function () {
  122. $('.clsBtn,.cancel').click(function () {
  123. layer.close(layerCreateIndex2);
  124. // window.open("./index.html");
  125. })
  126. }
  127. })
  128. })