Commit e406eaeb authored by 张晨辰's avatar 张晨辰

feat: properties

parent 31899580
...@@ -5,8 +5,8 @@ import properties from '../../../utils/properties'; ...@@ -5,8 +5,8 @@ import properties from '../../../utils/properties';
export default { export default {
component: require('./index.vue'), component: require('./index.vue'),
properties: { properties: {
...properties().node, ...properties.node,
...properties().image ...properties.image
}, },
props: { props: {
type: 'image' type: 'image'
......
...@@ -5,8 +5,8 @@ import properties from '../../../utils/properties'; ...@@ -5,8 +5,8 @@ import properties from '../../../utils/properties';
export default { export default {
component: require('./index.vue'), component: require('./index.vue'),
properties: { properties: {
...properties().node, ...properties.node,
...properties().label ...properties.label
}, },
props: { props: {
type: 'label' type: 'label'
......
...@@ -5,7 +5,7 @@ import properties from '../../../utils/properties'; ...@@ -5,7 +5,7 @@ import properties from '../../../utils/properties';
export default { export default {
component: require('./index.vue'), component: require('./index.vue'),
properties: { properties: {
...properties().node ...properties.node
}, },
props: { props: {
type: 'node' type: 'node'
......
...@@ -5,8 +5,8 @@ import properties from '../../../utils/properties'; ...@@ -5,8 +5,8 @@ import properties from '../../../utils/properties';
export default { export default {
component: require('./index.vue'), component: require('./index.vue'),
properties: { properties: {
...properties().node, ...properties.node,
...properties().rect ...properties.rect
}, },
props: { props: {
type: 'rect' type: 'rect'
......
...@@ -25,17 +25,4 @@ export function playWaiting(promise, text) { ...@@ -25,17 +25,4 @@ export function playWaiting(promise, text) {
}).finally(() => { }).finally(() => {
loading.close(); loading.close();
}) })
} }
\ No newline at end of file
export function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
// querySelector method uses CSS3 selectors for querying the DOM and CSS3
// doesn't support ID selectors that start with a digit
// for more:
// https://stackoverflow.com/questions/37270787/uncaught-syntaxerror-failed-to-execute-queryselector-on-document
return `xy-${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
}
export const componentsMap = [{
label: '文本',
value: 'label'
}, {
label: '图片',
value: 'image'
}, {
label: '视图',
value: 'node'
}, {
label: '形状',
value: 'rect'
}];
\ No newline at end of file
import { guid } from './index'; import { guid } from './index';
import _ from 'lodash';
import { getComposedComponents } from './getComposedComponents'; import { getComposedComponents } from './getComposedComponents';
const composedComponents = getComposedComponents(); const composedComponents = getComposedComponents();
...@@ -9,8 +10,8 @@ export const compoleteComponentData = (views) => { ...@@ -9,8 +10,8 @@ export const compoleteComponentData = (views) => {
view.id = view.id || guid(); view.id = view.id || guid();
let _composedCmp = composedComponents[view.type]; let _composedCmp = composedComponents[view.type];
view.component = _composedCmp.component.default; view.component = _composedCmp.component.default;
let _composedProps = {..._composedCmp.properties}; // 组件预设的属性,Object类型 let _composedProps = _.cloneDeep(_composedCmp.properties); // 组件预设的属性,Object类型
let _viewProps = view.properties || {}; // 组件对象的具体属性,key:value let _viewProps = view.properties || {}; // 组件对象的具体属性,key:value
let _keys = Object.keys(_viewProps); let _keys = Object.keys(_viewProps);
_keys.forEach(k => { _keys.forEach(k => {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import { Message, Loading } from "element-ui"; import { Message, Loading } from "element-ui";
import i18n from '../i18n' import i18n from '../i18n'
import generateUUID from "uuid/v4";
export function messageError(e) { export function messageError(e) {
Message({ Message({
...@@ -28,14 +29,5 @@ export function playWaiting(promise, text) { ...@@ -28,14 +29,5 @@ export function playWaiting(promise, text) {
} }
export function guid() { export function guid() {
function s4() { return `xy-${generateUUID()}`;
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
// querySelector method uses CSS3 selectors for querying the DOM and CSS3
// doesn't support ID selectors that start with a digit
// for more:
// https://stackoverflow.com/questions/37270787/uncaught-syntaxerror-failed-to-execute-queryselector-on-document
return `xy-${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
} }
// 属性 // 属性
export default () => ({ export default {
node: { node: {
groupName: '基础', groupName: '基础',
left: { left: {
...@@ -108,4 +108,4 @@ export default () => ({ ...@@ -108,4 +108,4 @@ export default () => ({
} }
} }
} }
}); }
<template> <template>
<pane icon="el-icon-s-operation" :title="$t('panes.Inspector')"> <pane icon="el-icon-s-operation" :title="$t('panes.Inspector')">
<div class="inspec-test" style="background-color:#fff; width: 100%;height: 100px;" @click.native="testGetter"> <div class="zero-inspector-form">
<el-form ref="form" size="mini" v-if="activeComponentId" :model="activeComponent.properties" label-width="80px">
<el-form-item >
<el-button @click="testGetter">test</el-button>
</el-form-item>
<p>基础</p>
<el-divider></el-divider>
<el-form-item label="类型">
<el-select v-model="activeComponent.type" placeholder="请选择类型">
<el-option v-for="cmp in componentsMap" :key="cmp.value" :label="cmp.label" :value="cmp.value"></el-option>
</el-select>
</el-form-item>
<p>{{activeComponent.properties.groupName}}</p>
<el-divider></el-divider>
<!-- <template v-for=""></template> -->
</el-form>
</div>
<div class="inspec-test" style="position: absolute;bottom: 0;font-size: 12px;background-color:#fff; width: 100%;height: 100px;" @click.native="testGetter">
{{JSON.stringify(activeComponent.properties)}} {{JSON.stringify(activeComponent.properties)}}
</div> </div>
<el-button @click="testGetter">默认按钮</el-button>
</pane> </pane>
</template> </template>
<script> <script>
import { mapState, mapActions, mapGetters } from 'vuex'; import { mapState, mapActions, mapGetters } from 'vuex';
import Pane from '../../components/Pane'; import Pane from '../../components/Pane';
import properties from '../../utils/properties';
import { componentsMap } from '../../utils/common';
export default { export default {
name: 'Inspector', name: 'Inspector',
components: { Pane }, components: { Pane },
data() {
return {
componentsMap,
sel: ''
};
},
computed: { computed: {
...mapGetters([ ...mapGetters(['activeComponent', 'activeComponentId']),
'activeComponent' form: function() {
]) console.log(this.activeComponent.properties);
},
methods: { return this.activeComponent.properties;
testGetter() { },
console.log('testGetter', this.activeComponent); cmpProps: function() {
debugger; if (!this.activeComponentId) {
this.$store; return [];
debugger; } else {
let _node = Object.keys(properties.node);
}
} }
}
},
methods: {
testGetter() {
console.log(this.$store);
console.log('testGetter', this.activeComponentId, this.activeComponent);
}
}
}; };
</script> </script>
<style scoped> <style lang="scss">
.zero-inspector-form {
width: 100%;
.el-form-item--mini.el-form-item {
margin-bottom: 10px;
}
}
</style> </style>
\ No newline at end of file
...@@ -132,8 +132,6 @@ export default { ...@@ -132,8 +132,6 @@ export default {
}, },
computed: { computed: {
cmpId() { cmpId() {
console.log('this.componentData', this.componentData);
return this.componentData.id; return this.componentData.id;
}, },
active() { active() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment