状态显示 代码调整
This commit is contained in:
parent
c1356549ec
commit
85de91411e
@ -42,12 +42,12 @@ class JMap {
|
||||
|
||||
this.draw = opts.draw;
|
||||
// 实例化zr
|
||||
this.$zr = zrender.init(opts.dom, { renderer, devicePixelRatio, width, height, ...utils.deepClone(opts.config||{})});
|
||||
this.$zr = zrender.init(opts.dom, { renderer, devicePixelRatio, width, height, ...utils.deepClone(opts.config || {})});
|
||||
this.$zr.dom.setAttribute('tabIndex', -1);
|
||||
this.$zr.dom.style.cursor = 'auto';
|
||||
|
||||
// 实例化缩放偏移缩放参数
|
||||
this.$option = new Option({ scaleRate: 1, offsetX: 0, offsetY: 0, ...utils.deepClone(opts.option||{})}, (dataZoom) => { this.$controller.trigger(events.DataZoom, dataZoom); }); // 缩放
|
||||
this.$option = new Option({ scaleRate: 1, offsetX: 0, offsetY: 0, ...utils.deepClone(opts.option || {})}, (dataZoom) => { this.$controller.trigger(events.DataZoom, dataZoom); }); // 缩放
|
||||
|
||||
// 实例化绘图模块
|
||||
this.$painter = new Painter(this);
|
||||
@ -75,11 +75,11 @@ class JMap {
|
||||
};
|
||||
|
||||
// 加载插件
|
||||
this.plugins = opts.plugins||[];
|
||||
this.plugins = opts.plugins || [];
|
||||
this.plugins.forEach(el => { this.use(el); });
|
||||
}
|
||||
|
||||
setMap(templates=[], source={}, eventOpts={}) {
|
||||
setMap(templates = [], source = {}, eventOpts = {}) {
|
||||
// 清楚数据
|
||||
this.$shapeFactory.clear();
|
||||
this.$painter.clear();
|
||||
@ -91,7 +91,7 @@ class JMap {
|
||||
this.$painter.updateTransform(this.$option);
|
||||
|
||||
// 解析模板
|
||||
this.$shapeFactory.parseTemplates(templates)
|
||||
this.$shapeFactory.parseTemplates(templates);
|
||||
|
||||
// 数据加载完成 回调
|
||||
this.$eventEmitter.trigger(events.DataLoaded);
|
||||
@ -116,8 +116,8 @@ class JMap {
|
||||
return this;
|
||||
}
|
||||
|
||||
setOption(opts={}) {
|
||||
this.$option.update(opts.type == this.events.__Zoom? pullBack(this.$zr, this.$option, opts):opts);
|
||||
setOption(opts = {}) {
|
||||
this.$option.update(opts.type == this.events.__Zoom ? pullBack(this.$zr, this.$option, opts) : opts);
|
||||
this.$painter.updateTransform(this.$option);
|
||||
|
||||
this.$controller.disable();
|
||||
@ -142,41 +142,41 @@ class JMap {
|
||||
return this;
|
||||
}
|
||||
|
||||
setCursorStyle(cursorStyle='auto') {
|
||||
setCursorStyle(cursorStyle = 'auto') {
|
||||
this.$zr.setCursorStyle(cursorStyle);
|
||||
return this;
|
||||
}
|
||||
|
||||
repaint(source={}) {
|
||||
repaint(source = {}) {
|
||||
this.$shapeFactory.parse(source, shape => {
|
||||
if (shape) {
|
||||
this.$painter.add(shape)
|
||||
this.$painter.add(shape);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
render(list=[]) {
|
||||
render(list = []) {
|
||||
list.forEach(({model, action}) => {
|
||||
let updateModel = this.isDrawing() ? this.$shapeFactory.updateSource(model, action): model;
|
||||
let updateModel = this.isDrawing() ? this.$shapeFactory.updateSource(model, action) : model;
|
||||
let curShape = this.$shapeFactory.getShapeByCode(updateModel.code);
|
||||
let deps = null;
|
||||
let oldShape = null
|
||||
let oldShape = null;
|
||||
let newShape = null;
|
||||
|
||||
if (updateModel) {
|
||||
this.$controller.clear();
|
||||
switch(action.order) {
|
||||
switch (action.order) {
|
||||
case orders.Binding:
|
||||
case orders.Add:
|
||||
newShape = this.$shapeFactory.createShape(updateModel, action.shapeType);
|
||||
this.$shapeFactory.addShape(newShape)
|
||||
this.$shapeFactory.addShape(newShape);
|
||||
this.$painter.add(newShape);
|
||||
break;
|
||||
case orders.Delete:
|
||||
deps = curShape.getDepShapes();
|
||||
deps.forEach(el => {
|
||||
updateModel = this.isDrawing() ? this.$shapeFactory.updateSource(el, {...action, shapeType: el.shapeType}): el;
|
||||
updateModel = this.isDrawing() ? this.$shapeFactory.updateSource(el, {...action, shapeType: el.shapeType}) : el;
|
||||
if (updateModel) {
|
||||
curShape = this.$shapeFactory.getShapeByCode(updateModel.code);
|
||||
oldShape = this.$shapeFactory.removeShape(curShape);
|
||||
@ -188,7 +188,7 @@ class JMap {
|
||||
oldShape = this.$shapeFactory.removeShape(curShape);
|
||||
this.$painter.remove(oldShape);
|
||||
newShape = this.$shapeFactory.createShape(updateModel, action.shapeType);
|
||||
this.$shapeFactory.addShape(newShape)
|
||||
this.$shapeFactory.addShape(newShape);
|
||||
this.$painter.add(newShape);
|
||||
break;
|
||||
case orders.Unbinding:
|
||||
@ -197,6 +197,12 @@ class JMap {
|
||||
this.$shapeFactory.addShape(oldShape);
|
||||
this.$painter.add(oldShape);
|
||||
break;
|
||||
case orders.changeStatus:
|
||||
debugger;
|
||||
break;
|
||||
case orders.ResetStatus:
|
||||
debugger;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -205,7 +211,7 @@ class JMap {
|
||||
return this;
|
||||
}
|
||||
|
||||
update(list=[]) {
|
||||
update(list = []) {
|
||||
this.$painter.update(this.$stateHandle.update(this.$shapeFactory, list));
|
||||
this.$eventEmitter.trigger(events.StateUpdate, list);
|
||||
return this;
|
||||
@ -272,11 +278,11 @@ class JMap {
|
||||
this.$shapeFactory.clear();
|
||||
this.$controller.clear();
|
||||
this.$painter.clear();
|
||||
this.$zr.refresh()
|
||||
this.$zr.refresh();
|
||||
}
|
||||
|
||||
use(el) {
|
||||
this.plugins.includes(el)||this.plugins.push(el)
|
||||
this.plugins.includes(el) || this.plugins.push(el);
|
||||
el.install(this);
|
||||
}
|
||||
|
||||
@ -289,7 +295,7 @@ class JMap {
|
||||
this.$zr && this.$zr.dispose();
|
||||
this.plugins.forEach(el => {
|
||||
el.uninstall(this);
|
||||
})
|
||||
});
|
||||
this.plugins = [];
|
||||
}
|
||||
|
||||
@ -390,7 +396,7 @@ class JMap {
|
||||
}
|
||||
}
|
||||
|
||||
function pullBack(zr, option={}, payload={}) {
|
||||
function pullBack(zr, option = {}, payload = {}) {
|
||||
const zrWidth = zr.getWidth();
|
||||
const zrHeight = zr.getHeight();
|
||||
const originX = payload.originX || zrWidth / 2;
|
||||
|
@ -4,4 +4,6 @@ export default {
|
||||
Update: '&UPT',
|
||||
Binding: '&Binding',
|
||||
Unbinding: '&Unbinding',
|
||||
}
|
||||
ChangeStatus:'&ChangeStatus',
|
||||
ResetStatus:'&ResetStatus'
|
||||
};
|
||||
|
@ -66,7 +66,7 @@
|
||||
<template slot-scope="scope">
|
||||
<el-button type="success" size="mini" @click="modifyStatus(scope.$index,scope.row)">编辑状态组合</el-button>
|
||||
<el-button type="danger" size="mini" style="margin-top:5px;" @click="deleteStatus(scope.$index,scope.row)">删除</el-button>
|
||||
<el-button type="primary" size="mini" style="margin-top:5px;" @click="previewStatus(scope.$index,scope.row)">预览</el-button>
|
||||
<!-- <el-button type="primary" size="mini" style="margin-top:5px;" @click="previewStatus(scope.$index,scope.row)">预览</el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -333,25 +333,25 @@ export default {
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
previewStatus(index, row) {
|
||||
// const that = this;
|
||||
// if(needDefault)
|
||||
const list = Object.values(row.covertStatusList);
|
||||
list.forEach(each=>{
|
||||
if (each.loop) {
|
||||
}
|
||||
// previewStatus(index, row) {
|
||||
// // const that = this;
|
||||
// // if(needDefault)
|
||||
// const list = Object.values(row.covertStatusList);
|
||||
// list.forEach(each=>{
|
||||
// if (each.loop) {
|
||||
|
||||
} else {
|
||||
const frameList = each.frameList;
|
||||
frameList.forEach(frame=>{
|
||||
// frame.name;
|
||||
// frame.status;
|
||||
// this.$iscs.
|
||||
});
|
||||
}
|
||||
});
|
||||
// this.show = false;
|
||||
}
|
||||
// } else {
|
||||
// const frameList = each.frameList;
|
||||
// frameList.forEach(frame=>{
|
||||
// // frame.name;
|
||||
// // frame.status;
|
||||
// // this.$iscs.
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// // this.show = false;
|
||||
// }
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -2,22 +2,37 @@
|
||||
<transition name="el-zoom-in-center">
|
||||
<div class="mapPaint">
|
||||
<div class="map-view">
|
||||
<iscs-canvas ref="iscsCanvas" @selected="onSelected" />
|
||||
<iscs-canvas ref="iscsCanvas" @selected="onSelected" @setData="setData" />
|
||||
</div>
|
||||
<div class="right-card">
|
||||
<!-- :class="{'hide': draftShow}" -->
|
||||
<el-card type="border-card" class="heightClass">
|
||||
<div slot="header" class="clearfix">
|
||||
<!-- 组件id为{{ $route.query.id }} -->
|
||||
状态编辑
|
||||
状态预览
|
||||
<!-- -->
|
||||
<el-button
|
||||
type="text"
|
||||
style="float: right; padding: 3px 0; margin-right: 5px;"
|
||||
@click="resetDefaultStatus"
|
||||
>重置状态</el-button>
|
||||
</div>
|
||||
<div class="stateList">
|
||||
<el-tabs v-model="statusTab" class="card" type="card" @tab-click="onSelectTab">
|
||||
<el-tab-pane v-for="(composeElem,index) in composeElemList" :key="index" :label="composeElem.name" :name="composeElem.code" :lazy="true">
|
||||
<!-- <el-card style="margin-top:10px;height:100%"> -->
|
||||
<div v-for="(state,index) in stateList" :key="index" class="eachStatus">
|
||||
<div>状态属性:{{ state.status }}</div>
|
||||
<div>状态描述:{{ state.description }}</div>
|
||||
<div>状态权重:{{ state.weight }}</div>
|
||||
<div>状态是否可以初始化:{{ state.needDefault?'是':'否' }}</div>
|
||||
<el-button type="primary" size="mini" style="margin-top:5px;" @click="previewStatus(state)">预览</el-button>
|
||||
</div>
|
||||
<!-- </el-card> -->
|
||||
<!-- <el-tabs v-model="statusTab" class="card" type="card" @tab-click="onSelectTab"> -->
|
||||
<!-- <el-tab-pane v-for="(composeElem,index) in composeElemList" :key="index" :label="composeElem.name" :name="composeElem.code" :lazy="true"> -->
|
||||
<!-- <table-form :ref="'tableform'+composeElem.code" :compose-elem="composeElem" /> -->
|
||||
<!-- stateList -->
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<!-- </el-tab-pane> -->
|
||||
<!-- </el-tabs> -->
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
@ -25,8 +40,10 @@
|
||||
</transition>
|
||||
</template>
|
||||
<script>
|
||||
import * as utils from '@/iscs_new/utils/utils';
|
||||
import iscsCanvas from './iscsCanvas';
|
||||
import { EventBus } from '@/scripts/event-bus';
|
||||
import orders from '@/iscs_new/utils/orders';
|
||||
import shapeType from '@/iscs_new/constant/shapeType.js';
|
||||
export default {
|
||||
name:'IscsPreview',
|
||||
components: {
|
||||
@ -37,55 +54,89 @@ export default {
|
||||
draftShow: false,
|
||||
selected: null,
|
||||
statusTab:'',
|
||||
composeElemList:[]
|
||||
stateList:[],
|
||||
elementList:[]
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
EventBus.$on('getComposeElemList', () => {
|
||||
this.getComposeElemList();
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
onSelectTab() {
|
||||
|
||||
},
|
||||
getComposeElemList() {
|
||||
const source = this.$iscs.getSource();
|
||||
if (source &&
|
||||
source.elementList &&
|
||||
source.elementList.length) {
|
||||
this.composeElemList = source.elementList;
|
||||
this.statusTab = this.composeElemList[0].code;
|
||||
} else {
|
||||
this.composeElemList = [];
|
||||
}
|
||||
setData(data ) {
|
||||
this.stateList = data.stateList;
|
||||
this.elementList = utils.deepClone(data.shapeList);
|
||||
},
|
||||
onSelected(em) {
|
||||
// if (em.model) {
|
||||
// this.selected = JSON.parse(JSON.stringify(em.model));
|
||||
// const elem = this.elementList.find(el => el.type == this.selected.type);
|
||||
// if (elem) {
|
||||
// elem.model = this.selected;
|
||||
// this.enabledTab = this.selected.type;
|
||||
// this.cardTab = 'first';
|
||||
previewStatus(data) {
|
||||
this.resetDefaultStatus();
|
||||
const that = this;
|
||||
const list = Object.values(data.covertStatusList);
|
||||
list.forEach(each=>{
|
||||
if (each.loop) {
|
||||
debugger;
|
||||
// ChangeStatus
|
||||
} else {
|
||||
const frameList = each.frameList;
|
||||
frameList.forEach(frame=>{
|
||||
const element = that.elementList.find(ele=>{ return ele.name == frame.name; });
|
||||
if (element) {
|
||||
const elementStyle = element.stateList.find(state=>{ return state.status == frame.status; });
|
||||
if (elementStyle) {
|
||||
const model = utils.deepClone(element);
|
||||
const style = elementStyle.style || {};
|
||||
// model.changeStyle =
|
||||
// if (style && JSON.stringify(style) != '{}') {
|
||||
// const keys = Object.keys(style);
|
||||
// keys.forEach(eachKey=>{
|
||||
// model.style[eachKey] = style[eachKey];
|
||||
// });
|
||||
// }
|
||||
const shape = elementStyle.shape || {};
|
||||
// if (shape && JSON.stringify(shape) != '{}') {
|
||||
// const keys = Object.keys(shape);
|
||||
// keys.forEach(eachShape=>{
|
||||
// model.shape[eachShape] = style[eachShape];
|
||||
// });
|
||||
// }
|
||||
// this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.ChangeStatus}}]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
resetDefaultStatus() {
|
||||
this.elementList.forEach(element=>{
|
||||
const model = utils.deepClone(element);
|
||||
// this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.ResetStatus}}]);
|
||||
});
|
||||
},
|
||||
// getComposeElemList() {
|
||||
// const source = this.$iscs.getSource();
|
||||
// if (source &&
|
||||
// source.elementList &&
|
||||
// source.elementList.length) {
|
||||
// this.composeElemList = source.elementList;
|
||||
// this.statusTab = this.composeElemList[0].code;
|
||||
// } else {
|
||||
// this.selected = null;
|
||||
// this.clear(this.enabledTab);
|
||||
// this.composeElemList = [];
|
||||
// }
|
||||
// },
|
||||
onSelected(em) {
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.mapPaint{
|
||||
.mapPaint{
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
width:100%;
|
||||
position:absolute;
|
||||
left:0;top:0;
|
||||
}
|
||||
.right-card{
|
||||
}
|
||||
.right-card{
|
||||
width: 500px;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
@ -94,5 +145,22 @@ export default {
|
||||
transition: all 0.5s;
|
||||
background: #fff;
|
||||
z-index: 9;
|
||||
}
|
||||
}
|
||||
.heightClass{height:100%;overflow:hidden;display:flex;width: 100%;flex-direction: column;}
|
||||
.eachStatus{
|
||||
padding: 15px 30px;
|
||||
border-bottom: 1px #ccc solid;
|
||||
line-height: 150%;
|
||||
}
|
||||
.statelist{
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss">
|
||||
.heightClass .el-card__body{
|
||||
flex:1;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
@ -97,22 +97,22 @@ export default {
|
||||
selecting: false,
|
||||
selectable: false,
|
||||
reflect: true
|
||||
}
|
||||
};
|
||||
if (this.$route.query.id) {
|
||||
setTimeout(_ => {
|
||||
Idb.select('composeList', this.$route.query.id).then(resp => {
|
||||
Idb.select('composeTemplateList', this.$route.query.id).then(resp => {
|
||||
this.$iscs.setMap([], {
|
||||
elementList: resp.elementList||[],
|
||||
composeList: resp.composeList||[]
|
||||
elementList: resp.shapeList || [],
|
||||
composeList: resp.composeList || []
|
||||
}, option);
|
||||
EventBus.$emit('getComposeElemList');
|
||||
this.$emit('setData', resp);
|
||||
}).catch(error => {
|
||||
this.$iscs.setMap([], {
|
||||
elementList: [],
|
||||
composeList: []
|
||||
}, option);
|
||||
})
|
||||
}, 1000)
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
this.$iscs.setMap([], {
|
||||
elementList: [],
|
||||
@ -138,14 +138,14 @@ export default {
|
||||
console.log(hook);
|
||||
},
|
||||
// 点击选择事件
|
||||
onClick(em={}) {
|
||||
onClick(em = {}) {
|
||||
this.$emit('selected', em);
|
||||
},
|
||||
onReflect(em={}) {
|
||||
onReflect(em = {}) {
|
||||
this.$emit('selected', this.$iscs.getShapeByCode(em.code));
|
||||
},
|
||||
// 右键点击事件
|
||||
onContextMenu(em={}) {
|
||||
onContextMenu(em = {}) {
|
||||
this.$emit('contextMenu', em.model);
|
||||
},
|
||||
// 执行操作
|
||||
@ -169,7 +169,7 @@ export default {
|
||||
this.$iscs = null;
|
||||
Vue.prototype.$iscs = null;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user