123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <template>
- <div class="machine-container">
- <div class="main">
- <img
- src="../../../../../assets/device/machine.png"
- alt="Machine"
- style="height: 100%; width: 100%;"
- >
- <div
- v-if="isOnline === '0'"
- class="offLine"
- >
- 离线
- </div>
- <div
- v-if="isOnline === '1'"
- class="onLineGreen"
- >
- 在线
- </div>
- <div
- v-if="isOnline === '2'"
- class="onLine"
- >
- 生产中
- </div>
- </div>
- <div class="title">
- {{ title }}
- </div>
- <div
- ref="echarts"
- class="chart"
- />
- </div>
- </template>
- <script>
- // Echarts的组件
- import * as echarts from "echarts";
- import "echarts-liquidfill"; // 水球图
- export default {
- name: "Machine",
- props: {
- status: {
- type: String,
- default: () => {
- return "offLine";
- },
- },
- title: {
- type: String,
- default: () => {
- return "";
- },
- },
- progress: {
- type: Number || String,
- default: () => {
- return 0;
- },
- },
- isOnline: {
- type: String,
- default: () => {
- return '0';
- }
- },
- },
- data() {
- return {
- machineId:""
- };
- },
- mounted() {
- this.alarm(this.progress);
- //this.alarm(99);
- },
- watch:{
- progress(newValue) {
- // 监听 progress 的变化并更新图表
- this.alarm(newValue);
- },
- },
- methods: {
- //水球图
- alarm(value,) {
- console.log("value:"+value)
- value = value == 0 ? 0 : value;
- this.myChartThree = echarts.init(
- this.$refs.echarts
- );
- var option = {
- title: [
- {
- text: value + "%",
- top: "25%",
- left: "40%",
- textStyle: {
- fontSize: "20",
- fontWeight: "300",
- color: "#fff",
- },
- },
- ],
- series: [
- {
- name: "最外层-虚线",
- type: "gauge",
- radius: "97%",
- center: ["58%", "50%"],
- startAngle: 0,
- endAngle: 360,
- axisLine: {
- show: false,
- },
- axisTick: {
- distance: -6,
- length: 2,
- lineStyle: {
- color: "#2AECFF",
- width: 5,
- type: [20],
- dashOffset: 19,
- opacity: 0.8,
- },
- splitNumber: 6,
- },
- splitLine: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- pointer: {
- show: false,
- },
- },
- {
- type: "liquidFill",
- radius: "85%",
- z: 5,
- center: ["58%", "50%"],
- amplitude: 14,
- backgroundStyle: {
- color: "#0d2d42",
- },
- color: [
- {
- type: "linear",
- x: 0,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [
- {
- offset: 1,
- color: "#0061A2",
- },
- {
- offset: 0,
- color: "#00FFE5",
- },
- ],
- globalCoord: false,
- },
- {
- type: "linear",
- x: 0,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [
- {
- offset: 1,
- color: "#0061A2",
- },
- {
- offset: 0,
- color: "#00FFE5",
- },
- ],
- globalCoord: false,
- },
- {
- type: "linear",
- x: 0,
- y: 0,
- x2: 0,
- y2: 1,
- colorStops: [
- {
- offset: 1,
- color: "#0061A2",
- },
- {
- offset: 0,
- color: "#00FFE5",
- },
- ],
- globalCoord: false,
- },
- ],
- data: [
- value + 0.02,
- {
- value: value - 0.01,
- direction: "left",
- },
- value - 0.01,
- ],
- label: {
- normal: {
- formatter: "",
- },
- },
- outline: {
- show: true,
- borderDistance: 0,
- itemStyle: {
- borderWidth: 2,
- borderColor: "#2AECFF",
- },
- },
- },
- ],
- };
- this.myChartThree.setOption(option);
- },
- },
- };
- </script>
- <style lang="css" scoped>
- .machine-container {
- width: 80%;
- background-color: #90aab2;
- position: relative;
- left: 15%;
- border-radius: 10px;
- .main {
- position: relative;
- height: 70%;
- .offLine {
- position: absolute;
- display: flex;
- align-items: center;
- justify-content: center;
- top: 60%;
- height: 20%;
- width: 20%;
- background-color: grey;
- color: #ffffff;
- font-size: 2vh;
- border-radius: 5px;
- }
- .onLine {
- position: absolute;
- display: flex;
- align-items: center;
- justify-content: center;
- top: 60%;
- height: 20%;
- width: 20%;
- background-color: yellow;
- color: #000;
- font-size: 2vh;
- border-radius: 5px;
- }
- .onLineGreen {
- position: absolute;
- display: flex;
- align-items: center;
- justify-content: center;
- top: 60%;
- height: 20%;
- width: 20%;
- background-color: green;
- color: #000;
- font-size: 2vh;
- border-radius: 5px;
- }
- }
- .title {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 30%;
- font-size: 2vw;
- color: yellow;
- }
- .chart {
- height: 30%;
- width: 30%;
- position: absolute;
- top: 10%;
- left: -5%;
- }
- }
- </style>
|