WarnChart.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div>
  3. <div class="text-container" :style="{height:height,width:width}">
  4. <div class="inner-container">
  5. <p class="text"
  6. v-for="(text, index) in arr"
  7. :key="index"
  8. v-on:mouseover="changeActive"
  9. v-on:mouseout="removeActive"
  10. @click="chooseWarn(text)">
  11. {{text}}</p>
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { homeList } from "@/api/system/alarmhistory";
  18. const totalDuration = 2000;
  19. export default {
  20. name: "WarnChart",
  21. props: {
  22. width: {
  23. type: String,
  24. default: '100%'
  25. },
  26. height: {
  27. type: String,
  28. default: '410px'
  29. }
  30. },
  31. data() {
  32. return {
  33. arr: [],
  34. number: 0,
  35. // 查询参数
  36. queryParams: {},
  37. }
  38. },
  39. computed: {
  40. text() {
  41. return {
  42. id: this.number,
  43. val: this.arr[this.number]
  44. }
  45. }
  46. },
  47. created() {
  48. this.getList();
  49. },
  50. mounted() {
  51. this.startMove()
  52. },
  53. methods: {
  54. /** 查询报警记录管理列表 */
  55. getList() {
  56. this.loading = true;
  57. homeList(this.queryParams).then(response => {
  58. this.arr = response;
  59. //设置文字滚动一轮时间
  60. let elem = document.querySelector('.inner-container');
  61. let state = elem.style['animation'];
  62. let time = this.arr.length * 1.5 + 5
  63. elem.style['animation'] = 'myMove ' + time + 's linear infinite';
  64. //设置文字无缝滚动高度
  65. let param = this.arr.length * 60
  66. let myFirstkeyframes = "@keyframes myMove{0% {transform: translateY(200px);}100% {transform: translateY(-" + param +"px);}}";
  67. let style = document.createElement("style");
  68. style.setAttribute("type", "text/css");
  69. document.head.appendChild(style);
  70. const sheet = style.sheet;
  71. sheet.insertRule(myFirstkeyframes, 0);
  72. this.loading = false;
  73. });
  74. },
  75. // 鼠标移入
  76. changeActive() {
  77. let elem = document.querySelector('.inner-container');
  78. let state = elem.style['animationPlayState'];
  79. elem.style['animationPlayState'] = 'paused';
  80. },
  81. // 鼠标移出
  82. removeActive() {
  83. let elem = document.querySelector('.inner-container');
  84. let state = elem.style['animationPlayState'];
  85. elem.style['animationPlayState'] = 'running';
  86. },
  87. //点击事件
  88. chooseWarn(data) {
  89. var warnType = data.split("(")
  90. var type = warnType[0];
  91. if (type === '安全阀清单') {
  92. this.$router.push("/reliability/safetyvavle");
  93. }else if (type === "环保批文清单") {
  94. this.$router.push("/ehs/environapproval");
  95. }else if (type === "消防批文清单") {
  96. this.$router.push("/ehs/fireapproval");
  97. }else if (type === "安全批文清单") {
  98. this.$router.push("/ehs/safetyapproval");
  99. }else if (type === "故障管理跟踪") {
  100. this.$router.push("/reliability/list");
  101. }else if (type === "MSDS管理") {
  102. this.$router.push("/ehs/msds");
  103. }else if (type === "管线清单") {
  104. this.$router.push("/reliability/pipe");
  105. }else if (type === "装置程序清单") {
  106. this.$router.push("/document/plantproglist");
  107. }else if (type === "PPE发放登记") {
  108. this.$router.push("/affair/ppe");
  109. }else if (type === "压力管道" || type === "锅炉证" || type === "加氢工艺" || type === "裂化工艺") {
  110. this.$router.push("/training/workcertificate");
  111. }else if (type === "上岗证一览表") {
  112. this.$router.push("/training/worklicense");
  113. }else if (type === "灭火器") {
  114. this.$router.push("/ehs/fireextinguisher");
  115. }else if (type === "洗眼器") {
  116. this.$router.push("/ehs/eyewasher");
  117. }else if (type === "消防水带箱") {
  118. this.$router.push("/ehs/firehose");
  119. }else if (type === "消防栓") {
  120. this.$router.push("/ehs/firehydrant");
  121. }else if (type === "高压消防炮") {
  122. this.$router.push("/ehs/highpresfire");
  123. }else if (type === "自动喷淋系统") {
  124. this.$router.push("/ehs/autosprinkler");
  125. }else if (type === "消防竖管") {
  126. this.$router.push("/ehs/firestandpipe");
  127. }
  128. },
  129. startMove() {
  130. if (this.remove === true) {
  131. let timer = setTimeout(() => {
  132. if (this.number === 3) {
  133. this.number = 0;
  134. } else {
  135. this.number += 1;
  136. }
  137. this.startMove();
  138. }, totalDuration)
  139. }
  140. },
  141. },
  142. }
  143. </script>
  144. <style scoped>
  145. .text-container {
  146. line-height: 30px;
  147. /*border: 1px solid cornflowerblue;*/
  148. overflow: hidden;
  149. }
  150. .text {
  151. margin: 0 0 0 10px;
  152. cursor: pointer; /*鼠标悬停变小手*/
  153. color: #ffffff;
  154. }
  155. p:hover {
  156. background-color: #296b9bb5;
  157. }
  158. .inner-container {
  159. /*animation: myMove 10s linear infinite;*/
  160. animation-fill-mode: forwards;
  161. }
  162. /*文字无缝滚动*/
  163. /*@keyframes myMove {
  164. 0% {
  165. transform: translateY(200px);
  166. }
  167. 100% {
  168. transform: translateY(-400px);
  169. }
  170. }*/
  171. /*文字停顿滚动*/
  172. @keyframes myMove2 {
  173. 0% {
  174. transform: translateY(0);
  175. }
  176. 10% {
  177. transform: translateY(-30px);
  178. }
  179. 20% {
  180. transform: translateY(-30px);
  181. }
  182. 30% {
  183. transform: translateY(-60px);
  184. }
  185. 40% {
  186. transform: translateY(-60px);
  187. }
  188. 50% {
  189. transform: translateY(-90px);
  190. }
  191. 60% {
  192. transform: translateY(-90px);
  193. }
  194. 70% {
  195. transform: translateY(-120px);
  196. }
  197. 80% {
  198. transform: translateY(-120px);
  199. }
  200. 90% {
  201. transform: translateY(-150px);
  202. }
  203. 100% {
  204. transform: translateY(-150px);
  205. }
  206. }
  207. </style>