HandlerHistoryTable.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. debugger
  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. // 列表页面公共参数、方法
  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. baseColProps: {
  81. // offset: 0.5,
  82. xs: 24,
  83. sm: 24,
  84. md: 24,
  85. lg: 9,
  86. xl: 7,
  87. xxl: 4,
  88. },
  89. schemas: [
  90. {
  91. label: '时间范围',
  92. field: 'createTime',
  93. component: 'RangePicker',
  94. componentProps: {
  95. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  96. },
  97. },
  98. {
  99. label: '查询设备',
  100. field: 'gdeviceid',
  101. component: 'ApiSelect',
  102. componentProps: {
  103. api: props.deviceListApi,
  104. resultField: 'records',
  105. labelField: 'strname',
  106. valueField: 'id',
  107. },
  108. },
  109. ],
  110. fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], '']],
  111. },
  112. fetchSetting: {
  113. listField: 'records',
  114. },
  115. pagination: {
  116. current: 1,
  117. pageSize: 10,
  118. pageSizeOptions: ['5', '10', '20'],
  119. },
  120. beforeFetch(params) {
  121. params.gdevicetype = props.deviceType + '*';
  122. if (props.sysId) {
  123. params.sysId = props.sysId;
  124. }
  125. },
  126. },
  127. });
  128. //注册table数据
  129. const [registerTable, { reload, setLoading }] = tableContext;
  130. defineExpose({ setLoading })
  131. </script>
  132. <style scoped lang="less">
  133. @ventSpace: zxm;
  134. // :deep(.@{ventSpace}-table-body) {
  135. // height: auto !important;
  136. // }
  137. :deep(.zxm-picker){
  138. height: 30px !important;
  139. }
  140. .handler-history-table {
  141. width: 100%;
  142. :deep(.jeecg-basic-table-form-container) {
  143. .@{ventSpace}-form {
  144. padding: 0 !important;
  145. border: none !important;
  146. margin-bottom: 0 !important;
  147. .@{ventSpace}-picker,
  148. .@{ventSpace}-select-selector {
  149. width: 100% !important;
  150. height: 100%;
  151. background: #00000017;
  152. border: 1px solid #b7b7b7;
  153. input,
  154. .@{ventSpace}-select-selection-item,
  155. .@{ventSpace}-picker-suffix {
  156. color: #fff;
  157. }
  158. .@{ventSpace}-select-selection-placeholder {
  159. color: #ffffffaa;
  160. }
  161. }
  162. }
  163. .@{ventSpace}-table-title {
  164. min-height: 0 !important;
  165. }
  166. }
  167. }
  168. </style>