cxs-ui
Version:
Vue 动态表格组件和动态表单组件
33 lines (32 loc) • 1.15 kB
JavaScript
export default {
closeDialog() {
this.resetForm();
this.$emit('update:show', false);
},
resetForm() {
this.$refs['editFormRef'].resetFields();
this.formData = JSON.parse(JSON.stringify(this.data));
this.$nextTick(() => {
let formWidth = Number(this.$refs['editFormRef'].$el.offsetWidth);
this.itemLeftWidth = this.labelWidth + "px";
if (this.inline) {
// 如果是行内表单,则计算表单项的宽度
this.itemWidth = formWidth / Number(this.column) - 10;
this.itemRightWidth = "width: " + (this.itemWidth - Number(this.labelWidth)) + "px;";
} else {
this.itemWidth = formWidth - 40;
this.itemRightWidth = "";
}
})
},
onSubmit() {
this.$refs['editFormRef'].validate((valid) => {
if (valid) {
this.$emit('onSubmit', this.formData);
} else {
console.log('error submit!!');
return false;
}
});
},
}