waterConsumption.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <el-row class="el-row-container" v-loading="loading">
  3. <el-col :span="4" style="height:100%;padding-bottom:32px;">
  4. <el-card style="margin:16px;height: 100%; overflow-y: auto">
  5. <data-report-left @setCurrentData="setCurrentData" :treeData="treeData"></data-report-left>
  6. </el-card>
  7. </el-col>
  8. <el-col :span="20" style="padding: 16px 16px 16px 0; height: 100%;">
  9. <el-card style="height: 100%; overflow-y: auto">
  10. <el-col :span="24" class="elrow-main__col-top">
  11. <div style="display:flex;width:100%;justify-content:space-between;align-items:center">
  12. <div>
  13. <el-date-picker
  14. v-model="dateValue"
  15. type="daterange"
  16. value-format="yyyy-MM-dd HH:mm:ss"
  17. :default-time="['00:00:00', '23:59:59']"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期"
  20. style="width: 300px; margin-right: 20px"
  21. >
  22. </el-date-picker>
  23. <el-input style="width: 250px;margin-right: 16px;" placeholder="请输入机井名称" v-model="keyword" />
  24. <el-button type="primary" size="small" @click="handleSearch">查询</el-button>
  25. </div>
  26. <i
  27. class="el-icon-download"
  28. @click="downloadHandler"
  29. ></i>
  30. </div>
  31. </el-col>
  32. <el-col :span="24" class="elrow-main__col-bottom">
  33. <b-table ref="tableRef" :args="{ 'highlight-current-row': true }" :data="loadData" :columns="columns"
  34. isShowIndex>
  35. </b-table>
  36. </el-col>
  37. </el-card>
  38. </el-col>
  39. </el-row>
  40. </template>
  41. <script>
  42. import { getWaterList } from '@/api/statistics/index.js'
  43. import { getTree } from '@/api/tree.js'
  44. import BTable from '@/components/Table/index.vue';
  45. import DataReportLeft from '@/components/DataReportLeft/index.vue'
  46. import { assign, omit } from 'lodash-es';
  47. export default {
  48. name: "waterConsumption",
  49. components: { BTable, DataReportLeft },
  50. data() {
  51. return {
  52. currentYear: '',
  53. keyword: '',
  54. loading: false,
  55. treeData: [],
  56. currentClickId: '',
  57. dateValue: [],
  58. areaId: '',
  59. queryParams: {},
  60. columns: [
  61. {
  62. label: '机井名称',
  63. prop: 'waterName',
  64. customRender: '',
  65. align: 'center'
  66. }, {
  67. label: '终端编号',
  68. prop: 'waterNum',
  69. customRender: '',
  70. align: 'center'
  71. },
  72. {
  73. label: '累计用水量(m³)',
  74. prop: 'waterNumTotal',
  75. customRender: '',
  76. align: 'center'
  77. },
  78. {
  79. label: '灌溉次数',
  80. prop: 'count',
  81. customRender: '',
  82. align: 'center'
  83. },
  84. {
  85. label: '累计用电量(度)',
  86. prop: 'elecNumTotal',
  87. customRender: '',
  88. align: 'center'
  89. }
  90. ]
  91. };
  92. },
  93. methods: {
  94. handleSearch() {
  95. this.$refs.tableRef.refresh(true);
  96. },
  97. downloadHandler() {
  98. const [startTime, endTime] = this.dateValue ??= []
  99. const params = {
  100. areaId: this.currentClickId,
  101. startTime,
  102. endTime,
  103. keyword: this.keyword
  104. }
  105. this.download(
  106. 'wpr/stat/water/export',
  107. {
  108. ...params
  109. },
  110. `FmsCrop_${new Date().getTime()}.xlsx`
  111. );
  112. },
  113. async loadData(parameter) {
  114. if (!this.currentClickId) {
  115. const treeList = this.$store.state.tree.treeList
  116. let res = []
  117. if (treeList.code === '000000') {
  118. res = treeList
  119. } else {
  120. res = await getTree()
  121. this.$store.dispatch('tree/setTree', res)
  122. }
  123. this.treeData = res?.data
  124. this.currentClick = res?.data[0]
  125. this.currentClickId = this.currentClick?.cusareaId
  126. }
  127. const [startTime, endTime] = this.dateValue ??= []
  128. const params = {
  129. areaId: this.currentClickId,
  130. startTime,
  131. endTime,
  132. keyword: this.keyword
  133. }
  134. const payload = omit(assign({}, parameter, params), []);
  135. return getWaterList(payload);
  136. },
  137. setCurrentData(areaId) {
  138. this.currentClickId = areaId
  139. this.$refs.tableRef.refresh(false);
  140. },
  141. }
  142. };
  143. </script>
  144. <style lang="scss" scoped>
  145. .el-row-container {
  146. height: 100%;
  147. }
  148. .elrow-main__col-top {
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-between;
  152. margin-bottom: 15px;
  153. .top-left {
  154. height: 100%;
  155. display: flex;
  156. align-items: center;
  157. i {
  158. background-color: #40d5ec;
  159. height: 45%;
  160. width: 5px;
  161. margin-right: 5px;
  162. }
  163. }
  164. .el-icon-download{
  165. font-size:26px;
  166. color:#14A478;
  167. cursor: pointer;
  168. }
  169. }
  170. </style>