Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wxs77577/rest-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
wxs77577 committed Apr 17, 2019
2 parents f91bf79 + 9f939eb commit 0a9ee40
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 20 additions & 19 deletions src/components/FormBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {
props: {
subForm: {
type: String,
default: ''
default: ""
},
id: {
type: String,
Expand Down Expand Up @@ -163,12 +163,7 @@ export default {
errors: []
};
},
watch: {
value(val) {
this.model = Object.assign({}, val);
},
},
watch: {},
computed: {
tag() {
return this.subForm ? "div" : "form";
Expand All @@ -190,20 +185,20 @@ export default {
}
},
methods: {
getFieldId(name){
getFieldId(name) {
if (this.subForm) {
return `input_${this.subForm}_${name}`
return `input_${this.subForm}_${name}`;
}
return `input_${name}`
return `input_${name}`;
},
getFieldName(name){
getFieldName(name) {
if (this.subForm) {
return `${this.subForm}[${name}]`
return `${this.subForm}[${name}]`;
}
return name
return name;
},
setValue(name, value, lang) {
const isIntl = this.fields[name].multilingual || this.fields[name].intl
const isIntl = this.fields[name].multilingual || this.fields[name].intl;
if (!isIntl) {
this.$set(this.model, name, value);
// _.set(this.model, name, value);
Expand All @@ -212,7 +207,7 @@ export default {
} else {
this.$set(this.model[name], lang, value);
}
return this.$emit('input', this.model)
return this.$emit("input", this.model);
},
titlize() {},
isShowField(field) {
Expand All @@ -239,9 +234,9 @@ export default {
},
handleSubmit() {
if (this.beforeSubmit) {
const ret = this.beforeSubmit(this.model)
const ret = this.beforeSubmit(this.model);
if (ret === false) {
return false
return false;
}
}
if (this.submitRawForm) {
Expand Down Expand Up @@ -275,15 +270,21 @@ export default {
},
mounted() {
this.model = Object.assign({}, this.value);
for (let [k, v] of Object.entries(this.fields)) {
if (v.type === "object" && !this.model[k]) {
this.$set(this.model, k, {});
}
}
this.$watch("value", (val) => {
this.model = Object.assign({}, val);
}, { deep: true });
// global.console.log(this.fields, this.model)
},
created() {}
created() {
}
};
</script>

7 changes: 6 additions & 1 deletion src/components/FormSelect2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export default {
}
},
set(val) {
if (val === null) {
return this.$emit('input', null)
}
let ret;
if (this.multiple) {
const isChanged = JSON.stringify(val) !== JSON.stringify(this.value);
Expand All @@ -62,7 +65,9 @@ export default {
} else {
ret = val.value;
}
ret && this.$emit("input", ret);
if (ret !== null) {
this.$emit("input", ret);
}
}
}
},
Expand Down

0 comments on commit 0a9ee40

Please sign in to comment.