This commit is contained in:
朱菊兰 2023-01-04 15:23:46 +08:00
parent bd4d0e897b
commit 9e9d6dde22
4 changed files with 80 additions and 47 deletions

BIN
src/assets/empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -1,5 +1,11 @@
<template> <template>
<el-form ref="form" :rules="rules" label-width="100px" :model="form"> <el-form
ref="form"
:rules="rules"
label-width="100px"
:model="form"
class="device-add"
>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="产线" prop="proLineId"> <el-form-item label="产线" prop="proLineId">
@ -144,7 +150,7 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="设备图片" prop="imgId"> <el-form-item label="设备图片" prop="imgId">
<div v-if="deviceImg" style="position: relative"> <div v-if="deviceImg" style="position: relative" class="img-box">
<el-image <el-image
:src="deviceImg" :src="deviceImg"
class="avatar" class="avatar"
@ -232,8 +238,10 @@ export default {
this.isEdit = true this.isEdit = true
getEquipment({ id }).then((res) => { getEquipment({ id }).then((res) => {
if (res.code === 0) { if (res.code === 0) {
this.form = res.data
this.form.proLineId = res.data.proLineId this.form.proLineId = res.data.proLineId
getUnitList(this.form.proLineId).then((res) => {
this.unitModuleList = res.data || []
})
this.form.unitId = res.data.unitId this.form.unitId = res.data.unitId
this.form.name = res.data.name this.form.name = res.data.name
this.form.spec = res.data.spec this.form.spec = res.data.spec
@ -342,38 +350,45 @@ export default {
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.avatar { .device-add {
width: 100%; .device-uploader {
cursor: pointer;
}
.avatar-close-icon {
font-size: 24px;
position: absolute;
right: -10px;
top: -10px;
cursor: pointer;
}
.device-uploader {
width: 178px;
height: 178px;
display: block;
.el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px; width: 178px;
height: 178px; height: 178px;
line-height: 178px; display: block;
text-align: center; .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
}
}
</style>
<style lang="scss" scoped>
.img-box {
border: 1px dashed #d9d9d9;
.avatar {
width: 100%;
cursor: pointer;
}
.avatar-close-icon {
font-size: 24px;
position: absolute;
right: -10px;
top: -10px;
cursor: pointer;
} }
} }
</style> </style>

View File

@ -5,8 +5,10 @@
<el-tree <el-tree
:data="treeData" :data="treeData"
node-key="id" node-key="id"
ref="deviceStatusTree"
:props="defaultProps" :props="defaultProps"
default-expand-all default-expand-all
highlight-current
@node-click="clickDevice" @node-click="clickDevice"
> >
</el-tree> </el-tree>
@ -19,10 +21,11 @@
<li>设备模式{{ eqMessage.mode }}</li> <li>设备模式{{ eqMessage.mode }}</li>
<li>设备状态{{ eqMessage.state }}</li> <li>设备状态{{ eqMessage.state }}</li>
<li>设备报警{{ eqMessage.alarmNum }}</li> <li>设备报警{{ eqMessage.alarmNum }}</li>
<li>剩余维护时间{{ eqMessage.mode }}</li> <li>剩余维护时间{{ eqMessage.remainMainTime }}</li>
</ul> </ul>
<div class="img-box"> <div class="img-box">
<img src="./../../assets/monitor/eq_img.jpg" alt="设备图片" /> <img v-if="eqMessage.imgId" :src="deviceImg" alt="设备图片" />
<img v-else src="./../../assets/empty.png" alt="设备图片" />
</div> </div>
</div> </div>
</el-col> </el-col>
@ -40,35 +43,49 @@ export default {
children: 'children', children: 'children',
label: 'name' label: 'name'
}, },
eqMessage: {} eqMessage: {},
equipmentId: '',
deviceImg: ''
} }
}, },
mounted() { mounted() {
this.getTree() this.getTree()
this.getMsg()
}, },
methods: { methods: {
getTree() { getTree() {
getTreeData().then((res) => { getTreeData().then((res) => {
this.treeData = res.data this.treeData = res.data
this.equipmentId = this.getId(res.data)
this.setCurrent()
this.getMsg()
}) })
}, },
getId(val) {
if (val[0].children) {
return this.getId(val[0].children)
} else {
return val[0].id
}
},
setCurrent() {
let _this = this
setTimeout(function () {
_this.$refs.deviceStatusTree.setCurrentKey(1)
}, 500)
},
getMsg() { getMsg() {
eqMonitorGet({ equipmentId: 1 }).then((res) => { eqMonitorGet({ equipmentId: this.equipmentId }).then((res) => {
console.log(res) console.log(res)
this.eqMessage = res.data this.eqMessage = res.data
this.deviceImg = process.env.VUE_APP_VIEW_PIC + res.data.imgId
}) })
}, },
clickDevice(val) { clickDevice(val) {
console.log(val) console.log(val)
// if (!val.children) { if (!val.children) {
// this.$refs.searchBarForm.resetForm() this.equipmentId = val.id
// this.listQuery.spec = '' this.getMsg()
// this.listQuery.code = '' }
// this.listQuery.id = val.id
// this.listQuery.current = 1
// this.getList()
// }
} }
} }
} }
@ -119,6 +136,7 @@ export default {
} }
} }
.img-box { .img-box {
text-align: center;
img { img {
max-width: 100%; max-width: 100%;
max-height: calc(100vh - 300px); max-height: calc(100vh - 300px);

File diff suppressed because one or more lines are too long