Skip to content

Commit

Permalink
feat:topoNode copy
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxiaobo1010 committed Dec 2, 2022
1 parent 20d960d commit 858619c
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 74 deletions.
18 changes: 9 additions & 9 deletions src/utils/konva/core/topoBasic.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const topoBasic = {
createImage(args) {
console.info(
'src/utils/konva/core/topoBasic.js',
'createdEvidence',
'createdGIf',
// args.path,
args
)
Expand Down Expand Up @@ -375,10 +375,10 @@ const topoBasic = {
if (args.data.src) {
console.log('1111111触发了', args)
let src = args.data.src
if (src.indexOf('http') < 0) {
console.log(' this.$FileServe', Vue.prototype.$FileServe)
src = Vue.prototype.$FileServe + src
}
// if (src.indexOf('http') < 0) {
// console.log(' this.$FileServe', Vue.prototype.$FileServe)
// src = Vue.prototype.$FileServe + src
// }
var imageObj = new Image()
imageObj.src = src
// imageObj.onload = () => {
Expand Down Expand Up @@ -430,10 +430,10 @@ const topoBasic = {
)
if (args.data.src) {
let src = args.data.src
if (src.indexOf('http') < 0) {
console.log(' this.$FileServe', Vue.prototype.$FileServe)
src = Vue.prototype.$FileServe + src
}
// if (src.indexOf('http') < 0) {
// console.log(' this.$FileServe', Vue.prototype.$FileServe)
// src = Vue.prototype.$FileServe + src
// }
var imageObj = new Image()
imageObj.src = src
// imageObj.onload = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/konva/core/topoBg.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const topoBg = {
// canvas.bgNode = {}
})
const BgimageObj = new Image()
const bgSrc = src.includes('//') ? src : Cookies.get('fileServer') + src
const bgSrc = src.includes('//') ? src : src // Cookies.get('fileServer') +
// bgNode.on('contextmenu', (e) => {
// console.log('组态底图点击触发了鼠标右键事件 现在没有写处理事件 可能用得上 contextmenu', e.target)
// })
Expand Down
9 changes: 7 additions & 2 deletions src/utils/konva/core/topoStage.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ const topoStage = {
node.setAttrs({
image: image,
})
image.src = node.attrs.src
image.src = node.attrs.src.includes('//')
? node.attrs.src
: Vue.prototype.$FileServe + node.attrs.src
}

// }
Expand Down Expand Up @@ -252,7 +254,10 @@ const topoStage = {
node.setAttrs({
image: image,
})
image.src = node.attrs.src
console.log('查看', Vue.prototype.$FileServe, node.attrs.src)
image.src = node.attrs.src.includes('//')
? node.attrs.src
: Vue.prototype.$FileServe + node.attrs.src
}
node.on('contextmenu', (e) => {
canvas.contextmenu = e.target
Expand Down
2 changes: 1 addition & 1 deletion src/views/CloudFunction/topo/components/Amis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
skip: 0,
where: {
key: this.$route.query.productid,
type: 'amis',
type: 'Amis',
},
})
this.amisDict = amisDict
Expand Down
87 changes: 56 additions & 31 deletions src/views/CloudFunction/topo/components/TopoTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<img
draggable="true"
size="mini"
src="https://mp0.usr.cn/uploads/drawimg/1612317621248_0251.gif"
:src="$FileServe + '/dgiot_file/topo/gif/pump.gif'"
style="
width: 40px;
height: 40px;
Expand All @@ -133,8 +133,11 @@
createBasicThing({
productid: $route.query.productid,
type: 'knovaimage',
image:
'https://mp0.usr.cn/uploads/drawimg/1612317621248_0251.gif',
image: '/dgiot_file/topo/gif/pump.gif',
data: {
width: 180,
height: 200,
},
hidden: false,
})
"
Expand All @@ -146,7 +149,7 @@
<img
draggable="true"
size="mini"
src="https://mp0.usr.cn/uploads/drawimg/1612317616625_0334.png"
:src="$FileServe + '/dgiot_file/topo/static/datawindow.png'"
style="
width: 40px;
height: 40px;
Expand All @@ -162,8 +165,7 @@
width: 180,
height: 200,
},
image:
'https://mp0.usr.cn/uploads/drawimg/1612317616625_0334.png',
image: '/dgiot_file/topo/static/datawindow.png',
hidden: false,
})
"
Expand Down Expand Up @@ -276,30 +278,6 @@
数据卡片
</el-button>
<el-divider />
<!-- <el-button
draggable="true"
size="mini"
style="margin: 5px"
type="primary"
@click.native="
createBasicThing({
productid: $route.query.productid,
type: 'vuecomponent',
data: {
id: 'device_poweron_poweroff',
width: 350,
height: 300,
fill: 'rgba(30, 30, 30, 0.7)',
text: '饼图',
source: 'mqtt',
},
chart: 'pie',
hidden: false,
})
"
>
开关机饼图
</el-button> -->
<div style="text-align: left; margin: 10px; font-weight: 600">
开关机饼图
</div>
Expand Down Expand Up @@ -827,6 +805,8 @@
</template>

<script>
import addNodeEvent from '@/utils/konva/common'
import canvas from '@/utils/konva/core/canvas'
import createThing from '@/utils/konva/createThing'
import { mapMutations } from 'vuex'
import getSvgPath from '@/utils/konva/getSvgPath'
Expand Down Expand Up @@ -901,7 +881,52 @@
created() {
// this.fetchData()
},
mounted() {},
mounted() {
this.$dgiotBus.$off('copyNode')
this.$dgiotBus.$on('copyNode', (e) => {
console.log('接收节点', e)
if (
e.attrs.type == 'thing' ||
e.attrs.type == 'static' ||
e.parent.attrs.name == 'amis'
) {
//实时数据
let data = e.parent.attrs
data.x = data.x - 10
data.y = data.y - 10
var simpleLabel = new Konva.Label(data)
simpleLabel.add(new Konva.Tag(e.parent.children[0].attrs))
simpleLabel.add(new Konva.Text(e.parent.children[1].attrs))
canvas.layer.add(simpleLabel)
} else if (
e.attrs.type == 'konvaimage' ||
e.attrs.type == 'staticimage'
) {
// 控制绑定
let data = e.attrs
data.x = data.x - 10
data.y = data.y - 10
// var imageObj = new Image()
// imageObj.src = data.src
// data.image = imageObj
var simpleImage = new Konva.Image(data)
canvas.layer.add(simpleImage)
} else if (e.attrs.type == 'label') {
// 控制绑定
let data = e.attrs
data.x = data.x - 10
data.y = data.y - 10
var simpleText = new Konva.Text(data)
canvas.layer.add(simpleText)
}
addNodeEvent({
type: 'handleChildren',
stage: canvas.stage,
layer: canvas.layer,
args: canvas.handlerArgs,
})
})
},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
Expand Down
12 changes: 11 additions & 1 deletion src/views/CloudFunction/topo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@
</el-select>
</el-form-item>
</el-form>
<el-button
@click="copyNode"
style="position: absolute; bottom: 10px; left: 10px"
>
复制节点
</el-button>
</el-drawer>
</el-main>
</el-container>
Expand Down Expand Up @@ -1023,6 +1029,10 @@
setTreeFlag: 'settings/setTreeFlag',
createdEvidence: 'topo/createdEvidence',
}),
copyNode() {
// console.log(this.editNode)
this.$dgiotBus.$emit('copyNode', this.editNode)
},
handleEditViewId(e) {
console.log(e, this.editForm)
let params = {
Expand Down Expand Up @@ -1347,7 +1357,7 @@
const { message = '', data = {} } = await _getTopo(params)
// 绘制前不光需要获取到组态数据,还需要获取产品数据
const productconfig = await getProduct(_this.$route.query.productid)
console.log('productconfigproductconfigproductconfig', productconfig)
// console.log('productconfigproductconfigproductconfig', productconfig)
let wmxList = productconfig.thing?.properties || []
let nowlist = []
wmxList.forEach((wmxitem) => {
Expand Down
2 changes: 1 addition & 1 deletion src/views/CloudFunction/topo/js/evidence.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ export default {
order: '-createdAt',
skip: 0,
where: {
reportId: this.nowItem.objectId,
reportId: this.nowItem.objectId, //view 视图 objectId
'original.controlid': this.evidenceList.node.attrs.id,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@
methods: {
async handletabs(tabs) {
this.viewForm = {
class: 'ProductTemplet',
type: 'amis',
class: '', //ProductTemplet
type: 'Amis',
key: this.productId,
title: '',
disabled: true,
data: {
type: 'page',
initApi: {
url: 'iotapi/classes/Device/parse_objectid',
url: '/iotapi/classes/Device/parse_objectid',
method: 'get',
adaptor:
'return {\r\n "status":0,\r\n "msg":"",\r\n "data":response.data.basedata\r\n }',
Expand All @@ -415,7 +415,7 @@
type: 'form',
api: {
method: 'put',
url: 'iotapi/classes/Device/parse_objectid',
url: '/iotapi/classes/Device/parse_objectid',
headers: {
store: 'localStorage',
dgiotReplace: 'parse_objectid',
Expand Down
Loading

0 comments on commit 858619c

Please sign in to comment.