Browse Source

BI-90461 fix:优化全选逻辑

es6
Jimmy.Chai 3 years ago
parent
commit
c7f4635899
  1. 31
      src/widget/multiselect/multiselect.combo.js
  2. 32
      src/widget/multiselect/multiselect.combo.nobar.js
  3. 14
      src/widget/multiselect/multiselect.insert.combo.js
  4. 32
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  5. 30
      src/widget/multiselectlist/multiselectlist.insert.js
  6. 30
      src/widget/multiselectlist/multiselectlist.insert.nobar.js
  7. 30
      src/widget/multiselectlist/multiselectlist.js

31
src/widget/multiselect/multiselect.combo.js

@ -336,26 +336,27 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
var self = this; var o = this.options;
this._assertValue(res);
this.requesting = true;
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var change = false;
var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
this._adjust(callback);
return;
}
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()],
selectedValues: this.storeValue.value,
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];

32
src/widget/multiselect/multiselect.combo.nobar.js

@ -363,25 +363,27 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var change = false;
var map = self._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
this._adjust(callback);
return;
}
o.itemsCreator({
type: BI.MultiSelectNoBarCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
keywords: [this.trigger.getKey()],
selectedValues: this.storeValue.value,
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];

14
src/widget/multiselect/multiselect.insert.combo.js

@ -352,10 +352,16 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
this.requesting = true;
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var resultArray = BI.concat(result.match, result.find);
this.storeValue.value = BI.filter(this.storeValue.value, function (i, value) {
return !BI.contains(resultArray, value);
}) || [];
var change = false;
var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
this._adjust(callback);
return;
}

32
src/widget/multiselect/multiselect.insert.combo.nobar.js

@ -348,25 +348,27 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var change = false;
var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
this._adjust(callback);
return;
}
o.itemsCreator({
type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
keywords: [this.trigger.getKey()],
selectedValues: this.storeValue.value,
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
self.storeValue.assist && self.storeValue.assist.push(map[v]);
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];

30
src/widget/multiselectlist/multiselectlist.insert.js

@ -239,24 +239,26 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var change = false;
var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
callback();
return;
}
o.itemsCreator({
type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA,
keywords: [self.trigger.getKeyword()]
keywords: [this.trigger.getKeyword()],
selectedValues: this.storeValue.value,
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
callback();
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];

30
src/widget/multiselectlist/multiselectlist.insert.nobar.js

@ -243,24 +243,26 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var change = false;
var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
callback();
return;
}
o.itemsCreator({
type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA,
keywords: [self.trigger.getKeyword()]
keywords: [this.trigger.getKeyword()],
selectedValues: this.storeValue.value,
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
callback();
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];

30
src/widget/multiselectlist/multiselectlist.js

@ -229,24 +229,26 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
if (this.storeValue.type === res.type) {
var result = BI.Func.getSearchResult(this.storeValue.value, this.trigger.getKey());
var change = false;
var map = this._makeMap(this.storeValue.value);
BI.each(BI.concat(result.match, result.find), function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (this.storeValue.value = BI.values(map));
this._adjust(callback);
return;
}
o.itemsCreator({
type: BI.MultiSelectList.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
keywords: [this.trigger.getKey()],
selectedValues: this.storeValue.value,
}, function (ob) {
var items = BI.map(ob.items, "value");
if (self.storeValue.type === res.type) {
var change = false;
var map = self._makeMap(self.storeValue.value);
BI.each(items, function (i, v) {
if (BI.isNotNull(map[v])) {
change = true;
delete map[v];
}
});
change && (self.storeValue.value = BI.values(map));
self._adjust(callback);
return;
}
var selectedMap = self._makeMap(self.storeValue.value);
var notSelectedMap = self._makeMap(res.value);
var newItems = [];

Loading…
Cancel
Save