HandlerHistoryTable.vue 4.2 KB

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