Merge remote-tracking branch 'origin/master'

yangwl
wws 1 year ago
commit 54ae8deb7e

@ -38,6 +38,7 @@
"clipboard": "2.0.8",
"core-js": "3.25.3",
"echarts": "5.4.0",
"echarts-gl": "^2.0.9",
"element-ui": "2.15.12",
"file-saver": "2.0.5",
"fuse.js": "6.4.3",

@ -0,0 +1,18 @@
import request from '@/utils/request'
// 获取工厂下拉列表
export function getBoardFactory(data) {
return request({
url: '/mes/wcsInterface/getBoardFactory',
method: 'post',
data: data
});
}
// 获取产量数据
export function getMesBoardEquProductionToday(data) {
return request({
url: '/mes/wcsInterface/getMesBoardEquProductionToday',
method: 'post',
data: data
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

@ -215,7 +215,7 @@ export default {
},
//
handleRowChange(row) {
debugger;
// debugger;
if(row){
this.selectedRows = row;
}

@ -4,7 +4,9 @@ import Cookies from 'js-cookie'
import Element from 'element-ui'
import './assets/styles/element-variables.scss'
import * as echarts from 'echarts'
import 'echarts-gl' // 3d图表库
import '@/assets/styles/index.scss' // global css
import '@/assets/styles/open-platform.scss' // OpenPlatform css
import App from './App'
@ -41,6 +43,7 @@ import DictData from '@/components/DictData'
import Print from 'print-js'
// 全局方法挂载
Vue.prototype.$echarts = echarts
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime

@ -87,7 +87,19 @@ export const constantRoutes = [
meta: { title: '个人中心', icon: 'user' }
}
]
}
},
// 看板路由
{
path: "/kanban/dailyoutput",
component: () => import("@/views/kanban/dailyoutput/index"),
hidden: true,
},
// 看板路由
{
path: "/kanban/3decharts",
component: () => import("@/views/kanban/3decharts/index"),
hidden: true,
},
]
// 动态路由,基于用户权限动态去加载

@ -0,0 +1,280 @@
/**
* 绘制3d图
* @param pieData 总数据
* @param internalDiameterRatio:透明的空心占比
* @param distance 视角到主体的距离
* @param alpha 旋转角度
* @param pieHeight 立体的高度
* @param opacity 饼或者环的透明度
*/
const getPie3D = (pieData, internalDiameterRatio, distance, alpha, pieHeight, opacity = 1) => {
if(pieData.length <0){
return
}
console.log(pieData)
const series = []
let sumValue = 0
let startValue = 0
let endValue = 0
let legendData = []
let legendBfb = []
const k = 1 - internalDiameterRatio
pieData.sort((a, b) => {
return b.value - a.value
})
// 为每一个饼图数据,生成一个 series-surface 配置
for (let i = 0; i < pieData.length; i++) {
sumValue += pieData[i].value
const seriesItem = {
name:
typeof pieData[i].name === 'undefined'
? `series${i}`
: pieData[i].name,
type: 'surface',
parametric: true,
wireframe: {
show: false
},
pieData: pieData[i],
pieStatus: {
selected: false,
hovered: false,
k: k
},
center: ['10%', '50%']
}
if (typeof pieData[i].itemStyle !== 'undefined') {
const itemStyle = {}
itemStyle.color =
typeof pieData[i].itemStyle.color !== 'undefined'
? pieData[i].itemStyle.color
: opacity
itemStyle.opacity =
typeof pieData[i].itemStyle.opacity !== 'undefined'
? pieData[i].itemStyle.opacity
: opacity
seriesItem.itemStyle = itemStyle
}
series.push(seriesItem)
}
// 使用上一次遍历时,计算出的数据和 sumValue调用 getParametricEquation 函数,
// 向每个 series-surface 传入不同的参数方程 series-surface.parametricEquation也就是实现每一个扇形。
legendData = []
legendBfb = []
for (let i = 0; i < series.length; i++) {
endValue = startValue + series[i].pieData.value
series[i].pieData.startRatio = startValue / sumValue
series[i].pieData.endRatio = endValue / sumValue
series[i].parametricEquation = getParametricEquation(
series[i].pieData.startRatio,
series[i].pieData.endRatio,
false,
false,
k,
series[i].pieData.value
)
startValue = endValue
const bfb = fomatFloat(series[i].pieData.value / sumValue, 4)
legendData.push({
name: series[i].name,
value: bfb
})
legendBfb.push({
name: series[i].name,
value: bfb
})
}
const boxHeight = getHeight3D(series, pieHeight) // 通过pieHeight设定3d饼/环的高度单位是px
// 准备待返回的配置项,把准备好的 legendData、series 传入。
const option = {
legend: {
show: false,
data: legendData,
orient: 'vertical',
left: 10,
top: 10,
itemGap: 10,
textStyle: {
color: '#A1E2FF'
},
icon: 'circle',
formatter: function (param) {
const item = legendBfb.filter(item => item.name === param)[0]
const bfs = fomatFloat(item.value * 100, 2) + '%'
return `${item.name} ${bfs}`
}
},
labelLine: {
show: true,
lineStyle: {
color: '#fff'
}
},
label: {
show: true,
position: 'outside',
formatter: '{b} \n{c} {d}%'
},
tooltip: {
backgroundColor: '#033b77',
borderColor: '#21f2c4',
textStyle: {
color: '#fff',
fontSize: 13
},
formatter: params => {
if (
params.seriesName !== 'mouseoutSeries' &&
params.seriesName !== 'pie2d'
) {
const bfb = (
(option.series[params.seriesIndex].pieData.endRatio -
option.series[params.seriesIndex].pieData.startRatio) *
100
).toFixed(2)
return (
`${params.seriesName}<br/>` +
`<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${params.color};"></span>` +
`${bfb}%`
)
}
}
},
xAxis3D: {
min: -1,
max: 1
},
yAxis3D: {
min: -1,
max: 1
},
zAxis3D: {
min: -1,
max: 1
},
grid3D: {
show: false,
boxHeight: boxHeight,
// boxWidth:180, // 圆环的高度
viewControl: {
// 3d效果可以放大、旋转等请自己去查看官方配置
alpha, // 角度
distance, // 调整视角到主体的距离类似调整zoom
rotateSensitivity: 0, // 设置为0无法旋转
zoomSensitivity: 0, // 设置为0无法缩放
panSensitivity: 0, // 设置为0无法平移
autoRotate: false // 自动旋转
}
},
series: series
}
return option
}
/**
* 生成扇形的曲面参数方程用于 series-surface.parametricEquation
*/
const getParametricEquation = (startRatio, endRatio, isSelected, isHovered, k, h) => {
// 计算
const midRatio = (startRatio + endRatio) / 2
const startRadian = startRatio * Math.PI * 2
const endRadian = endRatio * Math.PI * 2
const midRadian = midRatio * Math.PI * 2
// 如果只有一个扇形,则不实现选中效果。
if (startRatio === 0 && endRatio === 1) {
isSelected = false
}
// 通过扇形内径/外径的值,换算出辅助参数 k默认值 1/3
k = typeof k !== 'undefined' ? k : 1 / 3
// 计算选中效果分别在 x 轴、y 轴方向上的位移(未选中,则位移均为 0
const offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0
const offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0
// 计算高亮效果的放大比例(未高亮,则比例为 1
const hoverRate = isHovered ? 1.05 : 1
// 返回曲面参数方程
return {
u: {
min: -Math.PI,
max: Math.PI * 3,
step: Math.PI / 32
},
v: {
min: 0,
max: Math.PI * 2,
step: Math.PI / 20
},
x: function (u, v) {
if (u < startRadian) {
return (
offsetX +
Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate
)
}
if (u > endRadian) {
return (
offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate
)
}
return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate
},
y: function (u, v) {
if (u < startRadian) {
return (
offsetY +
Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate
)
}
if (u > endRadian) {
return (
offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate
)
}
return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate
},
z: function (u, v) {
if (u < -Math.PI * 0.5) {
return Math.sin(u)
}
if (u > Math.PI * 2.5) {
return Math.sin(u) * h * 0.1
}
return Math.sin(v) > 0 ? 1 * h * 0.1 : -1
}
}
}
/**
* 获取3d丙图的最高扇区的高度
*/
const getHeight3D = (series, height) => {
series.sort((a, b) => {
return b.pieData.value - a.pieData.value
})
return (height * 25) / series[0].pieData.value
}
/**
* 格式化浮点数
*/
const fomatFloat = (num, n) => {
let f = parseFloat(num)
if (isNaN(f)) {
return false
}
f = Math.round(num * Math.pow(10, n)) / Math.pow(10, n) // n 幂
let s = f.toString()
let rs = s.indexOf('.')
// 判定如果是整数增加小数点再补0
if (rs < 0) {
rs = s.length
s += '.'
}
while (s.length <= rs + n) {
s += '0'
}
return s
}
export { getPie3D, getParametricEquation }

@ -56,7 +56,7 @@ service.interceptors.request.use(config => {
if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
const message = '数据正在处理,请勿重复提交';
console.warn(`[${s_url}]: ` + message)
return Promise.reject(new Error(message))
// return Promise.reject(new Error(message))
} else {
cache.session.setJSON('sessionObj', requestObj)
}
@ -93,7 +93,7 @@ service.interceptors.response.use(res => {
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
Message({ message: msg, type: 'error' })
return Promise.reject(new Error(msg))
// return Promise.reject(new Error(msg))
} else if (code === 601) {
Message({ message: msg, type: 'warning' })
return Promise.reject('error')

@ -53,7 +53,7 @@
}
},
mounted() {
debugger
// debugger
this.$nextTick(() => {
this.initChart()
})

@ -0,0 +1,543 @@
<template>
<div class="chart-container">
<div class="chart" ref="chart"></div>
<!-- 底座背景 -->
<div class="bg"></div>
<div style="margin: auto; width: 486px; height: 316px" ref="pie3d" />
</div>
</template>
<script>
export default {
data() {
return {
optionData: [
{
code: "3",
name: "病区四",
cws: 80,
zcs: 20,
zcl: "25%",
value: 80,
startRatio: 0,
endRatio: 0.34782608695652173,
},
{
code: "0",
name: "病区一",
cws: 60,
zcs: 30,
zcl: "50%",
value: 60,
startRatio: 0.34782608695652173,
endRatio: 0.6086956521739131,
},
{
code: "2",
name: "病区三",
cws: 50,
zcs: 20,
zcl: "40%",
value: 50,
startRatio: 0.6086956521739131,
endRatio: 0.8260869565217391,
},
{
code: "1",
name: "病区二",
cws: 40,
zcs: 30,
zcl: "75%",
value: 40,
startRatio: 0.8260869565217391,
endRatio: 1,
},
],
};
},
mounted() {
this.myChart = this.$echarts.init(this.$refs.pie3d);
this.setLabel()
this.init();
},
methods: {
//
setLabel() {
const that = this;
this.optionData.forEach((item, index) => {
// item.itemStyle = {
// color: that.color[index],
// };
item.label = {
normal: {
show: true,
// color: that.color[index],
formatter: ["{b|{b}}", "{c|{c}}{b|台}", "{d|{d}%}"].join("\n"), // \n
rich: {
b: {
color: "#fff",
lineHeight: 25,
align: "left",
},
c: {
fontSize: 22,
color: "#fff",
textShadowColor: "#1c90a6",
textShadowOffsetX: 0,
textShadowOffsetY: 2,
textShadowBlur: 5,
},
d: {
// color: that.color[index],
align: "left",
},
},
},
};
item.labelLine = {
normal: {
lineStyle: {
width: 1,
color: "rgba(255,255,255,0.7)",
},
},
};
});
},
init() {
// option ; getPie3D(01)
this.option = this.getPie3D(this.optionData, 0.85);
//
this.myChart.setOption(this.option);
//
this.bindListen(this.myChart);
},
//
bindListen(myChart) {
let that = this;
let selectedIndex = "";
let hoveredIndex = "";
//
myChart.on("click", function (params) {
// option.series
let isSelected =
!that.option.series[params.seriesIndex].pieStatus.selected;
let isHovered =
that.option.series[params.seriesIndex].pieStatus.hovered;
let k = that.option.series[params.seriesIndex].pieStatus.k;
let startRatio =
that.option.series[params.seriesIndex].pieData.startRatio;
let endRatio = that.option.series[params.seriesIndex].pieData.endRatio;
// option
if (selectedIndex !== "" && selectedIndex !== params.seriesIndex) {
that.option.series[selectedIndex].parametricEquation =
that.getParametricEquation(
that.option.series[selectedIndex].pieData.startRatio,
that.option.series[selectedIndex].pieData.endRatio,
false,
false,
k,
that.option.series[selectedIndex].pieData.value
);
that.option.series[selectedIndex].pieStatus.selected = false;
}
// / option
that.option.series[params.seriesIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[params.seriesIndex].pieData.value
);
that.option.series[params.seriesIndex].pieStatus.selected = isSelected;
// seriesIndex
isSelected ? (selectedIndex = params.seriesIndex) : null;
// 使 option
myChart.setOption(that.option);
});
// mouseover
myChart.on("mouseover", function (params) {
//
let isSelected;
let isHovered;
let startRatio;
let endRatio;
let k;
// mouseover
if (hoveredIndex === params.seriesIndex) {
return;
//
} else {
// option
if (hoveredIndex !== "") {
// option.series false
isSelected = that.option.series[hoveredIndex].pieStatus.selected;
isHovered = false;
startRatio = that.option.series[hoveredIndex].pieData.startRatio;
endRatio = that.option.series[hoveredIndex].pieData.endRatio;
k = that.option.series[hoveredIndex].pieStatus.k;
// option
that.option.series[hoveredIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[hoveredIndex].pieData.value
);
that.option.series[hoveredIndex].pieStatus.hovered = isHovered;
// seriesIndex
hoveredIndex = "";
}
// mouseover option
if (
params.seriesName !== "mouseoutSeries" &&
params.seriesName !== "pie2d"
) {
// option.series true
isSelected =
that.option.series[params.seriesIndex].pieStatus.selected;
isHovered = true;
startRatio =
that.option.series[params.seriesIndex].pieData.startRatio;
endRatio = that.option.series[params.seriesIndex].pieData.endRatio;
k = that.option.series[params.seriesIndex].pieStatus.k;
// option
that.option.series[params.seriesIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[params.seriesIndex].pieData.value + 5
);
that.option.series[params.seriesIndex].pieStatus.hovered =
isHovered;
// seriesIndex
hoveredIndex = params.seriesIndex;
}
// 使 option
myChart.setOption(that.option);
}
});
// bug
myChart.on("globalout", function () {
//
let isSelected;
let isHovered;
let startRatio;
let endRatio;
let k;
if (hoveredIndex !== "") {
// option.series true
isSelected = that.option.series[hoveredIndex].pieStatus.selected;
isHovered = false;
k = that.option.series[hoveredIndex].pieStatus.k;
startRatio = that.option.series[hoveredIndex].pieData.startRatio;
endRatio = that.option.series[hoveredIndex].pieData.endRatio;
// option
that.option.series[hoveredIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[hoveredIndex].pieData.value
);
that.option.series[hoveredIndex].pieStatus.hovered = isHovered;
// seriesIndex
hoveredIndex = "";
}
// 使 option
myChart.setOption(that.option);
});
},
getPie3D(pieData, internalDiameterRatio) {
let that = this;
let series = [];
let sumValue = 0;
let startValue = 0;
let endValue = 0;
let legendData = [];
let legendBfb = [];
let k = 1 - internalDiameterRatio;
pieData.sort((a, b) => {
return b.value - a.value;
});
// series-surface()
for (let i = 0; i < pieData.length; i++) {
sumValue += pieData[i].value;
let seriesItem = {
//
name:
typeof pieData[i].name === "undefined"
? `series${i}`
: pieData[i].name,
type: "surface",
//
parametric: true,
//线
wireframe: {
show: false,
},
pieData: pieData[i],
pieStatus: {
selected: false,
hovered: false,
k: k,
},
};
//
// if (typeof pieData[i].itemStyle != "undefined") {
// let itemStyle = {};
// typeof pieData[i].itemStyle.color != "undefined"
// ? (itemStyle.color = pieData[i].itemStyle.color)
// : null;
// typeof pieData[i].itemStyle.opacity != "undefined"
// ? (itemStyle.opacity = pieData[i].itemStyle.opacity)
// : null;
// seriesItem.itemStyle = itemStyle;
// }
series.push(seriesItem);
}
// 使 sumValue getParametricEquation
// series-surface series-surface.parametricEquation
legendData = [];
legendBfb = [];
for (let i = 0; i < series.length; i++) {
endValue = startValue + series[i].pieData.value;
series[i].pieData.startRatio = startValue / sumValue;
series[i].pieData.endRatio = endValue / sumValue;
series[i].parametricEquation = this.getParametricEquation(
series[i].pieData.startRatio,
series[i].pieData.endRatio,
false,
false,
k,
series[i].pieData.value
);
startValue = endValue;
let bfb = that.fomatFloat(series[i].pieData.value / sumValue, 4);
legendData.push({
name: series[i].name,
value: bfb,
});
legendBfb.push({
name: series[i].name,
value: bfb,
});
}
//()
let boxHeight = this.getHeight3D(series, 15); //3d/
// legendDataseries
let option = {
//
legend: {
data: legendData,
//
orient: "horizontal",
left: "0%",
//
itemGap: 10,
textStyle: {
color: "#A1E2FF",
fontSize: "0.5rem",
},
show: true,
icon: "circle",
//
// formatter: function (name) {
// var target;
// for (var i = 0, l = pieData.length; i < l; i++) {
// if (pieData[i].name == name) {
// target = pieData[i].value;
// }
// }
// return `${name}: ${target}`;
// }
//
// formatter: function(param) {
// let item = legendBfb.filter(item => item.name == param)[0];
// let bfs = that.fomatFloat(item.value * 100, 2) + "%";
// console.log(item.name)
// return `${item.name} :${bfs}`;
// }
},
//
tooltip: {
formatter: (params) => {
if (
params.seriesName !== "mouseoutSeries" &&
params.seriesName !== "pie2d"
) {
let bfb = (
(option.series[params.seriesIndex].pieData.endRatio -
option.series[params.seriesIndex].pieData.startRatio) *
100
).toFixed(2);
return (
`${params.seriesName}<br/>` +
`<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${params.color};"></span>` +
`${bfb}`
);
}
},
},
//
xAxis3D: {
min: -1,
max: 1,
},
yAxis3D: {
min: -1,
max: 1,
},
zAxis3D: {
min: -1,
max: 1,
},
//
grid3D: {
show: false,
boxHeight: boxHeight, //
//
top: "15%",
viewControl: {
//3d
alpha: 35, //( )
distance: 165, //zoom()
rotateSensitivity: 1, //0
zoomSensitivity: 0, //0
panSensitivity: 0, //0
autoRotate: true, //
},
},
series: series,
};
return option;
},
getHeight3D(series, height) {
series.sort((a, b) => {
return b.pieData.value - a.pieData.value;
});
return (height * 25) / series[0].pieData.value;
},
getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h) {
//
let midRatio = (startRatio + endRatio) / 2;
let startRadian = startRatio * Math.PI * 2;
let endRadian = endRatio * Math.PI * 2;
let midRadian = midRatio * Math.PI * 2;
//
if (startRatio === 0 && endRatio === 1) {
isSelected = false;
}
// / k 1/3
k = typeof k !== "undefined" ? k : 1 / 3;
// x y 0
let offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0;
let offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0;
// 1
let hoverRate = isHovered ? 1.05 : 1;
//
return {
u: {
min: -Math.PI,
max: Math.PI * 3,
step: Math.PI / 32,
},
v: {
min: 0,
max: Math.PI * 2,
step: Math.PI / 20,
},
x: function (u, v) {
if (u < startRadian) {
return (
offsetX +
Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
if (u > endRadian) {
return (
offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate;
},
y: function (u, v) {
if (u < startRadian) {
return (
offsetY +
Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
if (u > endRadian) {
return (
offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate;
},
z: function (u, v) {
if (u < -Math.PI * 0.5) {
return Math.sin(u);
}
if (u > Math.PI * 2.5) {
return Math.sin(u) * h * 0.1;
}
return Math.sin(v) > 0 ? 1 * h * 0.1 : -1;
},
};
},
fomatFloat(num, n) {
var f = parseFloat(num);
if (isNaN(f)) {
return false;
}
f = Math.round(num * Math.pow(10, n)) / Math.pow(10, n); // n
var s = f.toString();
var rs = s.indexOf(".");
//0
if (rs < 0) {
rs = s.length;
s += ".";
}
while (s.length <= rs + n) {
s += "0";
}
return s;
},
},
};
</script>
<style lang='scss' scoped>
.chart-container {
position: relative;
width: 100%;
height: 100%;
.chart,.pie3d,
.bg {
width: 100%;
height: 100%;
}
.bg {
position: absolute;
bottom: 50px;
left: 50%;
z-index: -1;
width: 180px;
height: 73px;
background: no-repeat center;
background-image: url("https://ks3-cn-beijing.ksyun.com/sxjg-elevator/datav-platform-2.0/images/chart_opacity_bg.png");
background-size: 100% 100%;
transform: translateX(-50%);
}
}
</style>

@ -0,0 +1,334 @@
<template>
<div class="chart-container">
<div class="chart" :class="{'activehide':isActive}" ref="chart"></div>
<!-- 底座背景 -->
</div>
</template>
<script>
import { getPie3D, getParametricEquation } from "../../../utils/echart.js"; //js
const color = ["#005aff", "#f8b551"];
export default {
name: "chart",
props: ["list", "colorlist"],
data() {
return {
optionData: [],
statusChart: null,
option: {},
isActive:false,
// color:["#005aff", "#f8b551",'#7CDCAC'],
};
},
watch: {
list: function (newVal, oldVal) {
console.log(newVal, oldVal)
if(newVal.length < 0){
return
}
if(newVal.length == oldVal.length){
return
}
if (this.list.length > 0) {
this.setLabel();
this.isActive = false
setTimeout(() => {
this.initChart();
}, 1000);
}else{
this.optionData = []
this.isActive = true
// setTimeout(() => {
// this.initChart();
// }, 1000);
}
},
colorlist: function (newVal, oldVal) {},
},
created() {
// console.log(this.list);
// this.color = this.colorlist
},
mounted() {
// this.setLabel();
// this.initChart();
//
const that = this;
window.onresize = function () {
that.changeSize();
};
},
methods: {
// label
setLabel() {
const that = this;
this.optionData = this.list;
this.optionData.forEach((item, index) => {
// item.itemStyle = {
// color: that.color[index],
// };
item.label = {
normal: {
show: true,
// color: that.color[index],
formatter: ["{b|{b}}:", "{d|{d}%}"].join(""), // \n
rich: {
b: {
color: "#fff",
lineHeight: 25,
align: "left",
},
c: {
fontSize: 22,
color: "#fff",
textShadowColor: "#1c90a6",
textShadowOffsetX: 0,
textShadowOffsetY: 2,
textShadowBlur: 5,
},
d: {
color: "#fff",
align: "left",
textShadowOffsetX: 0,
textShadowOffsetY: 2,
textShadowBlur: 5,
},
},
},
};
item.labelLine = {
normal: {
lineStyle: {
width: 1,
color: "rgba(255,255,255,0.7)",
},
},
};
});
},
//
initChart() {
this.statusChart = this.$echarts.init(this.$refs.chart);
// option, 3d,
this.optionData = this.list;
this.option = getPie3D(this.optionData, 0.8, 240, 50, 26, 0.5);
this.statusChart.setOption(this.option);
// label线2d使labelLine3dsetOption
this.option.series.push({
// backgroundColor: "transparent",
type: "pie",
label: {
// show: true,
opacity: 1,
alignTo: "labelLine",
color: "#FFFFFF",
fontSize: 12,
// lineHeight: 20,
},
labelLine: {
length: 30,
length2: 0,
maxSurfaceAngle: 100,
},
startAngle: -40, // [0, 360]
clockwise: false, // 3d
radius: ["50%", "70%"],
center: ["50%", "50%"],
data: this.optionData,
itemStyle: {
opacity: 0, //02d
},
});
this.statusChart.setOption(this.option);
this.bindListen(this.statusChart);
},
//
// optionNameoptionopiton
bindListen(myChart, optionName = "option") {
let selectedIndex = "";
let hoveredIndex = "";
//
myChart.on("click", (params) => {
// option.series
const isSelected =
!this[optionName].series[params.seriesIndex].pieStatus.selected;
const isHovered =
this[optionName].series[params.seriesIndex].pieStatus.hovered;
const k = this[optionName].series[params.seriesIndex].pieStatus.k;
const startRatio =
this[optionName].series[params.seriesIndex].pieData.startRatio;
const endRatio =
this[optionName].series[params.seriesIndex].pieData.endRatio;
// option
if (selectedIndex !== "" && selectedIndex !== params.seriesIndex) {
this[optionName].series[selectedIndex].parametricEquation =
getParametricEquation(
this[optionName].series[selectedIndex].pieData.startRatio,
this[optionName].series[selectedIndex].pieData.endRatio,
false,
false,
k,
this[optionName].series[selectedIndex].pieData.value
);
this[optionName].series[selectedIndex].pieStatus.selected = false;
}
// / option
this[optionName].series[params.seriesIndex].parametricEquation =
getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
this[optionName].series[params.seriesIndex].pieData.value
);
this[optionName].series[params.seriesIndex].pieStatus.selected =
isSelected;
// seriesIndex
selectedIndex = isSelected ? params.seriesIndex : null;
// 使 option
myChart.setOption(this[optionName]);
});
// mouseover
myChart.on("mouseover", (params) => {
//
let isSelected;
let isHovered;
let startRatio;
let endRatio;
let k;
// mouseover
if (hoveredIndex === params.seriesIndex) {
//
} else {
// option
if (hoveredIndex !== "") {
// option.series false
isSelected =
this[optionName].series[hoveredIndex].pieStatus.selected;
isHovered = false;
startRatio =
this[optionName].series[hoveredIndex].pieData.startRatio;
endRatio = this[optionName].series[hoveredIndex].pieData.endRatio;
k = this[optionName].series[hoveredIndex].pieStatus.k;
// option
this[optionName].series[hoveredIndex].parametricEquation =
getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
this[optionName].series[hoveredIndex].pieData.value
);
this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered;
// seriesIndex
hoveredIndex = "";
}
// mouseover option
if (
params.seriesName !== "mouseoutSeries" &&
params.seriesName !== "pie2d"
) {
// option.series true
isSelected =
this[optionName].series[params.seriesIndex].pieStatus.selected;
isHovered = true;
startRatio =
this[optionName].series[params.seriesIndex].pieData.startRatio;
endRatio =
this[optionName].series[params.seriesIndex].pieData.endRatio;
k = this[optionName].series[params.seriesIndex].pieStatus.k;
// option
this[optionName].series[params.seriesIndex].parametricEquation =
getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
this[optionName].series[params.seriesIndex].pieData.value + 60
);
this[optionName].series[params.seriesIndex].pieStatus.hovered =
isHovered;
// seriesIndex
hoveredIndex = params.seriesIndex;
}
// 使 option
myChart.setOption(this[optionName]);
}
});
// bug
myChart.on("globalout", () => {
//
let isSelected;
let isHovered;
let startRatio;
let endRatio;
let k;
if (hoveredIndex !== "") {
// option.series true
isSelected = this[optionName].series[hoveredIndex].pieStatus.selected;
isHovered = false;
k = this[optionName].series[hoveredIndex].pieStatus.k;
startRatio = this[optionName].series[hoveredIndex].pieData.startRatio;
endRatio = this[optionName].series[hoveredIndex].pieData.endRatio;
// option
this[optionName].series[hoveredIndex].parametricEquation =
getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
this[optionName].series[hoveredIndex].pieData.value
);
this[optionName].series[hoveredIndex].pieStatus.hovered = isHovered;
// seriesIndex
hoveredIndex = "";
}
// 使 option
myChart.setOption(this[optionName]);
});
},
//
changeSize() {
this.statusChart.resize();
},
},
};
</script>
<style lang='scss' scoped>
.chart-container {
position: relative;
width: 100%;
height: 100%;
.chart,
.bg {
width: 100%;
height: 100%;
}
.bg {
position: absolute;
bottom: 50px;
left: 50%;
z-index: -1;
width: 180px;
height: 73px;
background: no-repeat center;
background-image: url("https://ks3-cn-beijing.ksyun.com/sxjg-elevator/datav-platform-2.0/images/chart_opacity_bg.png");
background-size: 100% 100%;
transform: translateX(-50%);
}
}
.activehide{
display: none;
}
</style>

@ -0,0 +1,540 @@
<template>
<div class="chart-container">
<!-- 底座背景 -->
<div style="margin: auto; width: 439.17px; height: 183px" ref="pie3d" />
</div>
</template>
<script>
export default {
props: ["list", "colorlist"],
data() {
return {
optionData: [],
};
},
watch: {
list: function (newVal, oldVal) {
// this.optionData = this.list;
if(this.optionData.length >0){
}
this.init();
},
},
mounted() {
this.myChart = this.$echarts.init(this.$refs.pie3d);
this.setLabel();
this.init();
},
methods: {
setLabel() {
const that = this;
this.optionData.forEach((item, index) => {
// item.itemStyle = {
// color: that.color[index],
// };
item.label = {
normal: {
show: true,
// color: that.color[index],
formatter: ["{b|{b}}", "{c|{c}}{b|台}", "{d|{d}%}"].join("\n"), // \n
rich: {
b: {
color: "#fff",
lineHeight: 25,
align: "left",
},
c: {
fontSize: 22,
color: "#fff",
textShadowColor: "#1c90a6",
textShadowOffsetX: 0,
textShadowOffsetY: 2,
textShadowBlur: 5,
},
d: {
// color: that.color[index],
align: "left",
},
},
},
};
item.labelLine = {
normal: {
lineStyle: {
width: 1,
color: "rgba(255,255,255,0.7)",
},
},
};
});
},
//
init() {
// option ; getPie3D(01)
this.optionData = this.list;
this.option = this.getPie3D(this.optionData, 0.85)
this.option.series.push({
// backgroundColor: "transparent",
type: "pie",
label: {
// show: true,
opacity: 1,
alignTo: "labelLine",
color: "#FFFFFF",
fontSize: 12,
// lineHeight: 20,
},
labelLine: {
length: 50,
length2: 0,
maxSurfaceAngle: 100,
},
startAngle: -40, // [0, 360]
clockwise: false, // 3d
radius: ["20%", "50%"],
center: ["50%", "48%"],
data: this.optionData,
itemStyle: {
opacity: 0, //02d
},
});
//
this.myChart.setOption(this.option);
//
this.bindListen(this.myChart);
},
//
bindListen(myChart) {
let that = this;
let selectedIndex = "";
let hoveredIndex = "";
//
myChart.on("click", function (params) {
// option.series
let isSelected =
!that.option.series[params.seriesIndex].pieStatus.selected;
let isHovered =
that.option.series[params.seriesIndex].pieStatus.hovered;
let k = that.option.series[params.seriesIndex].pieStatus.k;
let startRatio =
that.option.series[params.seriesIndex].pieData.startRatio;
let endRatio = that.option.series[params.seriesIndex].pieData.endRatio;
// option
if (selectedIndex !== "" && selectedIndex !== params.seriesIndex) {
that.option.series[selectedIndex].parametricEquation =
that.getParametricEquation(
that.option.series[selectedIndex].pieData.startRatio,
that.option.series[selectedIndex].pieData.endRatio,
false,
false,
k,
that.option.series[selectedIndex].pieData.value
);
that.option.series[selectedIndex].pieStatus.selected = false;
}
// / option
that.option.series[params.seriesIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[params.seriesIndex].pieData.value
);
that.option.series[params.seriesIndex].pieStatus.selected = isSelected;
// seriesIndex
isSelected ? (selectedIndex = params.seriesIndex) : null;
// 使 option
myChart.setOption(that.option);
});
// mouseover
myChart.on("mouseover", function (params) {
//
let isSelected;
let isHovered;
let startRatio;
let endRatio;
let k;
// mouseover
if (hoveredIndex === params.seriesIndex) {
return;
//
} else {
// option
if (hoveredIndex !== "") {
// option.series false
isSelected = that.option.series[hoveredIndex].pieStatus.selected;
isHovered = false;
startRatio = that.option.series[hoveredIndex].pieData.startRatio;
endRatio = that.option.series[hoveredIndex].pieData.endRatio;
k = that.option.series[hoveredIndex].pieStatus.k;
// option
that.option.series[hoveredIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[hoveredIndex].pieData.value
);
that.option.series[hoveredIndex].pieStatus.hovered = isHovered;
// seriesIndex
hoveredIndex = "";
}
// mouseover option
if (
params.seriesName !== "mouseoutSeries" &&
params.seriesName !== "pie2d"
) {
// option.series true
isSelected =
that.option.series[params.seriesIndex].pieStatus.selected;
isHovered = true;
startRatio =
that.option.series[params.seriesIndex].pieData.startRatio;
endRatio = that.option.series[params.seriesIndex].pieData.endRatio;
k = that.option.series[params.seriesIndex].pieStatus.k;
// option
that.option.series[params.seriesIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[params.seriesIndex].pieData.value + 5
);
that.option.series[params.seriesIndex].pieStatus.hovered =
isHovered;
// seriesIndex
hoveredIndex = params.seriesIndex;
}
// 使 option
myChart.setOption(that.option);
}
});
// bug
myChart.on("globalout", function () {
//
let isSelected;
let isHovered;
let startRatio;
let endRatio;
let k;
if (hoveredIndex !== "") {
// option.series true
isSelected = that.option.series[hoveredIndex].pieStatus.selected;
isHovered = false;
k = that.option.series[hoveredIndex].pieStatus.k;
startRatio = that.option.series[hoveredIndex].pieData.startRatio;
endRatio = that.option.series[hoveredIndex].pieData.endRatio;
// option
that.option.series[hoveredIndex].parametricEquation =
that.getParametricEquation(
startRatio,
endRatio,
isSelected,
isHovered,
k,
that.option.series[hoveredIndex].pieData.value
);
that.option.series[hoveredIndex].pieStatus.hovered = isHovered;
// seriesIndex
hoveredIndex = "";
}
// 使 option
myChart.setOption(that.option);
});
},
getPie3D(pieData, internalDiameterRatio) {
let that = this;
let series = [];
let sumValue = 0;
let startValue = 0;
let endValue = 0;
let legendData = [];
let legendBfb = [];
let k = 1 - internalDiameterRatio;
pieData.sort((a, b) => {
return b.value - a.value;
});
// series-surface()
for (let i = 0; i < pieData.length; i++) {
sumValue += pieData[i].value;
let seriesItem = {
//
name:
typeof pieData[i].name === "undefined"
? `series${i}`
: pieData[i].name,
type: "surface",
//
parametric: true,
//线
wireframe: {
show: false,
},
pieData: pieData[i],
pieStatus: {
selected: false,
hovered: false,
k: k,
},
};
//
if (typeof pieData[i].itemStyle != "undefined") {
let itemStyle = {};
typeof pieData[i].itemStyle.color != "undefined"
? (itemStyle.color = pieData[i].itemStyle.color)
: null;
typeof pieData[i].itemStyle.opacity != "undefined"
? (itemStyle.opacity = pieData[i].itemStyle.opacity)
: null;
seriesItem.itemStyle = itemStyle;
}
series.push(seriesItem);
}
// 使 sumValue getParametricEquation
// series-surface series-surface.parametricEquation
legendData = [];
legendBfb = [];
for (let i = 0; i < series.length; i++) {
endValue = startValue + series[i].pieData.value;
series[i].pieData.startRatio = startValue / sumValue;
series[i].pieData.endRatio = endValue / sumValue;
series[i].parametricEquation = this.getParametricEquation(
series[i].pieData.startRatio,
series[i].pieData.endRatio,
false,
false,
k,
series[i].pieData.value
);
startValue = endValue;
let bfb = that.fomatFloat(series[i].pieData.value / sumValue, 4);
legendData.push({
name: series[i].name,
value: bfb,
});
legendBfb.push({
name: series[i].name,
value: bfb,
});
}
//()
let boxHeight = this.getHeight3D(series, 15); //3d/
// legendDataseries
let option = {
//
legend: {
data: legendData,
//
orient: "horizontal",
left: "0%",
//
itemGap: 10,
textStyle: {
color: "#A1E2FF",
fontSize: 12,
},
show: true,
icon: "circle",
//
// formatter: function (name) {
// var target;
// for (var i = 0, l = pieData.length; i < l; i++) {
// if (pieData[i].name == name) {
// target = pieData[i].value;
// }
// }
// return `${name}: ${target}`;
// }
//
formatter: function (param) {
let item = legendBfb.filter((item) => item.name == param)[0];
let bfs = that.fomatFloat(item.value * 100, 2) + "%";
return `${item.name} :${bfs}`;
},
},
//
tooltip: {
formatter: (params) => {
if (
params.seriesName !== "mouseoutSeries" &&
params.seriesName !== "pie2d"
) {
let bfb = (
(option.series[params.seriesIndex].pieData.endRatio -
option.series[params.seriesIndex].pieData.startRatio) *
100
).toFixed(2);
return (
`${params.seriesName}<br/>` +
`<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${params.color};"></span>` +
`${bfb}`+
`%`
);
}
},
},
//
xAxis3D: {
min: -1,
max: 1,
},
yAxis3D: {
min: -1,
max: 1,
},
zAxis3D: {
min: -1,
max: 1,
},
//
grid3D: {
show: false,
boxHeight: boxHeight, //
//
top: "22%",
left:"-10%",
viewControl: {
//3d
alpha: 30, //( )
distance: 175, //zoom()
rotateSensitivity: 1, //0
zoomSensitivity: 0, //0
panSensitivity: 0, //0
autoRotate: true, //
},
},
series: series,
};
return option;
},
getHeight3D(series, height) {
series.sort((a, b) => {
return b.pieData.value - a.pieData.value;
});
return (height * 25) / series[0].pieData.value;
},
getParametricEquation(startRatio, endRatio, isSelected, isHovered, k, h) {
//
let midRatio = (startRatio + endRatio) / 2;
let startRadian = startRatio * Math.PI * 2;
let endRadian = endRatio * Math.PI * 2;
let midRadian = midRatio * Math.PI * 2;
//
if (startRatio === 0 && endRatio === 1) {
isSelected = false;
}
// / k 1/3
k = typeof k !== "undefined" ? k : 1 / 3;
// x y 0
let offsetX = isSelected ? Math.cos(midRadian) * 0.1 : 0;
let offsetY = isSelected ? Math.sin(midRadian) * 0.1 : 0;
// 1
let hoverRate = isHovered ? 1.05 : 1;
//
return {
u: {
min: -Math.PI,
max: Math.PI * 3,
step: Math.PI / 32,
},
v: {
min: 0,
max: Math.PI * 2,
step: Math.PI / 20,
},
x: function (u, v) {
if (u < startRadian) {
return (
offsetX +
Math.cos(startRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
if (u > endRadian) {
return (
offsetX + Math.cos(endRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
return offsetX + Math.cos(u) * (1 + Math.cos(v) * k) * hoverRate;
},
y: function (u, v) {
if (u < startRadian) {
return (
offsetY +
Math.sin(startRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
if (u > endRadian) {
return (
offsetY + Math.sin(endRadian) * (1 + Math.cos(v) * k) * hoverRate
);
}
return offsetY + Math.sin(u) * (1 + Math.cos(v) * k) * hoverRate;
},
z: function (u, v) {
if (u < -Math.PI * 0.5) {
return Math.sin(u);
}
if (u > Math.PI * 2.5) {
return Math.sin(u) * h * 0.1;
}
return Math.sin(v) > 0 ? 1 * h * 0.1 : -1;
},
};
},
fomatFloat(num, n) {
var f = parseFloat(num);
if (isNaN(f)) {
return false;
}
f = Math.round(num * Math.pow(10, n)) / Math.pow(10, n); // n
var s = f.toString();
var rs = s.indexOf(".");
//0
if (rs < 0) {
rs = s.length;
s += ".";
}
while (s.length <= rs + n) {
s += "0";
}
return s;
},
},
};
</script>
<style lang='scss' scoped>
.chart-container {
position: relative;
width: 100%;
height: 100%;
.chart,
.pie3d,
.bg {
width: 100%;
height: 100%;
}
.bg {
position: absolute;
bottom: 50px;
left: 50%;
z-index: -1;
width: 180px;
height: 73px;
background: no-repeat center;
background-image: url("https://ks3-cn-beijing.ksyun.com/sxjg-elevator/datav-platform-2.0/images/chart_opacity_bg.png");
background-size: 100% 100%;
transform: translateX(-50%);
}
}
</style>

File diff suppressed because it is too large Load Diff

@ -371,7 +371,7 @@ export default {
/** 分配用户操作 */
handleAuthUser: function(row) {
const datasourceId = row.id;
debugger
// debugger
this.$router.push("/system/datasource-auth/user/" + datasourceId);
},
/** 查询部门下拉树结构 */

@ -328,7 +328,7 @@ export default {
},
/** 提交按钮 */
submitForm() {
debugger
// debugger
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.contentId != null) {

@ -292,7 +292,7 @@ export default {
},
/** 提交按钮 */
submitForm() {
debugger
// debugger
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.contentId != null) {

@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://localhost:8080`,
target: `http://192.168.3.93:8080`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save