AlarmHistoryTable.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="alarm-history-table">
  3. <BasicTable ref="alarmHistory" @register="registerTable" />
  4. </div>
  5. </template>
  6. <script lang="ts" name="system-user" setup>
  7. //ts语法
  8. import { watch, ref, defineExpose } from 'vue'
  9. import { BasicTable } from '/@/components/Table';
  10. import { useListPage } from '/@/hooks/system/useListPage';
  11. import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  12. import { defHttp } from '/@/utils/http/axios';
  13. import { prefetchApps } from 'qiankun';
  14. const list = (params) => defHttp.get({ url: '/safety/ventanalyAlarmLog/list', params });
  15. const props = defineProps({
  16. columnsType: {
  17. type: String,
  18. required: true,
  19. },
  20. deviceType: {
  21. type: String,
  22. required: true,
  23. },
  24. deviceListApi: {
  25. type: Function,
  26. required: true,
  27. },
  28. designScope: {
  29. type: String,
  30. },
  31. sysId: {
  32. type: String,
  33. },
  34. scroll: {
  35. type: Object,
  36. default: () => { }
  37. }
  38. });
  39. const alarmHistory = ref()
  40. const columns = ref([])
  41. watch(
  42. () => {
  43. return props.columnsType;
  44. },
  45. (newVal) => {
  46. const column = getTableHeaderColumns(newVal + '_history')
  47. if (column && column.length < 1) {
  48. const arr = newVal.split('_')
  49. const columnKey = arr.reduce((prev, cur, index) => {
  50. if (index !== arr.length - 2) {
  51. return prev + '_' + cur
  52. } else {
  53. return prev
  54. }
  55. })
  56. columns.value = getTableHeaderColumns(arr[0] + '_history');
  57. } else {
  58. columns.value = column
  59. }
  60. if (alarmHistory.value) reload()
  61. },
  62. {
  63. immediate: true
  64. }
  65. );
  66. // 列表页面公共参数、方法
  67. const { tableContext } = useListPage({
  68. tableProps: {
  69. api: list,
  70. columns: columns,
  71. canResize: true,
  72. showTableSetting: false,
  73. showActionColumn: false,
  74. bordered: false,
  75. size: 'small',
  76. scroll: props.scroll,
  77. formConfig: {
  78. labelAlign: 'left',
  79. showAdvancedButton: false,
  80. // autoAdvancedCol: 2,
  81. schemas: [
  82. {
  83. label: '时间范围',
  84. field: 'createTime',
  85. component: 'RangePicker',
  86. componentProps: {
  87. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  88. },
  89. },
  90. {
  91. label: '查询设备',
  92. field: 'gdeviceid',
  93. component: 'ApiSelect',
  94. componentProps: {
  95. api: props.deviceListApi,
  96. resultField: 'records',
  97. labelField: 'strname',
  98. valueField: 'id',
  99. },
  100. },
  101. ],
  102. fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], '']],
  103. },
  104. fetchSetting: {
  105. listField: 'records',
  106. },
  107. pagination: {
  108. current: 1,
  109. pageSize: 10,
  110. pageSizeOptions: ['5', '10', '20'],
  111. },
  112. beforeFetch(params) {
  113. params.gdevicetype = props.deviceType + '*';
  114. if (props.sysId) {
  115. params.sysId = props.sysId;
  116. }
  117. },
  118. },
  119. });
  120. //注册table数据
  121. const [registerTable, { reload, setLoading }] = tableContext;
  122. defineExpose({ setLoading })
  123. </script>
  124. <style scoped lang="less">
  125. @ventSpace: zxm;
  126. :deep(.ventSpace-table-body) {
  127. height: auto !important;
  128. }
  129. :deep(.zxm-picker){
  130. height: 30px !important;
  131. }
  132. .alarm-history-table {
  133. width: 100%;
  134. :deep(.jeecg-basic-table-form-container) {
  135. .@{ventSpace}-form {
  136. padding: 0 !important;
  137. border: none !important;
  138. margin-bottom: 0 !important;
  139. .@{ventSpace}-picker,
  140. .@{ventSpace}-select-selector {
  141. width: 100% !important;
  142. background: #00000017;
  143. border: 1px solid #b7b7b7;
  144. input,
  145. .@{ventSpace}-select-selection-item,
  146. .@{ventSpace}-picker-suffix {
  147. color: #fff;
  148. }
  149. .@{ventSpace}-select-selection-placeholder {
  150. color: #ffffffaa;
  151. }
  152. }
  153. }
  154. .@{ventSpace}-table-title {
  155. min-height: 0 !important;
  156. }
  157. }
  158. }
  159. </style>