484 lines
20 KiB
JavaScript
484 lines
20 KiB
JavaScript
var vms = Vue.component("amplify-gzzb", {
|
|
template: `
|
|
<div>
|
|
<div class="amplify-title-icon">
|
|
<img src="https://fileimg.makalu.cc/WEB_DBD5893450984E50AFF356EF44FF4139.png" @click="openAmplify">
|
|
</div>
|
|
<transition name="el-zoom-in-top">
|
|
<div class="amplify-fixed" v-show="show" style="display: none" @click="closeAmplifyAll">
|
|
<div class="amplify-max">
|
|
<div class="amplify-title">
|
|
<div>工种占比</div>
|
|
<div class="amplify-close" @click="closeAmplify"><i class="el-icon-close"></i></div>
|
|
</div>
|
|
<div class="amplify-content">
|
|
<!--内容区域-->
|
|
<el-row>
|
|
<!--左边内容-->
|
|
<el-col :span="11">
|
|
<div class="amplify-leftHeader">
|
|
<div class="amplify-leftCircle" ref="amplifyBox"></div>
|
|
<div class="amplify-chart-gifs amplify-chart-work-gifs" v-if="typedata.length>0"></div>
|
|
</div>
|
|
</el-col>
|
|
<!--右边内容-->
|
|
<el-col :span="13">
|
|
<div class="amplify-rightHeader" >
|
|
<div class="amplify-rightPro" ref="amplifyStyle"></div>
|
|
</div>
|
|
</el-col>
|
|
</el-row>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</transition>
|
|
</div>
|
|
`,
|
|
props: {},
|
|
data() {
|
|
return {
|
|
show: false,
|
|
typedata:[],
|
|
projectId:JSON.parse(localStorage.getItem("data")).id,
|
|
}
|
|
},
|
|
mounted() {
|
|
|
|
},
|
|
methods: {
|
|
openAmplify() {
|
|
this.show = true
|
|
this.getGZData()
|
|
},
|
|
closeAmplify() {
|
|
this.show = false
|
|
},
|
|
closeAmplifyAll(e) {
|
|
if (e.target.className == 'amplify-fixed') {
|
|
this.show = false
|
|
}
|
|
},
|
|
getGZData() {
|
|
axios.post("https://smz.makalu.cc/mkl/screenApi/getCqWorkTypeData?token=" + JSON.parse(localStorage.getItem("data")).smz_token + "&deptId=131&typtDeptId=" + JSON.parse(localStorage.getItem("data")).dept_id + "&typtProjectId=" + JSON.parse(localStorage.getItem("data")).id+"&team_type="+1, {}).then(res => {
|
|
var workPropData = [];
|
|
if (res.data.code != "-1") {
|
|
var data = res.data.workTypeData;
|
|
for (let i = 0; i < data.length; i++) {
|
|
workPropData.push({
|
|
text: data[i].name,
|
|
value: data[i].value,
|
|
prop: data[i].percent,
|
|
id: data[i].id
|
|
})
|
|
}
|
|
}
|
|
var workPropDataNew = []
|
|
var val={
|
|
id : '',
|
|
text:'其他工种',
|
|
prop : 0,
|
|
value : 0,
|
|
}
|
|
|
|
if(workPropData.length > 0){
|
|
for (let i = 0; i < workPropData.length ; i++) {
|
|
if(workPropData[i].text == '其他工种' || workPropData[i].text == '其他'){
|
|
val.id += workPropData[i].id+','
|
|
val.prop += Number(workPropData[i].prop)
|
|
val.value += Number(workPropData[i].value)
|
|
}else {
|
|
workPropDataNew.push(workPropData[i])
|
|
}
|
|
}
|
|
}
|
|
workPropDataNew.push(val)
|
|
this.typedata = workPropDataNew;
|
|
|
|
this.getChartData()
|
|
this.getChartData1()
|
|
}).catch(err => {
|
|
})
|
|
},
|
|
//左边圆形图
|
|
getChartData(){
|
|
//品类金额占比 饼图
|
|
var chChartPie = echarts.init(this.$refs.amplifyBox);
|
|
this.echartPie(chChartPie,this.typedata)
|
|
},
|
|
echartPie(chChart,chartData){
|
|
// console.log(chartData)
|
|
let newPromise = new Promise((resolve) => {
|
|
resolve()
|
|
})
|
|
|
|
//然后异步执行echarts的初始化函数
|
|
newPromise.then(() => {
|
|
var total_datas = 0;
|
|
var data = [];
|
|
var legendData = [];
|
|
var color = ['#4974ff','#52aef7','#6863d7','#1d5d89','#20e6ff','#67feef']
|
|
for (let i = 0; i <chartData.length ; i++) {
|
|
total_datas += Number(chartData[i].value);
|
|
legendData.push(chartData[i].text)
|
|
data.push(
|
|
{
|
|
value: chartData[i].value,
|
|
name: chartData[i].text,
|
|
itemStyle: {
|
|
normal: {
|
|
//颜色渐变
|
|
color: color[i]
|
|
},
|
|
},
|
|
},
|
|
)
|
|
}
|
|
/* let total = chartData.reduce((a, b) => {
|
|
return a + b.value;
|
|
}, 0);*/
|
|
this.option = {
|
|
title: {
|
|
text: total_datas,
|
|
subtext: "总人数",
|
|
x: "center",
|
|
y: "143",
|
|
textStyle: {
|
|
color: "#0dd2fd",
|
|
fontSize: 52,
|
|
fontWeight: "normal",
|
|
align: "center",
|
|
width: "200px",
|
|
},
|
|
subtextStyle: {
|
|
color: "#a5b5f0",
|
|
fontSize: 28,
|
|
fontWeight: "normal",
|
|
align: "center",
|
|
},
|
|
},
|
|
tooltip: {
|
|
trigger: 'item',
|
|
formatter: "{b} <br/>{c} ({d}%)"
|
|
},
|
|
series: [
|
|
{
|
|
name: "品类金额占比",
|
|
type: "pie",
|
|
center: ["50%", "50%"],
|
|
radius: ["53%", "70%"],
|
|
data: data,
|
|
label: {
|
|
show: false,
|
|
},
|
|
itemStyle: {
|
|
normal: {
|
|
borderWidth: 10,
|
|
borderColor: "#051a36"
|
|
}
|
|
},
|
|
|
|
},
|
|
{
|
|
name: "外边框",
|
|
type: "pie",
|
|
clockWise: false, //顺时加载
|
|
hoverAnimation: false, //鼠标移入变大
|
|
center: ["50%", "50%"],
|
|
radius: ["78%", "78%"],
|
|
label: {
|
|
normal: {
|
|
show: false,
|
|
},
|
|
},
|
|
data: [
|
|
{
|
|
value: 9,
|
|
name: "",
|
|
itemStyle: {
|
|
normal: {
|
|
borderWidth: 6,
|
|
borderColor: "#152c65",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
}
|
|
chChart.setOption(this.option);
|
|
window.onresize = chChart.resize;
|
|
})
|
|
},
|
|
//右边进度图
|
|
getChartData1(){
|
|
var chChartBar = echarts.init(this.$refs.amplifyStyle);
|
|
this.echartBar(chChartBar,this.typedata)
|
|
},
|
|
echartBar(chChart,chartData){
|
|
console.log(chartData)
|
|
var that = this
|
|
|
|
let newPromise = new Promise((resolve) => {
|
|
resolve()
|
|
})
|
|
//然后异步执行echarts的初始化函数
|
|
newPromise.then(() => {
|
|
|
|
|
|
var value = [];
|
|
var prop = [];
|
|
var text = [];
|
|
var zero = []
|
|
|
|
var total = 0
|
|
for (let i = chartData.length-1; i >=0; i--) {
|
|
total += chartData[i].value;
|
|
value.push(chartData[i].value)
|
|
prop.push(chartData[i].prop.toFixed(2))
|
|
text.push(chartData[i].text)
|
|
zero.push(0)
|
|
}
|
|
|
|
|
|
var data = []
|
|
var data_all = new Array(prop.length)
|
|
for (let i = 0; i <prop.length ; i++) {
|
|
let tmp = new Array(prop.length).fill(0)
|
|
tmp[i] = prop[i]
|
|
data.push(tmp)
|
|
let tmp_all = 0
|
|
|
|
for(let j = i;j<prop.length;j++){
|
|
tmp_all+= prop[j];
|
|
}
|
|
data_all[i] = tmp_all;
|
|
}
|
|
|
|
data_all.splice(0,1)
|
|
data_all.push(0)
|
|
|
|
|
|
var color = ['#4974ff','#52aef7','#6863d7','#1d5d89','#20e6ff','#67feef']
|
|
|
|
var series =[
|
|
//背景色--------------------我是分割线君------------------------------//
|
|
{
|
|
show: true,
|
|
type: 'bar',
|
|
barGap: '-100%',
|
|
barWidth: '12', //统计条宽度
|
|
itemStyle: {
|
|
normal: {
|
|
color: 'rgba(27, 61, 133,0.5)',
|
|
},
|
|
|
|
},
|
|
z: 1,
|
|
data: [100, 100, 100, 100, 100, 100]
|
|
},
|
|
//数据条--------------------我是分割线君------------------------------//
|
|
{
|
|
show: true,
|
|
type: 'bar',
|
|
xAxisIndex: 1, //代表使用第二个X轴刻度!!!!!!!!!!!!!!!!!!!!!!!!
|
|
barGap: '-100%',
|
|
barWidth: '12', //统计条宽度
|
|
itemStyle: {
|
|
normal: {
|
|
color: 'rgba(22,203,115,0.05)'
|
|
},
|
|
},
|
|
label: {
|
|
normal: {
|
|
show: true,
|
|
//label 的position位置可以是top bottom left,right,也可以是固定值
|
|
//在这里需要上下统一对齐,所以用固定值
|
|
position: [0, '-40'],
|
|
rich: { //富文本
|
|
prop: { //自定义颜色
|
|
color: '#c6d9fa',
|
|
fontSize:'28',
|
|
},
|
|
value: { //自定义颜色
|
|
color: '#6cbbfe',
|
|
fontSize:'28',
|
|
},
|
|
index:{
|
|
color: '#fcbc02',
|
|
fontStyle: 'italic',
|
|
padding:[0,0,0,5],
|
|
fontSize:'28',
|
|
},
|
|
name: {
|
|
width: 160,
|
|
color: '#c6d9fa',
|
|
padding:[0,0,0,10],
|
|
fontSize:'24',
|
|
},
|
|
color:{
|
|
color: '#8ca2be',
|
|
fontSize:'24',
|
|
},
|
|
|
|
arrow1:{
|
|
width:20,
|
|
height:20,
|
|
backgroundColor: '#4974ff',
|
|
borderRadius:50
|
|
},
|
|
arrow2:{
|
|
width:20,
|
|
height:20,
|
|
backgroundColor: '#52aef7',
|
|
borderRadius:50
|
|
},
|
|
arrow3:{
|
|
width:20,
|
|
height:20,
|
|
backgroundColor: '#6863d7',
|
|
borderRadius:50
|
|
},
|
|
arrow4:{
|
|
width:20,
|
|
height:20,
|
|
backgroundColor: '#1d5d89',
|
|
borderRadius:50
|
|
},
|
|
arrow5:{
|
|
width:20,
|
|
height:20,
|
|
backgroundColor: '#20e6ff',
|
|
borderRadius:50
|
|
},
|
|
arrow6:{
|
|
width:20,
|
|
height:20,
|
|
backgroundColor: '#67feef',
|
|
borderRadius:50
|
|
},
|
|
},
|
|
formatter: function(data) {
|
|
//富文本固定格式{colorName|这里填你想要写的内容}
|
|
if (data.dataIndex == 5) {
|
|
return '{arrow1|}{name|' + text[data.dataIndex] + '}{value|' + value[data.dataIndex] + '}{color| 人} {prop|' + prop[data.dataIndex] + '} {color| %}';
|
|
}else if(data.dataIndex == 4){
|
|
return '{arrow2|}{name|' + text[data.dataIndex] + '}{value|' + value[data.dataIndex] + '}{color| 人} {prop|' + prop[data.dataIndex] + '} {color| %}';
|
|
}else if(data.dataIndex == 3){
|
|
return '{arrow3|}{name|' + text[data.dataIndex] + '}{value|' + value[data.dataIndex] + '}{color| 人} {prop|' + prop[data.dataIndex] + '} {color| %}';
|
|
}else if(data.dataIndex == 2){
|
|
return '{arrow4|}{name|' + text[data.dataIndex] + '}{value|' + value[data.dataIndex] + '}{color| 人} {prop|' + prop[data.dataIndex] + '} {color| %}';
|
|
}else if(data.dataIndex == 1){
|
|
return '{arrow5|}{name|' + text[data.dataIndex] + '}{value|' + value[data.dataIndex] + '}{color| 人} {prop|' + prop[data.dataIndex] + '} {color| %}';
|
|
}else if(data.dataIndex == 0){
|
|
return '{arrow6|}{name|' + text[data.dataIndex] + '}{value|' + value[data.dataIndex] + '}{color| 人} {prop|' + prop[data.dataIndex] + '} {color| %}';
|
|
}
|
|
|
|
},
|
|
}
|
|
},
|
|
data: value
|
|
},
|
|
{
|
|
type: "bar",
|
|
stack: "总",
|
|
barWidth: 12,
|
|
itemStyle: {
|
|
normal: {
|
|
barBorderColor: 'rgba(0,0,0,0)',
|
|
color: 'rgba(0,0,0,0)'
|
|
}
|
|
},
|
|
data: data_all
|
|
},
|
|
|
|
|
|
]
|
|
for (let i = 0; i < data.length; i++) {
|
|
series.push({
|
|
type: "bar",
|
|
barWidth: 12 ,
|
|
stack: "总",
|
|
itemStyle: {
|
|
normal: {
|
|
color: color[data.length-1-i]
|
|
}
|
|
},
|
|
/*itemStyle: {
|
|
normal: {
|
|
color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
|
|
{
|
|
offset: 0,
|
|
color: "#41adf5",
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: "#175eac",
|
|
},
|
|
]),
|
|
barBorderRadius: [5,5,5,5],
|
|
},
|
|
},*/
|
|
data: data[i]
|
|
})
|
|
}
|
|
|
|
this.option1 = {
|
|
grid: {
|
|
left: '2%',
|
|
right: '10%',
|
|
bottom: '-8%',
|
|
top: '3%',
|
|
containLabel: true
|
|
},
|
|
yAxis: {
|
|
type: 'category',
|
|
axisLabel: {
|
|
show: false, //让Y轴数据不显示
|
|
},
|
|
itemStyle: {
|
|
|
|
},
|
|
axisTick: {
|
|
show: false, //隐藏Y轴刻度
|
|
},
|
|
axisLine: {
|
|
show: false, //隐藏Y轴线段
|
|
},
|
|
data: text,
|
|
},
|
|
|
|
xAxis: [{
|
|
show: false,
|
|
},
|
|
//由于下边X轴已经是百分比刻度了,所以需要在顶部加一个X轴,刻度是金额,也隐藏掉
|
|
{
|
|
show: false,
|
|
}
|
|
],
|
|
series: series
|
|
};
|
|
|
|
chChart.setOption(this.option1);
|
|
window.onresize = chChart.resize;
|
|
|
|
|
|
chChart.off('click')
|
|
|
|
chChart.on('click', function (params) {
|
|
for(let i= 0;i<chartData.length;i++){
|
|
if(params.name == chartData[i].text){
|
|
that.$emit('personnel',chartData[i]);
|
|
break
|
|
}
|
|
}
|
|
})
|
|
|
|
})
|
|
},
|
|
},
|
|
watch: {},
|
|
|
|
})
|
|
|
|
|