Skip to content

Commit

Permalink
修复表单不能重置switch标签默认值的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jxx committed Dec 8, 2019
1 parent 5643d26 commit acdff63
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Vol.Vue/src/components/basic/ViewGridConfig/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ let methods = {
formData.forEach(item => {
item.forEach(x => {
let data;
if (x.bind && x.bind.data) {
if (x.type == 'switch') {
this.keyValueType[x.field] = 1;
}
else if (x.bind && x.bind.data) {
data = x.bind.data;
} else if (x.data) {
if (x.data instanceof Array) {
Expand All @@ -314,7 +317,8 @@ let methods = {
}
}
if (data && data.length > 0 && !this.keyValueType.hasOwnProperty(x.field)) {
this.keyValueType[x.field] = typeof data[0].key;

this.keyValueType[x.field] = data[0].key;
}
})
})
Expand All @@ -341,7 +345,9 @@ let methods = {
for (const key in form) {
if (sourceObj.hasOwnProperty(key)) {
let newVal = sourceObj[key];
if (typeof(this.keyValueType[key] == 'number') && newVal * 1 == newVal) {
if (this.keyValueType.hasOwnProperty(key)
&& typeof (this.keyValueType[key]) == 'number'
&& newVal * 1 == newVal) {
newVal = newVal * 1;
} else {
if (newVal == null || newVal == undefined) {
Expand Down Expand Up @@ -715,7 +721,7 @@ let methods = {
initColumns(scoure, dicKeys, keys) {
if (!scoure || !(scoure instanceof Array)) return;
scoure.forEach(item => {
if (!item.bind || (item.bind.data&&item.bind.data.length>0)) return true;
if (!item.bind || (item.bind.data && item.bind.data.length > 0)) return true;
if (this.hasKeyField.indexOf(item.field) == -1) {
this.hasKeyField.push(item.field);
}
Expand Down

0 comments on commit acdff63

Please sign in to comment.