添加图片绘制

master
fanluyan 2 years ago
parent 93a8b2adcd
commit ecce8d0d83

@ -0,0 +1,64 @@
<template>
<el-dialog
class="deviceUpgradeDialog"
title="装置升级"
:visible.sync="isShow"
:close-on-click-modal="false"
width="400px"
>
<div class="upload">
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="handleRemove"
:file-list="fileList"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">
只能上传jpg/png文件且不超过500kb
</div>
</el-upload>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</template>
<script>
export default {
props: {
title: String,
},
data() {
return {
isShow: false,
fileList: [],
};
},
mounted() {},
methods: {
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
//
submitForm() {
this.isShow = false;
},
display() {
this.isShow = true;
},
hide() {
this.isShow = false;
},
},
};
</script>
<style lang="less">
.deviceUpgradeDialog {
}
</style>

@ -0,0 +1,172 @@
<template>
<el-dialog
class="pictureTagsDialog"
title="图片绘制"
:visible.sync="isShow"
:close-on-click-modal="false"
width="1000px"
>
<div class="picPannel">
<div class="imgbox">
<img
src="http://47.96.238.157/image/2023/04/24/01/DSH10H00000000001_1_FF_20230424192442.jpg"
/>
<canvas
id="myCanvas"
class="myCanvas"
ref="myCanvas"
@mousedown="mousedown"
@mouseup="mouseup"
@mousemove="mousemove"
></canvas>
</div>
<div class="setBox">
<div class="infoCompany">
<p><label>电压等级</label><span>220kv</span></p>
<p><label>线路名称</label><span>i1测试线路-SH</span></p>
<p><label>装置名称</label><span>XY-SIMULATOR-0001</span></p>
</div>
<div class="setColor">
<p>
<label>颜色</label
><el-color-picker v-model="color"></el-color-picker>
</p>
<p>
<label>线宽</label>
<el-input-number
v-model="num"
controls-position="right"
@change="handleChange"
:min="1"
:max="10"
></el-input-number>
</p>
<p>
<el-button type="primary">重新绘制</el-button>
<el-button type="primary">保存绘制</el-button>
</p>
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</template>
<script>
export default {
props: {
title: String,
},
data() {
return {
color: "#409EFF",
num: 1,
flag: false,
x: 0,
y: 0,
isShow: false,
fileList: [],
};
},
mounted() {},
methods: {
//线
handleChange(value) {
console.log(value);
},
//
submitForm() {
this.isShow = false;
},
display() {
this.isShow = true;
},
hide() {
this.isShow = false;
},
mousedown(e) {
console.log("鼠标落下");
this.flag = true;
this.x = e.offsetX; // X
this.y = e.offsetY; // Y
console.log(this.x, this.y);
},
mouseup(e) {
console.log("鼠标抬起");
this.flag = false;
},
mousemove(e) {
console.log("鼠标移动");
this.drawRect(e);
},
drawRect(e) {
if (this.flag) {
console.log("绘制图形");
const canvas = this.$refs.myCanvas;
var ctx = canvas.getContext("2d");
let x = this.x;
let y = this.y;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
//线
ctx.strokeStyle = this.color;
// 线
ctx.lineWidth = this.num;
console.log(x, y, e.offsetX - x, e.offsetY - y);
ctx.strokeRect(x, y, e.offsetX - x, e.offsetY - y);
}
},
},
};
</script>
<style lang="less">
.pictureTagsDialog {
.picPannel {
display: flex;
flex-direction: row;
justify-content: space-between;
position: relative;
.imgbox {
width: 698px;
position: relative;
img {
width: 100%;
height: 100%;
}
.myCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
.setBox {
width: 230px;
padding: 12px;
border: 3px solid #2d8cf0;
.infoCompany {
display: flex;
flex-direction: column;
line-height: 32px;
margin-bottom: 16px;
}
}
.setColor {
display: flex;
flex-direction: column;
line-height: 32px;
p {
display: flex;
align-items: center;
margin-bottom: 16px;
}
}
}
}
</style>

@ -76,7 +76,7 @@
>装置复位</el-button
>
<el-button type="primary" @click="handleShowErr"
<el-button type="primary" @click="handlePanel"
>图片标记</el-button
>
@ -86,11 +86,18 @@
<el-button type="primary" @click="handleShowErr">
设备信息</el-button
>
<el-button type="primary" @click="handleUpGrade"
>装置升级</el-button
>
</div>
</div>
</div>
</div>
<setschedule ref="setschedule_ref"></setschedule>
<!-- 装置升级 -->
<deviceUpgrade ref="deviceupgrade_ref"></deviceUpgrade>
<!-- 绘制图片 -->
<pictureTags ref="pictureTags_ref"></pictureTags>
</div>
</div>
</template>
@ -104,11 +111,15 @@ import {
import carouselChart from "../components/carouselChart.vue";
import setschedule from "./components/setschedule.vue";
import deviceUpgrade from "./components/deviceUpgrade.vue";
import pictureTags from "./components/pictureTags.vue";
export default {
components: {
carouselChart,
setschedule,
deviceUpgrade,
pictureTags,
},
data() {
return {
@ -268,6 +279,14 @@ export default {
type: "warning",
});
},
//
handleUpGrade() {
this.$refs.deviceupgrade_ref.display();
},
//
handlePanel() {
this.$refs.pictureTags_ref.display();
},
},
};
</script>

Loading…
Cancel
Save