warningInfo.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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
  13. :option="option"
  14. :table-loading="loading"
  15. :data="data"
  16. ref="crud"
  17. v-model="form"
  18. :permission="permissionList"
  19. @row-del="rowDel"
  20. @row-update="rowUpdate"
  21. @row-save="rowSave"
  22. @search-change="searchChange"
  23. @search-reset="searchReset"
  24. @selection-change="selectionChange"
  25. @current-change="currentChange"
  26. @size-change="sizeChange"
  27. @refresh-change="refreshChange"
  28. @on-load="onLoad"
  29. @before-open="beforeOpen"
  30. >
  31. </avue-crud>
  32. </basic-container>
  33. </div>
  34. </template>
  35. <script>
  36. import { getList, getDetail, add, update } from "@/api/workbench/monitoring";
  37. import { mapGetters } from "vuex";
  38. export default {
  39. data() {
  40. return {
  41. id: "",
  42. editForm: {},
  43. editDialog: false,
  44. form: {},
  45. selectionList: [],
  46. query: {},
  47. loading: true,
  48. page: {
  49. pageSize: 5,
  50. currentPage: 1,
  51. total: 0,
  52. },
  53. option: {
  54. labelWidth: 120,
  55. viewLabelWidth: 100,
  56. searchlabelWidth: 100,
  57. height: "auto",
  58. calcHeight: 30,
  59. align: "center",
  60. headerAlign: "center",
  61. tip: false,
  62. simplePage: true,
  63. searchShow: true,
  64. searchMenuSpan: 6,
  65. addBtn: false,
  66. border: true,
  67. index: true,
  68. height: 300,
  69. editBtn: false,
  70. delBtn: false,
  71. menuWidth: 220,
  72. dialogType: "drawer",
  73. menu: false,
  74. dialogClickModal: false,
  75. column: [
  76. {
  77. label: "预警信息",
  78. prop: "rtuName",
  79. search: true,
  80. span: 12,
  81. },
  82. {
  83. label: "预警时间",
  84. prop: "rtuCode",
  85. span: 12,
  86. search: true,
  87. },
  88. {
  89. label: "恢复时间",
  90. prop: "orgId",
  91. span: 12,
  92. },
  93. ],
  94. },
  95. data: [],
  96. };
  97. },
  98. prop: {
  99. id: ["String"],
  100. },
  101. methods: {
  102. init() {
  103. this.onLoad(this.page);
  104. },
  105. rowSave(row, done, loading) {
  106. add(row).then(
  107. () => {
  108. this.onLoad(this.page);
  109. this.$message({
  110. type: "success",
  111. message: "操作成功!",
  112. });
  113. done();
  114. },
  115. (error) => {
  116. window.console.log(error);
  117. loading();
  118. }
  119. );
  120. },
  121. rowUpdate(row, index, done, loading) {
  122. update(row).then(
  123. () => {
  124. this.onLoad(this.page);
  125. this.$message({
  126. type: "success",
  127. message: "操作成功!",
  128. });
  129. done();
  130. },
  131. (error) => {
  132. window.console.log(error);
  133. loading();
  134. }
  135. );
  136. },
  137. rowDel(row) {
  138. this.$confirm("确定将选择数据删除?", {
  139. confirmButtonText: "确定",
  140. cancelButtonText: "取消",
  141. type: "warning",
  142. })
  143. .then(() => {
  144. return remove(row.id);
  145. })
  146. .then(() => {
  147. this.onLoad(this.page);
  148. this.$message({
  149. type: "success",
  150. message: "操作成功!",
  151. });
  152. });
  153. },
  154. searchReset() {
  155. this.query = {};
  156. this.onLoad(this.page);
  157. },
  158. searchChange(params, done) {
  159. this.query = params;
  160. this.page.currentPage = 1;
  161. this.onLoad(this.page, params);
  162. done();
  163. },
  164. selectionChange(list) {
  165. this.selectionList = list;
  166. },
  167. selectionClear() {
  168. this.selectionList = [];
  169. this.$refs.crud.toggleSelection();
  170. },
  171. handleDelete() {
  172. if (this.selectionList.length === 0) {
  173. this.$message.warning("请选择至少一条数据");
  174. return;
  175. }
  176. this.$confirm("确定将选择数据删除?", {
  177. confirmButtonText: "确定",
  178. cancelButtonText: "取消",
  179. type: "warning",
  180. })
  181. .then(() => {
  182. return remove(this.ids);
  183. })
  184. .then(() => {
  185. this.onLoad(this.page);
  186. this.$message({
  187. type: "success",
  188. message: "操作成功!",
  189. });
  190. this.$refs.crud.toggleSelection();
  191. });
  192. },
  193. beforeOpen(done, type) {
  194. if (["edit", "view"].includes(type)) {
  195. getDetail(this.form.id).then((res) => {
  196. this.form = res.data.data;
  197. });
  198. }
  199. done();
  200. },
  201. currentChange(currentPage) {
  202. this.page.currentPage = currentPage;
  203. },
  204. sizeChange(pageSize) {
  205. this.page.pageSize = pageSize;
  206. },
  207. refreshChange() {
  208. this.onLoad(this.page, this.query);
  209. },
  210. onLoad(page, params = {}) {
  211. this.loading = true;
  212. getList(
  213. page.currentPage,
  214. page.pageSize,
  215. Object.assign(params, this.query)
  216. ).then((res) => {
  217. const data = res.data.data;
  218. this.page.total = data.total;
  219. this.data = data.records;
  220. this.loading = false;
  221. this.selectionClear();
  222. });
  223. },
  224. },
  225. };
  226. </script>