Просмотр исходного кода

Merge branch 'feature/Selector.select_all_range' into 'release'

Merge of feature/【流程管理】人员选择器根据职务选择的时候,允许跨层级全选 to release

See merge request o2oa/o2oa!883

(cherry picked from commit 40304f70a0d01885ce1a246ad0c29a17917d87ce)

3ac60bbb 允许职务跨层级全选
蔡祥熠 5 лет назад
Родитель
Сommit
93e4ec018a

+ 22 - 10
o2web/source/x_component_Selector/Person.js

@@ -17,6 +17,7 @@ MWF.xApplication.Selector.Person = new Class({
         "expand": true,
         "embedded" : false, //是否嵌入在其他容器中
         "selectAllEnable" : false, //是否允许全选
+        "selectAllRange" : "direct", //全选直属人员 还是 所有下级人员
 
         "level1Indent" : 10, //第一级的缩进
         "indent" : 10, //后续的缩进
@@ -2119,10 +2120,10 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             }).inject(selectAllWrap);
             this.selectAllNode.addEvent( "click", function(ev){
                 if( this.isSelectedAll ){
-                    this.unselectAll(ev);
+                    this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev) : this.unselectAll(ev);
                     this.selector.fireEvent("unselectCatgory",[this])
                 }else{
-                    this.selectAll(ev);
+                    this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev) : this.selectAll(ev);
                     this.selector.fireEvent("selectCatgory",[this])
                 }
                 ev.stopPropagation();
@@ -2139,8 +2140,10 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         //    this.textNode.setStyle("color", "#333");
         //}
 
-        if( this.selectAllNode && !this._hasChildItem() ){
-            this.selectAllNode.setStyle("display", "none");
+        if( this.selectAllNode ){
+            if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
+                this.selectAllNode.setStyle("display", "none");
+            }
         }
 
         this.node.addEvents({
@@ -2202,10 +2205,12 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             }).inject(this.node);
             this.selectAllNode.addEvent( "click", function(ev){
                 if( this.isSelectedAll ){
-                    this.unselectAll(ev);
+                    // this.unselectAll(ev);
+                    this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev) : this.unselectAll(ev);
                     this.selector.fireEvent("unselectCatgory",[this])
                 }else{
-                    this.selectAll(ev);
+                    // this.selectAll(ev);
+                    this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev) : this.selectAll(ev);
                     this.selector.fireEvent("selectCatgory",[this])
                 }
                 ev.stopPropagation();
@@ -2247,8 +2252,11 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             this.actionNode.setStyle("background", "transparent");
             this.textNode.setStyle("color", "#777");
         }
-        if( this.selectAllNode && !this._hasChildItem() ){
-            this.selectAllNode.setStyle("display", "none");
+
+        if( this.selectAllNode ){
+            if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
+                this.selectAllNode.setStyle("display", "none");
+            }
         }
 
         this.setEvent();
@@ -2263,6 +2271,9 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
             "styles": this.selector.css.selectorItemCategory,
             "title" : this._getTtiteText()
         }).inject(this.container);
+    },
+    isSelectAllEnable : function(){
+
     },
     unselectAll : function(ev, exclude){
         var excludeList = exclude || [];
@@ -2291,6 +2302,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         }
     },
     selectAllNested : function(){
+        debugger;
         this.selectAll();
         if( this.subCategorys && this.subCategorys.length ){
             this.subCategorys.each( function( category ){
@@ -2313,7 +2325,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         }
     },
     _selectAll : function( ev ){
-        if( !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;
         if (!count) count = 0;
         var selectedSubItemCount = 0;
@@ -2341,7 +2353,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
     checkSelectAll : function(){
         if( !this.isSelectedAll )return;
         if( !this.selectAllNode )return;
-        if( ! this.subItems )return;
+        if( !this.subItems )return;
         var hasSelectedItem = false;
         for( var i=0; i< this.subItems.length; i++ ){
             if( this.subItems[i].isSelected ){

+ 4 - 2
o2web/source/x_component_Selector/Unit.js

@@ -280,10 +280,12 @@ MWF.xApplication.Selector.Unit.Item = new Class({
                 }).inject(this.textNode, "before");
                 this.selectAllNode.addEvent( "click", function(ev){
                     if( this.isSelectedAll ){
-                        this.unselectAll(ev);
+                        // this.unselectAll(ev);
+                        this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev) : this.unselectAll(ev);
                         this.selector.fireEvent("unselectCatgory",[this])
                     }else{
-                        this.selectAll(ev);
+                        // this.selectAll(ev);
+                        this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev) : this.selectAll(ev);
                         this.selector.fireEvent("selectCatgory",[this])
                     }
                     ev.stopPropagation();

+ 4 - 2
o2web/source/x_component_Selector/UnitWithType.js

@@ -165,10 +165,12 @@ MWF.xApplication.Selector.UnitWithType.Item = new Class({
                 //}.bind(this))
                 this.selectAllNode.addEvent( "click", function(ev) {
                     if (this.isSelectedAll) {
-                        this.unselectAll(ev);
+                        // this.unselectAll(ev);
+                        this.selector.options.selectAllRange === "all" ? this.unselectAllNested(ev) : this.unselectAll(ev);
                         this.selector.fireEvent("unselectCatgory", [this])
                     } else {
-                        this.selectAll(ev);
+                        // this.selectAll(ev);
+                        this.selector.options.selectAllRange === "all" ? this.selectAllNested(ev) : this.selectAll(ev);
                         this.selector.fireEvent("selectCatgory", [this])
                     }
                     ev.stopPropagation();