diff --git a/src/iscs_new/core/abstractShape.js b/src/iscs_new/core/abstractShape.js index d4ce84740..8721b09e0 100644 --- a/src/iscs_new/core/abstractShape.js +++ b/src/iscs_new/core/abstractShape.js @@ -58,7 +58,12 @@ class AbstractShape extends Group { // 设置显隐 setInvisible(hide) { - hide ? this.hide(): this.show(); + if (hide) { + super.hide() + } else { + super.show(); + } + super.dirty(); } // 设置高亮 diff --git a/src/iscs_new/core/form/elementConst.js b/src/iscs_new/core/form/elementConst.js index 06a5d7afc..842d2e249 100644 --- a/src/iscs_new/core/form/elementConst.js +++ b/src/iscs_new/core/form/elementConst.js @@ -253,7 +253,7 @@ export const elementConst = { rules:[ { required: true, message:'请输入坐标集合', trigger: 'blur' } ], - value: 10, + value: 0, description: '取值范围为 0 到 1 之间的数字,0 表示不圆滑' } ] diff --git a/src/iscs_new/plugins/shapeBuilder/shapeTypeSelect.vue b/src/iscs_new/plugins/shapeBuilder/shapeTypeSelect.vue index b41142909..b636452bf 100644 --- a/src/iscs_new/plugins/shapeBuilder/shapeTypeSelect.vue +++ b/src/iscs_new/plugins/shapeBuilder/shapeTypeSelect.vue @@ -14,7 +14,6 @@ export default { }; }, mounted() { - console.log('xxxxxxxxxxx'); this.$emit('change', {shapeType: 'Rect'}); } }; diff --git a/src/iscs_new/transformHandle.js b/src/iscs_new/transformHandle.js index 3046d9fff..8aad9a282 100644 --- a/src/iscs_new/transformHandle.js +++ b/src/iscs_new/transformHandle.js @@ -15,7 +15,7 @@ export default class TransformHandle { // 检查显隐 checkVisible(shape) { - return shape.model && !shape.model.base.hide || utils.createBoundingRectCheckVisible(shape, this.transform).intersect(this.rect); + return (!shape.model || !shape.model.base.hide) && utils.createBoundingRectCheckVisible(shape, this.transform).intersect(this.rect); } // 重新计算显隐 diff --git a/src/router/index.js b/src/router/index.js index c93263f19..3ee5dad54 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1148,31 +1148,22 @@ export const asyncRouter = [ ] }, { - path: '/iscs_new', - component: Layout, - hidden: true, - meta: { - i18n: 'router.iscsSystem', - roles: [admin] - }, - children: [ - { - path:'design', - redirect: '/iscs/design/edit', - component: IscsNewDesign, - meta: { - i18n: 'router.iscsDraw', - roles: [admin] - }, - children: [ - { - path: 'edit', - component: IscsNewDraw, - hidden: true - } - ] - } - ] + path:'/iscs_new/design/compose/edit', + hidden: true, + component: IscsNewDesign, + meta: { + i18n: 'router.iscsDraw', + roles: [admin] + } + }, + { + path:'/iscs_new/design/map/edit', + hidden: true, + component: IscsNewDraw, + meta: { + i18n: 'router.iscsDraw', + roles: [admin] + } }, { // iscs系统 path: '/iscs', diff --git a/src/views/iscs_new/iscsDesign/index.vue b/src/views/iscs_new/iscsDesign/index.vue index a9e41d9ed..c823dd798 100644 --- a/src/views/iscs_new/iscsDesign/index.vue +++ b/src/views/iscs_new/iscsDesign/index.vue @@ -1,114 +1,252 @@ - + diff --git a/src/views/iscs_new/iscsDesign/iscsCanvas.vue b/src/views/iscs_new/iscsDesign/iscsCanvas.vue new file mode 100644 index 000000000..b8c3a600d --- /dev/null +++ b/src/views/iscs_new/iscsDesign/iscsCanvas.vue @@ -0,0 +1,157 @@ + + + + diff --git a/src/views/iscs_new/iscsDraw/index.vue b/src/views/iscs_new/iscsDraw/index.vue index 311b264cd..94ccb0aa8 100644 --- a/src/views/iscs_new/iscsDraw/index.vue +++ b/src/views/iscs_new/iscsDraw/index.vue @@ -36,6 +36,7 @@ import BuilderFactory from '@/iscs_new/core/form/builderFactory'; import DataForm from '../components/dataForm'; import orders from '@/iscs_new/utils/orders'; import * as utils from '@/iscs_new/utils/utils'; +import IndexedDb from '../utils/indexedDb.js'; import shapeType from '@/iscs_new/constant/shapeType.js'; export default { @@ -69,6 +70,8 @@ export default { } }, mounted() { + this.db = new IndexedDb(['composeList']); + console.log(this.db, 11111111111); this.composeName = this.$route.query.composeName; this.elementList = new BuilderFactory().getFormList(); this.enabledTab = this.elementList[0].code; @@ -83,8 +86,8 @@ export default { }, onSave() { const id = this.$route.query.id; - const name = this.$route.query.name; - const type = this.$route.query.type; + const name = this.$route.query.name||"<模型名称>"; + const type = this.$route.query.type||"<模型类型>"; const source = this.$iscs.getSource(); if (id && source) { const shapeList = source.elementList.map(el => { @@ -92,28 +95,9 @@ export default { }); const rect = shapeList.reduce( (temp,el) => el&&temp? temp.union(el.getBoundingRect().clone()): el.getBoundingRect(), null); - const dx = (rect.x + rect.width)/2; - const dy = (rect.y + rect.height)/2; - const computed = (prop, shape, n) => shape.hasOwnProperty(prop)? shape[prop] = shape[prop] - n: null; - shapeList.map(el => { - const shape = el.model.shape; - computed('x', shape, dx); - computed('y', shape, dy); - computed('x1', shape, dx); - computed('y1', shape, dy); - computed('x2', shape, dx); - computed('y2', shape, dy); - computed('cx', shape, dx); - computed('cy', shape, dy); - if (shape.hasOwnProperty('point')) { - shape.point = [shape.point[0] - dx, shape.point[1] - dy]; - } - if (shape.hasOwnProperty('points')) { - shape.points = shape.points.map(([point,i]) => [point[0] - dx, point[1] - dy]); - } - }) - console.log(shapeList) - // const model = { id, name, type, shapeList }; + const position = [(rect.x + rect.width)/2, (rect.y + rect.height)/2]; + const model = { id, name, type, shapeList, position }; + console.log(model) } }, onSelectTab() { @@ -135,8 +119,9 @@ export default { if (valid) { const formModel = this.$refs['dataform' + this.enabledTab][0].formModel; const newModel = JSON.parse(JSON.stringify(formModel)); + newModel.code = utils.getUID(this.enabledTab); newModel.type = this.enabledTab; - newModel.code = utils.getUID(this.enabledTab); + newModel.name = '<名称>'; newModel.stateList = []; this.$refs.iscsCanvas.doAction([{model: newModel, action: {shapeType: shapeType.Element, order: orders.ADD}}]); this.clear(this.enabledTab); @@ -149,6 +134,7 @@ export default { const model = this.$refs['dataform' + this.enabledTab][0].formModel; model.code = this.selected.code; model.type = this.selected.type; + model.name = this.selected.name; this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.UPDATE}}]); this.clear(this.enabledTab); } @@ -160,6 +146,7 @@ export default { const model = this.$refs['dataform' + this.enabledTab][0].formModel; model.code = this.selected.code; model.type = this.selected.type; + model.name = this.selected.name; this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.DELETE}}]); this.clear(this.enabledTab); } diff --git a/src/views/iscs_new/utils/indexedDb.js b/src/views/iscs_new/utils/indexedDb.js new file mode 100644 index 000000000..abd2afb8f --- /dev/null +++ b/src/views/iscs_new/utils/indexedDb.js @@ -0,0 +1,112 @@ + +import { getBaseUrl } from '@/utils/baseUrl' + +let db = null; + +class IndexedDb { + constructor(tableList) { + this.open(tableList); + } + + init(tableList) { + const baseUrl = getBaseUrl(); + const indexedDBName = baseUrl.replace(/http.?:\/\/(.*)[\/|:].*/, "$1"); + const request = window.indexedDB.open(indexedDBName, 1); + request.onerror = function (e) { + console.log('数据库打开报错'); + }; + + request.onsuccess = function (e) { + db = request.result; + }; + request.onupgradeneeded = function (e) { + if (db) { + tableList.forEach(name => { + db.createObjectStore(name, { keyPath: 'id' }); + }) + } + }; + } + + add(tableName, data) { + return new Promise((resolve, reject) => { + if (db) { + const request = db.transaction([tableName], 'readwrite').objectStore(tableName).add(data); + request.onsuccess = function(e) { + console.log('数据写入成功'); + resolve(request.result); + }; + request.onerror = function(e) { + console.log('数据写入失败'); + reject(e); + }; + } else { + this.open(); + reject({message: '数据库未打开!'}); + } + }); + } + + modify(tableName, data) { + return new Promise((resolve, reject) => { + if (db) { + const request = db.transaction([tableName], 'readwrite').objectStore(tableName).put(data); + request.onsuccess = function(e) { + console.log('数据更新成功'); + resolve(request.result); + }; + request.onerror = function(e) { + console.log('数据更新失败'); + reject(e); + }; + } else { + this.open(); + reject({message: '数据库未打开!'}); + } + }); + } + + delete(tableName, key) { + return new Promise((resolve, reject) => { + if (db) { + const request = db.transaction([tableName], 'readwrite').objectStore(tableName).delete(key); + request.onsuccess = function(event) { + console.log('数据删除成功'); + resolve(request.result); + }; + request.onerror = function(event) { + console.log('数据删除失败'); + reject(event); + }; + } else { + this.open(); + reject({message: '数据库未打开!'}); + } + }); + } + + query(tableName, key) { + return new Promise((resolve, reject) => { + if (db) { + const request = db.transaction([tableName]).objectStore(tableName).get(key); + request.onsuccess = function(e) { + console.log('数据读取成功'); + resolve(request.result); + }; + request.onerror = function(e) { + console.log('数据读取失败'); + reject(e); + }; + } else { + this.open(); + reject({message: '数据库未打开!'}); + } + }); + } + + destroy() { + } +} + +export default IndexedDb; +