rtuWarningList.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!--
  2. * @Title:
  3. * @Description:
  4. * @Author: 893699165@qq.com
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <basic-container>
  12. <avue-crud :option="option" :table-loading="loading" :page.sync="page" :data="data" ref="crud"
  13. v-model="form" :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate"
  14. @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
  15. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  16. @refresh-change="refreshChange" @on-load="onLoad" @before-open="beforeOpen">
  17. <template slot="warningStatus" slot-scope="row">
  18. <div v-if="row.row.warningStatus==0" style="color: orangered;">
  19. 预警中
  20. </div>
  21. <div v-else style="color: blue;">
  22. 关闭
  23. </div>
  24. </template>
  25. <template slot-scope="{ row, index }" slot="menu">
  26. <el-button icon="el-icon-link" type="text" size="small" @click="toWarnInfoDetail(row)">预警详情
  27. </el-button>
  28. </template>
  29. </avue-crud>
  30. <el-drawer :visible.sync="drawer" title="预警信息详情" direction="rtl" size="40%" append-to-body="true">
  31. <originalWarnInfoDetail :id="dataFromId" ref="originalWarnInfoDetail"></originalWarnInfoDetail>
  32. </el-drawer>
  33. </basic-container>
  34. </div>
  35. </template>
  36. <script>
  37. import { getPage, getDetail } from "@/api/warning/warning";
  38. // import { mapGetters } from "vuex";
  39. import originalWarnInfoDetail from "./originalWarnInfoDetail";
  40. export default {
  41. components: { originalWarnInfoDetail },
  42. data() {
  43. return {
  44. dataFromId: '',
  45. drawer: false,
  46. // rtuCode: "",
  47. editForm: {},
  48. editDialog: false,
  49. form: {},
  50. selectionList: [],
  51. query: {},
  52. loading: true,
  53. page: {
  54. pageSize: 10,
  55. currentPage: 1,
  56. total: 0,
  57. },
  58. option: {
  59. labelWidth: 120,
  60. viewLabelWidth: 100,
  61. searchlabelWidth: 100,
  62. // height: "auto",
  63. calcHeight: 30,
  64. align: "center",
  65. headerAlign: "center",
  66. tip: false,
  67. simplePage: true,
  68. searchShow: true,
  69. searchMenuSpan: 6,
  70. menu: true,
  71. border: true,
  72. index: true,
  73. height: 300,
  74. editBtn: false,
  75. delBtn: false,
  76. addBtn: false,
  77. viewBtn: false,
  78. viewBtnText: "预警详情",
  79. menuWidth: 220,
  80. dialogType: "drawer",
  81. dialogClickModal: false,
  82. column: [
  83. {
  84. label: "预警类型",
  85. prop: "warningKind",
  86. span: 12,
  87. },
  88. {
  89. label: "预警信息",
  90. prop: "warningDesc",
  91. span: 12,
  92. },
  93. {
  94. label: "预警时间",
  95. prop: "warningHappenTime",
  96. span: 12,
  97. search: true,
  98. },
  99. {
  100. label: "恢复时间",
  101. prop: "warningRecoveryTime",
  102. span: 12,
  103. search: true,
  104. },
  105. {
  106. label: "预警状态",
  107. prop: "warningStatus",
  108. span: 12,
  109. solt: true,
  110. },
  111. ],
  112. },
  113. data: [],
  114. };
  115. },
  116. props: {
  117. rtuCode: {
  118. type: [String],
  119. required: true
  120. },
  121. },
  122. created() {
  123. this.init();
  124. },
  125. methods: {
  126. init() {
  127. //this.$message.success(this.rtuCode)
  128. this.onLoad(this.page);
  129. },
  130. toWarnInfoDetail(row) {
  131. this.dataFromId = row.dataFromId;
  132. this.drawer = true;
  133. },
  134. searchReset() {
  135. this.query = {};
  136. this.onLoad(this.page);
  137. },
  138. searchChange(params, done) {
  139. this.query = params;
  140. this.page.currentPage = 1;
  141. this.onLoad(this.page, params);
  142. done();
  143. },
  144. selectionChange(list) {
  145. this.selectionList = list;
  146. },
  147. selectionClear() {
  148. this.selectionList = [];
  149. this.$refs.crud.toggleSelection();
  150. },
  151. beforeOpen(done, type) {
  152. if (["view"].includes(type)) {
  153. getDetail(this.form.id).then((res) => {
  154. this.form = res.data.data;
  155. });
  156. }
  157. done();
  158. },
  159. currentChange(currentPage) {
  160. this.page.currentPage = currentPage;
  161. },
  162. sizeChange(pageSize) {
  163. this.page.pageSize = pageSize;
  164. },
  165. refreshChange() {
  166. this.onLoad(this.page, this.query);
  167. },
  168. onLoad(page, params = {}) {
  169. this.loading = true;
  170. params['rtuCode'] = this.rtuCode;
  171. getPage(
  172. page.currentPage,
  173. page.pageSize,
  174. Object.assign(params, this.query)
  175. ).then((res) => {
  176. const data = res.data.data;
  177. this.page.total = data.total;
  178. this.data = data.records;
  179. this.loading = false;
  180. this.selectionClear();
  181. });
  182. },
  183. },
  184. };
  185. </script>