新增模板 预览 修正部分语法

2.1
咬轮猫 4 years ago
parent 13e23fc4dc
commit 070af46c61

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

@ -182,7 +182,7 @@
"type": "TextSvg",
"title": "文字",
"panel_class":"draggable",
"template": "<text x=\"0\" y=\"0\" font-size=\"50\" :fill=\"prop_data.svgColor\">{{prop_data.title}}</text>",
"template": "<text x=\"0\" y=\"0\" font-size=\"10\" :fill=\"prop_data.svgColor\">{{prop_data.title}}</text>",
"props": ["prop_data"],
"default_attr":{
"color":"#FF0000"
@ -208,7 +208,7 @@
"type": "TransformerYSvg",
"title": "电流互感器Y",
"panel_class":"draggable",
"template": "<ellipse cx=\"0\" cy=\"0\" rx=\"10\" ry=\"10\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></ellipse> <line x1=\"-2\" y1=\"-6\" x2=\"-2\" y2=\"6\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line> <line x1=\"-2\" y1=\"-6\" x2=\"4\" y2=\"0\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line> <line x1=\"4\" y1=\"2\" x2=\"-2\" y2=\"6\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line>",
"template": "<ellipse cx=\"0\" cy=\"0\" rx=\"10\" ry=\"10\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></ellipse> <line x1=\"5\" y1=\"-5\" x2=\"0\" y2=\"0\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line> <line x1=\"-5\" y1=\"-5\" x2=\"0\" y2=\"0\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line> <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"5\" fill=\"none\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line>",
"props": ["prop_data"],
"default_attr":{
"color":"#FF0000"
@ -269,11 +269,37 @@
"create_type":"click",
"priview_img":"/VerticalLineSvg.png"
},
{
"type": "ConnHorizontalLineSvg",
"title": "连接线-横线",
"panel_class":"draw",
"template": "<line x1=\"0\" y1=\"0\" :x2=\"(prop_data.mPoint.endX-prop_data.mPoint.startX)\" y2=\"0\" :fill=\"prop_data.svgColor\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line>",
"props": ["prop_data"],
"default_attr":{
"color":"#FF0000"
},
"data_type":"none",
"create_type":"click",
"priview_img":"/ConnHorizontalLineSvg.png"
},
{
"type": "ConnVerticalLineSvg",
"title": "连接线-竖线",
"panel_class":"draw",
"template": "<line x1=\"0\" y1=\"0\" x2=\"0\" :y2=\"(prop_data.mPoint.endY-prop_data.mPoint.startY)\" :fill=\"prop_data.svgColor\" :stroke=\"prop_data.svgColor\" stroke-width=\"2\"></line>",
"props": ["prop_data"],
"default_attr":{
"color":"#FF0000"
},
"data_type":"none",
"create_type":"click",
"priview_img":"/VerticalLineSvg.png"
},
{
"type": "EchartsPieSvg",
"title": "Echart饼图",
"panel_class":"chart",
"template": "<foreignObject x=\"0\" y=\"0\" width=\"400\" height=\"400\"> <v-chart :option=\"prop_data.echarts_option\" /></foreignObject>",
"template": "<foreignObject x=\"0\" y=\"0\" width=\"600\" height=\"500\"> <v-chart :option=\"prop_data.echartsOption\" /></foreignObject>",
"props": ["prop_data"],
"default_attr":{
"color":"#000000",
@ -287,7 +313,7 @@
"type": "EchartsBasicBarSvg",
"title": "Echart基础柱状图",
"panel_class":"chart",
"template": "<foreignObject x=\"0\" y=\"0\" width=\"400\" height=\"400\"> <v-chart :option=\"prop_data.echarts_option\" /></foreignObject>",
"template": "<foreignObject x=\"0\" y=\"0\" width=\"400\" height=\"400\"> <v-chart :option=\"prop_data.echartsOption\" /></foreignObject>",
"props": ["prop_data"],
"default_attr":{
"color":"#000000",

File diff suppressed because it is too large Load Diff

@ -24,7 +24,7 @@
<ul class="svg-nav-list">
<li v-for="item in drawComponentList"
:key="item"
:class="$store.state.CurrentlySelectedToolBar.CreateType==item.create_type?'toolbar-selected':''">
:class="$store.state.CurrentlySelectedToolBar.Type==item.type?'toolbar-selected':''">
<div class="title">{{item.title}}</div>
<img :title="item.title"
@mousedown="Mousedown(item.type,item.title,item.default_attr,item.create_type)"

@ -36,6 +36,8 @@
@ok="versionModelHandleOk">
<p>新增绘制组件</p>
<p>新增图表</p>
<p>新增模板-加载模板后点击预览-点击模拟硬件-等待两秒查看效果</p>
<p>如果图片加载不出来请清空缓存刷新(F12右键刷新按钮-选择清空缓存并进行硬刷新)</p>
</a-modal>
<!-- <a-button type="primary"
@ -46,6 +48,9 @@
<a-button type="danger"
@click="versionModelVisible=true">当前为2.1版本</a-button>
<a-button type="primary"
@click="testA"
style="margin-left:20px">载入模板</a-button>
<a-button type="primary"
@click="testH"
style="margin-left:20px">预览</a-button>
@ -70,13 +75,18 @@
<a-button type="primary">在线绘图</a-button>
</a>
<a style="margin-left:20px"
href="https://github.com/yaolunmao/vue-webtopo-svgeditor">
href="https://www.cnblogs.com/Hero-/p/14784744.html"
target="_blank">
<a-button type="primary">帮助</a-button>
</a>
<a style="margin-left:20px">
<a-button type="primary"
@click="exportSvg">导出svg</a-button>
</a>
<a style="margin-left:20px">
<a-button type="primary"
@click="exportData">导出数据</a-button>
</a>
</a-layout-header>
<span v-if="!shrink"
@click="exitFullscreen"
@ -85,25 +95,29 @@
<a-layout-sider class="leftNav">
<LeftToolBar :svgInfoData=svgInfoData></LeftToolBar>
</a-layout-sider>
<a-layout-content class="centerContain"
:class="{ fixed: !shrink }">
<a-layout-content
:class="{ fixed: !shrink }"
style="transform: scale(1)">
<div class="canvas-content"
id="canvas"
ref="canvas"
@mousemove="MouseMove"
@mousedown="MousedownCanvas"
@mouseup="MouseupCanvas"
@dblclick="DblClick"
@mousewheel="MouseWheel">
<!--拖动辅助线-->
<div id="guide-x"></div>
<div id="guide-y"></div>
<div id="guide-x"
ref="guidex_dom"></div>
<div id="guide-y"
ref="guidey_dom"></div>
<!-- 画布 -->
<svg version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
style="background-color:#000000"
width="100%"
height="100%"
width="1920"
height="1080"
id="svgCanvas">
<defs />
<filter x="0"
@ -168,9 +182,6 @@ export default {
positionX: '',
positiony: ''
},
//线
guideX: '',
guideY: '',
selectSvg: {
ID: '',//svg
Index: 0,
@ -200,9 +211,25 @@ export default {
this.versionModelVisible = false;
},
exportSvg () {
var exportStr = document.querySelector("#svgCanvas").outerHTML;
let exportStr = document.querySelector("#svgCanvas").outerHTML;
exportStr = exportStr.replace('width="100%"', 'width="1920"').replace('height="100%"', 'height="1080"');
let datastr = 'data:text;charset=utf-8,' + encodeURIComponent(exportStr)
let download = document.createElement('a')
download.setAttribute('href', datastr)
download.setAttribute('download', 'download.html')
download.click()
download.remove()
console.log(exportStr);
alert("请使用F12查看consolo面板");
},
exportData () {
localStorage.setItem('svginfo', JSON.stringify(this.svgLists));
let datastr = 'data:text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(this.svgLists))
let download = document.createElement('a')
download.setAttribute('href', datastr)
download.setAttribute('download', 'download.json')
download.click()
download.remove()
console.log(JSON.stringify(this.svgLists));
},
MouseMove (e) {
let _this = this;
@ -247,22 +274,22 @@ export default {
return list.svgPositionX === svgPositionX
});
if (exitsNowX.length > 0) {
_this.guideY.style.setProperty('left', svgPositionX - 1 + 'px');
_this.guideY.style.display = 'inline';
_this.$refs.guidey_dom.style.setProperty('left', svgPositionX - 1 + 'px');
_this.$refs.guidey_dom.style.display = 'inline';
}
else {
_this.guideY.style.display = 'none';
_this.$refs.guidey_dom.style.display = 'none';
}
//y
let exitsNowY = anyPositionList.filter(function (list) {
return list.svgPositionY === svgPositionY
});
if (exitsNowY.length > 0) {
_this.guideX.style.setProperty('top', svgPositionY + 'px');
_this.guideX.style.display = 'inline';
_this.$refs.guidex_dom.style.setProperty('top', svgPositionY + 'px');
_this.$refs.guidex_dom.style.display = 'inline';
}
else {
_this.guideX.style.display = 'none';
_this.$refs.guidex_dom.style.display = 'none';
}
}, 1);
}
@ -324,8 +351,8 @@ export default {
if (this.mouseStatus == 0) {
return;
}
this.guideX.style.display = 'none';
this.guideY.style.display = 'none';
this.$refs.guidex_dom.style.display = 'none';
this.$refs.guidey_dom.style.display = 'none';
// if (this.$store.state.CurrentlySelectedToolBar.Type != '') {
// return;
// }
@ -365,6 +392,18 @@ export default {
this.selectSvgInfo = '';
this.$store.clearCurrentlySelectedToolBarAction();
},
testA () {
let _this = this;
//
this.$axios.get('/example.json')
.then(function (response) {
_this.svgLists = response.data;
// console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
},
testD () {
alert(JSON.stringify(this.svgLists));
},
@ -413,9 +452,8 @@ export default {
},
mounted () {
let _this = this;
let canvasdiv = document.querySelector('#canvas');
_this.guideX = document.querySelector('#guide-x');//线x
_this.guideY = document.querySelector('#guide-y');//线y
this.$nextTick(() => {
let canvasdiv = _this.$refs.canvas;
canvasdiv.addEventListener("dragover", function (e) {
e.preventDefault();
}, false);
@ -434,7 +472,7 @@ export default {
svgColor: _this.$store.state.CurrentlySelectedToolBar.Color,
svgPositionX: e.offsetX,
svgPositionY: e.offsetY,
echarts_option: eChartsOption ? JSON.parse(eChartsOption) : "",
echartsOption: eChartsOption ? JSON.parse(eChartsOption) : "",
size: 1,
angle: 0
//translate:`translate(${this.mousePosition.positionX},${this.mousePosition.positionY})`
@ -442,6 +480,7 @@ export default {
_this.svgLists.push(svgItem);
_this.selectSvgInfo = svgItem;
}, false);
})
},
created () {
let _this = this;
@ -571,6 +610,11 @@ export default {
.canvas-content {
width: 1920px;
height: 1080px;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
}
.btns-content {
position: fixed;
@ -631,13 +675,6 @@ export default {
left: 100px;
top: 0px;
}
#canvas {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
}
.ant-slider {
margin-bottom: 16px;
}

@ -19,12 +19,12 @@
</g>
</svg>
</div>
<!-- <div class="btns-content">
<div class="btns-content">
<a-button type="primary"
@click="testF">模拟硬件</a-button>
<a-button type="primary"
@click="testG">取消模拟硬件</a-button>
</div> -->
</div>
</div>
</template>
<script>
@ -41,20 +41,20 @@ export default {
}
},
methods: {
/**
* @description: 此方法仅为演示使用 真正修改组件数据请判断data_type属性
* @param {*}
* @return {*}
*/
testF () {
//
let anyCircuitBreakerList = this.svgLists.filter(f => f.type == 'CircuitBreakerSvg');
//线
let anyWireBreakList = this.svgLists.filter(f => f.type == 'WireConnectionSvg' || f.type == 'WireBreakOffSvg');
//
let anyTable = this.svgLists.filter(f => f.type == 'TableSvg')[0];
let anyTableList;
if (anyTable == 'undefined' || anyTable == null) {
anyTableList = [];
}
else {
anyTableList = anyTable.tableData.map(m => m.cols);
}
let anyWireBreakList = this.svgLists.filter(f => f.type == 'WireBreakOnSvg' || f.type == 'WireBreakOffSvg');
//
let anyEchartsPieList = this.svgLists.filter(f => f.type == 'EchartsPieSvg');
//
let anyEchartsBasicBarSvgList = this.svgLists.filter(f => f.type == 'EchartsBasicBarSvg');
this.analogDataTimer = setInterval(function () {
anyCircuitBreakerList.forEach(anyCircuitBreaker => {
//
@ -70,23 +70,28 @@ export default {
//
let random = Math.round(Math.random() * 10);
if (random < 5) {
anyWireBreak.type = 'WireConnectionSvg';
anyWireBreak.svgColor = "#FF0000"
anyWireBreak.type = 'WireBreakOnSvg';
anyWireBreak.svgColor = "#00FF00"
}
else {
anyWireBreak.type = 'WireBreakOffSvg';
anyWireBreak.svgColor = "#FF0000"
}
});
anyTableList.forEach(anyTables => {
anyTables.forEach(anyTable => {
if (anyTable.type == 'ff85bc7f-3b69-454f-8cf8-21c9f1903dd6' || anyTable.id == 'f8271273-d07d-4033-8b6c-6b52c04fe3e5'
|| anyTable.id == 'dc5931bc-7e8e-47f4-b28e-5bc42fb207da' || anyTable.id == '560f5404-6539-422f-8fb9-77bac641e72b') {
anyEchartsPieList.forEach(anyEchartsPie => {
anyEchartsPie.echartsOption.series[0].data.forEach(f => {
//
let random = Math.round(Math.random() * 100);
anyTable.val = random;
}
});
f.value = random;
});
})
anyEchartsBasicBarSvgList.forEach(anyEchartsBasicBar => {
let data_arr=[Math.round(Math.random() * 300),Math.round(Math.random() * 300),Math.round(Math.random() * 300),Math.round(Math.random() * 300),Math.round(Math.random() * 300),Math.round(Math.random() * 300),Math.round(Math.random() * 300)];
anyEchartsBasicBar.echartsOption.series[0].data=data_arr;
})
}, 2000)
},
@ -96,12 +101,14 @@ export default {
},
created () {
let _this = this;
_this.svgLists = JSON.parse(localStorage.getItem('svginfo'));
//
this.$axios.get('/InterfaceReturn.json')
.then(function (response) {
_this.svgInfoData = response.data;
console.log(response.data);
//
_this.svgLists = JSON.parse(localStorage.getItem('svginfo'));
})
.catch(function (error) {
console.log(error);

Loading…
Cancel
Save