Merge remote-tracking branch 'origin/dev' into test

This commit is contained in:
fan 2019-09-06 17:03:07 +08:00
commit c3a98567a3
7 changed files with 73 additions and 56 deletions

File diff suppressed because one or more lines are too long

View File

@ -152,6 +152,7 @@ class IbpPan {
updateIbpData(elem);
const oDevice = this.ibpDevice[code] || deviceFactory(type, elem);
const nDevice = deviceFactory(type, Object.assign(oDevice.model || {}, elem));
delete this.mapDevice[code];
this.$painter.delete(oDevice);
if (!elem._dispose) {
this.ibpDevice[code] = nDevice;

View File

@ -117,9 +117,9 @@ class MouseController extends Eventful {
this._x = e.offsetX;
this._y = e.offsetY;
debugger;
if (this._dragging) {
if (this.eventTarget._type === deviceType.Background) {
if (this.eventTarget._type === deviceType.Background || !this.isAllowDragging) {
this._preventDefaultMouseMove && eventTool.stop(e.event);
this.trigger(this.events.__Pan, { dx, dy, oldX, oldY, newX: this._x, newY: this._y });
return true;
@ -133,12 +133,12 @@ class MouseController extends Eventful {
}
mouseup(e) {
if (!eventTool.notLeftMouse(e)) {
if (!eventTool.notLeftMouse(e)&&this.isAllowDragging) {
this.eventTarget.setModel(e.offsetX - this._offsetX, e.offsetY - this._offsetY);
this.eventTarget.dirty();
this._dragging = false;
this.eventTarget = '';
}
this._dragging = false;
}
mousewheel(e) {

View File

@ -154,6 +154,7 @@ class Jlmap {
const oDevice = this.mapDevice[code] || deviceFactory(type, elem);
const nDevice = Object.assign(oDevice || {}, elem);
this.$painter.delete(oDevice);
delete this.mapDevice[code];
if (!elem._dispose) {
this.mapDevice[code] = nDevice;
this.$painter.add(nDevice);

View File

@ -167,3 +167,51 @@ export function parser(data, skinCode) {
return mapDevice;
}
// 同步绘制数据到原始数据
export function updateForList(model, map, liststr) {
const list = map[liststr];
if (list && list instanceof Array) {
const i = list.findIndex(elem => { return elem.code == model.code; });
if (model._dispose) {
i >= 0 && list.splice(i, 1);
} else if (!list[i]) {
list.push(Object.assign({}, model));
} else if (i >= 0) {
const item = list[i];
Object.keys(model).forEach(key => {
if (key != 'instance') {
item[key] = model[key];
}
});
}
} else {
map[liststr] = [model];
}
}
export function updateMapData(state, model) {
const map = state.map;
if (map && model) {
switch (model._type) {
case deviceType.Link: updateForList(model, map, 'linkList'); break;
case deviceType.Section: updateForList(model, map, 'sectionList'); break;
case deviceType.Switch: updateForList(model, map, 'switchList'); break;
case deviceType.Signal: updateForList(model, map, 'signalList'); break;
case deviceType.Station: updateForList(model, map, 'stationList'); break;
case deviceType.StationStand: updateForList(model, map, 'stationStandList'); break;
case deviceType.StationControl: updateForList(model, map, 'stationControlList'); break;
case deviceType.StationCounter: updateForList(model, map, 'stationCounterList'); break;
case deviceType.ZcControl: updateForList(model, map, 'zcControlList'); break;
case deviceType.StationDelayUnlock:updateForList(model, map, 'stationDelayUnlockList'); break;
case deviceType.LcControl: updateForList(model, map, 'lcControlList'); break;
case deviceType.ButtonControl: updateForList(model, map, 'buttonList'); break;
case deviceType.LimitControl: updateForList(model, map, 'tempSpeedLimitList'); break;
case deviceType.ImageControl: updateForList(model, map, 'imageControl'); break;
case deviceType.Train: updateForList(model, map, 'trainList'); break;
case deviceType.TrainWindow: updateForList(model, map, 'trainWindowList'); break;
case deviceType.Line: updateForList(model, map, 'lineList'); break;
case deviceType.Text: updateForList(model, map, 'textList'); break;
}
}
}

View File

@ -1,5 +1,5 @@
import deviceType from '@/jmap/constant/deviceType';
import { parser } from '@/jmap/utils/parser';
import { parser, updateMapData } from '@/jmap/utils/parser';
import Vue from 'vue';
/**
* 查询向上受影响的Devices
@ -191,53 +191,6 @@ function saveMapDeviceDefaultRelations(state) {
}
}
// 同步绘制数据到原始数据
function dataSync(model, map) {
var prop = null;
var type = model._type;
var code = model.code;
switch (type) {
case deviceType.Link: prop = 'linkList'; break;
case deviceType.Section: prop = 'sectionList'; break;
case deviceType.Switch: prop = 'switchList'; break;
case deviceType.Signal: prop = 'signalList'; break;
case deviceType.Station: prop = 'stationList'; break;
case deviceType.StationStand: prop = 'stationStandList'; break;
case deviceType.StationControl: prop = 'stationControlList'; break;
case deviceType.StationCounter: prop = 'stationCounterList'; break;
case deviceType.ZcControl: prop = 'zcControlList'; break;
case deviceType.StationDelayUnlock: prop = 'stationDelayUnlockList'; break;
case deviceType.LcControl: prop = 'lcControlList'; break;
case deviceType.ButtonControl: prop = 'buttonList'; break;
case deviceType.LimitControl: prop = 'tempSpeedLimitList'; break;
case deviceType.ImageControl: prop = 'imageControl'; break;
case deviceType.Train: prop = 'trainList'; break;
case deviceType.TrainWindow: prop = 'trainWindowList'; break;
case deviceType.Line: prop = 'lineList'; break;
case deviceType.Text: prop = 'textList'; break;
}
const list = map[prop] || [];
const idex = list.findIndex(elem => { return elem.code == code; });
if (list) {
if (model._dispose) {
idex >= 0 && list.splice(idex, 1);
} else {
const elem = list[idex];
if (elem) {
Object.keys(model).forEach(key => {
if (key != 'instance') {
elem[key] = model[key];
}
});
} else {
list.push(Object.assign({}, model));
}
}
}
}
/**
* 实训状态数据
*/
@ -483,7 +436,7 @@ const map = {
},
mapRender: (state, devices) => {
if (state.map) {
devices.forEach(elem => { dataSync(elem, state.map); });
devices.forEach(elem => { updateMapData(state, elem); });
}
if (Vue.prototype.$jlmap) {

View File

@ -15,6 +15,12 @@
<el-form-item label="Y轴坐标">
<el-input-number v-model="form.y" controls-position="right" :min="1"></el-input-number>
</el-form-item>
<el-form-item label="提示颜色" prop="rotateTipColor">
<el-select v-model="form.rotateTipColor" placeholder="请选择按钮颜色">
<el-option label="红色" value="red"></el-option>
<el-option label="黑色" value="black"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit('form')">{{ buttonText }}</el-button>
<el-button v-show="showDeleteButton" @click="deleteDevice" type="danger">删除</el-button>
@ -37,6 +43,7 @@
form: {
code: '',
rotateTipWidth: '',
rotateTipColor: 'black',
x: 10,
y: 10
},
@ -46,6 +53,9 @@
],
rotateTipWidth: [
{ required: true, message: '请输入旋转提示宽度', trigger: 'blur' },
],
rotateTipColor: [
{ required: true, message: '请选择按钮颜色', trigger: 'change'}
]
}
};
@ -62,6 +72,7 @@
this.isUpdate = true;
this.form.code = model.code;
this.form.rotateTipWidth = model.width;
this.form.rotateTipColor = model.color?model.color:'black';
this.form.x = model.point.x;
this.form.y = model.point.y;
}
@ -82,6 +93,7 @@
_type: 'RotateTip',
code: this.form.code,
width: this.form.rotateTipWidth,
color: this.form.rotateTipColor
};
this.$emit('createRotateTip', rotateTipModel);
this.initPage();
@ -98,9 +110,10 @@
y: this.form.y
},
draggable: true,
_type: 'Key',
_type: 'RotateTip',
code: this.form.code,
width: this.form .rotateTipWidth,
color: this.form.rotateTipColor
};
this.$emit('deleteDataModel',rotateTipModel);
this.initPage();
@ -112,6 +125,7 @@
this.form = {
code: '',
rotateTipWidth: '',
rotateTipColor: 'black',
x: 10,
y: 10
};