HandlerHistoryTable.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. showIndexColumn: true,
  91. bordered: false,
  92. size: 'small',
  93. scroll: tableScroll,
  94. formConfig: {
  95. labelAlign: 'left',
  96. showAdvancedButton: false,
  97. baseColProps: {
  98. // offset: 0.5,
  99. xs: 24,
  100. sm: 24,
  101. md: 24,
  102. lg: 9,
  103. xl: 7,
  104. xxl: 4,
  105. },
  106. schemas: [
  107. {
  108. field: 'createTime_begin',
  109. label: '开始时间',
  110. component: 'DatePicker',
  111. defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  112. required: true,
  113. componentProps: {
  114. showTime: true,
  115. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  116. getPopupContainer: getAutoScrollContainer,
  117. },
  118. colProps: {
  119. span: 4,
  120. },
  121. },
  122. {
  123. field: 'createTime_end',
  124. label: '结束时间',
  125. component: 'DatePicker',
  126. defaultValue: dayjs(),
  127. required: true,
  128. componentProps: {
  129. showTime: true,
  130. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  131. getPopupContainer: getAutoScrollContainer,
  132. },
  133. colProps: {
  134. span: 4,
  135. },
  136. },
  137. // {
  138. // label: '查询设备',
  139. // field: 'gdeviceid',
  140. // component: 'ApiSelect',
  141. // componentProps: {
  142. // api: props.deviceListApi,
  143. // resultField: 'records',
  144. // labelField: 'strname',
  145. // valueField: 'id',
  146. // },
  147. // },
  148. ],
  149. },
  150. fetchSetting: {
  151. listField: 'records',
  152. },
  153. pagination: {
  154. current: 1,
  155. pageSize: 10,
  156. pageSizeOptions: ['10', '30', '50', '100'],
  157. },
  158. beforeFetch(params) {
  159. params.devicetype = props.deviceType + '*';
  160. if (props.sysId) {
  161. params.sysId = props.sysId;
  162. }
  163. if (props.deviceId) {
  164. params.deviceid = props.deviceId;
  165. }
  166. },
  167. },
  168. });
  169. //注册table数据
  170. const [registerTable, { reload, setLoading }] = tableContext;
  171. defineExpose({ setLoading });
  172. </script>
  173. <style scoped lang="less">
  174. @ventSpace: zxm;
  175. // :deep(.@{ventSpace}-table-body) {
  176. // height: auto !important;
  177. // }
  178. :deep(.zxm-picker) {
  179. height: 30px !important;
  180. }
  181. .handler-history-table {
  182. width: 100%;
  183. :deep(.jeecg-basic-table-form-container) {
  184. .@{ventSpace}-form {
  185. padding: 0 !important;
  186. border: none !important;
  187. margin-bottom: 0 !important;
  188. .@{ventSpace}-picker,
  189. .@{ventSpace}-select-selector {
  190. width: 100% !important;
  191. height: 100%;
  192. background: #00000017;
  193. border: 1px solid #b7b7b7;
  194. input,
  195. .@{ventSpace}-select-selection-item,
  196. .@{ventSpace}-picker-suffix {
  197. color: #fff;
  198. }
  199. .@{ventSpace}-select-selection-placeholder {
  200. color: #ffffffaa;
  201. }
  202. }
  203. }
  204. .@{ventSpace}-table-title {
  205. min-height: 0 !important;
  206. }
  207. }
  208. }
  209. </style>