This commit is contained in:
2023-04-19 15:06:31 +08:00
24 changed files with 751 additions and 26 deletions

View File

@@ -0,0 +1,110 @@
<template>
<div :class="className" :style="{height:height,width:width}" />
</template>
<script>
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import { debounce } from '@/utils'
export default {
props: {
className: {
type: String,
default: 'chart'
},
width: {
type: String,
default: '100%'
},
height: {
type: String,
default: '380px'
},
chartData: {
type: Object,
required: true
}
},
data() {
return {
chart: null
}
},
watch: {
chartData: {
deep: true,
handler(val) {
this.setOptions(val)
}
}
},
mounted() {
this.initChart()
this.__resizeHandler = debounce(() => {
if (this.chart) {
this.chart.resize()
}
}, 100)
window.addEventListener('resize', this.__resizeHandler)
},
beforeDestroy() {
if (!this.chart) {
return
}
window.removeEventListener('resize', this.__resizeHandler)
this.chart.dispose()
this.chart = null
},
methods: {
initChart() {
this.chart = echarts.init(this.$el, 'macarons')
this.setOptions(this.chartData)
},
setOptions({ expectedData, actualData } = {}) {
this.chart.setOption({
title: {
text: '一周任务数'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: expectedData,
axisTick: {
alignWithLabel: true
}
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '任务数',
type: 'bar',
barWidth: '60%',
data: actualData,
itemStyle: {
color: 'green'
}
}
]
})
}
}
}
</script>

View File

@@ -0,0 +1,17 @@
import request from '@/utils/request'
export function queryDeviceInfo(data) { // 获取设备信息
return request({
url: 'api/wms/task/queryDeviceInfo',
method: 'post',
data: data
})
}
export function sendAgvChargeTask(data) { // 下发AGV充电任务
return request({
url: 'api/wms/task/sendAgvChargeTask',
method: 'post',
data: data
})
}

View File

@@ -0,0 +1,201 @@
<template>
<div style="background-color: rgb(240, 242, 245); padding-top: 10px;padding-bottom: 10px">
<div style="margin-top: 20px;margin-left: 30px">
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="80px"
label-suffix=":"
>
<el-form-item label="车间区域">
<el-select
v-model="form.flag"
size="mini"
placeholder="请选择"
class="filter-item"
@change="changeFlag"
>
<el-option
v-for="item in agvRegionList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-form>
</div>
<el-row :gutter="24" style="margin-top: 10px; margin-left: 10px; margin-right: 10px; margin-bottom: 500px">
<el-col :span="18" style="margin-left: 150px; margin-right: 150px; margin-top: 50px">
<el-col v-for="agvObj in agvList" :span="24/agvList.length">
<el-card>
<!-- <div v-if="agvObj.car_no === '' || agvObj.car_no == null" class="grid-content bg-purple" style="height: 250px;background-color: white;border-bottom:3px solid rgb(240, 242, 245)">-->
<!-- 请添加更多AGV设备-->
<!-- </div>-->
<div v-if="agvObj.car_no !== '' && agvObj.car_no != null" class="grid-content bg-purple" style="height: 350px;background-color: white;border-bottom:0px solid rgb(240, 242, 245)">
<el-row>
<el-col :span="8">
<img
:src="require('@/assets/images/home_agv.png')"
alt=""
width="50px"
height="50px;"
style="margin-top: 10px;margin-left: 50px; vertical-align:bottom;transform: rotate(0deg);"
>
</el-col>
<el-col :span="16">
<div class="grid-content bg-purple" style="height: 70px; font-size: 30px; text-align: center;line-height: 70px;">{{ agvObj.car_no }}
</div>
</el-col>
</el-row>
<el-row>
<div class="grid-content bg-purple" style="height: 50px;">
<el-col :span="8" style="line-height: 40px; text-align: center">
电量
</el-col>
<el-col :span="16">
<el-progress v-if="agvObj.electricity<=30" :text-inside="true" :stroke-width="25" :percentage="agvObj.electricity" status="exception" style="margin-top: 7px; margin-right: 5px;"/>
<el-progress v-if="agvObj.electricity>30 && agvObj.electricity<100" :text-inside="true" :stroke-width="25" :percentage="agvObj.electricity" status="warning" style="margin-top: 7px; margin-right: 5px;"/>
<el-progress v-if="agvObj.electricity == 100" :text-inside="true" :stroke-width="25" :percentage="agvObj.electricity" status="success" style="margin-top: 7px; margin-right: 5px;"/>
</el-col>
</div>
</el-row>
<el-row>
<div class="grid-content bg-purple" style="height: 50px;">
<el-col :span="8" style="line-height: 40px; text-align: center">
状态
</el-col>
<el-col :span="16" style="line-height: 40px; text-align: center">
{{ agvObj.status_name }}
</el-col>
</div>
</el-row>
<el-row>
<div class="grid-content bg-purple" style="height: 50px;">
<el-col :span="8" style="line-height: 40px; text-align: center">
任务
</el-col>
<el-col :span="16" style="line-height: 40px; text-align: center">
{{ agvObj.task_code }}
</el-col>
</div>
</el-row>
<el-row>
<div class="grid-content bg-purple" style="height: 50px;">
<el-col :span="8" style="line-height: 40px; text-align: center">
报警
</el-col>
<el-col :span="16" style="line-height: 40px; text-align: center">
{{ agvObj.fault }}
</el-col>
</div>
</el-row>
<el-row>
<div v-if="form.flag === '5'" class="grid-content bg-purple" style="padding-left: 400px; padding-top: 30px">
<el-button
class="filter-item"
type="success"
icon="el-icon-position"
size="mini"
@click="charge_task(agvObj)"
>
AGV充电
</el-button>
</div>
<div v-if="form.flag !== '5'" class="grid-content bg-purple" style="padding-left: 160px; padding-top: 30px">
<el-button
class="filter-item"
type="success"
icon="el-icon-position"
size="mini"
@click="charge_task(agvObj)"
>
AGV充电
</el-button>
</div>
</el-row>
</div>
</el-card>
</el-col>
</el-col>
</el-row>
</div>
</template>
<script>
import { queryDeviceInfo, sendAgvChargeTask } from '@/views/wms/agvrush/charge/chargeQuery'
export default {
name: 'Dashboard',
components: {},
data() {
return {
form: {
flag: '1'
},
listA1: [],
listLk: [],
agvList: [
],
agvRegionList: [
{ 'label': 'A1', 'value': '1' },
{ 'label': 'A2', 'value': '2' },
{ 'label': 'A3', 'value': '3' },
{ 'label': 'A4', 'value': '4' },
{ 'label': 'LK', 'value': '5' }
]
}
},
mounted() {
this.init()
},
beforeDestroy() {
// js提供的clearInterval方法用来清除定时器
console.log('定时器销毁')
clearInterval(this.timer)
},
methods: {
init() {
this.initStatus()
this.timer = setInterval(() => { // 定时刷新
console.log('定时器启动')
this.initStatus()
}, 10000)
},
initStatus() {
const data = {
'region_code': this.form.flag
}
queryDeviceInfo(data).then(res => {
this.listA1 = res.data.jsonA1
this.listLk = res.data.jsonLK
this.changeFlag(this.form.flag)
})
},
changeFlag(val) {
if (val === '1') {
this.agvList = this.listA1
} else if (val === '5') {
this.agvList = this.listLk
} else {
this.agvList = []
}
},
charge_task(data) {
sendAgvChargeTask(data).then(res => {
this.$message({
message: '下发成功',
type: 'success'
})
})
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>

View File

@@ -138,7 +138,6 @@ export default {
// 展开显示设备信息 todo: 1
if (data.data.type !== 'pro-rect' && data.data.type !== 'pro-circle' && data.data.type !== 'triangle' && data.data.type !== 'rect-radius') {
if (data.data.properties.struct_id) {
debugger
this.moveShow(data.data) // 传递节点数据用来获取id做比对
this.dialogDeviceMsgVisible = true
this.struct_id = data.data.properties.struct_id // ?暂时没用