efview-plus
Version:
A high quality Service UI components Library with Vue.js
79 lines (77 loc) • 2.36 kB
JavaScript
export default {
name:'size',
data () {
return {
calHeight:1,
calWidth:1,
adjustHeight:0,
adjustWidth:0,
};
},
computed:{
clientHeight () {
return this.$Store.state.app.clientHeight;
},
clientWidth () {
return this.$Store.state.app.clientWidth;
},
currentHeight () {
let culheight = this.clientHeight;
if (this.calHeight) {
if (Number(this.calHeight) <= 1) {
culheight = culheight * Number(this.calHeight);
culheight = Number(culheight.toFixed(0));
} else {
culheight = this.calHeight;
}
}
if (this.adjustHeight) {
culheight = culheight - Number(this.adjustHeight);
}
return culheight;
},
currentWidth () {
let culwidth = this.clientWidth;
if (this.calWidth) {
if (Number(this.calWidth) <= 1) {
culwidth = culwidth * Number(this.calWidth);
culwidth = Number(culwidth.toFixed(1));
} else {
culwidth = this.calWidth;
}
}
if (this.adjustWidth) {
culwidth = culwidth - Number(this.adjustWidth);
}
return culwidth;
}
},
methods:{
setCalHeight (value) {
this.calHeight = value;
},
setAdjustHeight (value) {
this.adjustHeight = value;
},
setCalWidth (value) {
this.calWidth = value;
},
setAdjustWidth(value) {
this.adjustWidth = value;
},
setSizeConfig (config) {
if (config.height) {
this.setCalHeight(config.height);
}
if (config.width) {
this.setCalWidth(config.width);
}
if (config.adjustHeight) {
this.setAdjustHeight(config.adjustHeight);
}
if (config.adjustWidth) {
this.setAdjustWidth(config.adjustWidth);
}
}
},
};