From 54d11f9a2f395e021486e6a31912616274b3feda Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期一, 08 九月 2025 11:55:10 +0800 Subject: [PATCH] 车间智慧看板页面新增定时刷新功能 --- src/views/mdc/base/modules/WorkshopSignage/UtilizationRateRankChart.vue | 195 ++++++++++++++++++++++++------------------------ 1 files changed, 97 insertions(+), 98 deletions(-) diff --git a/src/views/mdc/base/modules/WorkshopSignage/UtilizationRateRankChart.vue b/src/views/mdc/base/modules/WorkshopSignage/UtilizationRateRankChart.vue index cd1a9ab..e22aad6 100644 --- a/src/views/mdc/base/modules/WorkshopSignage/UtilizationRateRankChart.vue +++ b/src/views/mdc/base/modules/WorkshopSignage/UtilizationRateRankChart.vue @@ -15,7 +15,6 @@ } }, mounted() { - this.getUtilizationRateRankByApi() window.addEventListener('resize', this.handleWindowSizeChange) }, methods: { @@ -68,7 +67,7 @@ } ] const defaultData = [] - const dataMax = +data.sort((x, y) => +y.value - +x.value)[0].value + const dataMax = data.length > 0 ? +data.sort((x, y) => +y.value - +x.value)[0].value : 0 let yAxisMax if (dataMax === 0) yAxisMax = 1 // 鑻ユ暟鎹腑鏈�澶у�间负0锛屽垯灏嗚儗鏅粯璁ゅ�艰缃负1 else yAxisMax = Math.ceil(dataMax / 5) * 5 // 璁剧疆鏌卞浘鑳屾櫙闃村奖榛樿鍊硷紝鎬濊矾涓烘暟鎹渶澶у�兼渶鎺ヨ繎鐨勮兘琚�5鏁撮櫎鐨勬暟瀛� @@ -118,98 +117,102 @@ show: false } }, - yAxis: [{ - type: 'category', - inverse: true, - triggerEvent: true, - axisLabel: { - show: true, - textStyle: { - color: '#fff', - fontSize: '14', - fontWeight: 'bolder' - }, - formatter: function(value) { - return `${data.find(item => item.name === value).name}` - } - }, - splitLine: { - show: false - }, - axisTick: { - show: false - }, - axisLine: { - show: false - }, - data: data.map(item => item.name) - }, { - type: 'category', - inverse: true, - axisTick: 'none', - axisLine: 'none', - show: true, - axisLabel: { - textStyle: { - color: '#ffffff', - fontSize: '14' - }, - formatter: function(value) { - return `${value}%` - } - }, - data: data - }], - series: [{ - name: '鍒╃敤鐜�', - type: 'bar', - zlevel: 1, - itemStyle: { - barBorderRadius: 100, - color: function(params) { - let num = colorArray.length - return { - type: 'linear', - colorStops: [{ - offset: 0, - color: colorArray[params.dataIndex % num].bottom - }, { - offset: 1, - color: colorArray[params.dataIndex % num].top - }, { - offset: 0, - color: colorArray[params.dataIndex % num].bottom - }, { - offset: 1, - color: colorArray[params.dataIndex % num].top - }, { - offset: 0, - color: colorArray[params.dataIndex % num].bottom - }, { - offset: 1, - color: colorArray[params.dataIndex % num].top - }, { - offset: 0, - color: colorArray[params.dataIndex % num].bottom - }, { - offset: 1, - color: colorArray[params.dataIndex % num].top - }, { - offset: 0, - color: colorArray[params.dataIndex % num].bottom - }, { - offset: 1, - color: colorArray[params.dataIndex % num].top - }, { - offset: 0, - color: colorArray[params.dataIndex % num].bottom - }] + yAxis: [ + { + type: 'category', + inverse: true, + triggerEvent: true, + axisLabel: { + show: true, + textStyle: { + color: '#fff', + fontSize: '14', + fontWeight: 'bolder' + }, + formatter: function(value) { + return `${data.find(item => item.name === value).name}` } - } + }, + splitLine: { + show: false + }, + axisTick: { + show: false + }, + axisLine: { + show: false + }, + data: data.map(item => item.name) }, - barWidth: 12, - data: data - }, + { + type: 'category', + inverse: true, + axisTick: 'none', + axisLine: 'none', + show: true, + axisLabel: { + textStyle: { + color: '#ffffff', + fontSize: '14' + }, + formatter: function(value) { + return `${value}%` + } + }, + data: data + } + ], + series: [ + { + name: '鍒╃敤鐜�', + type: 'bar', + zlevel: 1, + itemStyle: { + borderRadius: 100, + color: function(params) { + let num = colorArray.length + return { + type: 'linear', + colorStops: [{ + offset: 0, + color: colorArray[params.dataIndex % num].bottom + }, { + offset: 1, + color: colorArray[params.dataIndex % num].top + }, { + offset: 0, + color: colorArray[params.dataIndex % num].bottom + }, { + offset: 1, + color: colorArray[params.dataIndex % num].top + }, { + offset: 0, + color: colorArray[params.dataIndex % num].bottom + }, { + offset: 1, + color: colorArray[params.dataIndex % num].top + }, { + offset: 0, + color: colorArray[params.dataIndex % num].bottom + }, { + offset: 1, + color: colorArray[params.dataIndex % num].top + }, { + offset: 0, + color: colorArray[params.dataIndex % num].bottom + }, { + offset: 1, + color: colorArray[params.dataIndex % num].top + }, { + offset: 0, + color: colorArray[params.dataIndex % num].bottom + }] + } + } + }, + barWidth: 12, + data: data + }, { name: '鑳屾櫙', type: 'bar', @@ -218,7 +221,7 @@ data: defaultData, itemStyle: { color: '#11294d', - barBorderRadius: 100 + borderRadius: 100 } } ] @@ -240,8 +243,4 @@ } } } -</script> - -<style scoped lang="less"> - -</style> \ No newline at end of file +</script> \ No newline at end of file -- Gitblit v1.9.3