index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="68px"
  10. >
  11. <el-form-item label="日期">
  12. <el-date-picker
  13. v-model="dateRange"
  14. size="small"
  15. style="width: 360px"
  16. type="daterange"
  17. range-separator="-"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. ></el-date-picker>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button
  24. type="primary"
  25. icon="el-icon-search"
  26. size="mini"
  27. @click="handleQuery"
  28. >搜索</el-button>
  29. <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> -->
  30. </el-form-item>
  31. </el-form>
  32. <el-row :gutter="10" class="mb8">
  33. <el-col :span="1.5">
  34. <el-button
  35. type="warning"
  36. plain
  37. icon="el-icon-download"
  38. size="mini"
  39. @click="handleExport"
  40. v-hasPermi="['ems:emselectricityday:export']"
  41. >导出
  42. </el-button>
  43. </el-col>
  44. <right-toolbar
  45. :showSearch.sync="showSearch"
  46. @queryTable="getList"
  47. ></right-toolbar>
  48. </el-row>
  49. <el-table
  50. v-loading="loading"
  51. :data="emselectricitydayList"
  52. >
  53. <el-table-column label="序号" width="55">
  54. <template slot-scope="scope">
  55. <span>{{
  56. (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
  57. }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="设备名称" align="center" prop="equipmentname" />
  61. <el-table-column label="设备编号" align="center" prop="equipmentcode" />
  62. <el-table-column label="用电量(kWh)" align="center" prop="electricityvalue" />
  63. </el-table>
  64. </div>
  65. </template>
  66. <script>
  67. import { httpAction, getAction } from '@/api/manage'
  68. export default {
  69. name: "emselectricityday",
  70. data() {
  71. return {
  72. description: '日用电量',
  73. // 遮罩层
  74. loading: false,
  75. // 选中数组
  76. ids: [],
  77. // 非单个禁用
  78. single: true,
  79. // 非多个禁用
  80. multiple: true,
  81. // 显示搜索条件
  82. showSearch: true,
  83. // 总条数
  84. total: 0,
  85. // 分时电量数据表格数据
  86. emselectricitydayList: [],
  87. // 弹出层标题
  88. title: "",
  89. // 日期范围
  90. dateRange: [],
  91. // 是否显示弹出层
  92. open: false,
  93. // 查询参数
  94. queryParams: {
  95. pageNum: 1,
  96. pageSize: 1000,
  97. },
  98. url: {
  99. list: "/ems/emselectricityday/liststa",
  100. },
  101. };
  102. },
  103. created() {
  104. this.getDate();
  105. this.getList();
  106. },
  107. methods: {
  108. getDate() {
  109. var begindate = this.dateformat(new Date()).substring(0, 10);
  110. var enddate = this.dateformat(new Date()).substring(0, 10);
  111. this.dateRange = [ begindate, enddate ];
  112. },
  113. dateformat(date) {
  114. var year = date.getFullYear();
  115. var month = date.getMonth() + 1;
  116. month = month < 10 ? "0" + month : month;
  117. var strDate = date.getDate();
  118. strDate = strDate < 10 ? "0" + strDate : strDate;
  119. var hour = date.getHours();
  120. hour = hour < 10 ? "0" + hour : hour;
  121. var minute = date.getMinutes();
  122. minute = minute < 10 ? "0" + minute : minute;
  123. var second = date.getSeconds();
  124. second = second < 10 ? "0" + second : second;
  125. return year + "-" + month + "-" + strDate + " " + hour + ":" + minute + ":" + second;
  126. },
  127. /** 查询分时电量数据列表 */
  128. getList() {
  129. if (this.dateRange == null || this.dateRange.length < 2) {
  130. this.$modal.msgError("请先选择日期!");
  131. return false;
  132. }
  133. this.loading = true;
  134. this.dateRange[0] = this.dateformat(new Date(this.dateRange[0])).substring(0, 10);
  135. this.dateRange[1] = this.dateformat(new Date(this.dateRange[1])).substring(0, 10);
  136. getAction(this.url.list, this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
  137. this.emselectricitydayList = response.rows;
  138. this.total = response.total;
  139. this.loading = false;
  140. });
  141. },
  142. // 取消按钮
  143. cancel() {
  144. this.open = false;
  145. this.reset();
  146. },
  147. /** 搜索按钮操作 */
  148. handleQuery() {
  149. this.queryParams.pageNum = 1;
  150. this.getList();
  151. },
  152. /** 重置按钮操作 */
  153. resetQuery() {
  154. this.resetForm("queryForm");
  155. this.dateRange = [];
  156. this.handleQuery();
  157. },
  158. /** 导出按钮操作 */
  159. handleExport() {
  160. this.download(
  161. "ems/emselectricityday/exportsta",
  162. {
  163. ...this.queryParams,
  164. },
  165. `用电量_${new Date().getTime()}.xlsx`
  166. );
  167. },
  168. },
  169. };
  170. </script>