component.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <customHeader
  3. :fieldNames="{ label: 'systemname', value: 'id', options: 'children' }"
  4. :options="options"
  5. :optionValue="optionValue"
  6. @change="changeSelectRow"
  7. >
  8. {{ mainTitle }}
  9. </customHeader>
  10. <div class="bg" style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden">
  11. <a-spin :spinning="loading" />
  12. <div id="model3D" v-show="!loading" style="width: 100%; height: 100%; position: absolute; overflow: hidden"></div>
  13. <slot name="monitorSlot3D"></slot>
  14. </div>
  15. <div class="scene-box">
  16. <div class="center-container">
  17. <template v-if="activeKey == 'monitor'">
  18. <!-- <balancePressHome v-if="activeKey == 'monitor'" :deviceId="optionValue" /> -->
  19. </template>
  20. <div v-else class="history-group">
  21. <div class="device-button-group" v-if="deviceList.length > 0">
  22. <div
  23. class="device-button"
  24. :class="{ 'device-active': deviceActive == device.deviceType }"
  25. v-for="(device, index) in deviceList"
  26. :key="index"
  27. @click="deviceChange(index)"
  28. >{{ device.deviceName }}</div
  29. >
  30. </div>
  31. <div class="history-container">
  32. <HistoryTable
  33. v-if="activeKey == 'monitor_history'"
  34. class="vent-margin-t-20"
  35. :columns-type="`${deviceType}`"
  36. :device-type="deviceType"
  37. :sysId="optionValue"
  38. :scroll="{ y: 650 }"
  39. :only-bouned-devices="monitorHistoryConfig.onlyBounedDevices"
  40. :show-history-curve="monitorHistoryConfig.showHistoryCurve"
  41. />
  42. <HandlerHistoryTable
  43. v-if="activeKey == 'handler_history'"
  44. class="vent-margin-t-20"
  45. columns-type="operator_history"
  46. :deviceType="deviceType"
  47. :device-list-api="getHandlerList"
  48. />
  49. <AlarmHistoryTable
  50. v-if="activeKey == 'faultRecord'"
  51. columns-type="alarm"
  52. :device-type="deviceType"
  53. :list="getAlarmList"
  54. :sys-id="optionValue"
  55. :device-list-api="workFaceDeviceList.bind(null, { id: optionValue })"
  56. designScope="alarm-history"
  57. />
  58. </div>
  59. </div>
  60. </div>
  61. <BottomMenu @change="changeActive" />
  62. </div>
  63. </template>
  64. <script setup lang="ts">
  65. import customHeader from '/@/components/vent/customHeader.vue';
  66. import { ref, onMounted, onUnmounted } from 'vue';
  67. import { getDevice, sysList } from '../comment/comment.api';
  68. import BottomMenu from '/@/views/vent/comment/components/bottomMenu.vue';
  69. // import balancePressHome from './components/balancePressHome.vue';
  70. import HistoryTable from '../comment/HistoryTable.vue';
  71. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  72. import { useRouter } from 'vue-router';
  73. import { Config } from '../../deviceManager/configurationTable/types';
  74. import { defHttp } from '/@/utils/http/axios';
  75. import { workFaceDeviceList } from '../../deviceManager/comment/warningTabel/warning.api';
  76. type DeviceType = { deviceType: string; deviceName: string; datalist: any[] };
  77. const props = withDefaults(
  78. defineProps<{
  79. mainTitle: string;
  80. /** 获取各表格配置时依赖的设备类型 */
  81. // deviceType: string;
  82. /** 主要模块配置 */
  83. mainConfig: {
  84. configs: Config[];
  85. };
  86. /** 历史数据配置 */
  87. monitorHistoryConfig: {
  88. /** 请求历史数据时传入的类型字符 */
  89. columnsType: string;
  90. /** 仅展示已绑定设备,选择是则从系统中获取sysId下已绑定设备。仅能查询到已绑定设备的历史数据 */
  91. onlyBounedDevices: boolean;
  92. /** 显示历史数据曲线图 */
  93. showHistoryCurve: boolean;
  94. };
  95. /** 操作历史配置 */
  96. handlerHistoryConfig: {
  97. /** 请求操作历史时传入的类型字符 */
  98. columnsType: string;
  99. };
  100. /** 报警历史配置 */
  101. alarmHistoryConfig: {
  102. /** 请求报警历史时传入的类型字符 */
  103. columnsType: string;
  104. };
  105. /** 请求场景数据传入的类型字符 */
  106. strtype: string;
  107. /** 请求场景数据传入的页面类型字符 */
  108. pagetype: string;
  109. }>(),
  110. {
  111. pagetype: 'normal',
  112. onlyBounedDevices: false,
  113. showHistoryCurve: false,
  114. }
  115. );
  116. const { currentRoute } = useRouter();
  117. const loading = ref(false);
  118. const activeKey = ref('monitor');
  119. function changeActive(activeValue) {
  120. activeKey.value = activeValue;
  121. }
  122. const options = ref([]);
  123. const optionValue = ref('');
  124. async function getSysDataSource() {
  125. const res = await sysList({ strtype: props.strtype, pagetype: props.pagetype });
  126. // 初始时选择第一条数据
  127. options.value = res.records || [];
  128. if (!optionValue.value) {
  129. changeSelectRow(options.value[0]['id']);
  130. }
  131. }
  132. // 切换检测数据
  133. function changeSelectRow(deviceID) {
  134. optionValue.value = deviceID;
  135. getDeviceList();
  136. }
  137. //关联设备
  138. const deviceList = ref<DeviceType[]>([]);
  139. const deviceActive = ref('');
  140. const deviceType = ref('');
  141. function deviceChange(index) {
  142. deviceType.value = deviceList.value[index].deviceType;
  143. deviceActive.value = deviceList.value[index].deviceType;
  144. }
  145. // 查询关联设备列表
  146. async function getDeviceList() {
  147. const { msgTxt = [] } = await getDevice({ devicetype: 'sys', systemID: optionValue.value });
  148. deviceList.value = msgTxt.reduce((arr, item) => {
  149. const data = item.datalist.forEach((data: any) => {
  150. return Object.assign(data, data.readData);
  151. });
  152. // sys代表场景本身,应该过滤掉去处理该场景下的关联设备
  153. if (item.type != 'sys') {
  154. arr.unshift({
  155. deviceType: item.type,
  156. deviceName: item.typeName || item.datalist[0].typeName,
  157. datalist: data,
  158. });
  159. }
  160. return arr;
  161. });
  162. if (!deviceActive.value) {
  163. deviceChange(0);
  164. }
  165. }
  166. /** 获取操作历史 */
  167. function getHandlerList() {
  168. return sysList({ strtype: deviceType.value });
  169. }
  170. function getAlarmList() {
  171. return (params) => defHttp.get({ url: '/safety/managesysAutoLog/list', params });
  172. }
  173. onMounted(() => {
  174. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) {
  175. optionValue.value = currentRoute.value['query']['id'] as string;
  176. }
  177. getSysDataSource();
  178. });
  179. onUnmounted(() => {});
  180. </script>
  181. <style lang="less" scoped>
  182. @import '/@/design/vent/modal.less';
  183. @ventSpace: zxm;
  184. .scene-box {
  185. margin-top: 20px;
  186. pointer-events: none;
  187. .history-group {
  188. padding: 0 20px;
  189. .history-container {
  190. pointer-events: auto;
  191. position: relative;
  192. background: #6195af1a;
  193. width: calc(100% + 10px);
  194. top: 0px;
  195. left: -10px;
  196. border: 1px solid #00fffd22;
  197. padding: 10px 0;
  198. box-shadow: 0 0 20px #44b4ff33 inset;
  199. }
  200. }
  201. .device-button-group {
  202. // margin: 0 20px;
  203. display: flex;
  204. pointer-events: auto;
  205. position: relative;
  206. margin-top: 90px;
  207. &::after {
  208. position: absolute;
  209. content: '';
  210. width: calc(100% + 10px);
  211. height: 2px;
  212. top: 30px;
  213. left: -10px;
  214. border-bottom: 1px solid #0efcff;
  215. }
  216. .device-button {
  217. padding: 4px 15px;
  218. position: relative;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. font-size: 14px;
  223. color: #fff;
  224. cursor: pointer;
  225. margin: 0 3px;
  226. &::before {
  227. content: '';
  228. position: absolute;
  229. top: 0;
  230. right: 0;
  231. bottom: 0;
  232. left: 0;
  233. border: 1px solid #6176af;
  234. transform: skewX(-38deg);
  235. background-color: rgba(0, 77, 103, 85%);
  236. z-index: -1;
  237. }
  238. }
  239. .device-active {
  240. // color: #0efcff;
  241. &::before {
  242. border-color: #0efcff;
  243. box-shadow: 1px 1px 3px 1px #0efcff inset;
  244. }
  245. }
  246. }
  247. }
  248. .center-container {
  249. width: 100%;
  250. height: calc(100% - 200px);
  251. }
  252. .input-box {
  253. display: flex;
  254. align-items: center;
  255. padding-left: 10px;
  256. .input-title {
  257. color: #73e8fe;
  258. width: auto;
  259. }
  260. .@{ventSpace}-input-number {
  261. border-color: #ffffff88 !important;
  262. }
  263. margin-right: 10px;
  264. }
  265. </style>