提交 9bbdc0fb 编写于 作者: U unknown

增加人员选择嵌套全选的功能

上级 79599b52
...@@ -55,8 +55,8 @@ MWF.xApplication.Selector.Group = new Class({ ...@@ -55,8 +55,8 @@ MWF.xApplication.Selector.Group = new Class({
if (callback) callback.apply(this, [json]); if (callback) callback.apply(this, [json]);
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.Group.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.Group.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
if (this.options.groups.length || this.options.roles.length) key = this.getLikeKey( key ); if (this.options.groups.length || this.options.roles.length) key = this.getLikeKey( key );
......
...@@ -207,8 +207,8 @@ MWF.xApplication.Selector.Identity = new Class({ ...@@ -207,8 +207,8 @@ MWF.xApplication.Selector.Identity = new Class({
if (callback) callback.apply(this, [json]); if (callback) callback.apply(this, [json]);
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.Identity.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.Identity.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
this._listItem( "pinyin", callback, failure, key ); this._listItem( "pinyin", callback, failure, key );
...@@ -457,6 +457,43 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({ ...@@ -457,6 +457,43 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
var style = this.selector.options.style; var style = this.selector.options.style;
this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/companyicon.png)"); this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/companyicon.png)");
}, },
_beforeSelectAll : function( _selectAllFun ){
if( this.selector.options.ignorePerson ){
_selectAllFun();
return;
}
//批量获取个人
var object = {};
if( this.selector.options.resultType === "person" ){
this.subItems.each( function(item){
var isPerson = false;
if( item.data && item.data.distinguishedName ){
var dn = item.data.distinguishedName;
if( dn.substr(dn.length-1, 1).toLowerCase() === "p" )isPerson = true;
}
if( !isPerson && !item.data.woPerson && item.data.person ){
object[ item.data.person ] = item;
}
}.bind(this))
}else{
this.subItems.each( function (item) {
if (!item.data.woPerson && item.data.person ){
object[ item.data.person ] = item;
}
}.bind(this))
}
var keys = Object.keys( object );
if( keys.length > 0 ){
o2.Actions.load("x_organization_assemble_express").PersonAction.listObject({"identityList":keys}, function (json) {
json.data.each( function ( p ){
if(object[ p.id ])object[ p.id ].data.woPerson = p;
}.bind(this));
_selectAllFun();
})
}else{
_selectAllFun();
}
},
clickItem: function( callback ){ clickItem: function( callback ){
if (this._hasChild()){ if (this._hasChild()){
var firstLoaded = !this.loaded; var firstLoaded = !this.loaded;
......
...@@ -122,8 +122,8 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({ ...@@ -122,8 +122,8 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
if (callback) callback.apply(this, [json]); if (callback) callback.apply(this, [json]);
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.IdentityWidthDuty.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.IdentityWidthDuty.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
if (this.options.units.length) key = {"key": key, "unitList": this.options.units}; if (this.options.units.length) key = {"key": key, "unitList": this.options.units};
......
...@@ -321,8 +321,8 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({ ...@@ -321,8 +321,8 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
// if (callback) callback.apply(this, [json]); // if (callback) callback.apply(this, [json]);
//}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); //}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
if (this.options.units.length) key = {"key": key, "unitList": this.options.units}; if (this.options.units.length) key = {"key": key, "unitList": this.options.units};
......
...@@ -1332,8 +1332,8 @@ MWF.xApplication.Selector.Person = new Class({ ...@@ -1332,8 +1332,8 @@ MWF.xApplication.Selector.Person = new Class({
if (callback) callback.apply(this, [json]); if (callback) callback.apply(this, [json]);
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.Person.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.Person.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
this.orgAction.listPersonByPinyin(function(json){ this.orgAction.listPersonByPinyin(function(json){
...@@ -1862,7 +1862,7 @@ MWF.xApplication.Selector.Person.Item = new Class({ ...@@ -1862,7 +1862,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
this.selector.fireEvent("unselectItem",[this]); this.selector.fireEvent("unselectItem",[this]);
if( checkValid )this.selector.fireEvent("valid", [this.selector, this]); if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
}, },
selected: function( checkValid, callback ){ selected: function( checkValid, callback, selectedNode ){
var count = this.selector.options.maxCount || this.selector.options.count; var count = this.selector.options.maxCount || this.selector.options.count;
count = count.toInt(); count = count.toInt();
if (!count) count = 0; if (!count) count = 0;
...@@ -1882,7 +1882,7 @@ MWF.xApplication.Selector.Person.Item = new Class({ ...@@ -1882,7 +1882,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected ); this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
} }
} }
this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this); this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this, selectedNode);
this.selectedItem.check(); this.selectedItem.check();
this.selector.selectedItems.push(this.selectedItem); this.selector.selectedItems.push(this.selectedItem);
...@@ -1980,10 +1980,10 @@ MWF.xApplication.Selector.Person.Item = new Class({ ...@@ -1980,10 +1980,10 @@ MWF.xApplication.Selector.Person.Item = new Class({
MWF.xApplication.Selector.Person.ItemSelected = new Class({ MWF.xApplication.Selector.Person.ItemSelected = new Class({
Extends: MWF.xApplication.Selector.Person.Item, Extends: MWF.xApplication.Selector.Person.Item,
initialize: function(data, selector, item){ initialize: function(data, selector, item, selectedNode){
this.data = data; this.data = data;
this.selector = selector; this.selector = selector;
this.container = this.selector.selectedNode; this.container = selectedNode || this.selector.selectedNode;
this.isSelected = false; this.isSelected = false;
this.clazz = "ItemSelected"; this.clazz = "ItemSelected";
this.items = []; this.items = [];
...@@ -2086,7 +2086,14 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({ ...@@ -2086,7 +2086,14 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
} }
}, },
destroy: function(){ destroy: function(){
if(this.node)this.node.destroy(); if(this.node){
// var parent = this.node.getParent(".categorySelectedNode");
// if( parent && !this.node.getPrevious() && !this.node.getNext() ){ //parent.getChildren().length <= 1
// parent.destroy();
// }else{
this.node.destroy();
// }
}
delete this; delete this;
} }
}); });
...@@ -2242,7 +2249,12 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({ ...@@ -2242,7 +2249,12 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
this.selector.fireEvent("unselectCatgory",[this]); this.selector.fireEvent("unselectCatgory",[this]);
}else{ }else{
// this.selectAll(ev); // this.selectAll(ev);
this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev, true) : this.selectAll(ev, true); if( this.selector.options.selectAllRange === "all" ){
var node = new Element("div.categorySelectedNode").inject( this.selector.selectedNode );
this.selectAllNested(ev, true, node );
}else{
this.selectAll(ev, true)
}
this.selector.fireEvent("selectCatgory",[this]); this.selector.fireEvent("selectCatgory",[this]);
} }
ev.stopPropagation(); ev.stopPropagation();
...@@ -2339,21 +2351,24 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({ ...@@ -2339,21 +2351,24 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
}) })
} }
}, },
selectAllNested : function( ev, checkValid ){ selectAllNested : function( ev, checkValid, selectedNode ){
debugger; debugger;
this.selectAll(ev, checkValid); var node;
if(selectedNode)node = new Element("div.categorySelectedNode").inject( selectedNode );
this.selectAll(ev, checkValid, node);
if( this.subCategorys && this.subCategorys.length ){ if( this.subCategorys && this.subCategorys.length ){
this.subCategorys.each( function( category ){ this.subCategorys.each( function( category ){
category.selectAllNested(ev, checkValid) if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
category.selectAllNested(ev, checkValid, node)
}) })
} }
}, },
selectAll: function(ev, checkValid){ selectAll: function(ev, checkValid, selectedNode){
if( this.loaded || this.selector.isFlatCategory ){ if( this.loaded || this.selector.isFlatCategory ){
this._selectAll( ev, checkValid ); this._selectAll( ev, checkValid, selectedNode );
}else{ }else{
this.clickItem( function(){ this.clickItem( function(){
this._selectAll( ev, checkValid ); this._selectAll( ev, checkValid, selectedNode );
//this.children.setStyles({ //this.children.setStyles({
// "display": "none", // "display": "none",
// "height": "0px" // "height": "0px"
...@@ -2362,7 +2377,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({ ...@@ -2362,7 +2377,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
}.bind(this)); }.bind(this));
} }
}, },
_selectAll : function( ev, checkValid ){ _selectAll : function( ev, checkValid, selectedNode ){
if( this.selector.options.selectAllRange === "direct" && ( !this.subItems || !this.subItems.length ) )return; if( this.selector.options.selectAllRange === "direct" && ( !this.subItems || !this.subItems.length ) )return;
var count = this.selector.options.maxCount || this.selector.options.count; var count = this.selector.options.maxCount || this.selector.options.count;
if (!count) count = 0; if (!count) count = 0;
...@@ -2372,13 +2387,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({ ...@@ -2372,13 +2387,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
}.bind(this)); }.bind(this));
if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){ if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){
var checkedCount = 0; var checkedCount = 0;
var doSelectAll = function () {
this.subItems.each( function(item){ this.subItems.each( function(item){
if(!item.isSelected && !item.disabled )item.selected( false, function () { if(!item.isSelected && !item.disabled )item.selected( false, function () {
checkedCount++; checkedCount++;
if( this.subItems.length === checkedCount ){ if( this.subItems.length === checkedCount ){
if( checkValid )this.selector.fireEvent("valid", [this.selector, this]); if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
} }
}.bind(this)); }.bind(this), selectedNode);
}.bind(this)); }.bind(this));
if( this.selectAllNode ){ if( this.selectAllNode ){
...@@ -2388,8 +2405,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({ ...@@ -2388,8 +2405,15 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ); this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
} }
} }
this.isSelectedAll = true; this.isSelectedAll = true;
}.bind(this);
if( this._beforeSelectAll ){
this._beforeSelectAll( doSelectAll );
}else{
doSelectAll();
}
}else{ }else{
MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node); MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
} }
......
...@@ -22,8 +22,8 @@ MWF.xApplication.Selector.Role = new Class({ ...@@ -22,8 +22,8 @@ MWF.xApplication.Selector.Role = new Class({
if (callback) callback.apply(this, [json]); if (callback) callback.apply(this, [json]);
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.Role.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.Role.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key); if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key);
......
...@@ -173,8 +173,8 @@ MWF.xApplication.Selector.Unit = new Class({ ...@@ -173,8 +173,8 @@ MWF.xApplication.Selector.Unit = new Class({
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.Unit.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.Unit.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
if (this.options.units.length){ if (this.options.units.length){
...@@ -336,7 +336,12 @@ MWF.xApplication.Selector.Unit.Item = new Class({ ...@@ -336,7 +336,12 @@ MWF.xApplication.Selector.Unit.Item = new Class({
this.selector.fireEvent("unselectCatgory",[this]) this.selector.fireEvent("unselectCatgory",[this])
}else{ }else{
// this.selectAll(ev); // this.selectAll(ev);
this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev, true) : this.selectAll(ev ,true); if( this.selector.options.selectAllRange === "all" ){
var node = new Element("div.categorySelectedNode").inject( this.selector.selectedNode );
this.selectAllNested(ev, true, node)
}else{
this.selectAll(ev ,true)
}
this.selector.fireEvent("selectCatgory",[this]) this.selector.fireEvent("selectCatgory",[this])
} }
ev.stopPropagation(); ev.stopPropagation();
...@@ -392,39 +397,47 @@ MWF.xApplication.Selector.Unit.Item = new Class({ ...@@ -392,39 +397,47 @@ MWF.xApplication.Selector.Unit.Item = new Class({
}) })
} }
}, },
selectAllNested : function(ev, checkValid){ selectAllNested : function(ev, checkValid, selectedNode){
this.selectAll(ev, checkValid); var node;
if( selectedNode )node = new Element("div.categorySelectedNode").inject( selectedNode );
this.selectAll(ev, checkValid, node);
if( this.subCategorys && this.subCategorys.length ){ if( this.subCategorys && this.subCategorys.length ){
this.subCategorys.each( function( category ){ this.subCategorys.each( function( category ){
if(category.selectAllNested)category.selectAllNested, checkValid() if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
if(category.selectAllNested)category.selectAllNested(ev, checkValid, node)
}) })
} }
if( this.subItems && this.subItems.length ){ if( this.subItems && this.subItems.length ){
this.subItems.each( function( item ){ this.subItems.each( function( item ){
if(item.selectAllNested)item.selectAllNested(ev, checkValid) if(selectedNode)var node = new Element("div.categorySelectedNode").inject( selectedNode );
if(item.selectAllNested)item.selectAllNested(ev, checkValid, node)
}) })
} }
}, },
selectAll: function(ev, checkValid){ selectAll: function(ev, checkValid, selectedNode){
if( this.loaded || this.selector.isFlatCategory ){ if( this.loaded || this.selector.isFlatCategory ){
this._selectAll( ev, checkValid ) this._selectAll( ev, checkValid, selectedNode )
}else{ }else{
this.loadSubItems(function(){ this.loadSubItems(function(){
this._selectAll( ev, checkValid ) this._selectAll( ev, checkValid, selectedNode )
}.bind(this)); }.bind(this));
this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand); this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
this.isExpand = true; this.isExpand = true;
} }
}, },
_selectAll : function( ev, checkValid ){ _selectAll : function( ev, checkValid, selectedNode ){
if( !this.subItems || !this.subItems.length )return; if( !this.subItems || !this.subItems.length )return;
var count = this.selector.options.maxCount || this.selector.options.count; var count = this.selector.options.maxCount || this.selector.options.count;
if (!count) count = 0; if (!count) count = 0;
var selectedSubItemCount = 0; var selectedSubItemCount = 0;
this.subItems.each( function(item){ this.subItems.each( function(item){
if(item.isSelected)selectedSubItemCount++ if(item.isSelected)selectedSubItemCount++
}.bind(this)); }.bind(this));
if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){ if ((count.toInt()===0) || (this.selector.selectedItems.length+(this.subItems.length-selectedSubItemCount))<=count){
var doSelectAll = function () {
var checkedCount = 0; var checkedCount = 0;
this.subItems.each( function(item){ this.subItems.each( function(item){
if(!item.isSelected && !item.disabled )item.selected(false, function () { if(!item.isSelected && !item.disabled )item.selected(false, function () {
...@@ -432,7 +445,7 @@ MWF.xApplication.Selector.Unit.Item = new Class({ ...@@ -432,7 +445,7 @@ MWF.xApplication.Selector.Unit.Item = new Class({
if( this.subItems.length === checkedCount ){ if( this.subItems.length === checkedCount ){
if( checkValid )this.selector.fireEvent("valid", [this.selector, this]); if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
} }
}.bind(this)); }.bind(this), selectedNode);
}.bind(this)); }.bind(this));
if( this.selectAllNode ){ if( this.selectAllNode ){
...@@ -444,6 +457,14 @@ MWF.xApplication.Selector.Unit.Item = new Class({ ...@@ -444,6 +457,14 @@ MWF.xApplication.Selector.Unit.Item = new Class({
} }
this.isSelectedAll = true; this.isSelectedAll = true;
}.bind(this);
if( this._beforeSelectAll ){
this._beforeSelectAll( doSelectAll );
}else{
doSelectAll();
}
}else{ }else{
MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node); MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
} }
......
...@@ -87,8 +87,8 @@ MWF.xApplication.Selector.UnitWithType = new Class({ ...@@ -87,8 +87,8 @@ MWF.xApplication.Selector.UnitWithType = new Class({
}.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async); }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
}, },
_newItemSelected: function(data, selector, item){ _newItemSelected: function(data, selector, item, selectedNode){
return new MWF.xApplication.Selector.UnitWithType.ItemSelected(data, selector, item) return new MWF.xApplication.Selector.UnitWithType.ItemSelected(data, selector, item, selectedNode)
}, },
_listItemByPinyin: function(callback, failure, key){ _listItemByPinyin: function(callback, failure, key){
key = {"key": key}; key = {"key": key};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册