WorkFaceHandlerHistoryTable.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. import { getAutoScrollContainer } from '/@/utils/common/compUtils';
  14. import dayjs from 'dayjs';
  15. const list = (params) => defHttp.get({ url: '/safety/ventanalyDevicesetLog/list', params });
  16. const props = defineProps({
  17. columnsType: {
  18. type: String,
  19. required: true,
  20. },
  21. deviceType: {
  22. type: String,
  23. required: true,
  24. },
  25. deviceListApi: {
  26. type: Function,
  27. },
  28. designScope: {
  29. type: String,
  30. },
  31. sysId: {
  32. type: String,
  33. },
  34. scroll: {
  35. type: Object,
  36. default: () => {},
  37. },
  38. });
  39. const handlerHistory = ref();
  40. const columns = 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. // 列表页面公共参数、方法
  67. const { tableContext } = useListPage({
  68. tableProps: {
  69. api: list,
  70. columns: columns,
  71. canResize: true,
  72. showTableSetting: false,
  73. showActionColumn: false,
  74. showIndexColumn: true,
  75. bordered: false,
  76. size: 'small',
  77. scroll: props.scroll,
  78. formConfig: {
  79. labelAlign: 'left',
  80. showAdvancedButton: false,
  81. baseColProps: {
  82. // offset: 0.5,
  83. xs: 24,
  84. sm: 24,
  85. md: 24,
  86. lg: 9,
  87. xl: 7,
  88. xxl: 4,
  89. },
  90. schemas: [
  91. {
  92. field: 'createTime_begin',
  93. label: '开始时间',
  94. component: 'DatePicker',
  95. defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  96. required: true,
  97. componentProps: {
  98. showTime: true,
  99. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  100. getPopupContainer: getAutoScrollContainer,
  101. },
  102. colProps: {
  103. span: 4,
  104. },
  105. },
  106. {
  107. field: 'createTime_end',
  108. label: '结束时间',
  109. component: 'DatePicker',
  110. defaultValue: dayjs(),
  111. required: true,
  112. componentProps: {
  113. showTime: true,
  114. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  115. getPopupContainer: getAutoScrollContainer,
  116. },
  117. colProps: {
  118. span: 4,
  119. },
  120. },
  121. ],
  122. fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], '']],
  123. },
  124. fetchSetting: {
  125. listField: 'records',
  126. },
  127. pagination: {
  128. current: 1,
  129. pageSize: 10,
  130. pageSizeOptions: ['10', '30', '50', '100'],
  131. },
  132. beforeFetch(params) {
  133. params.devicetype = props.deviceType + '*';
  134. if (props.sysId) {
  135. params.sysId = props.sysId;
  136. }
  137. },
  138. },
  139. });
  140. //注册table数据
  141. const [registerTable, { reload, setLoading }] = tableContext;
  142. defineExpose({ setLoading });
  143. </script>
  144. <style scoped lang="less">
  145. @ventSpace: zxm;
  146. // :deep(.@{ventSpace}-table-body) {
  147. // height: auto !important;
  148. // }
  149. :deep(.zxm-picker) {
  150. height: 30px !important;
  151. }
  152. .handler-history-table {
  153. width: 100%;
  154. :deep(.jeecg-basic-table-form-container) {
  155. .@{ventSpace}-form {
  156. padding: 0 !important;
  157. border: none !important;
  158. margin-bottom: 0 !important;
  159. .@{ventSpace}-picker,
  160. .@{ventSpace}-select-selector {
  161. width: 100% !important;
  162. height: 100%;
  163. background: #00000017;
  164. border: 1px solid #b7b7b7;
  165. input,
  166. .@{ventSpace}-select-selection-item,
  167. .@{ventSpace}-picker-suffix {
  168. color: #fff;
  169. }
  170. .@{ventSpace}-select-selection-placeholder {
  171. color: #ffffffaa;
  172. }
  173. }
  174. }
  175. .@{ventSpace}-table-title {
  176. min-height: 0 !important;
  177. }
  178. }
  179. }
  180. </style>