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

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

Merge of feature/[人员选择]修复传入自定义unit选项的时候,待选顺序不是传入的顺序的问题 to release

See merge request o2oa/o2oa!1024

(cherry picked from commit 5c5d72c9375cc8cac80e0aae87a08668560d255c)

72363cdd 选择框相关修改
5751c277 修复传入自定义unit选项的时候,待选顺序不是传入的顺序
6d24d423 修复保存表单的时候,表单提示框不显示保存不成功的问题
26c4ac69 自定义选择器增加expandSub和destroy方法
7a83d20d Merge branch 'release' into 'feature/Selector.curstom_category_reload'
蔡祥熠 5 лет назад
Родитель
Сommit
e6dca5e395

+ 28 - 2
o2web/source/x_component_Selector/Person.js

@@ -1739,8 +1739,10 @@ MWF.xApplication.Selector.Person.Item = new Class({
         if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
         }
+        // if( this.category ){
+        //     this.category.checkSelectAll();
+        // }
     },
-
     setEvent: function(){
         this.node.addEvents({
             "mouseover": function(){
@@ -1864,6 +1866,10 @@ MWF.xApplication.Selector.Person.Item = new Class({
             this.selectedItem.check();
             this.selector.selectedItems.push(this.selectedItem);
 
+            if( this.category ){
+                this.category.checkSelectAll();
+            }
+
             this.selector.fireEvent("selectItem",[this])
         }else{
             MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
@@ -1884,7 +1890,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         }
 
         if( this.category ){
-            this.category.checkSelectAll();
+            this.category.checkUnselectAll();
         }
 
         if( this.selector.searchItems && this.selector.searchItems.length ){
@@ -2351,6 +2357,26 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         }
     },
     checkSelectAll : function(){
+        if( this.isSelectedAll )return;
+        if( !this.selectAllNode )return;
+        if( !this.subItems )return;
+        var isAllItemSelected = true;
+        for( var i=0; i< this.subItems.length; i++ ){
+            if( !this.subItems[i].isSelected ){
+                isAllItemSelected = false;
+                break;
+            }
+        }
+        if( isAllItemSelected ){
+            if( this.selector.isFlatCategory ){
+                this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
+            }else if( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
+                this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
+            }
+            this.isSelectedAll = true;
+        }
+    },
+    checkUnselectAll : function(){
         if( !this.isSelectedAll )return;
         if( !this.selectAllNode )return;
         if( !this.subItems )return;

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

@@ -19,6 +19,9 @@ MWF.xApplication.Selector.Unit = new Class({
     loadSelectItems: function(addToNext){
         if (this.options.units.length){
             this.options.units.each(function(unit){
+
+                var container = new Element("div").inject( this.itemAreaNode );
+
                 // this.action.listUnitByKey(function(json){
                 //     if (json.data.length){
                 //         json.data.each(function(data){
@@ -41,11 +44,11 @@ MWF.xApplication.Selector.Unit = new Class({
                             json.data.each( function(data){
                                 if( this.options.expandSubEnable ){
                                     if (data.subDirectUnitCount){
-                                        var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
+                                        var category = this._newItemCategory("ItemCategory", data, this, container );
                                         this.subCategorys.push(category);
                                     }
                                 }else{
-                                    var item = this._newItem( data, this, this.itemAreaNode);
+                                    var item = this._newItem( data, this, container );
                                     this.subItems.push(item);
                                 }
                             }.bind(this));
@@ -60,11 +63,11 @@ MWF.xApplication.Selector.Unit = new Class({
                             json.data.each( function(data){
                                 if( this.options.expandSubEnable ) {
                                     if (data.subDirectUnitCount){
-                                        var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
+                                        var category = this._newItemCategory("ItemCategory", data, this, container );
                                         this.subCategorys.push(category);
                                     }
                                 }else{
-                                    var item = this._newItem(data, this, this.itemAreaNode);
+                                    var item = this._newItem(data, this, container );
                                     this.subItems.push(item);
                                 }
                             }.bind(this));
@@ -392,6 +395,26 @@ MWF.xApplication.Selector.Unit.Item = new Class({
         }
     },
     checkSelectAll : function(){
+        if( this.isSelectedAll )return;
+        if( !this.selectAllNode )return;
+        if( !this.subItems )return;
+        var isAllItemSelected = true;
+        for( var i=0; i< this.subItems.length; i++ ){
+            if( !this.subItems[i].isSelected ){
+                isAllItemSelected = false;
+                break;
+            }
+        }
+        if( isAllItemSelected ){
+            if( this.selector.isFlatCategory ){
+                this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
+            }else if( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
+                this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
+            }
+            this.isSelectedAll = true;
+        }
+    },
+    checkUnselectAll : function(){
         if( !this.isSelectedAll )return;
         if( !this.selectAllNode )return;
         if( ! this.subItems )return;

+ 68 - 2
o2web/source/x_component_Template/Selector/Custom.js

@@ -228,6 +228,22 @@ MWF.xApplication.Template.Selector.Custom.Item = new Class({
             this.selectedItem = selectedItem[0];
             this.setSelected();
         }
+    },
+    destroy: function(){
+        if( this.isSelected )this.unSelected();
+        this.selector.items.erase( this );
+
+        if( this.category ){
+            if( this.category.subCategorys && this.category.subCategorys.length ){
+                this.category.subCategorys.erase( this );
+            }
+            if( this.category.subItems && this.category.subItems.length ){
+                this.category.subItems.erase( this );
+            }
+        }
+
+        if(this.node)this.node.destroy();
+        delete this;
     }
 });
 MWF.xApplication.Template.Selector.Custom.ItemSelected = new Class({
@@ -276,7 +292,6 @@ MWF.xApplication.Template.Selector.Custom.ItemCategory = new Class({
         return this.data.name;
     },
     clickItem: function (callback) {
-        debugger;
         if (this._hasChild()) {
             var firstLoaded = !this.loaded;
             this.loadSub(function () {
@@ -302,8 +317,29 @@ MWF.xApplication.Template.Selector.Custom.ItemCategory = new Class({
             }.bind(this));
         }
     },
+    destroy : function(){
+        while( this.subItems.length )this.subItems[0].destroy();
+
+        while( this.subCategorys.length )this.subCategorys[0].destroy();
+
+        if( this.category && this.category.subCategorys && this.category.subCategorys.length ){
+            this.category.subCategorys.erase( this );
+        }
+
+        if(this.node)this.node.destroy();
+        delete this;
+    },
+    reloadSub : function(callback){
+        while( this.subItems.length )this.subItems[0].destroy();
+        this.subItems = [];
+
+        while( this.subCategorys.length )this.subCategorys[0].destroy();
+        this.subCategorys = [];
+
+        this.loaded = false;
+        this.loadSub( callback )
+    },
     loadSub: function (callback) {
-        debugger;
         if (!this.loaded) {
             if( this._hasChildItem() ){
                 this.data.subItemList.each(function (subItem, index) {
@@ -355,6 +391,36 @@ MWF.xApplication.Template.Selector.Custom.ItemCategorySelectable = new Class({
     _getTtiteText: function () {
         return this.data.name;
     },
+    destroy : function(){
+        if( this.isSelected )this.unSelected();
+        this.selector.items.erase( this );
+
+        while( this.subItems.length )this.subItems[0].destroy();
+
+        while( this.subCategorys.length )this.subCategorys[0].destroy();
+
+        if( this.category ){
+            if( this.category.subCategorys && this.category.subCategorys.length ){
+                this.category.subCategorys.erase( this );
+            }
+            if( this.category.subItems && this.category.subItems.length ){
+                this.category.subItems.erase( this );
+            }
+        }
+
+        if(this.node)this.node.destroy();
+        delete this;
+    },
+    reloadSub : function(callback){
+        while( this.subItems.length )this.subItems[0].destroy();
+        this.subItems = [];
+
+        while( this.subCategorys.length )this.subCategorys[0].destroy();
+        this.subCategorys = [];
+
+        this.loaded = false;
+        this.loadSubItems( callback );
+    },
     loadSubItems: function( callback ){
         if (!this.loaded){
             if (!this.children){

+ 1 - 1
o2web/source/x_component_process_FormDesigner/Module/Form/form.html

@@ -189,4 +189,4 @@
 	<div title="JSON"  class="MWFTab">
 		<div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
 	</div>
-</div>
+</div>