getCapacityByDefend.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <!-- 抽查车牌号页面 -->
  3. <div class="homeworkPath">
  4. <div class="timerSelect">
  5. <el-date-picker
  6. v-model="startTime"
  7. type="datetime"
  8. placeholder="选择开始日期"
  9. >
  10. </el-date-picker>
  11. <span>至</span>
  12. <el-date-picker
  13. v-model="endTime"
  14. type="datetime"
  15. placeholder="选择结束日期"
  16. >
  17. </el-date-picker>
  18. <el-button type="primary" class="btn" @click="onclickSearch">
  19. <i class="el-icon-search"></i>查询
  20. </el-button>
  21. <el-button type="primary" @click="exportExcel"
  22. ><i class="el-icon-download"></i>导出(Excel)</el-button
  23. >
  24. <span style="margin-left: 1rem">合计车数:</span>
  25. <el-input
  26. v-model="totalCapacity"
  27. :disabled="true"
  28. style="width: 100px"
  29. ></el-input>
  30. <el-input
  31. placeholder="请输入车牌号/出厂门岗"
  32. v-model="input"
  33. style="width: 220px;margin-left: 1rem;"
  34. clearable
  35. >
  36. </el-input>
  37. <el-button type="primary" class="btn" @click="onclickSearch">
  38. <i class="el-icon-search"></i>查询
  39. </el-button>
  40. </div>
  41. <div class="table">
  42. <mergeRowTable
  43. ref="excelDom"
  44. v-bind.sync="option"
  45. @func="func"
  46. ></mergeRowTable>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import { sjTime } from "@/utils/sharedJsFile";
  52. import { getCookie } from "@/utils/util.js";
  53. import { exportExcelAdvanced } from "@/utils/exportExcelAdvanced.js";
  54. export default {
  55. data() {
  56. return {
  57. totalNumber: null,
  58. totalCapacity: null,
  59. startTime: null,
  60. endTime: null,
  61. input: null,
  62. tableTitle: "汽车抽查报表",
  63. option: {
  64. // 表格请求数据的地址
  65. requestUrl: "",
  66. comparison: "orderNumber",
  67. columnIndexs: [0, 1, 2, 7]
  68. },
  69. tableData: []
  70. };
  71. },
  72. created() {
  73. this.option.requestUrl =
  74. "/api/v1/tms/getCapacityByDefend?apiId=474&startTime=null&endTime=null&i=" +
  75. new Date();
  76. },
  77. methods: {
  78. exportExcel() {
  79. let startTime = null;
  80. let endTime = null;
  81. if (this.startTime && this.endTime) {
  82. startTime = sjTime(this.startTime);
  83. endTime = sjTime(this.endTime);
  84. } else {
  85. this.$message.info("没有选择时间,将默认导出当天时间");
  86. }
  87. const loading = this.$loading({
  88. lock: true,
  89. text: "请等待导出",
  90. spinner: "el-icon-loading",
  91. background: "rgba(0, 0, 0, 0.7)"
  92. });
  93. this.axios
  94. .post(
  95. "/api/v1/tms/getCapacityByDefend?apiId=474&yes=yes&startTime=" +
  96. startTime +
  97. "&endTime=" +
  98. endTime +
  99. "&con=" +
  100. this.input
  101. )
  102. .then(res => {
  103. this.tableData = res.data.data;
  104. console.log(res);
  105. console.log(this.tableData);
  106. exportExcelAdvanced(
  107. this.tableTitle,
  108. this.tableColumnData,
  109. this.tableData
  110. );
  111. setTimeout(() => {
  112. loading.close();
  113. }, 2000);
  114. });
  115. },
  116. func(res) {
  117. this.tableColumnData = res.columnData;
  118. var resultNetWeightTotal = 0;
  119. var currentCapacityTotal = 0;
  120. res.list.forEach(e => {
  121. currentCapacityTotal++;
  122. resultNetWeightTotal = resultNetWeightTotal + e.resultNetWeight;
  123. });
  124. this.totalNumber = resultNetWeightTotal.toFixed(2) + "t";
  125. this.totalCapacity = currentCapacityTotal;
  126. },
  127. onclick() {
  128. this.option.requestUrl =
  129. "/api/v1/tms/getCapacityByDefend?apiId=474&con=" + this.input;
  130. },
  131. getRequestUrl() {
  132. this.option.requestUrl =
  133. "/api/v1/tms/getCapacityByDefend?apiId=474&startTime=null&endTime=null&i=" +
  134. new Date() +
  135. "&con=" + this.input;
  136. },
  137. // 添加开始结束时间筛选
  138. onclickSearch() {
  139. console.log("aaaa");
  140. let startTime = null;
  141. let endTime = null;
  142. if (this.startTime) {
  143. startTime = sjTime(this.startTime);
  144. // console.log("startTime", startTime);
  145. }
  146. if (this.endTime) {
  147. endTime = sjTime(this.endTime);
  148. // console.log("endTime", endTime);
  149. }
  150. if (startTime && endTime) {
  151. if (startTime < endTime) {
  152. this.option.requestUrl =
  153. "/api/v1/tms/getCapacityByDefend?apiId=474&startTime=" +
  154. startTime +
  155. "&endTime=" +
  156. endTime +
  157. "&con=" + this.input +
  158. "&i=" +
  159. new Date();
  160. } else {
  161. this.startTime = null;
  162. this.endTime = null;
  163. this.$message.warning("开始时间要比结束时间早");
  164. }
  165. } else {
  166. this.getRequestUrl();
  167. }
  168. }
  169. }
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. .homeworkPath {
  174. .timerSelect {
  175. margin-top: 30px;
  176. margin-left: 30px;
  177. }
  178. }
  179. // .input_box {
  180. // // margin-top: -40px;
  181. // // .el-input {
  182. // // width: 240px;
  183. // // margin-left: 760px;
  184. // // }
  185. // }
  186. </style>