EquipmentInfo.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <div class="equipment-info-module">
  3. <common-title title="设备基本运行情况"></common-title>
  4. <div class="visualization-common-border box">
  5. <!-- <a-row>
  6. <a-col :span="12">
  7. 湿度实值
  8. </a-col>
  9. <a-col :span="12">
  10. 30%R.H
  11. </a-col>
  12. <a-col :span="12">
  13. 温度实值
  14. </a-col>
  15. <a-col :span="12">
  16. 20℃
  17. </a-col>
  18. <a-col :span="12">
  19. 辐射强度实值
  20. </a-col>
  21. <a-col :span="12">
  22. 20W/㎡
  23. </a-col>
  24. </a-row> -->
  25. <!-- <div id="demo1">
  26. <div>湿度实值</div>
  27. <div>温度实值</div>
  28. <div>辐射强度实值</div>
  29. </div>
  30. <div>
  31. <div>30%R.H</div>
  32. <div>20℃</div>
  33. <div>20W/㎡</div>
  34. </div> -->
  35. <!-- <div style="height: 32%;display: flex; justify-content: center; align-items: center; font-size: 39px;">程序运行</div> -->
  36. <div style="height: 32%; display: flex; justify-content: center; align-items: center; font-size: 26px">
  37. {{ runStatus == 1 ? '程序运行' : '定值运行' }}
  38. </div>
  39. <div style="height: 36%; display: flex; flex-direction: row">
  40. <!-- 左 -->
  41. <div class="le" style="margin: 0 0.1% 0 2.4%">
  42. <div style="height: 15%; display: flex; justify-content: space-between">
  43. <span style="font-size: 12px">温度</span>
  44. <span style="font-size: 11px">设定{{ targetT }}℃</span>
  45. </div>
  46. <div style="height: 70%; display: flex; justify-content: center; align-items: center">
  47. <span style="font-size: 35px">{{ template }}</span>
  48. </div>
  49. <div style="height: 15%; display: flex; justify-content: end; align-items: center">
  50. <span style="font-size: 12px">℃</span>
  51. </div>
  52. </div>
  53. <!-- 中 -->
  54. <div class="le" style="margin: 0 0.1% 0 1%">
  55. <div style="height: 15%; display: flex; justify-content: space-between">
  56. <span style="font-size: 12px">湿度</span>
  57. <span style="font-size: 11px">设定{{ targetH }}%R.H</span>
  58. </div>
  59. <div style="height: 70%; display: flex; justify-content: center; align-items: center">
  60. <span style="font-size: 35px">{{ humidity }}</span>
  61. </div>
  62. <div style="height: 15%; display: flex; justify-content: end; align-items: center">
  63. <span style="font-size: 12px">%R.H</span>
  64. </div>
  65. </div>
  66. <!-- 右 -->
  67. <div class="le" style="margin: 0 0.1% 0 1%">
  68. <div style="height: 15%; display: flex; justify-content: space-between">
  69. <span style="font-size: 12px">辐射强度</span>
  70. <span style="font-size: 11px">设定{{ targetF }}W/㎡</span>
  71. </div>
  72. <div style="height: 70%; display: flex; justify-content: center; align-items: center">
  73. <span style="font-size: 35px">{{ irradiation }}</span>
  74. </div>
  75. <div style="height: 15%; display: flex; justify-content: end; align-items: center">
  76. <span style="font-size: 12px">W/㎡</span>
  77. </div>
  78. </div>
  79. </div>
  80. <div style="height: 22%; margin-top: 2%">
  81. <div class="bo">
  82. <!-- <div style="width: 35%; padding-left: 2%">{{alarmTime}}</div>
  83. <div style="width: 65%;">{{ information }}</div> -->
  84. <div style="width: 35%; padding-left: 2%" class="scroll-text">
  85. <div>
  86. <div class="number">{{ time1 }}</div>
  87. <div class="number">{{ time2 }}</div>
  88. </div>
  89. </div>
  90. <div style="width: 65%" class="scroll-text">
  91. <div>
  92. <div class="number">{{ inform1 }}</div>
  93. <div class="number">{{ inform2 }}</div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import commonTitle from '../components/commonTitle.vue'
  103. import axios from 'axios'
  104. export default {
  105. components: { commonTitle },
  106. name: '',
  107. props: {
  108. data: {
  109. type: Array,
  110. default: function () {
  111. return [] // 使用工厂函数返回默认值
  112. },
  113. },
  114. // alarmData,
  115. alarmData: {
  116. type: Array,
  117. default: function () {
  118. return [] // 使用工厂函数返回默认值
  119. },
  120. },
  121. },
  122. data() {
  123. return {
  124. intervalId: null,
  125. // 获取数据(总)
  126. dataList: [],
  127. // 温度
  128. template: '',
  129. // 温度输出
  130. outputT: '',
  131. // 升温/降温(0升温,1降温,3啥也不是)
  132. statusT: 3,
  133. // 目标温度
  134. targetT: '',
  135. // 斜率设定(温度)
  136. slopeT: '',
  137. // 起始温度
  138. startT: '',
  139. // 辐照强度
  140. irradiation: '0',
  141. // 吹风
  142. // 时间
  143. // 辐照强度设定
  144. targetF: '0',
  145. // 辐射强度起始
  146. startF: '',
  147. // 湿度
  148. humidity: '',
  149. // 湿度输出
  150. outputH: '',
  151. // 加湿/除湿(0加湿,1除湿,3啥也不是)
  152. statusH: 3,
  153. // 目标湿度
  154. targetH: '',
  155. // 起始湿度
  156. startH: '',
  157. // 运行方式设定
  158. runStatus: '',
  159. // 报警信息
  160. alarmTime: '',
  161. information: '',
  162. time1: '',
  163. time2: '',
  164. inform1: '',
  165. inform2: '',
  166. inform: ['暂无数据'],
  167. time: [],
  168. // 测试
  169. // inform: ['Data 1', 'Data 2', 'Data 3', 'Data 4', 'Data 5', 'Data 6', 'Data 7', 'Data 8', 'Data 9'],
  170. // time: ['time 1', 'time 2', 'time 3', 'time 4', 'time 5', 'time 6', 'time 7', 'time 8', 'time 9'],
  171. counter: 0,
  172. }
  173. },
  174. watch: {
  175. data: {
  176. handler(newValue, oldValue) {
  177. // console.log('7878999',newValue, oldValue)
  178. if (newValue.length === 0) return
  179. this.dataList = newValue
  180. // this.getList()
  181. },
  182. immediate: true,
  183. deep: true,
  184. },
  185. alarmData: {
  186. handler(newValue, oldValue) {
  187. // console.log('7878999',newValue, oldValue)
  188. var isYuan = newValue.length === 1 && newValue[0] === '原数据'
  189. if (isYuan) return
  190. this.inform = newValue.map((res) => {
  191. return res.tagname
  192. })
  193. this.time = newValue.map((res) => {
  194. return res.logtime
  195. })
  196. this.showData()
  197. // var hasAlarm = newValue
  198. // var options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric' };
  199. // // this.information = hasAlarm ? newValue.tagname : '暂无数据'
  200. // // this.alarmTime = hasAlarm ? new Date(newValue.logtime.time).toLocaleDateString('zh-CN', options) : ''
  201. // var nInform = this.inform
  202. // var nTime = this.time
  203. // // ['原数据']表示按照原来数据进行,数据并未改变;[]和其他有数据的情况进行赋值并重新获取方法
  204. // // console.log(hasAlarm.length === 1 && hasAlarm[0] === '原数据')
  205. // var isYuan = hasAlarm.length === 1 && hasAlarm[0] === '原数据'
  206. // this.inform = !isYuan ? newValue.map(res => {
  207. // return res.tagname
  208. // }): nInform
  209. // this.time = !isYuan ? newValue.map(res => {
  210. // return res.logtime
  211. // }): nTime
  212. // // console.log(789, this.inform)
  213. // if(!isYuan){
  214. // this.showData()
  215. // }
  216. },
  217. immediate: true,
  218. deep: true,
  219. },
  220. },
  221. created() {
  222. // this.loginwa()
  223. this.refreshData();
  224. // 创建定时器,每1秒刷新一次数据
  225. // setTimeout(this.refreshData(), 1000)
  226. // this.showData()
  227. },
  228. mounted() {},
  229. methods: {
  230. loginwa() {
  231. const instance = axios.create({
  232. baseURL: 'https://192.168.2.246/WaWebService', // 目标服务器的URL
  233. timeout: 20000, // 请求超时时间
  234. headers: {
  235. 'Content-Type': 'application/json',
  236. Authorization: 'Basic YWRtaW46',
  237. },
  238. })
  239. console.log("登录前");
  240. instance
  241. .get('/Json/Logon')
  242. .then((response) => {
  243. console.log("登录", response);
  244. // console.log(response.header);
  245. })
  246. .catch((error) => {
  247. // 处理错误
  248. console.error(error)
  249. })
  250. },
  251. refreshData() {
  252. const instance = axios.create({
  253. baseURL: 'https://192.168.2.246/WaWebService/Json', // 目标服务器的URL
  254. timeout: 2000, // 请求超时时间
  255. headers: {
  256. 'Content-Type': 'application/json',
  257. Authorization: 'Basic YWRtaW46',
  258. },
  259. })
  260. var param = {
  261. Tags: [
  262. { Name: '当前温度值' },
  263. { Name: '温度设定值' },
  264. { Name: '当前湿度值' },
  265. { Name: '湿度设定值' },
  266. { Name: '运行方式设定' },
  267. ],
  268. }
  269. instance
  270. .post('GetTagValueText/瑞莱', param)
  271. .then((response) => {
  272. console.log("刷新数据", response.data)
  273. response.data.Values.forEach((item) => {
  274. // 温度
  275. if (item.Name == '当前温度值') {
  276. this.template = item.Value
  277. }
  278. if (item.Name == '温度设定值') {
  279. this.targetT = item.Value
  280. }
  281. // 辐照
  282. // 湿度
  283. if (item.Name == '当前湿度值') {
  284. this.humidity = item.Value
  285. }
  286. if (item.Name == '湿度设定值') {
  287. this.targetH = item.Value
  288. }
  289. // 运行方式
  290. if (item.Name == '运行方式设定') {
  291. this.runStatus = item.Value
  292. }
  293. })
  294. })
  295. .catch((error) => {
  296. // 处理错误
  297. console.error(error)
  298. })
  299. setTimeout(this.refreshData, 1000)
  300. },
  301. getList() {
  302. // console.log(this.dataList)
  303. for (var i = 0; i < this.dataList.length; i++) {
  304. // console.log(i,this.dataList[i].Name)
  305. // 温度
  306. if (this.dataList[i].Name == '当前温度值') {
  307. this.template = this.dataList[i].Value
  308. }
  309. if (this.dataList[i].Name == '温度设定值') {
  310. this.targetT = this.dataList[i].Value
  311. }
  312. // 辐照
  313. // 湿度
  314. if (this.dataList[i].Name == '当前湿度值') {
  315. this.humidity = this.dataList[i].Value
  316. }
  317. if (this.dataList[i].Name == '湿度设定值') {
  318. this.targetH = this.dataList[i].Value
  319. }
  320. // 运行方式
  321. if (this.dataList[i].Name == '运行方式设定') {
  322. this.runStatus = this.dataList[i].Value
  323. }
  324. }
  325. },
  326. showData() {
  327. // console.log(7891,this.inform)
  328. // 如果还有数据未显示
  329. if (this.counter < this.inform.length) {
  330. // 显示当前计数器指向的数据
  331. // console.log(this.inform[this.counter]);
  332. // console.log(this.time[this.counter]);
  333. this.time1 = this.time[this.counter]
  334. this.inform1 = this.inform[this.counter]
  335. // 如果还有一条数据可以显示
  336. if (this.counter + 1 < this.inform.length) {
  337. // console.log(this.inform[this.counter + 1]);
  338. // console.log(this.time[this.counter + 1]);
  339. this.time2 = this.time[this.counter + 1]
  340. this.inform2 = this.inform[this.counter + 1]
  341. }
  342. if (this.counter + 1 == this.inform.length) {
  343. this.time2 = ''
  344. this.inform2 = ''
  345. this.counter = -2
  346. }
  347. // 更新计数器
  348. this.counter += 2
  349. // 设置下一次调用的定时器
  350. setTimeout(this.showData, 3000)
  351. }
  352. if (this.counter == this.inform.length) {
  353. this.counter = 0
  354. }
  355. },
  356. },
  357. // 销毁定时器
  358. beforeDestroy(){
  359. clearTimeout(this.refreshData)
  360. }
  361. }
  362. </script>
  363. <style scoped>
  364. @import '~@/assets/less/uStyle.less';
  365. </style>
  366. <style lang="less" scoped>
  367. .equipment-info-module {
  368. width: 100%;
  369. height: 100%;
  370. }
  371. .box {
  372. width: 100%;
  373. height: calc(100% - 26px);
  374. border-width: 8px 0 0 6px;
  375. // border: 1px solid rgb(255, 255, 255);
  376. // display: flex;
  377. // /* row (默认值) : 主轴为水平万向,起点在左端。*/
  378. // flex-direction: row;
  379. }
  380. // .box>div#demo1{
  381. // width: 50%;
  382. // height: 94%;
  383. // margin: 2%;
  384. // color: #eeeeee;
  385. // font-size: 15px;
  386. // // border: 1px solid rgb(255, 255, 255);
  387. // }
  388. // .box>div{
  389. // width: 70%;
  390. // height: 94%;
  391. // margin-top: 2%;
  392. // color: #eeeeee;
  393. // font-size: 15px;
  394. // // border: 1px solid rgb(255, 255, 255);
  395. // }
  396. // .box>div>div{
  397. // padding: 5%;
  398. // }
  399. .box > div {
  400. width: 100%;
  401. color: #eeeeee;
  402. // border: 1px solid rgb(255, 255, 255);
  403. }
  404. .le {
  405. height: 100%;
  406. width: 31%;
  407. // border: 1px solid rgb(255, 255, 255);
  408. background: linear-gradient(#207ab7, #207ab7) left top, linear-gradient(#207ab7, #207ab7) left top,
  409. linear-gradient(#207ab7, #207ab7) right top, linear-gradient(#207ab7, #207ab7) right top,
  410. linear-gradient(#207ab7, #207ab7) left bottom, linear-gradient(#207ab7, #207ab7) left bottom,
  411. linear-gradient(#207ab7, #207ab7) right bottom, linear-gradient(#207ab7, #207ab7) right bottom;
  412. background-repeat: no-repeat;
  413. background-size: 0.05vw 1vw, 1vw 0.05vw;
  414. padding: 5px 2px;
  415. }
  416. .le > div {
  417. width: 100%;
  418. padding: 0 3% 0 3%;
  419. // border: 1px solid rgb(255, 255, 255);
  420. color: #eeeeee;
  421. align-items: center;
  422. }
  423. .bo {
  424. height: 95%;
  425. width: 95.5%;
  426. // border: 1px solid rgb(255, 255, 255);
  427. margin: 0 0.1% 0.5% 2.4%;
  428. background: linear-gradient(#207ab7, #207ab7) left top, linear-gradient(#207ab7, #207ab7) left top,
  429. linear-gradient(#207ab7, #207ab7) right top, linear-gradient(#207ab7, #207ab7) right top,
  430. linear-gradient(#207ab7, #207ab7) left bottom, linear-gradient(#207ab7, #207ab7) left bottom,
  431. linear-gradient(#207ab7, #207ab7) right bottom, linear-gradient(#207ab7, #207ab7) right bottom;
  432. background-repeat: no-repeat;
  433. background-size: 0.05vw 1vw, 1vw 0.05vw;
  434. display: flex;
  435. align-items: center;
  436. flex-direction: row;
  437. }
  438. .bo > div {
  439. height: 100%;
  440. color: #eeeeee;
  441. font-size: 16px;
  442. // padding-top: 0.2%;
  443. // border: 1px solid rgb(255, 255, 255);
  444. display: flex;
  445. align-items: center;
  446. }
  447. .scroll-text {
  448. overflow: hidden;
  449. white-space: nowrap;
  450. }
  451. .number {
  452. display: block;
  453. animation: scrollNumber 3s infinite steps(1);
  454. }
  455. // @keyframes scrollNumber {
  456. // 0% {
  457. // transform: translateX(20%);
  458. // }
  459. // 100% {
  460. // transform: translateX(-20%);
  461. // }
  462. // }
  463. </style>