WorkFaceAlarmHistoryTable.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. bordered: false,
  120. size: 'small',
  121. scroll: props.scroll,
  122. formConfig: {
  123. labelAlign: 'left',
  124. showAdvancedButton: false,
  125. // autoAdvancedCol: 2,
  126. schemas: [
  127. {
  128. field: 'createTime_begin',
  129. label: '开始时间',
  130. component: 'DatePicker',
  131. defaultValue: dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'),
  132. required: true,
  133. componentProps: {
  134. showTime: true,
  135. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  136. getPopupContainer: getAutoScrollContainer,
  137. },
  138. colProps: {
  139. span: 4,
  140. },
  141. },
  142. {
  143. field: 'createTime_end',
  144. label: '结束时间',
  145. component: 'DatePicker',
  146. defaultValue: dayjs(),
  147. required: true,
  148. componentProps: {
  149. showTime: true,
  150. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  151. getPopupContainer: getAutoScrollContainer,
  152. },
  153. colProps: {
  154. span: 4,
  155. },
  156. },
  157. {
  158. label: '查询设备',
  159. field: 'gdeviceid',
  160. component: 'Select',
  161. defaultValue: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '',
  162. componentProps: {
  163. options: deviceOptions,
  164. },
  165. colProps: {
  166. span: 4,
  167. },
  168. },
  169. ],
  170. },
  171. fetchSetting: {
  172. listField: 'records',
  173. },
  174. pagination: {
  175. current: 1,
  176. pageSize: 10,
  177. pageSizeOptions: ['10', '30', '50', '100'],
  178. },
  179. beforeFetch(params) {
  180. params.devicetype = props.deviceType + '*';
  181. if (props.sysId) {
  182. params.sysId = props.sysId;
  183. }
  184. },
  185. },
  186. exportConfig: {
  187. name: '预警历史列表',
  188. url: '/safety/ventanalyAlarmLog/exportXls',
  189. },
  190. });
  191. //注册table数据
  192. const [registerTable, { reload, setLoading, getForm }] = tableContext;
  193. onMounted(async () => {
  194. await getDeviceList();
  195. });
  196. defineExpose({ setLoading });
  197. </script>
  198. <style scoped lang="less">
  199. @ventSpace: zxm;
  200. :deep(.ventSpace-table-body) {
  201. height: auto !important;
  202. }
  203. :deep(.zxm-picker) {
  204. height: 30px !important;
  205. }
  206. .alarm-history-table {
  207. width: 100%;
  208. :deep(.jeecg-basic-table-form-container) {
  209. .@{ventSpace}-form {
  210. padding: 0 !important;
  211. border: none !important;
  212. margin-bottom: 0 !important;
  213. .@{ventSpace}-picker,
  214. .@{ventSpace}-select-selector {
  215. width: 100% !important;
  216. background: #00000017;
  217. border: 1px solid #b7b7b7;
  218. input,
  219. .@{ventSpace}-select-selection-item,
  220. .@{ventSpace}-picker-suffix {
  221. color: #fff;
  222. }
  223. .@{ventSpace}-select-selection-placeholder {
  224. color: #ffffffaa;
  225. }
  226. }
  227. }
  228. .@{ventSpace}-table-title {
  229. min-height: 0 !important;
  230. }
  231. }
  232. }
  233. </style>