machine.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="machine-container">
  3. <div class="main">
  4. <img
  5. src="../../../../../assets/device/machine.png"
  6. alt="Machine"
  7. style="height: 100%; width: 100%;"
  8. >
  9. <div
  10. v-if="isOnline === '0'"
  11. class="offLine"
  12. >
  13. 离线
  14. </div>
  15. <div
  16. v-if="isOnline === '1'"
  17. class="onLineGreen"
  18. >
  19. 在线
  20. </div>
  21. <div
  22. v-if="isOnline === '2'"
  23. class="onLine"
  24. >
  25. 生产中
  26. </div>
  27. </div>
  28. <div class="title">
  29. {{ title }}
  30. </div>
  31. <div
  32. ref="echarts"
  33. class="chart"
  34. />
  35. </div>
  36. </template>
  37. <script>
  38. // Echarts的组件
  39. import * as echarts from "echarts";
  40. import "echarts-liquidfill"; // 水球图
  41. export default {
  42. name: "Machine",
  43. props: {
  44. status: {
  45. type: String,
  46. default: () => {
  47. return "offLine";
  48. },
  49. },
  50. title: {
  51. type: String,
  52. default: () => {
  53. return "";
  54. },
  55. },
  56. progress: {
  57. type: Number || String,
  58. default: () => {
  59. return 0;
  60. },
  61. },
  62. isOnline: {
  63. type: String,
  64. default: () => {
  65. return '0';
  66. }
  67. },
  68. },
  69. data() {
  70. return {
  71. machineId:""
  72. };
  73. },
  74. mounted() {
  75. this.alarm(this.progress);
  76. //this.alarm(99);
  77. },
  78. watch:{
  79. progress(newValue) {
  80. // 监听 progress 的变化并更新图表
  81. this.alarm(newValue);
  82. },
  83. },
  84. methods: {
  85. //水球图
  86. alarm(value,) {
  87. console.log("value:"+value)
  88. value = value == 0 ? 0 : value;
  89. this.myChartThree = echarts.init(
  90. this.$refs.echarts
  91. );
  92. var option = {
  93. title: [
  94. {
  95. text: value + "%",
  96. top: "25%",
  97. left: "40%",
  98. textStyle: {
  99. fontSize: "20",
  100. fontWeight: "300",
  101. color: "#fff",
  102. },
  103. },
  104. ],
  105. series: [
  106. {
  107. name: "最外层-虚线",
  108. type: "gauge",
  109. radius: "97%",
  110. center: ["58%", "50%"],
  111. startAngle: 0,
  112. endAngle: 360,
  113. axisLine: {
  114. show: false,
  115. },
  116. axisTick: {
  117. distance: -6,
  118. length: 2,
  119. lineStyle: {
  120. color: "#2AECFF",
  121. width: 5,
  122. type: [20],
  123. dashOffset: 19,
  124. opacity: 0.8,
  125. },
  126. splitNumber: 6,
  127. },
  128. splitLine: {
  129. show: false,
  130. },
  131. axisLabel: {
  132. show: false,
  133. },
  134. pointer: {
  135. show: false,
  136. },
  137. },
  138. {
  139. type: "liquidFill",
  140. radius: "85%",
  141. z: 5,
  142. center: ["58%", "50%"],
  143. amplitude: 14,
  144. backgroundStyle: {
  145. color: "#0d2d42",
  146. },
  147. color: [
  148. {
  149. type: "linear",
  150. x: 0,
  151. y: 0,
  152. x2: 0,
  153. y2: 1,
  154. colorStops: [
  155. {
  156. offset: 1,
  157. color: "#0061A2",
  158. },
  159. {
  160. offset: 0,
  161. color: "#00FFE5",
  162. },
  163. ],
  164. globalCoord: false,
  165. },
  166. {
  167. type: "linear",
  168. x: 0,
  169. y: 0,
  170. x2: 0,
  171. y2: 1,
  172. colorStops: [
  173. {
  174. offset: 1,
  175. color: "#0061A2",
  176. },
  177. {
  178. offset: 0,
  179. color: "#00FFE5",
  180. },
  181. ],
  182. globalCoord: false,
  183. },
  184. {
  185. type: "linear",
  186. x: 0,
  187. y: 0,
  188. x2: 0,
  189. y2: 1,
  190. colorStops: [
  191. {
  192. offset: 1,
  193. color: "#0061A2",
  194. },
  195. {
  196. offset: 0,
  197. color: "#00FFE5",
  198. },
  199. ],
  200. globalCoord: false,
  201. },
  202. ],
  203. data: [
  204. value + 0.02,
  205. {
  206. value: value - 0.01,
  207. direction: "left",
  208. },
  209. value - 0.01,
  210. ],
  211. label: {
  212. normal: {
  213. formatter: "",
  214. },
  215. },
  216. outline: {
  217. show: true,
  218. borderDistance: 0,
  219. itemStyle: {
  220. borderWidth: 2,
  221. borderColor: "#2AECFF",
  222. },
  223. },
  224. },
  225. ],
  226. };
  227. this.myChartThree.setOption(option);
  228. },
  229. },
  230. };
  231. </script>
  232. <style lang="css" scoped>
  233. .machine-container {
  234. width: 80%;
  235. background-color: #90aab2;
  236. position: relative;
  237. left: 15%;
  238. border-radius: 10px;
  239. .main {
  240. position: relative;
  241. height: 70%;
  242. .offLine {
  243. position: absolute;
  244. display: flex;
  245. align-items: center;
  246. justify-content: center;
  247. top: 60%;
  248. height: 20%;
  249. width: 20%;
  250. background-color: grey;
  251. color: #ffffff;
  252. font-size: 2vh;
  253. border-radius: 5px;
  254. }
  255. .onLine {
  256. position: absolute;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. top: 60%;
  261. height: 20%;
  262. width: 20%;
  263. background-color: yellow;
  264. color: #000;
  265. font-size: 2vh;
  266. border-radius: 5px;
  267. }
  268. .onLineGreen {
  269. position: absolute;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. top: 60%;
  274. height: 20%;
  275. width: 20%;
  276. background-color: green;
  277. color: #000;
  278. font-size: 2vh;
  279. border-radius: 5px;
  280. }
  281. }
  282. .title {
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. height: 30%;
  287. font-size: 2vw;
  288. color: yellow;
  289. }
  290. .chart {
  291. height: 30%;
  292. width: 30%;
  293. position: absolute;
  294. top: 10%;
  295. left: -5%;
  296. }
  297. }
  298. </style>