HandlerHistoryTable.vue 5.4 KB

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