WorkFaceAlarmHistoryTable.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div class="alarm-history-table">
  3. <BasicTable ref="alarmHistory" @register="registerTable">
  4. <template #form-onExportXls>
  5. <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls()"> 导出</a-button>
  6. </template>
  7. </BasicTable>
  8. </div>
  9. </template>
  10. <script lang="ts" name="system-user" setup>
  11. //ts语法
  12. import { watch, ref, defineExpose, onMounted, inject } from 'vue';
  13. import { BasicTable } from '/@/components/Table';
  14. import { useListPage } from '/@/hooks/system/useListPage';
  15. import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  16. import { defHttp } from '/@/utils/http/axios';
  17. import dayjs from 'dayjs';
  18. import { getAutoScrollContainer } from '/@/utils/common/compUtils';
  19. const globalConfig = inject('globalConfig');
  20. const props = defineProps({
  21. columnsType: {
  22. type: String,
  23. required: true,
  24. },
  25. deviceType: {
  26. type: String,
  27. required: true,
  28. },
  29. deviceListApi: {
  30. type: Function,
  31. default: (params) => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params }),
  32. },
  33. designScope: {
  34. type: String,
  35. },
  36. sysId: {
  37. type: String,
  38. },
  39. scroll: {
  40. type: Object,
  41. default: () => {},
  42. },
  43. list: {
  44. type: Function,
  45. default: (params) => defHttp.get({ url: '/safety/ventanalyAlarmLog/list', params }),
  46. },
  47. });
  48. const alarmHistory = ref();
  49. const columns = ref([]);
  50. const deviceOptions = ref([]);
  51. watch(
  52. () => {
  53. return props.columnsType;
  54. },
  55. (newVal) => {
  56. const column = getTableHeaderColumns(newVal + '_history');
  57. if (column && column.length < 1) {
  58. const arr = newVal.split('_');
  59. const columnKey = arr.reduce((prev, cur, index) => {
  60. if (index !== arr.length - 2) {
  61. return prev + '_' + cur;
  62. } else {
  63. return prev;
  64. }
  65. });
  66. columns.value = getTableHeaderColumns(arr[0] + '_history');
  67. } else {
  68. columns.value = column;
  69. }
  70. if (alarmHistory.value) reload();
  71. },
  72. {
  73. immediate: true,
  74. }
  75. );
  76. async function getDeviceList() {
  77. let result;
  78. if (globalConfig.History_Type == 'vent') {
  79. if (props.deviceListApi) {
  80. result = await props.deviceListApi();
  81. } else {
  82. result = await defHttp.get({
  83. url: '/safety/ventanalyManageSystem/linkdevicelist',
  84. params: { sysId: props.sysId, deviceType: props.deviceType, pageSize: 9999 },
  85. });
  86. }
  87. } else {
  88. result = await defHttp.get({
  89. url: '/safety/ventanalyManageSystem/linkdevicelist',
  90. params: { sysId: props.sysId, deviceType: props.deviceType.startsWith('vehicle') ? 'location_normal' : props.deviceType },
  91. });
  92. }
  93. if (result) {
  94. deviceOptions.value = [];
  95. deviceOptions.value = result.map((item) => {
  96. return {
  97. label: item['strname'],
  98. value: item['id'],
  99. strtype: item['strtype'],
  100. strinstallpos: item['strinstallpos'],
  101. devicekind: item['devicekind'],
  102. };
  103. // return { label: item['strname'], value: item['id']}
  104. });
  105. // globalConfig.History_Type == 'vent' && deviceOptions.value[0]
  106. // ? getForm().setFieldsValue({ deviceId: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '' })
  107. // : getForm().setFieldsValue({ deviceId: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '' });
  108. getForm().setFieldsValue({ deviceId: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '' });
  109. }
  110. }
  111. // 列表页面公共参数、方法
  112. const { tableContext, onExportXls } = useListPage({
  113. tableProps: {
  114. api: props.list,
  115. columns: columns,
  116. canResize: true,
  117. showTableSetting: false,
  118. showActionColumn: false,
  119. showIndexColumn: true,
  120. bordered: false,
  121. size: 'small',
  122. scroll: props.scroll,
  123. formConfig: {
  124. labelAlign: 'left',
  125. showAdvancedButton: false,
  126. // autoAdvancedCol: 2,
  127. schemas: [
  128. {
  129. field: 'createTime_begin',
  130. label: '开始时间',
  131. component: 'DatePicker',
  132. defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  133. required: true,
  134. componentProps: {
  135. showTime: true,
  136. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  137. getPopupContainer: getAutoScrollContainer,
  138. },
  139. colProps: {
  140. span: 4,
  141. },
  142. },
  143. {
  144. field: 'createTime_end',
  145. label: '结束时间',
  146. component: 'DatePicker',
  147. defaultValue: dayjs(),
  148. required: true,
  149. componentProps: {
  150. showTime: true,
  151. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  152. getPopupContainer: getAutoScrollContainer,
  153. },
  154. colProps: {
  155. span: 4,
  156. },
  157. },
  158. {
  159. label: '查询设备',
  160. field: 'gdeviceid',
  161. component: 'Select',
  162. defaultValue: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '',
  163. componentProps: {
  164. options: deviceOptions,
  165. },
  166. colProps: {
  167. span: 4,
  168. },
  169. },
  170. ],
  171. },
  172. fetchSetting: {
  173. listField: 'records',
  174. },
  175. pagination: {
  176. current: 1,
  177. pageSize: 10,
  178. pageSizeOptions: ['10', '30', '50', '100'],
  179. },
  180. beforeFetch(params) {
  181. params.devicetype = props.deviceType + '*';
  182. if (props.sysId) {
  183. params.sysId = props.sysId;
  184. }
  185. },
  186. },
  187. exportConfig: {
  188. name: '预警历史列表',
  189. url: '/safety/ventanalyAlarmLog/exportXls',
  190. },
  191. });
  192. //注册table数据
  193. const [registerTable, { reload, setLoading, getForm }] = tableContext;
  194. onMounted(async () => {
  195. await getDeviceList();
  196. });
  197. defineExpose({ setLoading });
  198. </script>
  199. <style scoped lang="less">
  200. @ventSpace: zxm;
  201. :deep(.ventSpace-table-body) {
  202. height: auto !important;
  203. }
  204. :deep(.zxm-picker) {
  205. height: 30px !important;
  206. }
  207. .alarm-history-table {
  208. width: 100%;
  209. :deep(.jeecg-basic-table-form-container) {
  210. .@{ventSpace}-form {
  211. padding: 0 !important;
  212. border: none !important;
  213. margin-bottom: 0 !important;
  214. .@{ventSpace}-picker,
  215. .@{ventSpace}-select-selector {
  216. width: 100% !important;
  217. background: #00000017;
  218. border: 1px solid #b7b7b7;
  219. input,
  220. .@{ventSpace}-select-selection-item,
  221. .@{ventSpace}-picker-suffix {
  222. color: #fff;
  223. }
  224. .@{ventSpace}-select-selection-placeholder {
  225. color: #ffffffaa;
  226. }
  227. }
  228. }
  229. .@{ventSpace}-table-title {
  230. min-height: 0 !important;
  231. }
  232. }
  233. }
  234. </style>