import Vue from 'vue' var vms = Vue.component("amplify-sbyxzt", { template: `
`, props: { }, data() { return { show:false, typeDistributionData:[ { name:'运行', value:'0' }, { name:'静止 ', value:'0' } ], } }, mounted(){ }, methods: { openAmplify(){ this.show = true this.getDeviceInfoByProjectId() }, closeAmplify(){ this.show = false }, closeAmplifyAll(e){ if(e.target.className == 'amplify-fixed'){ this.show = false } }, //设备信息 getDeviceInfoByProjectId(){ var that = this; axios.post(requestUrl+"getDeviceInfoByProjectId?projectId="+JSON.parse(localStorage.getItem("data1")).jzgj, { }).then(res => { let runNumber = 0; let notRunNumber = 0; let deviceCount = 0; for(let i = 0;i { let deviceInfo = res.data.deviceInfo; //监控设备 if(smartTerminalNumber != ""){ //运行、静止设备 if(deviceInfo == undefined || deviceInfo.angleData == undefined){ notRunNumber ++; }else{ runNumber ++; } } if(deviceId == 71259 || smartTerminalNumber == "aqzg-415"){ that.oneData={ rentalAngleOne:deviceInfo== undefined?0:deviceInfo.angleData, rentalRangeOne:deviceInfo== undefined?0:deviceInfo.ampData, rentalBrachiumOne:deviceInfo== undefined?0:deviceInfo.foreArmLength, deviceNumOne:deviceNum, } }else if(deviceId == 71258 || smartTerminalNumber == "aqzg-411"){ that.twoData={ rentalAngleTwo:deviceInfo== undefined?0:deviceInfo.angleData, rentalRangeTwo:deviceInfo== undefined?0:deviceInfo.ampData, rentalBrachiumTwo:deviceInfo== undefined?0:deviceInfo.foreArmLength, deviceNumTwo:deviceNum, } }else if(deviceId == 71257 || smartTerminalNumber == "aqzg-412"){ that.threeData={ rentalAngleThree:deviceInfo== undefined?0:deviceInfo.angleData, rentalRangeThree:deviceInfo== undefined?0:deviceInfo.ampData, rentalBrachiumThree:deviceInfo== undefined?0:deviceInfo.foreArmLength, deviceNumThree:deviceNum, } }else if(deviceId == 71804 || smartTerminalNumber == "aqzg-413"){ that.fourData={ rentalAngleFour:deviceInfo== undefined?0:deviceInfo.angleData, rentalRangeFour:deviceInfo== undefined?0:deviceInfo.ampData, rentalBrachiumFour:deviceInfo== undefined?0:deviceInfo.foreArmLength, deviceNumFour:deviceNum, } }else if(deviceId == 71803 || smartTerminalNumber == "aqzg-414"){ that.fiveData={ rentalAngleFive:deviceInfo== undefined?0:deviceInfo.angleData, rentalRangeFive:deviceInfo== undefined?0:deviceInfo.ampData, rentalBrachiumFive:deviceInfo== undefined?0:deviceInfo.foreArmLength, deviceNumFive:deviceNum, } }else if(deviceId == 71802 || smartTerminalNumber == "aqzg-410"){ that.sixData={ rentalAngleSix:deviceInfo== undefined?0:deviceInfo.angleData, rentalRangeSix:deviceInfo== undefined?0:deviceInfo.ampData, rentalBrachiumSix:deviceInfo== undefined?0:deviceInfo.foreArmLength, deviceNumSix:deviceNum, } } if(parseInt(runNumber)+parseInt(notRunNumber) == deviceCount){ that.getTypeDistribution(runNumber,notRunNumber); } }).catch(err => { }) } }).catch(err => { console.log(err); }) }, //设备运行状态数据接口 getTypeDistribution(runNumber,notRunNumber){ var that = this; axios.post(requestUrl+"getRunningDynamics?deptId="+deptId+"&projectId="+JSON.parse(localStorage.getItem("data1")).jzgj, { }).then(res => { let data = res.data.data; let array = []; if(data.length > 0) { array = data; } else { array = [{ name:'运行', value:'0' }, { name:'静止', value:'0' }]; } console.log(array) let dataArray = []; for(let i = 0;i { }) }, //数据图 getChartData(){ //品类金额占比 饼图 var chChartPie = echarts.init(this.$refs.warningPieChart); this.echartPie(chChartPie,this.typeDistributionData) }, echartPie(chChart,chartData){ let newPromise = new Promise((resolve) => { resolve() }) //然后异步执行echarts的初始化函数 newPromise.then(() => { var total_datas = 0; var data = []; var legendData = []; var color = ['#4474fa','#52aef7','#2075ae'] for (let i = 0; i { return a + b.value; }, 0);*/ this.option = { title: { text: total_datas, subtext: "台", x: "center", y: "140", textStyle: { color: "#0dd2fd", fontSize: 42, fontWeight: "normal", align: "center", width: "300px", }, subtextStyle: { color: "#a5b5f0", fontSize: 25, fontWeight: "normal", align: "center", }, }, tooltip: { trigger: 'item', formatter: "{b}
{c} ({d}%)" }, legend: { width:'100%', left: "center", right: "0", bottom: "5", //icon: "circle", itemWidth: 25, itemGap:52, textStyle: { fontSize: 60, rich: { name: { color: "#c3dbfd", padding: [10, 5, 30, 5], // align: 'right' // width: 60 fontSize: 25, }, percent: { color: "#18DB9F", fontSize: 16, padding: [0, 5, 0, 5], // align: 'right' fontSize: 25, }, }, }, formatter: function (name) { let res = chartData.filter((v) => v.name === name); let percent = total_datas == 0?0:((res[0].value * 100) / total_datas).toFixed(2); return "{name| " + name + "}\n{percent|" + res[0].value + "}{percent|" + percent + "%}"; }, }, series: [ { name: "品类金额占比", type: "pie", center: ["50%", "40%"], radius: ["42%", "60%"], data: data, label: { show: false, }, itemStyle: { normal: { borderWidth: 10, borderColor: "#051a36" } }, }, { name: "外边框", type: "pie", clockWise: false, //顺时加载 hoverAnimation: false, //鼠标移入变大 center: ["50%", "40%"], radius: ["66%", "66%"], label: { normal: { show: false, }, }, data: [ { // value: 9, // name: "", // itemStyle: { // normal: { // borderWidth: 3, // borderColor: "#152c65", // }, // }, }, ], }, ], } chChart.setOption(this.option); window.onresize = chChart.resize; }) }, }, watch:{ }, })