index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <!-- 规则列表 -- 表格 -->
  2. <template>
  3. <div class="layout-pd">
  4. <el-row>
  5. <!--操作-->
  6. <el-col :xs="24">
  7. <el-card class="mt8" shadow="hover">
  8. <el-form :model="Data.Filter" @submit.stop.prevent>
  9. <el-form-item prop="name" style="width: 100%">
  10. <el-col :xs="24" :sm="12" :md="8" :lg="8" :xl="6" class="mb20">
  11. <el-form-item label="规则名称">
  12. <el-input v-model="Data.time1" placeholder="请输入规则名称" clearable></el-input>
  13. </el-form-item>
  14. </el-col>
  15. </el-form-item>
  16. </el-form>
  17. <hr>
  18. <!-- 按钮 -->
  19. <el-row justify="space-between" class="submit-button">
  20. <el-row>
  21. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  22. <el-button type="primary" icon="ele-RefreshRight" @click="onReset"> 重置 </el-button>
  23. </el-row>
  24. <el-row>
  25. <el-button type="primary" icon="ele-RefreshRight" @click="addAlarmRules"> 添加 </el-button>
  26. </el-row>
  27. </el-row>
  28. </el-card>
  29. </el-col>
  30. <!--表格-->
  31. <el-col :xs="24">
  32. <el-card style="height: 70vh" class="my-fill mt8" shadow="hover">
  33. <el-table ref="multipleTableRef" v-loading="Data.loading" stripe :data="Data.tableModel" row-key="id"
  34. style="width: 100%">
  35. <el-table-column v-for="column in Data.dynamicColumns" :key="column.prop" :prop="column.prop"
  36. :label="column.label" />
  37. </el-table>
  38. <div class="my-flex my-flex-end" style="margin-top: 20px">
  39. <el-pagination v-model:currentPage="Data.pageInput.currentPage" v-model:page-size="Data.pageInput.pageSize"
  40. :total="Data.total" :page-sizes="[5, 10, 20, 50, 100]" small background @size-change="onSizeChange"
  41. @current-change="onCurrentChange" layout="total, sizes, prev, pager, next, jumper" />
  42. </div>
  43. </el-card>
  44. </el-col>
  45. </el-row>
  46. <EditDialog ref="editDialogRef" />
  47. </div>
  48. </template>
  49. <script setup lang="ts" name="partsManagement/oilGun">
  50. import { defineAsyncComponent, onMounted, reactive, ref, watch } from "vue";
  51. import { alarmRluesFilterModel_SearchFilter, alarmRluesFilterModel, PageInputAlarmRluesFilterModel } from "/@/api/admin/AlarmService/alarmRulesDto";
  52. import { alarmRulesApi } from "/@/api/admin/AlarmService/alarmRulesApi";
  53. /**页面对象 */
  54. const Data = reactive({
  55. time1: '',
  56. /** 选择框列表 */
  57. statusList: [] as any,
  58. supplierList: [] as any,
  59. /**加载显示 */
  60. loading: false,
  61. /**条件查询模块 */
  62. Filter: {
  63. /** 规则名称 */
  64. ruleName: ""
  65. } as alarmRluesFilterModel_SearchFilter,
  66. /**表格信息 */
  67. tableModel: [] as alarmRluesFilterModel,
  68. /**动态表头 */
  69. dynamicColumns: [
  70. { prop: 'ruleName', label: '规则名称' },
  71. { prop: 'companyName', label: '角色' },
  72. { prop: 'pushMethod', label: '推送方式' },
  73. { prop: 'triggerMethod', label: '触发方式' },
  74. { prop: 'regular', label: '正则匹配' },
  75. { prop: 'taskPriority', label: '优先级' },
  76. { prop: 'isExclusive', label: '是否互斥' },
  77. { prop: 'stationName', label: '推送方式' },
  78. { prop: 'pushTemplateMappingID', label: '模板' },
  79. { prop: 'remark', label: '备注' },
  80. ],
  81. /**分页总数 */
  82. total: 0,
  83. /**分页标识 */
  84. pageInput: {
  85. currentPage: 1,
  86. pageSize: 10,
  87. } as PageInputAlarmRluesFilterModel,
  88. })
  89. /**引入组件*/
  90. const EditDialog = defineAsyncComponent(() => import('./components/add-alarmRules.vue'))
  91. const editDialogRef = ref()
  92. onMounted(() => {
  93. init()
  94. })
  95. // // 条件查询
  96. const init = async () => {
  97. Data.loading = true
  98. const res: any = await new alarmRulesApi().getData({ ...Data.pageInput, filter: Data.Filter })
  99. console.log(res)
  100. Data.tableModel = res?.data ?? []
  101. // Data.total = res?.data?.length ?? 0 // 接口中没有总的数据量
  102. Data.loading = false
  103. pushMethodChange()
  104. }
  105. const onQuery = () => {
  106. init()
  107. console.log("查询")
  108. }
  109. /**重置查询条件 */
  110. const resetQuery = () => {
  111. Data.Filter.ruleName = ''
  112. }
  113. /**重置 */
  114. const onReset = () => {
  115. resetQuery()
  116. init()
  117. }
  118. /**
  119. * 添加规则
  120. */
  121. const addAlarmRules = (() => {
  122. editDialogRef.value.openDialog()
  123. init()
  124. })
  125. /**
  126. * 页条变化
  127. * @param val
  128. */
  129. const onSizeChange = (val: number) => {
  130. Data.pageInput.pageSize = val
  131. init()
  132. }
  133. /**
  134. * 页数 变化
  135. * @param val
  136. */
  137. const onCurrentChange = (val: number) => {
  138. Data.pageInput.currentPage = val
  139. init()
  140. }
  141. /** 数据转换 */
  142. const pushMethodChange = (() => {
  143. // 推送方式
  144. Data.tableModel.forEach((item) => {
  145. const pushList = item['pushMethod'].split(',')
  146. for (var i = 0; i < pushList.length; i++) {
  147. if (pushList[i] == 'wx') {
  148. pushList[i] = "微信"
  149. } else if (pushList[i] == 'email') {
  150. pushList[i] = "电子邮箱"
  151. }
  152. }
  153. item['pushMethod'] = pushList.toString()
  154. // 是否互斥
  155. if (item['isExclusive'] == true) {
  156. item['isExclusive'] = "是"
  157. } else {
  158. item['isExclusive'] = "否"
  159. }
  160. // 触发方式
  161. if (item['triggerMethod'] == '0') {
  162. item['triggerMethod'] = '其中之一条件满足即触发'
  163. } else if (item['triggerMethod'] == '1') {
  164. item['triggerMethod'] = '全部满足时触发'
  165. }
  166. })
  167. })
  168. </script>
  169. <style scoped lang="scss">
  170. @import '/@/theme/tableStyle.scss';
  171. </style>