2024-09-09 修改了大部分下拉组件为模糊筛选,减轻前端渲染压力

This commit is contained in:
2024-09-09 15:26:17 +08:00
parent fe5d3b70df
commit 563132273c
717 changed files with 107188 additions and 138520 deletions

View File

@@ -0,0 +1,423 @@
<template>
<div>
<el-card style="height: 880px">
<!--<el-checkbox v-model="selectionStatus" style="margin-bottom: 80px; margin-left: 500px;margin-top: 20px" @change="searchData();disAble()">按设备</el-checkbox>-->
<!-- <span></span>-->
<!-- <el-select v-if="trigGer" v-model="MachineValue" filterable size="small" disabled style="width:160px;margin-bottom:90px; margin-top: 20px" placeholder="工位号"/>-->
<el-select v-model="MachineValue" filterable size="small" style="width:160px;margin-bottom:90px; margin-top: 20px;margin-left: 500px" placeholder="选择工位-设备">
<el-option
v-for="item in Machine"
:key="item.value"
:label="item.label"
:value="item.value">
<div style="float: left">{{ item.label }}</div>
<div style="float: right; color: #8492a6; font-size: 13px">{{ item.value2 }}</div>
</el-option>
</el-select>
<span style="font-size: 13px;color: black">查询时间</span>
<el-date-picker
v-model="dateRange"
size="small"
type="daterange"
align="center"
style="width: 240px; margin-top: 20px"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"/>
<el-button type="primary" plain size="small" icon="el-icon-search" style="margin-left: 15px; margin-top: 20px" @click="searchData()">查询</el-button>
<!-- <el-button type="primary" plain size="small" icon="el-icon-search" style="margin-left: 15px" @click="equipmentSearch()">总设备查询</el-button>-->
<div id="myChart1" style="width: 1620px; height: 520px; margin: auto"/>
</el-card>
</div>
</template>
<script>
export default {
data() {
return {
dateRange: [
],
// date1: '',
// date2: '',
MachineValue: '',
Machine: [],
colors: [],
state: [],
table1: [],
table: [],
num: 0,
trigGer: true,
stationNumber: true,
selectionStatus: false
// checked: true
}
},
watch: {
selectionStatus() {
this.searchData()
}
},
created() {
this.fetchData()
this.getCurrentTime()
this.searchData()
// this.$nextTick(function() {
// this.fetchData()
// this.getCurrentTime()
// this.searchData()
// })
},
methods: {
fetchData() {
var param = []
var Data = this.CreateData('11', '车间生产管理工艺_加工顺序调整_查询工位及人员', param)
this.ExecDatabase(Data).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.Machine.push({
label: response.data[i].终端编号,
value: response.data[i].终端编号,
value2: response.data[i].设备名称
})
}
})
},
getCurrentTime() {
this.dateRange[0] = this.getTime0(-10)
this.dateRange[1] = this.getTime0(0)
},
getTime0(num) {
var date0 = new Date()
var date = new Date(date0.getTime() + num * 24 * 60 * 60 * 1000)
var month = this.zeroFill(date.getMonth() + 1)
var day = this.zeroFill(date.getDate())
var hour = this.zeroFill(date.getHours())
var minute = this.zeroFill(date.getMinutes())
var second = this.zeroFill(date.getSeconds())
return date.getFullYear() + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
},
zeroFill(i) {
if (i >= 0 && i <= 9) {
return '0' + i
} else {
return i
}
},
/* disAble() {
if (this.selectionStatus === false) {
this.stationNumber = true
} else {
this.stationNumber = false
}
},*/
searchData() {
if (this.dateRange[0] === null || this.dateRange[1] === null) {
this.$message.warning('请选择开始时间或结束时间')
} else {
console.log('李显523')
console.log(this.dateRange[0], this.dateRange[1])
this.num = ((new Date(this.dateRange[1]) - new Date(this.dateRange[0])) / (1000 * 60 * 60 * 24)) + 1
var param = []
var Data = this.CreateData('11', 'MES_机加工MES_设备状态查询_初始化', param)
this.ExecDatabase(Data).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.colors.push(response.data[i].颜色)
this.state.push(response.data[i].状态)
}
})
var param2 = []
param2[0] = ['工位号', this.MachineValue]
param2[1] = ['开始时间', this.dateRange[0]]
param2[2] = ['结束时间', this.dateRange[1]]
var Data2 = this.CreateData('11', '车间生产管理_设备运行情况_查询数据_状态分布图_新', param2)
this.ExecDatabase(Data2).then(response => {
console.log('李显521')
console.log(this.MachineValue)
console.log(this.dateRange[0])
console.log(this.dateRange[1])
this.table1 = response.data
// this.time = true
// this.equipment = false
}).then(() => {
// this.drawLine()
this.drawLine()
})
}
},
drawLine() {
const _this = this
_this.data = []
_this.index = 0
_this.yAxisValue = []
for (let i = 0; i < _this.table1.length; i++) { // 取开始结束时间HH-mm取状态日期yyyy-MM-dd持续时间
_this.fixDate = _this.table1[0].日期.substr(0, 10)
_this.table1[i].开始时间 = _this.fixDate + ' ' + _this.table1[i].开始时间.substr(11, 5)
_this.table1[i].结束时间 = _this.fixDate + ' ' + _this.table1[i].结束时间.substr(11, 5)
_this.table1[i].日期 = _this.table1[i].日期.substr(0, 10)
}
if (_this.table1.length === 1) {
_this.data.push({
itemStyle: { normal: { color: _this.table1[0].颜色 }}, // 条形颜色
name: _this.table1[0].状态,
value: [0, _this.table1[0].开始时间, _this.table1[0].结束时间]
})
} else {
for (let i = 0; i < _this.table1.length; i++) {
if (i < _this.table1.length) {
if (i === 0) {
_this.index = 0
_this.yAxisValue.push(_this.table1[i].日期)
} else if (_this.table1[i].日期 !== _this.table1[i - 1].日期) {
_this.index++ // y轴索引
_this.yAxisValue.push(_this.table1[i].日期)
}
}
_this.data.push({
itemStyle: { normal: { color: _this.table1[i].颜色 }}, // 条形颜色
name: _this.table1[i].状态,
value: [parseInt(_this.index), _this.table1[i].开始时间, _this.table1[i].结束时间]
})
}
}
const myChart1 = _this.$echarts.init(document.getElementById('myChart1'))
myChart1.clear()
myChart1.setOption({
title: {
left: 'center',
text: '设备状态分布图'
},
color: _this.colors,
tooltip: { // 提示框
formatter(params) {
return params.value[1].substr(11, 5) + '~' + params.value[2].substr(11, 5)
} // 数据的值
},
legend: { // 图例
left: 'right',
selectedMode: false // 图例可点击
},
dataZoom: [{
type: 'inside',
start: 0,
end: 100
}, { // X轴可调
xAxisIndex: 0,
start: 0,
end: 100,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '80%',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
}
}],
grid: { // 绘图网格
left: '3%',
right: '3%',
top: '10%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'time',
interval: 1000 * 60 * 60,
axisLabel: {
formatter(value) {
var date = new Date(value)
return getzf(date.getHours()) + ':' + getzf(date.getMinutes())
function getzf(num) {
if (parseInt(num) < 10) {
num = '0' + num
}
return num
}
}
}
},
yAxis: {
data: _this.yAxisValue
},
series: [
// 用空bar来显示几个图例
{ name: _this.state[0], type: 'bar', data: [] },
{ name: _this.state[1], type: 'bar', data: [] },
{ name: _this.state[2], type: 'bar', data: [] },
{ name: _this.state[3], type: 'bar', data: [] },
{ name: _this.state[4], type: 'bar', data: [] },
{
type: 'custom', renderItem(params, api) { // 开发者自定义的图形元素渲染逻辑,是通过书写 renderItem 函数实现的
var categoryIndex = api.value(0) // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
var start = api.coord([api.value(1), categoryIndex]) // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
var end = api.coord([api.value(2), categoryIndex])
var height = 120 // 柱体宽度
return {
type: 'rect', // 表示这个图形元素是矩形。还可以是 'circle', 'sector', 'polygon' 等等。
shape: _this.$echarts.graphic.clipRectByRect({ // 矩形的位置和大小。
x: start[0],
y: start[1] - height / (_this.num > 4 ? 4 : _this.num),
width: end[0] - start[0],
height: height / (_this.num > 4 ? 4 : _this.num)
}, { // 当前坐标系的包围盒。
x: params.coordSys.x,
y: params.coordSys.y,
width: params.coordSys.width,
height: params.coordSys.height
}),
style: api.style()
}
},
encode: {
x: [1, 2], // data 中『维度1』和『维度2』对应到 X 轴
y: 0 // data 中『维度0』对应到 Y 轴
},
data: _this.data
}
]
})
},
drawLine1() {
const _this = this
_this.data = []
_this.index = 0
// _this.yAxisValue1 = []
_this.yAxisValue = ['OP1370', 'OP1050', 'OP1420', 'OP1380', 'OP1360', 'OP1520', 'OP1390', 'OP1340']
for (let i = 0; i < _this.table1.length; i++) { // 取开始结束时间HH-mm取状态日期yyyy-MM-dd持续时间
_this.fixDate = _this.table1[0].日期.substr(0, 10)
_this.table1[i].开始时间 = _this.fixDate + ' ' + _this.table1[i].开始时间.substr(11, 5)
_this.table1[i].结束时间 = _this.fixDate + ' ' + _this.table1[i].结束时间.substr(11, 5)
_this.table1[i].日期 = _this.table1[i].日期.substr(0, 10)
}
if (_this.table1.length === 1) {
_this.data.push({
itemStyle: { normal: { color: _this.table1[0].颜色 }}, // 条形颜色
name: _this.table1[0].状态,
value: [0, _this.table1[0].开始时间, _this.table1[0].结束时间]
})
} else {
for (let i = 0; i < _this.table1.length; i++) {
if (i < _this.table1.length) {
if (i === 0) {
_this.index = 0
} else if (_this.table1[i].日期 !== _this.table1[i - 1].日期) {
_this.index++ // y轴索引
}
}
_this.data.push({
itemStyle: { normal: { color: _this.table1[i].颜色 }}, // 条形颜色
name: _this.table1[i].状态,
value: [parseInt(_this.index), _this.table1[i].开始时间, _this.table1[i].结束时间]
})
}
}
const myChart1 = _this.$echarts.init(document.getElementById('myChart1'))
myChart1.clear()
myChart1.setOption({
title: {
left: 'center',
text: '设备状态分布图'
},
color: _this.colors,
tooltip: { // 提示框
formatter(params) {
return params.value[1].substr(11, 5) + '~' + params.value[2].substr(11, 5)
} // 数据的值
},
legend: { // 图例
left: 'right',
selectedMode: false // 图例可点击
},
dataZoom: [{
type: 'inside',
start: 0,
end: 100
}, { // X轴可调
xAxisIndex: 0,
start: 0,
end: 100,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '80%',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
}
}],
grid: { // 绘图网格
left: '3%',
right: '3%',
top: '10%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'time',
interval: 1000 * 60 * 60,
axisLabel: {
formatter(value) {
var date = new Date(value)
return getzf(date.getHours()) + ':' + getzf(date.getMinutes())
function getzf(num) {
if (parseInt(num) < 10) {
num = '0' + num
}
return num
}
}
}
},
yAxis: {
data: _this.yAxisValue
},
series: [
// 用空bar来显示几个图例
{ name: _this.state[0], type: 'bar', data: [] },
{ name: _this.state[1], type: 'bar', data: [] },
{ name: _this.state[2], type: 'bar', data: [] },
{ name: _this.state[3], type: 'bar', data: [] },
{
type: 'custom', renderItem(params, api) { // 开发者自定义的图形元素渲染逻辑,是通过书写 renderItem 函数实现的
var categoryIndex = api.value(0) // 这里使用 api.value(0) 取出当前 dataItem 中第一个维度的数值。
var start = api.coord([api.value(1), categoryIndex]) // 这里使用 api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
var end = api.coord([api.value(2), categoryIndex])
var height = 120 // 柱体宽度
return {
type: 'rect', // 表示这个图形元素是矩形。还可以是 'circle', 'sector', 'polygon' 等等。
shape: _this.$echarts.graphic.clipRectByRect({ // 矩形的位置和大小。
x: start[0],
y: start[1] - height / (_this.num > 4 ? 4 : _this.num),
width: end[0] - start[0],
height: height / (_this.num > 4 ? 4 : _this.num)
}, { // 当前坐标系的包围盒。
x: params.coordSys.x,
y: params.coordSys.y,
width: params.coordSys.width,
height: params.coordSys.height
}),
style: api.style()
}
},
encode: {
x: [1, 2], // data 中『维度1』和『维度2』对应到 X 轴
y: 0 // data 中『维度0』对应到 Y 轴
},
data: _this.data
}
]
})
}
}
}
</script>
<style scoped>
</style>