WorkFaceHandlerHistoryTable.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. 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. field: 'createTime_begin',
  92. label: '开始时间',
  93. component: 'DatePicker',
  94. defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  95. required: true,
  96. componentProps: {
  97. showTime: true,
  98. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  99. getPopupContainer: getAutoScrollContainer,
  100. },
  101. colProps: {
  102. span: 4,
  103. },
  104. },
  105. {
  106. field: 'createTime_end',
  107. label: '结束时间',
  108. component: 'DatePicker',
  109. defaultValue: dayjs(),
  110. required: true,
  111. componentProps: {
  112. showTime: true,
  113. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  114. getPopupContainer: getAutoScrollContainer,
  115. },
  116. colProps: {
  117. span: 4,
  118. },
  119. },
  120. ],
  121. fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], '']],
  122. },
  123. fetchSetting: {
  124. listField: 'records',
  125. },
  126. pagination: {
  127. current: 1,
  128. pageSize: 10,
  129. pageSizeOptions: ['10', '30', '50', '100'],
  130. },
  131. beforeFetch(params) {
  132. params.devicetype = props.deviceType + '*';
  133. if (props.sysId) {
  134. params.sysId = props.sysId;
  135. }
  136. },
  137. },
  138. });
  139. //注册table数据
  140. const [registerTable, { reload, setLoading }] = tableContext;
  141. defineExpose({ setLoading });
  142. </script>
  143. <style scoped lang="less">
  144. @ventSpace: zxm;
  145. // :deep(.@{ventSpace}-table-body) {
  146. // height: auto !important;
  147. // }
  148. :deep(.zxm-picker) {
  149. height: 30px !important;
  150. }
  151. .handler-history-table {
  152. width: 100%;
  153. :deep(.jeecg-basic-table-form-container) {
  154. .@{ventSpace}-form {
  155. padding: 0 !important;
  156. border: none !important;
  157. margin-bottom: 0 !important;
  158. .@{ventSpace}-picker,
  159. .@{ventSpace}-select-selector {
  160. width: 100% !important;
  161. height: 100%;
  162. background: #00000017;
  163. border: 1px solid #b7b7b7;
  164. input,
  165. .@{ventSpace}-select-selection-item,
  166. .@{ventSpace}-picker-suffix {
  167. color: #fff;
  168. }
  169. .@{ventSpace}-select-selection-placeholder {
  170. color: #ffffffaa;
  171. }
  172. }
  173. }
  174. .@{ventSpace}-table-title {
  175. min-height: 0 !important;
  176. }
  177. }
  178. }
  179. </style>