statement-warn.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  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-card>
  17. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
  18. label-width="68px">
  19. <!-- <el-form-item label="区域名称" prop="areaCode">-->
  20. <!-- <el-input-->
  21. <!-- v-model="queryParams.areaName"-->
  22. <!-- placeholder="请输入区域名称"-->
  23. <!-- clearable-->
  24. <!-- @keyup.enter.native="handleQuery"-->
  25. <!-- />-->
  26. <!-- </el-form-item>-->
  27. <el-form-item label="日期" prop="date">
  28. <el-date-picker clearable
  29. v-model="queryParams.date"
  30. type="date"
  31. value-format="yyyy-MM-dd"
  32. placeholder="请选择日期">
  33. </el-date-picker>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  38. <el-button
  39. type="warning"
  40. plain
  41. icon="el-icon-download"
  42. size="mini"
  43. @click="handleExport"
  44. >导出
  45. </el-button>
  46. </el-form-item>
  47. </el-form>
  48. <!-- <el-row :gutter="10" class="mb8">-->
  49. <!-- &lt;!&ndash; <el-col :span="1.5">&ndash;&gt;-->
  50. <!-- &lt;!&ndash; <el-button&ndash;&gt;-->
  51. <!-- &lt;!&ndash; type="primary"&ndash;&gt;-->
  52. <!-- &lt;!&ndash; plain&ndash;&gt;-->
  53. <!-- &lt;!&ndash; icon="el-icon-plus"&ndash;&gt;-->
  54. <!-- &lt;!&ndash; size="mini"&ndash;&gt;-->
  55. <!-- &lt;!&ndash; @click="handleAdd"&ndash;&gt;-->
  56. <!-- &lt;!&ndash; v-hasPermi="['ems:EmsEcoD:add']"&ndash;&gt;-->
  57. <!-- &lt;!&ndash; >新增</el-button>&ndash;&gt;-->
  58. <!-- &lt;!&ndash; </el-col>&ndash;&gt;-->
  59. <!-- &lt;!&ndash; <el-col :span="1.5">&ndash;&gt;-->
  60. <!-- &lt;!&ndash; <el-button&ndash;&gt;-->
  61. <!-- &lt;!&ndash; type="success"&ndash;&gt;-->
  62. <!-- &lt;!&ndash; plain&ndash;&gt;-->
  63. <!-- &lt;!&ndash; icon="el-icon-edit"&ndash;&gt;-->
  64. <!-- &lt;!&ndash; size="mini"&ndash;&gt;-->
  65. <!-- &lt;!&ndash; :disabled="single"&ndash;&gt;-->
  66. <!-- &lt;!&ndash; @click="handleUpdate"&ndash;&gt;-->
  67. <!-- &lt;!&ndash; v-hasPermi="['ems:EmsEcoD:edit']"&ndash;&gt;-->
  68. <!-- &lt;!&ndash; >修改</el-button>&ndash;&gt;-->
  69. <!-- &lt;!&ndash; </el-col>&ndash;&gt;-->
  70. <!-- &lt;!&ndash; <el-col :span="1.5">&ndash;&gt;-->
  71. <!-- &lt;!&ndash; <el-button&ndash;&gt;-->
  72. <!-- &lt;!&ndash; type="danger"&ndash;&gt;-->
  73. <!-- &lt;!&ndash; plain&ndash;&gt;-->
  74. <!-- &lt;!&ndash; icon="el-icon-delete"&ndash;&gt;-->
  75. <!-- &lt;!&ndash; size="mini"&ndash;&gt;-->
  76. <!-- &lt;!&ndash; :disabled="multiple"&ndash;&gt;-->
  77. <!-- &lt;!&ndash; @click="handleDelete"&ndash;&gt;-->
  78. <!-- &lt;!&ndash; v-hasPermi="['ems:EmsEcoD:remove']"&ndash;&gt;-->
  79. <!-- &lt;!&ndash; >删除</el-button>&ndash;&gt;-->
  80. <!-- &lt;!&ndash; </el-col>&ndash;&gt;-->
  81. <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
  82. <!-- </el-row>-->
  83. <el-table v-loading="loading" :data="pvAlarmHList">
  84. <el-table-column label="时间" align="center" prop="time">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.alarmTime }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="区域名称" align="center" prop="areaName"/>
  90. <el-table-column label="子系统名称" align="center" prop="subSystemName"/>
  91. <el-table-column label="告警内容" align="center" prop="alarmMsg"/>
  92. </el-table>
  93. <pagination
  94. v-show="total>0"
  95. :total="total"
  96. :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"
  99. />
  100. <!-- 添加或修改节能计量日对话框 -->
  101. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="园区代码" prop="areaCode">
  104. <el-input v-model="form.areaCode" placeholder="请输入园区代码"/>
  105. </el-form-item>
  106. <el-form-item label="日期" prop="date">
  107. <el-date-picker clearable
  108. v-model="form.date"
  109. type="date"
  110. value-format="yyyy-MM-dd"
  111. placeholder="请选择日期">
  112. </el-date-picker>
  113. </el-form-item>
  114. <el-form-item label="节电(千瓦时)" prop="elecEcoQuantity">
  115. <el-input v-model="form.elecEcoQuantity" placeholder="请输入节电"/>
  116. </el-form-item>
  117. <el-form-item label="节电金额(元)" prop="elecEcoCost">
  118. <el-input v-model="form.elecEcoCost" placeholder="请输入节电金额"/>
  119. </el-form-item>
  120. <el-form-item label="节水量 (吨)" prop="waterEcoQuantity">
  121. <el-input v-model="form.waterEcoQuantity" placeholder="请输入节水量 "/>
  122. </el-form-item>
  123. <el-form-item label="节水金额(元)" prop="waterEcoCost">
  124. <el-input v-model="form.waterEcoCost" placeholder="请输入节水金额"/>
  125. </el-form-item>
  126. </el-form>
  127. <div slot="footer" class="dialog-footer">
  128. <el-button type="primary" @click="submitForm">确 定</el-button>
  129. <el-button @click="cancel">取 消</el-button>
  130. </div>
  131. </el-dialog>
  132. </el-card>
  133. </el-col>
  134. </el-row>
  135. </div>
  136. </template>
  137. <script>
  138. import {addEmsEcoD, delEmsEcoD, getEmsEcoD, updateEmsEcoD} from "@/api/ems/EmsEcoD";
  139. import {listAlarmInfo} from "@/api/alarm/alarm-info";
  140. import {areaTreeByFacsCategory} from "@/api/basecfg/area";
  141. export default {
  142. name: "EmsEcoD",
  143. data() {
  144. return {
  145. areaName: undefined,
  146. defaultProps: {
  147. children: "children",
  148. label: "label"
  149. },
  150. // 表单参数
  151. areaOptions: [],
  152. facsCategory: 'E',
  153. facsSubCategory: '',
  154. // 遮罩层
  155. loading: true,
  156. // 选中数组
  157. ids: [],
  158. // 非单个禁用
  159. single: true,
  160. // 非多个禁用
  161. multiple: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 总条数
  165. total: 0,
  166. // 节能计量日表格数据
  167. EmsEcoDList: [],
  168. pvAlarmHList: [],
  169. // 弹出层标题
  170. title: "",
  171. // 是否显示弹出层
  172. open: false,
  173. // 查询参数
  174. queryParams: {
  175. pageNum: 1,
  176. pageSize: 10,
  177. areaCode: null,
  178. alarmDate: null,
  179. },
  180. // 表单参数
  181. form: {},
  182. // 表单校验
  183. rules: {
  184. areaCode: [
  185. {required: true, message: "园区代码不能为空", trigger: "blur"}
  186. ],
  187. alarmDate: [
  188. {required: true, message: "日期不能为空", trigger: "blur"}
  189. ],
  190. }
  191. };
  192. },
  193. async created() {
  194. await this.getAreaList()
  195. this.getList();
  196. },
  197. watch: {
  198. // 根据名称筛选区域树
  199. areaName(val) {
  200. this.$refs.tree.filter(val)
  201. }
  202. },
  203. methods: {
  204. // 查询区域列表
  205. async getAreaList() {
  206. await areaTreeByFacsCategory(this.facsCategory, this.facsSubCategory, false).then(response => {
  207. this.areaOptions = [{
  208. id: '-1',
  209. label: '全部',
  210. children: []
  211. }].concat(response.data)
  212. this.selectedLabel = '全部'
  213. this.queryParams.areaCode = '-1'
  214. })
  215. },
  216. /** 查询节能计量日列表 */
  217. getList() {
  218. this.loading = true;
  219. listAlarmInfo(this.queryParams).then(response => {
  220. this.pvAlarmHList = response.rows
  221. this.total = response.total
  222. this.loading = false
  223. })
  224. },
  225. // 取消按钮
  226. cancel() {
  227. this.open = false;
  228. this.reset();
  229. },
  230. // 表单重置
  231. reset() {
  232. this.form = {
  233. id: null,
  234. areaCode: null,
  235. date: null
  236. };
  237. this.resetForm("form");
  238. },
  239. /** 搜索按钮操作 */
  240. handleQuery() {
  241. this.queryParams.pageNum = 1;
  242. this.getList();
  243. },
  244. /** 重置按钮操作 */
  245. resetQuery() {
  246. this.resetForm("queryForm");
  247. this.handleQuery();
  248. },
  249. // 多选框选中数据
  250. handleSelectionChange(selection) {
  251. this.ids = selection.map(item => item.id)
  252. this.single = selection.length !== 1
  253. this.multiple = !selection.length
  254. },
  255. /** 新增按钮操作 */
  256. handleAdd() {
  257. this.reset();
  258. this.open = true;
  259. this.title = "添加节能计量日";
  260. },
  261. /** 修改按钮操作 */
  262. handleUpdate(row) {
  263. this.reset();
  264. const id = row.id || this.ids
  265. getEmsEcoD(id).then(response => {
  266. this.form = response.data;
  267. this.open = true;
  268. this.title = "修改节能计量日";
  269. });
  270. },
  271. /** 提交按钮 */
  272. submitForm() {
  273. this.$refs["form"].validate(valid => {
  274. if (valid) {
  275. if (this.form.id != null) {
  276. updateEmsEcoD(this.form).then(response => {
  277. this.$modal.msgSuccess("修改成功");
  278. this.open = false;
  279. this.getList();
  280. });
  281. } else {
  282. addEmsEcoD(this.form).then(response => {
  283. this.$modal.msgSuccess("新增成功");
  284. this.open = false;
  285. this.getList();
  286. });
  287. }
  288. }
  289. });
  290. },
  291. /** 删除按钮操作 */
  292. handleDelete(row) {
  293. const ids = row.id || this.ids;
  294. this.$modal.confirm('是否确认删除节能计量日编号为"' + ids + '"的数据项?').then(function () {
  295. return delEmsEcoD(ids);
  296. }).then(() => {
  297. this.getList();
  298. this.$modal.msgSuccess("删除成功");
  299. }).catch(() => {
  300. });
  301. },
  302. /** 导出按钮操作 */
  303. handleExport() {
  304. this.download('ems/alarm-info/export', {
  305. ...this.queryParams
  306. }, `alarm_${new Date().getTime()}.xlsx`)
  307. },
  308. // 筛选节点
  309. filterNode(value, data) {
  310. if (!value) return true
  311. return data.label.indexOf(value) !== -1
  312. },
  313. // 节点单击事件
  314. handleNodeClick(data) {
  315. this.queryParams.areaCode = data.id
  316. this.selectedLabel = data.label
  317. this.getList()
  318. },
  319. }
  320. };
  321. </script>