AlarmHistoryTable.vue 4.5 KB

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