HandlerHistoryTable.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="handler-history-table">
  3. <BasicTable ref="handlerHistory" @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 list = (params) => defHttp.get({ url: '/safety/ventanalyDevicesetLog/list', params });
  14. const props = defineProps({
  15. columnsType: {
  16. type: String,
  17. required: true,
  18. },
  19. deviceType: {
  20. type: String,
  21. required: true,
  22. },
  23. deviceListApi: {
  24. type: Function,
  25. required: true,
  26. },
  27. designScope: {
  28. type: String,
  29. },
  30. sysId: {
  31. type: String,
  32. },
  33. scroll: {
  34. type: Object,
  35. default: { y: 0 }
  36. }
  37. });
  38. const handlerHistory = ref()
  39. const columns = ref([])
  40. const tableScroll = props.scroll.y ? ref({ y: props.scroll.y - 100 }) : ref({})
  41. watch(
  42. () => {
  43. return props.columnsType;
  44. },
  45. (newVal) => {
  46. const column = getTableHeaderColumns(newVal)
  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 (handlerHistory.value) reload()
  61. },
  62. {
  63. immediate: true
  64. }
  65. );
  66. watch(() => props.scroll.y, (newVal) => {
  67. if (newVal) {
  68. tableScroll.value = { y: newVal - 100 }
  69. } else {
  70. tableScroll.value = {}
  71. }
  72. })
  73. // 列表页面公共参数、方法
  74. const { tableContext } = useListPage({
  75. tableProps: {
  76. api: list,
  77. columns: columns,
  78. canResize: true,
  79. showTableSetting: false,
  80. showActionColumn: false,
  81. bordered: false,
  82. size: 'small',
  83. scroll: tableScroll,
  84. formConfig: {
  85. labelAlign: 'left',
  86. showAdvancedButton: false,
  87. baseColProps: {
  88. // offset: 0.5,
  89. xs: 24,
  90. sm: 24,
  91. md: 24,
  92. lg: 9,
  93. xl: 7,
  94. xxl: 4,
  95. },
  96. schemas: [
  97. {
  98. label: '时间范围',
  99. field: 'createTime',
  100. component: 'RangePicker',
  101. componentProps: {
  102. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  103. },
  104. },
  105. // {
  106. // label: '查询设备',
  107. // field: 'gdeviceid',
  108. // component: 'ApiSelect',
  109. // componentProps: {
  110. // api: props.deviceListApi,
  111. // resultField: 'records',
  112. // labelField: 'strname',
  113. // valueField: 'id',
  114. // },
  115. // },
  116. ],
  117. fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], '']],
  118. },
  119. fetchSetting: {
  120. listField: 'records',
  121. },
  122. pagination: {
  123. current: 1,
  124. pageSize: 10,
  125. pageSizeOptions: ['10', '30', '50', '100'],
  126. },
  127. beforeFetch(params) {
  128. params.devicetype = props.deviceType + '*';
  129. if (props.sysId) {
  130. params.sysId = props.sysId;
  131. }
  132. },
  133. },
  134. });
  135. //注册table数据
  136. const [registerTable, { reload, setLoading }] = tableContext;
  137. defineExpose({ setLoading })
  138. </script>
  139. <style scoped lang="less">
  140. @ventSpace: zxm;
  141. // :deep(.@{ventSpace}-table-body) {
  142. // height: auto !important;
  143. // }
  144. :deep(.zxm-picker){
  145. height: 30px !important;
  146. }
  147. .handler-history-table {
  148. width: 100%;
  149. :deep(.jeecg-basic-table-form-container) {
  150. .@{ventSpace}-form {
  151. padding: 0 !important;
  152. border: none !important;
  153. margin-bottom: 0 !important;
  154. .@{ventSpace}-picker,
  155. .@{ventSpace}-select-selector {
  156. width: 100% !important;
  157. height: 100%;
  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>