diff --git a/src/iscs_new/core/form/formBuilder.js b/src/iscs_new/core/form/formBuilder.js index 8027f570e..87fd4e592 100644 --- a/src/iscs_new/core/form/formBuilder.js +++ b/src/iscs_new/core/form/formBuilder.js @@ -2,39 +2,39 @@ import elementConst from './elementConst'; import form2Base from './form2Base'; const formBuilder = { - buildForm(el) { - const form = {}; - form.type = el.type; - form.name = el.name; - form.formGroup = []; - form.model = {}; + buildForm(el) { + const form = {}; + form.type = el.type; + form.name = el.name; + form.formGroup = []; + form.model = {}; - // 添加通用配置 - form.model['base'] = {}; - form2Base.forEach(each=>{ - form.model['base'][each.prop] = each.value; - }); - form.formGroup.push({name:'通用配置', type:'base', styleList:form2Base}); + // 添加通用配置 + form.model['base'] = {}; + form2Base.forEach(each=>{ + form.model['base'][each.prop] = each.value; + }); + form.formGroup.push({name:'通用配置', type:'base', styleList:form2Base}); - 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; - }, + 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 formList = []; const elementList = Object.values(elementConst); elementList.forEach(el=>{ formList.push(this.buildForm(el)); }); return formList; } -} +}; export default formBuilder; diff --git a/src/utils/indexedDb.js b/src/utils/indexedDb.js index 3cffc3021..c139a4fb1 100644 --- a/src/utils/indexedDb.js +++ b/src/utils/indexedDb.js @@ -1,10 +1,10 @@ import Vue from 'vue'; -import { getBaseUrl } from '@/utils/baseUrl' +import { getBaseUrl } from '@/utils/baseUrl'; // 创建或者打开数据库 export function openIndexedDB() { - const baseUrl = getBaseUrl(); - const indexedDBName = baseUrl.replace(/http.?:\/\/(.*)[\/|:].*/, "$1"); + const baseUrl = getBaseUrl(); + const indexedDBName = baseUrl.replace(/http.?:\/\/(.*)[\/|:].*/, '$1'); const request = window.indexedDB.open(indexedDBName, 1); request.onerror = function (event) { console.log('数据库打开报错'); @@ -18,7 +18,7 @@ export function openIndexedDB() { Vue.prototype.$db = event.target.result; Vue.prototype.$db.createObjectStore('mapData', { keyPath: 'id' }); Vue.prototype.$db.createObjectStore('runPlan', { keyPath: 'templateId' }); - Vue.prototype.$db.createObjectStore('composeList', { keyPath: 'id' }); + Vue.prototype.$db.createObjectStore('composeTemplateList', { keyPath: 'id' }); }; } // 新增数据 diff --git a/src/views/iscs_new/components/tableForm.vue b/src/views/iscs_new/components/tableForm.vue index 9216d9224..8d9eefca0 100644 --- a/src/views/iscs_new/components/tableForm.vue +++ b/src/views/iscs_new/components/tableForm.vue @@ -20,7 +20,7 @@ - 添加 + 添加
@@ -41,10 +41,10 @@ - 添加 + 添加
-
-
+
+
删除
- + @@ -43,6 +43,9 @@ 保存
+ + +
@@ -115,21 +118,25 @@ export default { const type = this.$route.query.type || '<模型类型>'; const source = this.$iscs.getSource(); if (id && source) { - const elementList = source.elementList.map(el => { + const shapeList = source.elementList; + shapeList.forEach(el => { return this.$iscs.getShapeByCode(el.code).model; }); - const composeList = source.composeList.map(el => { - return this.$iscs.getShapeByCode(el.code).model; - }); - const rect = elementList.reduce((temp, el) => { - const shape = this.$iscs.getShapeByCode(el.code); - return shape && temp ? temp.union(shape.getBoundingRect().clone()) : shape.getBoundingRect(); - }, null); - const position = rect ? [(rect.x + rect.width) / 2, (rect.y + rect.height) / 2] : [0, 0]; - const model = { id, name, type, elementList, composeList, position }; - Idb.delete('composeList', model.id); - Idb.write('composeList', model); - Idb.list('composeList').then(list => { + // const composeList = source.composeList.map(el => { + // return this.$iscs.getShapeByCode(el.code).model; + // }); + // const rect = shapeList.reduce((temp, el) => { + // const shape = this.$iscs.getShapeByCode(el.code); + // return shape && temp ? temp.union(shape.getBoundingRect().clone()) : shape.getBoundingRect(); + // }, null); + // const position = rect ? [(rect.x + rect.width) / 2, (rect.y + rect.height) / 2] : [0, 0]; + const position = [0, 0]; + const stateList = []; + const model = { id, name, type, shapeList, stateList, position }; + + Idb.delete('composeTemplateList', model.id); + Idb.write('composeTemplateList', model); + Idb.list('composeTemplateList').then(list => { console.log(list); }); } diff --git a/src/views/iscs_new/iscsDraw/iscsCanvas.vue b/src/views/iscs_new/iscsDraw/iscsCanvas.vue index 85597ee5c..4955f0745 100644 --- a/src/views/iscs_new/iscsDraw/iscsCanvas.vue +++ b/src/views/iscs_new/iscsDraw/iscsCanvas.vue @@ -100,9 +100,9 @@ export default { } 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||[], + elementList: resp.shapeList||[], composeList: resp.composeList||[] }, option); EventBus.$emit('getComposeElemList'); diff --git a/src/views/iscs_new/iscsPreview/index.vue b/src/views/iscs_new/iscsPreview/index.vue index 188f632ba..22a2682d3 100644 --- a/src/views/iscs_new/iscsPreview/index.vue +++ b/src/views/iscs_new/iscsPreview/index.vue @@ -9,16 +9,13 @@
- 状态预览 + 状态编辑
- - -