WorkFaceAlarmHistoryTable.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. const globalConfig = inject('globalConfig');
  19. const props = defineProps({
  20. columnsType: {
  21. type: String,
  22. required: true,
  23. },
  24. deviceType: {
  25. type: String,
  26. required: true,
  27. },
  28. deviceListApi: {
  29. type: Function,
  30. default: (params) => defHttp.get({ url: '/safety/ventanalyManageSystem/linkdevicelist', params }),
  31. },
  32. designScope: {
  33. type: String,
  34. },
  35. sysId: {
  36. type: String,
  37. },
  38. scroll: {
  39. type: Object,
  40. default: () => {},
  41. },
  42. list: {
  43. type: Function,
  44. default: (params) => defHttp.get({ url: '/safety/ventanalyAlarmLog/list', params }),
  45. },
  46. });
  47. const alarmHistory = ref();
  48. const columns = ref([]);
  49. const deviceOptions = ref([]);
  50. watch(
  51. () => {
  52. return props.columnsType;
  53. },
  54. (newVal) => {
  55. const column = getTableHeaderColumns(newVal + '_history');
  56. if (column && column.length < 1) {
  57. const arr = newVal.split('_');
  58. const columnKey = arr.reduce((prev, cur, index) => {
  59. if (index !== arr.length - 2) {
  60. return prev + '_' + cur;
  61. } else {
  62. return prev;
  63. }
  64. });
  65. columns.value = getTableHeaderColumns(arr[0] + '_history');
  66. } else {
  67. columns.value = column;
  68. }
  69. if (alarmHistory.value) reload();
  70. },
  71. {
  72. immediate: true,
  73. }
  74. );
  75. async function getDeviceList() {
  76. let result;
  77. debugger;
  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. label: '时间范围',
  129. field: 'createTime',
  130. component: 'RangePicker',
  131. defaultValue: [dayjs().subtract(1, 'day'), dayjs()],
  132. componentProps: {
  133. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  134. },
  135. },
  136. {
  137. label: '查询设备',
  138. field: 'deviceId',
  139. component: 'Select',
  140. defaultValue: deviceOptions.value[0] ? deviceOptions.value[0]['value'] : '',
  141. required: true,
  142. componentProps: {
  143. options: deviceOptions,
  144. },
  145. },
  146. // {
  147. // label: '查询设备',
  148. // field: 'deviceId',
  149. // component: 'ApiSelect',
  150. // componentProps: {
  151. // api: props.deviceListApi,
  152. // resultField: 'records',
  153. // labelField: 'strname',
  154. // valueField: 'id',
  155. // },
  156. // },
  157. ],
  158. fieldMapToTime: [['createTime', ['starttime', 'endtime'], '']],
  159. },
  160. fetchSetting: {
  161. listField: 'records',
  162. },
  163. pagination: {
  164. current: 1,
  165. pageSize: 10,
  166. pageSizeOptions: ['10', '30', '50', '100'],
  167. },
  168. beforeFetch(params) {
  169. params.devicetype = props.deviceType + '*';
  170. if (props.sysId) {
  171. params.sysId = props.sysId;
  172. }
  173. },
  174. },
  175. exportConfig: {
  176. name: '预警历史列表',
  177. url: '/safety/ventanalyAlarmLog/exportXls',
  178. },
  179. });
  180. //注册table数据
  181. const [registerTable, { reload, setLoading, getForm }] = tableContext;
  182. onMounted(async () => {
  183. await getDeviceList();
  184. });
  185. defineExpose({ setLoading });
  186. </script>
  187. <style scoped lang="less">
  188. @ventSpace: zxm;
  189. :deep(.ventSpace-table-body) {
  190. height: auto !important;
  191. }
  192. :deep(.zxm-picker) {
  193. height: 30px !important;
  194. }
  195. .alarm-history-table {
  196. width: 100%;
  197. :deep(.jeecg-basic-table-form-container) {
  198. .@{ventSpace}-form {
  199. padding: 0 !important;
  200. border: none !important;
  201. margin-bottom: 0 !important;
  202. .@{ventSpace}-picker,
  203. .@{ventSpace}-select-selector {
  204. width: 100% !important;
  205. background: #00000017;
  206. border: 1px solid #b7b7b7;
  207. input,
  208. .@{ventSpace}-select-selection-item,
  209. .@{ventSpace}-picker-suffix {
  210. color: #fff;
  211. }
  212. .@{ventSpace}-select-selection-placeholder {
  213. color: #ffffffaa;
  214. }
  215. }
  216. }
  217. .@{ventSpace}-table-title {
  218. min-height: 0 !important;
  219. }
  220. }
  221. }
  222. </style>