Jelajahi Sumber

身份按职务选择时,可以根据传入职务顺序排序

unknown 5 tahun lalu
induk
melakukan
31bc7dcd6d

+ 86 - 15
o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js

@@ -18,6 +18,7 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         "selectAllEnable": true, //分类是否允许全选下一层
         "exclude": [],
         "dutyUnitLevelBy": "duty", //组织层级是按身份所在群组还是职务,
+        "identitySortBy" : "identityNumber", //身份排序按身份排序号,还是传入的duty
         "selectType": "identity"
     },
     _init: function () {
@@ -368,23 +369,53 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         return unitTree;
     },
     uniqueIdentity: function (tree) {
+
         var map = {};
-        var isExist = function (d) {
+        var indexMap = {};
+
+        var isExist = function (d, index) {
             if ((d.distinguishedName && map[d.distinguishedName]) ||
                 (d.levelName && map[d.levelName]) ||
                 (d.id && map[d.id]) ||
                 (d.unique && map[d.unique])) {
                 return true;
             } else {
-                map[typeOf(d) === "string" ? d : (d.distinguishedName || d.id || d.unique || d.employee || d.levelName)] = true;
+                var key = typeOf(d) === "string" ? d : (d.distinguishedName || d.id || d.unique || d.employee || d.levelName);
+                map[key] = true;
+                indexMap[key] = index+1;
                 return false;
             }
         };
 
+        var getIndex = function (d){
+            var index = ((d.distinguishedName && indexMap[d.distinguishedName]) ||
+                (d.levelName && indexMap[d.levelName]) ||
+                (d.id && indexMap[d.id]) ||
+                (d.unique && indexMap[d.unique]));
+            if( !index )index = 0;
+            return index-1;
+        };
+
         var identityList = [];
         if (tree.identityList) {
             for (var i = 0; i < tree.identityList.length; i++) {
-                if (!isExist(tree.identityList[i])) identityList.push(tree.identityList[i]);
+                if (!isExist(tree.identityList[i], i)){
+                    identityList.push(tree.identityList[i]);
+                }else if( this.options.identitySortBy !== "identityNumber" ){
+                    debugger;
+                    var index = getIndex(tree.identityList[i]);
+                    if( index > -1 ){
+                        var identity = tree.identityList[index];
+                        if( !identity.otherMatchUnitDutyList ){
+                            identity.otherMatchUnitDutyList = []
+                        }
+                        identity.otherMatchUnitDutyList.push({
+                            matchUnitDutyNumber : tree.identityList[i].matchUnitDutyNumber,
+                            matchUnitDutyName : tree.identityList[i].matchUnitDutyName
+                        })
+                    }
+
+                }
             }
         }
         tree.identityList = identityList;
@@ -553,6 +584,47 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
             return false;
         }
     },
+    sortIdentityList : function(){
+        if( this.selector.options.identitySortBy === "identityNumber" ){
+            this.data.identityList.sort(function (a, b) {
+                //this.selector.getUnitOrderNumber( a.unitLevelName )
+                if( a.orderNumber === 0 )a.orderNumber = -1;
+                if( b.orderNumber === 0 )b.orderNumber = -1;
+                return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
+            });
+        }else{
+            debugger;
+            var getOrderNumber = function (d) {
+                var orderNumber = "999";
+                if( d.matchUnitDutyName ){
+                    var idx = this.selector.options.dutys.indexOf( d.matchUnitDutyName );
+                    if( idx > -1 )orderNumber = idx.toString();
+                }
+                if( typeOf(d.matchUnitDutyNumber) === "number" ){
+                    orderNumber += d.matchUnitDutyNumber.toString();
+                }else{
+                    orderNumber += "9999";
+                }
+                return orderNumber.toInt();
+            }.bind(this);
+
+            var getOrder = function (d) {
+                if( d.otherMatchUnitDutyList && d.otherMatchUnitDutyList.length ){
+                    var array = [getOrderNumber(d)];
+                    d.otherMatchUnitDutyList.each(function (duty) {
+                        array.push( getOrderNumber(duty) );
+                    });
+                    return array.min();
+                }else{
+                   return getOrderNumber(d);
+                }
+            }.bind(this);
+
+            this.data.identityList.sort(function (a, b) {
+                return getOrder(a) - getOrder(b);
+            });
+        }
+    },
     loadSub: function (callback) {
         this._loadSub(function (firstLoad) {
             if (firstLoad && (this.selector.options.showSelectedCount || this.selector.options.isCheckStatus)) {
@@ -578,12 +650,9 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
         if (!this.loaded) {
             if (!this.itemLoaded) {
                 if (this.data.identityList && this.data.identityList.length > 0) {
-                    this.data.identityList.sort(function (a, b) {
-                        //this.selector.getUnitOrderNumber( a.unitLevelName )
-                        if( a.orderNumber === 0 )a.orderNumber = -1;
-                        if( b.orderNumber === 0 )b.orderNumber = -1;
-                        return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
-                    });
+
+                    this.sortIdentityList();
+
                     this.data.identityList.each(function (identity) {
                         // if( !this.selector.isExcluded( identity ) ) {
                         //     if( !this.isExisted( identity ) ){
@@ -636,12 +705,14 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit.ItemCategory = new Cla
     loadItemChildren: function (callback) {
         if (!this.itemLoaded) {
             if (this.data.identityList && this.data.identityList.length > 0) {
-                this.data.identityList.sort(function (a, b) {
-                    //this.selector.getUnitOrderNumber( a.unitLevelName )
-                    if( a.orderNumber === 0 )a.orderNumber = -1;
-                    if( b.orderNumber === 0 )b.orderNumber = -1;
-                    return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
-                });
+                // this.data.identityList.sort(function (a, b) {
+                //     if( a.orderNumber === 0 )a.orderNumber = -1;
+                //     if( b.orderNumber === 0 )b.orderNumber = -1;
+                //     return (a.orderNumber || 9999999) - (b.orderNumber || 9999999);
+                // });
+
+                this.sortIdentityList();
+
                 this.data.identityList.each(function (identity) {
                     // if( !this.selector.isExcluded( identity ) ) {
                     //     if( !this.isExisted( identity ) ){

+ 4 - 0
o2web/source/x_component_process_FormDesigner/$Main/bottom/formToolbars.html

@@ -18,6 +18,10 @@
 	
 	<span MWFnodetype="MWFToolBarButton" MWFButtonImage="help.png" title="帮助" MWFButtonAction="formHelp" MWFButtonText=""></span>
 
+	<span MWFnodetype="MWFToolBarSeparator"></span>
+
+	<span MWFnodetype="MWFToolBarButton" MWFButtonImage="clear.png" title="清除未在HTML树中的组件配置" MWFButtonAction="clearNoDomModule" MWFButtonText=""></span>
+
     <span MWFnodetype="MWFToolBarSeparator"></span>
     <input type="checkbox" value="autoSave" id="MWFFormAutoSaveCheck">自动保存
 

TEMPAT SAMPAH
o2web/source/x_component_process_FormDesigner/$Main/bottom/formtoolbar/clear.png


+ 4 - 0
o2web/source/x_component_process_FormDesigner/$Main/default/formToolbars.html

@@ -23,6 +23,10 @@
 	<span MWFnodetype="MWFToolBarButton" MWFButtonImage="help.png" title="帮助" MWFButtonAction="formHelp" MWFButtonText=""></span>
 
     <span MWFnodetype="MWFToolBarSeparator"></span>
+
+	<span MWFnodetype="MWFToolBarButton" MWFButtonImage="clear.png" title="清除未在HTML树中的组件配置" MWFButtonAction="clearNoDomModule" MWFButtonText=""></span>
+
+	<span MWFnodetype="MWFToolBarSeparator"></span>
     <input type="checkbox" value="autoSave" id="MWFFormAutoSaveCheck">自动保存
 
     <div id="MWFFormMobileDesignerAction"></div>

TEMPAT SAMPAH
o2web/source/x_component_process_FormDesigner/$Main/default/formtoolbar/clear.png


+ 9 - 0
o2web/source/x_component_process_FormDesigner/Main.js

@@ -1614,6 +1614,15 @@ MWF.xApplication.process.FormDesigner.Main = new Class({
     showFormVersion: function(){
         this.form.showFormVersion();
     },
+    clearNoDomModule: function(){
+	    var _self = this;
+        this.confirm("warn", new Event(),  MWF.APPFD.LP.clearNoDomModuleTitle, MWF.APPFD.LP.clearNoDomModuleContent, 460, 120, function(){
+            _self.form._clearNoDomModule();
+            this.close();
+        }, function(){
+            this.close();
+        });
+    },
     onPostClose: function(){
         if (this.pcForm){
             MWF.release(this.pcForm.moduleList);

+ 3 - 0
o2web/source/x_component_process_FormDesigner/lp/zh-cn.js

@@ -173,6 +173,9 @@ MWF.xApplication.process.FormDesigner.LP = {
 
     "imageClipper" : "图片编辑",
 
+    "clearNoDomModuleTitle" : "清除未在HTML树中的组件配置",
+    "clearNoDomModuleContent" : "是否清除未在HTML树中的组件配置?清除后需要保存生效。",
+
     "filter": {
         "and": "并且",
         "or": "或者",