From 5c19aab68c5e87ef829cc37fbd2d1c7235fba61f Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Fri, 9 Apr 2021 16:50:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=88=9B=E5=BB=BAiscs?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=85=83=E7=B4=A0=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iscs_new/core/form/builderFactory.js | 38 ---- src/iscs_new/core/form/elementConst.js | 29 +-- src/iscs_new/core/form/formBuilder.js | 67 +++--- src/iscs_new/map.js | 12 +- src/iscs_new/plugins/shapeBuilder/entry.vue | 36 +++- src/iscs_new/plugins/shapeBuilder/index.js | 20 +- .../plugins/shapeContextMenu/entry.vue | 121 +++++++++++ .../plugins/shapeContextMenu/index.js | 79 +++++++ .../plugins/shapeContextMenu/menu-item.vue | 202 ++++++++++++++++++ src/iscs_new/plugins/shapeProperty/entry.vue | 15 +- src/iscs_new/plugins/shapeProperty/index.js | 16 +- src/iscs_new/selectingHandle.js | 6 +- src/iscs_new/utils/events.js | 2 +- src/views/iscs_new/components/dataForm.vue | 28 +-- src/views/iscs_new/iscsDesign/index.vue | 4 +- src/views/iscs_new/iscsDraw/index.vue | 12 +- src/views/iscs_new/iscsDraw/iscsCanvas.vue | 6 +- src/views/test/index.vue | 4 +- 18 files changed, 536 insertions(+), 161 deletions(-) delete mode 100644 src/iscs_new/core/form/builderFactory.js create mode 100644 src/iscs_new/plugins/shapeContextMenu/entry.vue create mode 100644 src/iscs_new/plugins/shapeContextMenu/index.js create mode 100644 src/iscs_new/plugins/shapeContextMenu/menu-item.vue diff --git a/src/iscs_new/core/form/builderFactory.js b/src/iscs_new/core/form/builderFactory.js deleted file mode 100644 index 37dd19cad..000000000 --- a/src/iscs_new/core/form/builderFactory.js +++ /dev/null @@ -1,38 +0,0 @@ -import {elementConst} from './elementConst'; -import form2Base from './form2Base'; -class BuilderFactory { - constructor() { - this.formList = []; - } - getFormList() { - const elementList = Object.values(elementConst); - elementList.forEach(element=>{ - const temp = {}; - temp.code = element.code; - temp.name = element.name; - temp.formGroup = []; - temp.model = {}; - temp.model['name'] = '<名称>'; - // 添加通用配置 - temp.model['base'] = {}; - form2Base.forEach(each=>{ - temp.model['base'][each.prop] = each.value; - }); - temp.formGroup.push({name:'通用配置', code:'base', styleList:form2Base}); - - const list = [{name:'绘图配置', type:'shape'}, {name:'样式配置', type:'style'}]; - list.forEach(eachType=>{ - temp.model[eachType.type] = {}; - const eachList = element.formList[eachType.type]; - eachList.forEach(each=>{ - temp.model[eachType.type][each.prop] = each.value; - }); - temp.formGroup.push({name:eachType.name, code:eachType.type, styleList:eachList}); - }); - this.formList.push(temp); - }); - return this.formList; - } -} - -export default BuilderFactory; diff --git a/src/iscs_new/core/form/elementConst.js b/src/iscs_new/core/form/elementConst.js index a90884cf8..19c5e1c58 100644 --- a/src/iscs_new/core/form/elementConst.js +++ b/src/iscs_new/core/form/elementConst.js @@ -5,9 +5,9 @@ import form2TextStyle from './form2TextStyle'; import types from './types'; const graphicType = Object.fromEntries(Object.keys(graphic).map(type => [type, type])); -export const elementConst = { +const elementConst = { [graphicType.Line]: { - code: graphicType.Line, + type: graphicType.Line, name:'线段', formList: { style: [ @@ -66,7 +66,7 @@ export const elementConst = { } }, [graphicType.Text]: { - code: graphicType.Text, + type: graphicType.Text, name:'文字', formList: { style: [ @@ -77,7 +77,7 @@ export const elementConst = { } }, [graphicType.Rect]: { - code: graphicType.Rect, + type: graphicType.Rect, name:'矩形', formList: { style: [ @@ -158,7 +158,7 @@ export const elementConst = { } }, [graphicType.Circle]: { - code: graphicType.Circle, + type: graphicType.Circle, name:'圆形', formList:{ style: [ @@ -214,7 +214,7 @@ export const elementConst = { } }, [graphicType.Polygon]: { - code: graphicType.Polygon, + type: graphicType.Polygon, name:'多边形', formList: { style: [ @@ -260,7 +260,7 @@ export const elementConst = { } }, [graphicType.Arrow]: { - code: graphicType.Arrow, + type: graphicType.Arrow, name:'箭头', formList: { style: [ @@ -272,7 +272,7 @@ export const elementConst = { } }, [graphicType.Polyline]: { - code: graphicType.Polyline, + type: graphicType.Polyline, name:'多边形折线段', formList: { style: [ @@ -308,7 +308,7 @@ export const elementConst = { } }, [graphicType.Isogon]: { - code: graphicType.Isogon, + type: graphicType.Isogon, name:'正多边形', formList: { style: [ @@ -377,7 +377,7 @@ export const elementConst = { } }, [graphicType.Ellipse]: { - code: graphicType.Ellipse, + type: graphicType.Ellipse, name:'椭圆', formList: { style: [ @@ -446,7 +446,7 @@ export const elementConst = { } }, [graphicType.Arc]: { - code: graphicType.Arc, + type: graphicType.Arc, name:'圆弧', formList: { style: [ @@ -531,7 +531,7 @@ export const elementConst = { } }, [graphicType.Sector]: { - code: graphicType.Sector, + type: graphicType.Sector, name:'扇形', formList: { style: [ @@ -638,7 +638,7 @@ export const elementConst = { } }, [graphicType.Heart]: { - code: graphicType.Heart, + type: graphicType.Heart, name:'心形', formList: { style: [ @@ -707,7 +707,7 @@ export const elementConst = { } }, [graphicType.Droplet]: { - code: graphicType.Droplet, + type: graphicType.Droplet, name:'水滴', formList: { style: [ @@ -775,3 +775,4 @@ export const elementConst = { } } }; +export default elementConst diff --git a/src/iscs_new/core/form/formBuilder.js b/src/iscs_new/core/form/formBuilder.js index 7b9da0b1c..8027f570e 100644 --- a/src/iscs_new/core/form/formBuilder.js +++ b/src/iscs_new/core/form/formBuilder.js @@ -1,37 +1,40 @@ -class FormBuilder { - constructor(formStyle = {}) { - this.formStyle = { - style: {}, - ...JSON.parse(JSON.stringify(formStyle)), - } - } +import elementConst from './elementConst'; +import form2Base from './form2Base'; - setBase(base = {}) { - Object.assign(this.formStyle, - Object.fromEntries( - Object.entries(base).filter(el => !['style'].includes(el[0])) - ) - ); - return this; - } +const formBuilder = { + buildForm(el) { + const form = {}; + form.type = el.type; + form.name = el.name; + form.formGroup = []; + form.model = {}; - setStyle(style = {}) { - Object.assign(this.formStyle.style, - Object.fromEntries( - Object.entries(style).filter(el => !['truncate'].includes(el[0])) - ) - ); - return this; - } + // 添加通用配置 + form.model['base'] = {}; + form2Base.forEach(each=>{ + form.model['base'][each.prop] = each.value; + }); + form.formGroup.push({name:'通用配置', type:'base', styleList:form2Base}); - setTruncate(truncate = {}) { - this.formStyle.style.truncate = { ...truncate } - return this; - } - - build() { - return this.formStyle; - } + const list = [{name:'绘图配置', type:'shape'}, {name:'样式配置', type:'style'}]; + list.forEach(eachType=>{ + form.model[eachType.type] = {}; + const eachList = el.formList[eachType.type]; + eachList.forEach(each=>{ + form.model[eachType.type][each.prop] = each.value; + }); + form.formGroup.push({name:eachType.name, type: eachType.type, styleList:eachList}); + }); + return form; + }, + buildFormList() { + const formList = []; + const elementList = Object.values(elementConst); + elementList.forEach(el=>{ + formList.push(this.buildForm(el)); + }); + return formList; + } } -export default FormBuilder; +export default formBuilder; diff --git a/src/iscs_new/map.js b/src/iscs_new/map.js index b246e57d9..ae55759aa 100644 --- a/src/iscs_new/map.js +++ b/src/iscs_new/map.js @@ -341,9 +341,9 @@ class JMap { case events.Keyup: this.$controller.on(events.Keyup, cb, context); break; - case events.BuildShape: - this.$controller.on(events.BuildShape, cb, context); - break; + // case events.BuildShape: + // this.$controller.on(events.BuildShape, cb, context); + // break; } } } @@ -392,9 +392,9 @@ class JMap { case events.Keyup: this.$controller.off(events.Keyup, cb); break; - case events.BuildShape: - this.$controller.off(events.BuildShape, cb); - break; + // case events.BuildShape: + // this.$controller.off(events.BuildShape, cb); + // break; } } } diff --git a/src/iscs_new/plugins/shapeBuilder/entry.vue b/src/iscs_new/plugins/shapeBuilder/entry.vue index 5f3d1e19e..f7ce0c83b 100644 --- a/src/iscs_new/plugins/shapeBuilder/entry.vue +++ b/src/iscs_new/plugins/shapeBuilder/entry.vue @@ -1,35 +1,51 @@ + diff --git a/src/iscs_new/plugins/shapeContextMenu/index.js b/src/iscs_new/plugins/shapeContextMenu/index.js new file mode 100644 index 000000000..f544a5dc6 --- /dev/null +++ b/src/iscs_new/plugins/shapeContextMenu/index.js @@ -0,0 +1,79 @@ +import Vue from 'vue'; +import events from '@/iscs_new/utils/events'; +import entry from './entry.vue'; + +const elPage = Vue.extend(entry); + +const toggling = (page, e) => { + if (e&&e.code) { + Vue.nextTick(() => { + page.doShow({x: e.clientX, y: e.clientY}); + }); + } else { + page.doClose(); + } +}; + + +const handle = { + onClick(e) { + if (this.page) { + this.page.selected = e; + toggling(this.page, {}); + } + }, + onContextMenu(e) { + if (this.page) { + toggling(this.page, e); + } + } +} + +class ShapeBuilder { + constructor(map) { + this.zr = map.getZr(); + this.map = map; + this.page = this.initUI(); + } + + initUI() { + const el = this.zr.dom; + const page = new elPage({ + el: document.createElement('div'), + data () {} + }); + el.page = page; + el.dom = page.$el; + el.grSelectStyle = {}; + el.appendChild(el.dom); + return page; + } + + addEventListener() { + if (this.map) { + this.map.on(events.Click, handle.onClick, this); + this.map.on(events.ContextMenu, handle.onContextMenu, this); + } + } + + removeEventListener() { + if (this.map) { + this.map.off(events.Click, handle.onClick, this); + this.map.off(events.ContextMenu, handle.onContextMenu, this); + } + } +} + +export default { + el: null, + install(map) { + this.el = new ShapeBuilder(map); + this.el.addEventListener(); + }, + uninstall(map) { + if (this.el) { + this.el.removeEventListener(); + this.el = null; + } + } +} diff --git a/src/iscs_new/plugins/shapeContextMenu/menu-item.vue b/src/iscs_new/plugins/shapeContextMenu/menu-item.vue new file mode 100644 index 000000000..ec2687e95 --- /dev/null +++ b/src/iscs_new/plugins/shapeContextMenu/menu-item.vue @@ -0,0 +1,202 @@ + + + + + diff --git a/src/iscs_new/plugins/shapeProperty/entry.vue b/src/iscs_new/plugins/shapeProperty/entry.vue index c9eea5e49..dd8b046b5 100644 --- a/src/iscs_new/plugins/shapeProperty/entry.vue +++ b/src/iscs_new/plugins/shapeProperty/entry.vue @@ -1,21 +1,22 @@ diff --git a/src/iscs_new/plugins/shapeProperty/index.js b/src/iscs_new/plugins/shapeProperty/index.js index 29ba3ace5..6cfd56574 100644 --- a/src/iscs_new/plugins/shapeProperty/index.js +++ b/src/iscs_new/plugins/shapeProperty/index.js @@ -4,8 +4,8 @@ import entry from './entry.vue'; const elPage = Vue.extend(entry); -const toggling = (page, show) => { - if (show) { +const toggling = (page, e) => { + if (!!e) { Vue.nextTick(() => { page.visible = true; }); @@ -17,15 +17,13 @@ const toggling = (page, show) => { const handle = { onClick(e) { - console.log(this) - toggling(this.page, !!e); - // console.log('onClick', this, e) + toggling(this.page, e); }, onContextMenu(e) { - // console.log('onContextMenu', this, e) }, - onBuildShape(e) { - // console.log('onBuildShape', this, e) + onModify(e) { + }, + onDelete(e) { } } @@ -53,7 +51,6 @@ class ShapeBuilder { if (this.map) { this.map.on(events.Click, handle.onClick, this); this.map.on(events.ContextMenu, handle.onContextMenu, this); - this.map.on(events.BuildShape, handle.onBuildShape, this); } } @@ -61,7 +58,6 @@ class ShapeBuilder { if (this.map) { this.map.off(events.Click, handle.onClick, this); this.map.off(events.ContextMenu, handle.onContextMenu, this); - this.map.off(events.BuildShape, handle.onBuildShape, this); } } } diff --git a/src/iscs_new/selectingHandle.js b/src/iscs_new/selectingHandle.js index 34f9910e0..92119c7cd 100644 --- a/src/iscs_new/selectingHandle.js +++ b/src/iscs_new/selectingHandle.js @@ -260,9 +260,9 @@ export default class SelectingHandle { } }); - if (['Alt'].includes(keyStr)) { - this.$controller.trigger(events.BuildShape, {...selectingRect, option: this.$map.getOption()}); - } + // if (['Alt'].includes(keyStr)) { + // this.$controller.trigger(events.BuildShape, {...selectingRect, option: this.$map.getOption()}); + // } this.clear(); } diff --git a/src/iscs_new/utils/events.js b/src/iscs_new/utils/events.js index d0795bd07..8561a5d53 100644 --- a/src/iscs_new/utils/events.js +++ b/src/iscs_new/utils/events.js @@ -12,5 +12,5 @@ export default { ViewUpdate: 'viewUpdate', StateUpdate: 'stateUpdate', OptionUpdate: 'optionUpdate', - BuildShape: 'buildShape' + // BuildShape: 'buildShape' } diff --git a/src/views/iscs_new/components/dataForm.vue b/src/views/iscs_new/components/dataForm.vue index a105268ff..e09147c94 100644 --- a/src/views/iscs_new/components/dataForm.vue +++ b/src/views/iscs_new/components/dataForm.vue @@ -16,8 +16,8 @@ {{ styleGroup.name }}