fan-monitor.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <div class="fanMonitor">
  3. <div class="title-top" @click="getDetail">局部通风机监测与控制系统</div>
  4. <div class="toggle-search">
  5. <i class="icon-search">
  6. <SvgIcon class="icon" size="14" name="toggle" />
  7. </i>
  8. <a-select
  9. v-model:value="searchValue"
  10. style="width: 180px; margin-right: 10px"
  11. :options="fanTypeList"
  12. aria-placeholder="请选择"
  13. @change="changeSelect"
  14. />
  15. <div class="status-yx">
  16. <template v-if="fjStatus !== '断开' && fjStatus !== '-'">
  17. <div class="now-name">
  18. <i style="margin: 0px 5px 0px 5px">
  19. <SvgIcon class="icon" size="14" name="yxfj" />
  20. </i>
  21. <span style="color: #fff">运行风机</span>
  22. </div>
  23. <div class="now-status">{{ fjStatus }}</div>
  24. </template>
  25. <template v-else>
  26. <div v-if="fjStatus == '断开'" class="now-status" style="margin-left: 25px">断开</div>
  27. </template>
  28. </div>
  29. </div>
  30. <div class="fan-contents">
  31. <div v-if="!isShowGif" class="fan" ref="fan"></div>
  32. <img v-else src="@/assets/images/gif/fanlocal.gif" style="height: 100%; width: 100%" />
  33. </div>
  34. </div>
  35. </template>
  36. <script lang="ts" setup>
  37. import { ref, reactive, onMounted, nextTick, defineProps, watch } from 'vue';
  38. import { SvgIcon } from '/@/components/Icon';
  39. import * as echarts from 'echarts';
  40. import { useGo } from '/@/hooks/web/usePage';
  41. import { useGlobSetting } from '/@/hooks/setting';
  42. let props = defineProps({
  43. fandata: Array,
  44. });
  45. const emit = defineEmits(['goDetail']);
  46. const go = useGo();
  47. const { sysOrgCode } = useGlobSetting();
  48. let searchValue = ref('');
  49. let fanList = reactive<any[]>([]);
  50. let fanTypeList = reactive<any[]>([]); //下拉列表
  51. let fjStatus = ref(''); //运行风机
  52. const isShowGif = ref(false);
  53. //获取dom节点
  54. let fan = ref<any>();
  55. //echart图表数据
  56. let echartData = reactive<any>({
  57. xdata: 0,
  58. ydata: 0,
  59. });
  60. //跳转详情
  61. function getDetail() {
  62. emit('goDetail', 'fanLocal');
  63. }
  64. //选项切换
  65. function changeSelect(val) {
  66. searchValue.value = val;
  67. const selectData = fanList.find((item) => item['deviceID'] == val);
  68. if (selectData) {
  69. fjStatus.value =
  70. selectData.readData.Fan1StartStatus && selectData.readData.Fan1StartStatus == '1'
  71. ? sysOrgCode !== 'ymdnymdn'
  72. ? '主机'
  73. : '1#风机'
  74. : selectData.readData.Fan2StartStatus && selectData.readData.Fan2StartStatus == '1'
  75. ? sysOrgCode !== 'ymdnymdn'
  76. ? '备机'
  77. : '2#风机'
  78. : selectData.readData.Fan1StartStatus &&
  79. selectData.readData.Fan1StartStatus == '0' &&
  80. selectData.readData.Fan2StartStatus &&
  81. selectData.readData.Fan2StartStatus == '0'
  82. ? '断开'
  83. : '-';
  84. echartData.xdata = selectData.readData.windQuantity1 || selectData.readData.windQuantity1_merge;
  85. echartData.ydata = selectData.readData.windQuantity2 || selectData.readData.windQuantity2_merge;
  86. if (echartData.xdata && echartData.ydata) {
  87. getOption();
  88. } else {
  89. isShowGif.value = true;
  90. }
  91. } else {
  92. isShowGif.value = true;
  93. }
  94. }
  95. function getOption() {
  96. nextTick(() => {
  97. const myChart = echarts.init(fan.value);
  98. let option = {
  99. grid: {
  100. top: '20%',
  101. left: '7%',
  102. bottom: '14%',
  103. right: '7%',
  104. containLabel: true,
  105. },
  106. xAxis: [
  107. {
  108. type: 'category',
  109. data: ['吸风量', '供风量'],
  110. axisTick: {
  111. alignWithLabel: true,
  112. },
  113. nameTextStyle: {
  114. color: 'red',
  115. },
  116. axisLine: {
  117. //坐标轴轴线相关设置。数学上的x轴
  118. show: true,
  119. lineStyle: {
  120. color: 'rgba(62, 103, 164)',
  121. },
  122. },
  123. axisLabel: {
  124. //坐标轴刻度标签的相关设置
  125. textStyle: {
  126. color: '#b3b8cc',
  127. padding: 10,
  128. fontSize: 14,
  129. },
  130. formatter: function (data) {
  131. return data;
  132. },
  133. },
  134. },
  135. ],
  136. yAxis: [
  137. {
  138. type: 'value',
  139. min: 0,
  140. name: '(m³/min)',
  141. nameTextStyle: {
  142. color: '#b3b8cc',
  143. fontSize: 12,
  144. padding: 0,
  145. },
  146. splitLine: {
  147. show: false,
  148. lineStyle: {
  149. color: 'rgba(62, 103, 164,.4)',
  150. },
  151. },
  152. axisLine: {
  153. show: true,
  154. lineStyle: {
  155. color: 'rgba(62, 103, 164)',
  156. },
  157. },
  158. axisLabel: {
  159. show: true,
  160. textStyle: {
  161. color: '#b3b8cc',
  162. padding: 0,
  163. fontSize: 14,
  164. },
  165. formatter: function (value) {
  166. if (value === 0) {
  167. return value;
  168. }
  169. return value;
  170. },
  171. },
  172. axisTick: {
  173. show: false,
  174. },
  175. },
  176. ],
  177. series: [
  178. {
  179. name: '',
  180. type: 'pictorialBar',
  181. symbolSize: [60, 16],
  182. symbolOffset: [0, -10],
  183. symbolPosition: 'end',
  184. z: 12,
  185. //"barWidth": "20",
  186. label: {
  187. normal: {
  188. show: true,
  189. position: 'top',
  190. formatter: '{c}',
  191. color: '#fff',
  192. },
  193. },
  194. data: [
  195. {
  196. value: echartData.xdata,
  197. itemStyle: {
  198. color: '#59cb42',
  199. },
  200. },
  201. {
  202. value: echartData.ydata,
  203. itemStyle: {
  204. color: '#3cefff',
  205. },
  206. },
  207. ],
  208. },
  209. {
  210. name: '',
  211. type: 'pictorialBar',
  212. symbolSize: [60, 16],
  213. symbolOffset: [0, 10],
  214. // "barWidth": "20",
  215. z: 12,
  216. data: [
  217. {
  218. value: 100,
  219. itemStyle: {
  220. color: '#59cb42',
  221. },
  222. },
  223. {
  224. value: 100,
  225. itemStyle: {
  226. color: '#3cefff',
  227. },
  228. },
  229. ],
  230. },
  231. {
  232. name: '',
  233. type: 'pictorialBar',
  234. symbolSize: [90, 30],
  235. symbolOffset: [0, 20],
  236. z: 10,
  237. itemStyle: {
  238. normal: {
  239. color: 'transparent',
  240. borderColor: '#14b1eb',
  241. borderType: 'dashed',
  242. borderWidth: 5,
  243. },
  244. },
  245. data: [100, 100],
  246. },
  247. {
  248. type: 'bar',
  249. itemStyle: {
  250. normal: {
  251. //color: '#14b1eb',
  252. opacity: 0.7,
  253. },
  254. },
  255. //silent: true,
  256. barWidth: '60',
  257. //barGap: '-100%', // Make series be overlap
  258. data: [
  259. {
  260. value: echartData.xdata,
  261. itemStyle: {
  262. color: '#59cb42',
  263. },
  264. },
  265. {
  266. value: echartData.ydata,
  267. itemStyle: {
  268. color: '#3cefff',
  269. },
  270. },
  271. ],
  272. markLine: {
  273. symbol: 'none',
  274. label: {
  275. position: 'middle',
  276. formatter: '{b}',
  277. },
  278. // data: [
  279. // {
  280. // name: '目标值',
  281. // yAxis: 40, //res.targetTwo,
  282. // lineStyle: {
  283. // color: 'rgba(0, 119, 233,.8)',
  284. // },
  285. // },
  286. // ],
  287. },
  288. },
  289. ],
  290. };
  291. myChart.setOption(option);
  292. window.onresize = function () {
  293. myChart.resize();
  294. };
  295. });
  296. }
  297. watch(
  298. () => props.fandata,
  299. (val) => {
  300. console.log('000999', val);
  301. fanList = val[0];
  302. fanTypeList.length = 0;
  303. fanList.forEach((el) => {
  304. fanTypeList.push({
  305. label: el.strinstallpos,
  306. value: el.deviceID,
  307. });
  308. });
  309. if (searchValue.value) {
  310. changeSelect(searchValue.value);
  311. } else {
  312. searchValue.value = fanTypeList[0].value;
  313. changeSelect(searchValue.value);
  314. }
  315. },
  316. {
  317. deep: true,
  318. }
  319. );
  320. onMounted(() => {});
  321. </script>
  322. <style lang="less" scoped>
  323. @font-face {
  324. font-family: 'douyuFont';
  325. src: url('../../../../../assets/font/douyuFont.otf');
  326. }
  327. .fanMonitor {
  328. width: 100%;
  329. height: 100%;
  330. position: relative;
  331. .title-top {
  332. position: absolute;
  333. top: 9px;
  334. left: 46px;
  335. color: #fff;
  336. font-size: 16px;
  337. font-family: 'douyuFont';
  338. cursor: pointer;
  339. &:hover {
  340. color: #66ffff;
  341. }
  342. }
  343. .toggle-search {
  344. position: absolute;
  345. left: 9px;
  346. top: 37px;
  347. display: flex;
  348. .icon-search {
  349. position: absolute;
  350. top: 50%;
  351. left: 5px;
  352. transform: translate(0%, -50%);
  353. }
  354. .status-yx {
  355. height: 30px;
  356. width: 180px;
  357. background-color: rgba(8, 148, 255, 0.3);
  358. border: 1px solid #1d80da;
  359. display: flex;
  360. justify-content: space-between;
  361. align-items: center;
  362. .now-status {
  363. margin-right: 5px;
  364. padding-top: 3px;
  365. font-family: 'douyuFont';
  366. color: #3df6ff;
  367. }
  368. }
  369. }
  370. .fan-contents {
  371. position: absolute;
  372. top: 66px;
  373. left: 0;
  374. height: calc(100% - 66px);
  375. width: 100%;
  376. padding: 10px;
  377. .fan {
  378. width: 100%;
  379. height: 100%;
  380. }
  381. }
  382. }
  383. :deep .zxm-select-selector {
  384. width: 100%;
  385. height: 30px !important;
  386. padding: 0 11px 0px 25px !important;
  387. background-color: rgba(8, 148, 255, 0.3) !important;
  388. border: 1px solid #1d80da !important;
  389. }
  390. :deep .zxm-select-selection-item {
  391. color: #fff !important;
  392. line-height: 28px !important;
  393. }
  394. :deep .zxm-select-arrow {
  395. color: #fff !important;
  396. }
  397. </style>