WorkFaceAlarmHistoryTable.vue 4.1 KB

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