ca.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :span="4" :xs="24">
  5. <div class="head-container">
  6. <el-input v-model="areaName" placeholder="请输入区域名称" clearable size="small" prefix-icon="el-icon-search"
  7. style="margin-bottom: 20px" />
  8. </div>
  9. <div class="head-container" style="height: 100vh; overflow: hidden; position: relative;">
  10. <el-tree :data="areaOptions" :props="defaultProps" :expand-on-click-node="false"
  11. :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
  12. @node-click="handleNodeClick" style="height: calc(100vh - 50px); overflow-y: auto;" />
  13. </div>
  14. </el-col>
  15. <el-col :span="20" :xs="24">
  16. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  17. <el-form-item label="开始月份" prop="date">
  18. <el-date-picker clearable
  19. v-model="queryParams.startRecTime"
  20. type="month"
  21. value-format="yyyy-MM"
  22. placeholder="请选择月份">
  23. </el-date-picker>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-table v-loading="loading" :data="forecastCaList" >
  31. <el-table-column label="园区名称" align="center" prop="areaName" />
  32. <el-table-column label="月份" align="center" prop="month" width="180"/>
  33. <el-table-column label="碳排量(kg)" align="center" prop="caEmission" />
  34. </el-table>
  35. <pagination
  36. v-show="total>0"
  37. :total="total"
  38. :page.sync="queryParams.pageNum"
  39. :limit.sync="queryParams.pageSize"
  40. @pagination="getList"
  41. />
  42. </el-col>
  43. </el-row>
  44. </div>
  45. </template>
  46. <script>
  47. import { listForecastCa } from '@/api/prediction/forecastCa';
  48. import { areaTreeByFacsCategory } from '@/api/basecfg/area'
  49. export default {
  50. name: 'ForecastCa',
  51. data() {
  52. return {
  53. // 遮罩层
  54. loading: true,
  55. // 选中数组
  56. ids: [],
  57. // 非单个禁用
  58. single: true,
  59. // 非多个禁用
  60. multiple: true,
  61. // 显示搜索条件
  62. showSearch: true,
  63. // 总条数
  64. total: 0,
  65. // 碳排放预测表格数据
  66. forecastCaList: [],
  67. // 弹出层标题
  68. title: '',
  69. // 是否显示弹出层
  70. open: false,
  71. // 表单参数
  72. areaOptions: [],
  73. areaName: undefined,
  74. facsCategory: 'Z',
  75. facsSubCategory: '',
  76. defaultProps: {
  77. children: "children",
  78. label: "label"
  79. },
  80. // 查询参数
  81. queryParams: {
  82. pageNum: 1,
  83. pageSize: 10,
  84. areaCode: null,
  85. startRecTime: null,
  86. },
  87. // 表单参数
  88. form: {},
  89. // 表单校验
  90. rules: {
  91. areaCode: [
  92. {
  93. required: true,
  94. message: '园区代码不能为空',
  95. trigger: 'blur',
  96. },
  97. ],
  98. date: [
  99. {
  100. required: true,
  101. message: '日期不能为空',
  102. trigger: 'blur',
  103. },
  104. ],
  105. },
  106. };
  107. },
  108. created() {
  109. this.setTodayDate();
  110. this.getAreaList();
  111. this.getList();
  112. },
  113. methods: {
  114. /** 查询碳排放预测列表 */
  115. getList() {
  116. this.loading = true;
  117. listForecastCa(this.queryParams).then(response => {
  118. this.forecastCaList = response.rows;
  119. this.total = response.total;
  120. this.loading = false;
  121. });
  122. },
  123. // 查询区域列表
  124. async getAreaList () {
  125. await areaTreeByFacsCategory(this.facsCategory, this.facsSubCategory, false).then(response => {
  126. this.areaOptions = [{
  127. id: '-1',
  128. label: '全部',
  129. children: []
  130. }].concat(response.data)
  131. this.selectedLabel = '全部'
  132. this.queryParams.areaCode = '-1'
  133. })
  134. },
  135. setTodayDate() {
  136. // 获取当前日期
  137. const today = new Date();
  138. // 格式化日期为 yyyy-MM-dd 格式
  139. const year = today.getFullYear();
  140. const month = String(today.getMonth() + 1).padStart(2, '0');
  141. // 设置日期选择器的值
  142. this.queryParams.startRecTime = `${year}-${month}`;
  143. },
  144. // 取消按钮
  145. cancel() {
  146. this.open = false;
  147. this.reset();
  148. },
  149. // 表单重置
  150. reset() {
  151. this.form = {
  152. id: null,
  153. areaCode: null,
  154. date: null,
  155. caEmission: null,
  156. };
  157. this.resetForm('form');
  158. },
  159. /** 搜索按钮操作 */
  160. handleQuery() {
  161. this.queryParams.pageNum = 1;
  162. this.getList();
  163. },
  164. /** 重置按钮操作 */
  165. resetQuery() {
  166. this.resetForm('queryForm');
  167. this.handleQuery();
  168. },
  169. // 筛选节点
  170. filterNode (value, data) {
  171. if (!value) return true
  172. return data.label.indexOf(value) !== -1
  173. },
  174. // 节点单击事件
  175. handleNodeClick (data) {
  176. this.queryParams.areaCode = data.id
  177. this.getList()
  178. },
  179. },
  180. };
  181. </script>