增加代码

This commit is contained in:
ival 2021-03-31 18:29:17 +08:00
parent 143d6a67cc
commit 82f432136e
4 changed files with 24 additions and 5 deletions

View File

@ -23,6 +23,7 @@ function update2List(source, model, action, name='') {
let updateModel = model; let updateModel = model;
const i = list.findIndex(elem => { return elem.code == model.code; }) const i = list.findIndex(elem => { return elem.code == model.code; })
switch(action.order) { switch(action.order) {
case orders.BINDING:
case orders.ADD: case orders.ADD:
list.push(model); list.push(model);
break; break;

View File

@ -178,6 +178,9 @@ class JMap {
case orders.UNBINDING: case orders.UNBINDING:
this.$painter.remove(oldShape); this.$painter.remove(oldShape);
break; break;
case orders.BINDING:
// 暂不支持
break;
} }
} }
}); });

View File

@ -17,14 +17,12 @@ export default class SelectHandle {
if (e.target) { if (e.target) {
this.e = {...e}; this.e = {...e};
if (['Control'].includes(this.$controller.getKeyStr())) { if (['Control'].includes(this.$controller.getKeyStr())) {
console.log(this.$controller.isSelected(e.target.model.code));
if (this.$controller.isSelected(e.target.model.code)) { if (this.$controller.isSelected(e.target.model.code)) {
this.delSelected(e.target); this.delSelected(e.target);
} else { } else {
this.addSelected(e.target); this.addSelected(e.target);
} }
} else { } else {
console.log(2222)
this.clear(); this.clear();
this.addSelected(e.target); this.addSelected(e.target);
} }
@ -33,11 +31,13 @@ export default class SelectHandle {
addSelected(target) { addSelected(target) {
this.$controller.storage.set(target.model.code, target); this.$controller.storage.set(target.model.code, target);
console.log(this.$controller.storage.values());
target.active(); target.active();
} }
delSelected(target) { delSelected(target) {
target.inactive(); target.inactive();
console.log('bug')
this.$controller.storage.delete(target.model.code); this.$controller.storage.delete(target.model.code);
} }

View File

@ -112,7 +112,7 @@ export default {
fill: 'red', fill: 'red',
stroke: 'black' stroke: 'black'
}, },
composeCode: '4' composeCode: '100'
}, },
{ {
code: '2', code: '2',
@ -126,7 +126,7 @@ export default {
fill: 'red', fill: 'red',
stroke: 'black' stroke: 'black'
}, },
composeCode: '4' composeCode: '100'
}, },
{ {
code: '3', code: '3',
@ -142,11 +142,26 @@ export default {
stroke: 'black' stroke: 'black'
}, },
composeCode: '' composeCode: ''
},
{
code: '4',
type: 'Droplet',
shape: {
cx: 400,
cy: 200,
width: 20,
height: 20,
},
style: {
fill: 'red',
stroke: 'black'
},
composeCode: ''
} }
], ],
composeList: [ composeList: [
{ {
code: '4', code: '100',
type: 'Device', type: 'Device',
elementCodes: ['1', '2'] elementCodes: ['1', '2']
} }