index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <setting-search @search="reload"> </setting-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :pageSizes="tablePageSizes"
  9. :columns="columns"
  10. :datasource="datasource"
  11. cache-key="systemRoleTable"
  12. height="calc(100vh - 350px)"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <el-button
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="openEdit('add')"
  22. >
  23. 新建
  24. </el-button>
  25. </template>
  26. <template v-slot:enable="{ row }">
  27. <el-switch
  28. v-model="row.enable"
  29. active-color="#13ce66"
  30. inactive-color="#ff4949"
  31. :active-value="1"
  32. :inactive-value="0"
  33. disabled
  34. >
  35. </el-switch>
  36. </template>
  37. <template v-slot:code="{ row }">
  38. <el-link
  39. type="primary"
  40. :underline="false"
  41. @click="openEdit('view', row)"
  42. >
  43. {{ row.code }}
  44. </el-link>
  45. </template>
  46. <!-- 操作列 -->
  47. <template v-slot:action="{ row }">
  48. <el-link
  49. type="primary"
  50. :underline="false"
  51. icon="el-icon-edit"
  52. @click="openEdit('edit', row)"
  53. >
  54. 修改
  55. </el-link>
  56. <el-popconfirm
  57. class="ele-action"
  58. title="确定要删除此告警设置吗?"
  59. @confirm="remove(row)"
  60. >
  61. <template v-slot:reference>
  62. <el-link type="danger" :underline="false" icon="el-icon-delete">
  63. 删除
  64. </el-link>
  65. </template>
  66. </el-popconfirm>
  67. </template>
  68. </ele-pro-table>
  69. </el-card>
  70. <AddWarningDialog ref="addWarningDialogRef" @refreshList="reload" />
  71. </div>
  72. </template>
  73. <script>
  74. import SettingSearch from './components/setting-search.vue';
  75. import AddWarningDialog from './components/addWarningDialog.vue';
  76. import dictMixins from '@/mixins/dictMixins';
  77. import { getList, remove } from '@/api/warning/index.js';
  78. export default {
  79. mixins: [dictMixins],
  80. components: {
  81. SettingSearch,
  82. AddWarningDialog
  83. },
  84. data() {
  85. return {
  86. // 表格列配置
  87. columns: [
  88. {
  89. columnKey: 'index',
  90. label: '序号',
  91. type: 'index',
  92. width: 55,
  93. align: 'center',
  94. showOverflowTooltip: true,
  95. fixed: 'left'
  96. },
  97. {
  98. prop: 'code',
  99. label: '告警编码',
  100. align: 'center',
  101. slot: 'code',
  102. showOverflowTooltip: true,
  103. minWidth: 110
  104. },
  105. {
  106. prop: 'name',
  107. label: '告警名称',
  108. align: 'center',
  109. showOverflowTooltip: true,
  110. minWidth: 110
  111. },
  112. {
  113. prop: 'level',
  114. label: '告警级别',
  115. align: 'center',
  116. showOverflowTooltip: true,
  117. minWidth: 110,
  118. formatter: (_row, _column, cellValue) => {
  119. return { 1: '轻微', 2: '中等', 3: '严重', 4: '紧急', 5: '致命' }[
  120. cellValue
  121. ];
  122. }
  123. },
  124. {
  125. prop: 'deviceName',
  126. label: '告警设备名称',
  127. align: 'center',
  128. showOverflowTooltip: true,
  129. minWidth: 110
  130. },
  131. {
  132. prop: 'description',
  133. label: '告警描述',
  134. align: 'center',
  135. showOverflowTooltip: true,
  136. minWidth: 110
  137. },
  138. {
  139. columnKey: 'action',
  140. label: '操作',
  141. width: 150,
  142. align: 'center',
  143. resizable: false,
  144. slot: 'action',
  145. showOverflowTooltip: true
  146. }
  147. ],
  148. // 加载状态
  149. loading: false,
  150. pageType: 'add',
  151. dialogTitle: '',
  152. isBindPlan: false
  153. };
  154. },
  155. computed: {},
  156. created() {
  157. this.requestDict('告警级别');
  158. },
  159. methods: {
  160. /* 表格数据源 */
  161. datasource({ page, limit, where, order }) {
  162. return getList({
  163. pageNum: page,
  164. size: limit,
  165. ...where
  166. });
  167. },
  168. /* 刷新表格 */
  169. reload(where) {
  170. this.$refs.table.reload({ page: 1, where });
  171. },
  172. openEdit(type, row) {
  173. this.$refs.addWarningDialogRef.open(type, row);
  174. },
  175. remove(row) {
  176. remove([row.id]).then((res) => {
  177. this.$message.success('删除成功!');
  178. this.reload();
  179. });
  180. }
  181. }
  182. };
  183. </script>
  184. <style lang="scss" scoped></style>