Commit ede73eec authored by rockyl's avatar rockyl

Merge branch 'percent-input' into dev

parents 9c8bb573 ba4b3b75
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
@cmd-prop-change="onCmdPropChanged" @cmd-prop-change="onCmdPropChanged"
> >
<component <component
:is="getInput(property)" :is="getInput(property)"
:container="data" :container="data"
:value="data[key]" :value="data[key]"
:propertyName="key" :propertyName="key"
:property="property" :property="property"
:editable="editable" :editable="editable"
@input="onInput" :config ="property.input"
@input="onInput"
/> />
</component> </component>
</el-form> </el-form>
...@@ -83,9 +84,7 @@ ...@@ -83,9 +84,7 @@
SampleInputWrapper, SampleInputWrapper,
}, },
data() { data() {
return { return {}
}
}, },
props: { props: {
labelWidth: { labelWidth: {
...@@ -112,7 +111,7 @@ ...@@ -112,7 +111,7 @@
}, },
}, },
watch: { watch: {
data(v){ data(v) {
} }
}, },
...@@ -129,7 +128,7 @@ ...@@ -129,7 +128,7 @@
} }
this.$emit('input', value, container, propName, oldValue); this.$emit('input', value, container, propName, oldValue);
}, },
onCmdPropChanged(value, container, propName, oldValue){ onCmdPropChanged(value, container, propName, oldValue) {
this.$emit('input', value, container, propName, oldValue); this.$emit('input', value, container, propName, oldValue);
}, },
} }
......
<template> <template>
<el-input-number :disabled="!editable" :value="editValue" @change="onInput" controls-position="right" <div style="flex: 1; display: flex;">
:placeholder="defaultValue"></el-input-number> <el-input-number :disabled="!editable" :value="editValue" @change="onInput" controls-position="right"
:placeholder="defaultValue">
</el-input-number>
<span @click="onClickPercent" v-if="config && config.percent" style="position: absolute; right: 42px; cursor: pointer"
:class="{'percent-on': isPercent, 'percent-off': !isPercent}">%</span>
</div>
</template> </template>
<script> <script>
...@@ -11,21 +16,47 @@ ...@@ -11,21 +16,47 @@
export default { export default {
name: "NumberInput", name: "NumberInput",
components: {LinkableInputWrapper, CmdInputWrapper}, components: {LinkableInputWrapper, CmdInputWrapper},
props: ['value', 'container', 'property', 'propertyName', 'editable'], props: ['value', 'container', 'property', 'propertyName', 'editable', 'config'],
data() {
return {
isPercent: false,
}
},
computed: { computed: {
editValue() { editValue() {
return this.value === undefined ? this.property.default : this.value; let v = this.value;
if (v === undefined) {
this.isPercent = false;
return this.property.default;
} else {
this.isPercent = typeof v === 'string';
if(typeof v === 'string'){
v = parseInt(v);
}
return v;
}
}, },
defaultValue(){ defaultValue() {
return getInputDefaultValue(this.property); return getInputDefaultValue(this.property);
}, },
}, },
methods: { methods: {
onInput(v) { onInput(v) {
if(v !== this.value){ if (v !== this.value) {
this.$emit('input', v, this.container, this.propertyName, this.value); this.$emit('input', v, this.container, this.propertyName, this.value);
} }
} },
onClickPercent() {
if(this.isPercent){ //设置非百分比
this.onInput(parseInt(this.value))
}else{ //设置成百分比
if(!this.value && this.value !== 0){
this.onInput(undefined)
}else{
this.onInput(this.value + '%')
}
}
},
}, },
} }
</script> </script>
......
...@@ -899,7 +899,7 @@ export const projectStore = { ...@@ -899,7 +899,7 @@ export const projectStore = {
}) })
}, },
async importPsd({commit}, {file, action}) { async importPsd({commit}, {file, action}) {
const result = await toZeroing(file); const result = await toZeroing(file, {offset: {y: 172}});
let viewFile = new File([result], 'view.json'); let viewFile = new File([result], 'view.json');
const {view, assets} = await editorApi.uploadView(viewFile); const {view, assets} = await editorApi.uploadView(viewFile);
switch (action) { switch (action) {
......
...@@ -27,6 +27,8 @@ export const template = ...@@ -27,6 +27,8 @@ export const template =
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
background-color: white; background-color: white;
-webkit-touch-callout: none;
} }
.game-container{ .game-container{
width: 100%; width: 100%;
......
...@@ -501,6 +501,14 @@ $dock-pin-width: 9px; ...@@ -501,6 +501,14 @@ $dock-pin-width: 9px;
.node-select-container { .node-select-container {
flex: 1; flex: 1;
} }
.percent-on{
color: $--color-primary;
}
.percent-off{
color: $--color-text-placeholder;
}
} }
.source-input-popover { .source-input-popover {
......
...@@ -22,26 +22,44 @@ export default { ...@@ -22,26 +22,44 @@ export default {
width: { width: {
alias: '宽度', alias: '宽度',
type: 'number', type: 'number',
input: {
percent: true,
},
}, },
height: { height: {
alias: '高度', alias: '高度',
type: 'number', type: 'number',
input: {
percent: true,
},
}, },
left: { left: {
alias: '左边距', alias: '左边距',
type: 'number', type: 'number',
input: {
percent: true,
},
}, },
right: { right: {
alias: '右边距', alias: '右边距',
type: 'number', type: 'number',
input: {
percent: true,
},
}, },
top: { top: {
alias: '上边距', alias: '上边距',
type: 'number', type: 'number',
input: {
percent: true,
},
}, },
bottom: { bottom: {
alias: '下边距', alias: '下边距',
type: 'number', type: 'number',
input: {
percent: true,
},
}, },
horizonCenter: { horizonCenter: {
alias: '水平居中偏移', alias: '水平居中偏移',
......
...@@ -54,14 +54,14 @@ export default { ...@@ -54,14 +54,14 @@ export default {
return styles.getComponentStyle(this.activeComponentCopy, this.project, this.componentList, true); return styles.getComponentStyle(this.activeComponentCopy, this.project, this.componentList, true);
}, },
position() { position() {
let _props = this.activeComponentCopy.properties || {}; let {x, y, width, height} = this.activeComponentCopy.properties || {};
const props = properties.node.props; const props = properties.node.props;
// console.log('********', _props); // console.log('********', _props);
let result = { let result = {
x: _props.x || props.x.default, x: x || props.x.default,
y: _props.y || props.y.default, y: y || props.y.default,
w: _props.width || props.width.default, w: width ? (typeof width === 'string' ? parseInt(width) : width) : props.width.default,
h: _props.height || props.height.default, h: height ? (typeof height === 'string' ? parseInt(height) : height) : props.height.default,
}; };
// console.log('####position', result); // console.log('####position', result);
......
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