diff --git a/src/iscs_new/animateHandle.js b/src/iscs_new/animateHandle.js index 0a0c3067f..9b66d3e88 100644 --- a/src/iscs_new/animateHandle.js +++ b/src/iscs_new/animateHandle.js @@ -45,7 +45,8 @@ class Animate { const mapView = traverse(shape, {}); if(shape && frameList) { const size = frameList.length; - const frame = frameList[this.count%size]; + const index = this.count%size; + const frame = frameList[index]; Object.keys(frame).forEach(name => { const view = mapView[name]; const model = frame[name]; diff --git a/src/iscs_new/factory/templateParser.js b/src/iscs_new/factory/templateParser.js index 93dd0b04c..b26a89a28 100644 --- a/src/iscs_new/factory/templateParser.js +++ b/src/iscs_new/factory/templateParser.js @@ -1,4 +1,5 @@ -const defStatus = 'defStatus'; +import * as utils from '../utils/utils'; + class TemplateParser { constructor() { } @@ -17,10 +18,10 @@ class TemplateParser { parseShape(list=[], map={}) { list.forEach(el => { - const shapeMap = map[el.name] = {}; - shapeMap[defStatus] = { status: defStatus, style: el.style, shape: el.shape }; + const mapShape = map[el.name] = {}; + mapShape[utils.defStatus] = { status: utils.defStatus, style: el.style, shape: el.shape }; (el.stateList||[]).forEach(it => { - shapeMap[it.status] = it; + mapShape[it.status] = it; }) }) return map; diff --git a/src/iscs_new/stateHandle.js b/src/iscs_new/stateHandle.js index 338f79036..28b3aae70 100644 --- a/src/iscs_new/stateHandle.js +++ b/src/iscs_new/stateHandle.js @@ -1,3 +1,4 @@ +import * as utils from './utils/utils'; export default class StateHandle { constructor(map) { @@ -9,6 +10,16 @@ export default class StateHandle { const template = mapTemplate[state.type]; const templateState = template.mapState[state.status]; + if (templateState.needDefault) { + templateState.frameList.unshift( + Object.entries(template.mapShape).map(el => { + return { name: el[0], ...el[1][utils.defStatus]}; + }) + ); + } + + console.log(Object.entries(template.mapShape)) + return { ...state, ...templateState, diff --git a/src/iscs_new/utils/utils.js b/src/iscs_new/utils/utils.js index d6453e533..d3e948d37 100644 --- a/src/iscs_new/utils/utils.js +++ b/src/iscs_new/utils/utils.js @@ -1,12 +1,13 @@ import BoundingRect from 'zrender/src/core/BoundingRect'; import * as matrix from 'zrender/src/core/matrix'; -var base = 0; +// 默认状态标识 +export const defStatus = 'default'; // 获取一个UID -export function getUID(type) { - return [(type || ''), base++, Math.random().toFixed(5)].join('_'); -} +export const getUID =(function(base=0) { + return function(type) { return [(type || ''), base++, Math.random().toFixed(5)].join('_');} +})(); // 克隆一个对象 export function deepClone(obj) { diff --git a/src/views/test/index.vue b/src/views/test/index.vue index d08f9ef1d..dff11d677 100644 --- a/src/views/test/index.vue +++ b/src/views/test/index.vue @@ -286,17 +286,17 @@ export default { scale: [1, 1], position: [200, 0], rotation: 0, - // composeCode: '1000' + composeCode: '1000' }, - // { - // code: '1000', - // type: 'Device', - // scale: [1, 1], - // position: [0, 0], - // rotation: 0, - // elementCodes: ['100', '101'], - // composeCode: '' - // } + { + code: '1000', + type: 'Device', + scale: [1, 1], + position: [0, 0], + rotation: 0, + elementCodes: ['100', '101'], + composeCode: '' + } ] }, { panEnable: true,