HandlerHistoryTable.vue 5.2 KB

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