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

Merge branch 'feature/Common.password_expired' into 'develop'

Merge of feature/【登录页】登录时判断密码是否过期,如果过期需要弹出登录页 to develop

See merge request o2oa/o2oa!714
蔡祥熠 5 лет назад
Родитель
Сommit
09517b33b3

+ 10 - 1
o2web/source/o2_core/o2/lp/zh-cn.js

@@ -359,6 +359,7 @@ o2.LP.authentication = {
     "LoginFormTitle": "欢迎登录",
     "SignUpFormTitle": "欢迎注册",
     "ResetPasswordFormTitle": "找回密码",
+    "ChangePasswordFormTitle" : "密码已过期",
     "userName": "用户名",
     "password": "密码",
     "verificationCode": "验证码",
@@ -412,7 +413,15 @@ o2.LP.authentication = {
     "resetPasswordSuccessWord": "请牢记您新设置的密码。",
     "resetPasswordFailWord": "请核对您的用户名和短信验证码。",
     "backtoModify": "返回修改",
-    "pageNotFound": "404错误,未找到服务或服务器已断开"
+    "pageNotFound": "404错误,未找到服务或服务器已断开",
+    "submitAction" : "确定",
+    "oldPassword" : "原密码",
+    "inputYourOldPassword" : "请输入原密码",
+    "newPassword" : "新密码",
+    "inputYourNewPassword" : "请输入新密码",
+    "changePasswordSuccess" : "修改密码成功"
+
+
 };
 o2.LP.script = {
     "error": "脚本运行错误,请查看以下详细信息"

+ 270 - 2
o2web/source/o2_core/o2/xDesktop/Authentication.js

@@ -111,7 +111,7 @@ MWF.xDesktop.Authentication = new Class({
         });
         delete opt.width;
         delete opt.height;
-        if (this.options.popupStyle_signup) opt.popupStyle = this.options.popupStyle_signup
+        if (this.options.popupStyle_signup) opt.popupStyle = this.options.popupStyle_signup;
         var form = new MWF.xDesktop.Authentication.SignUpForm(this, {}, opt, this.popupPara);
         form.create();
     },
@@ -122,11 +122,22 @@ MWF.xDesktop.Authentication = new Class({
                 this.fireEvent("postOk", json)
             }.bind(this)
         });
-        if (this.options.popupStyle_password) opt.popupStyle = this.options.popupStyle_password
+        if (this.options.popupStyle_password) opt.popupStyle = this.options.popupStyle_password;
         // delete opt.width;
         // delete opt.height;
         var form = new MWF.xDesktop.Authentication.ResetPasswordForm(this, {}, opt, this.popupPara);
         form.create();
+    },
+    openChangePasswordForm: function (options, callback) {
+        var opt = Object.merge(this.popupOptions || {}, options || {}, {
+            onPostOk: function (json) {
+                if (callback) callback(json);
+                this.fireEvent("postOk", json)
+            }.bind(this)
+        });
+        // if (this.options.popupStyle_password) opt.popupStyle = this.options.popupStyle_password;
+        var form = new MWF.xDesktop.Authentication.ChangePasswordForm(this, {}, opt, this.popupPara);
+        form.create();
     }
 
 });
@@ -1010,6 +1021,12 @@ MWF.xDesktop.Authentication.LoginForm = new Class({
         this.explorer.openResetPasswordForm();
         this.close();
     },
+    gotoChangePassword : function(){ //密码过期
+        this.explorer.openChangePasswordForm( null, function(){
+            this.explorer.loadLogin();
+        }.bind(this));
+        this.close();
+    },
     checkBindStatus: function () {
         this.bindStatusInterval = setInterval(function () {
             this.actions.checkBindStatus(this.bindMeta, function (json) {
@@ -1062,8 +1079,11 @@ MWF.xDesktop.Authentication.LoginForm = new Class({
         var data = this.form.getResult(true, ",", true, false, true);
         if (data) {
             this._ok(data, function (json) {
+                debugger;
                 if (json.type === "error") {
                     if (this.app) this.app.notice(json.message, "error");
+                } else if( json.data.passwordExpired ){ //密码过期
+                    this.gotoChangePassword();
                 } else {
                     this._close();
                     if (this.formMaskNode) this.formMaskNode.destroy();
@@ -1583,6 +1603,7 @@ MWF.xDesktop.Authentication.SignUpForm = new Class({
     }
 });
 
+//忘记密码
 MWF.xDesktop.Authentication.ResetPasswordForm = new Class({
     Extends: MPopupForm,
     Implements: [Options, Events],
@@ -2034,3 +2055,250 @@ MWF.xDesktop.Authentication.ResetPasswordForm = new Class({
         this.close();
     }
 });
+
+//密码过期
+MWF.xDesktop.Authentication.ChangePasswordForm = new Class({
+    Extends: MPopupForm,
+    Implements: [Options, Events],
+    options: {
+        "style": "default",
+        "popupStyle": "o2platform",
+        "width": "650",
+        "height": "480",
+        "hasTop": true,
+        "hasIcon": false,
+        "hasTopIcon": true,
+        "hasTopContent": true,
+        "hasBottom": false,
+        "hasScroll": false,
+        "hasMark": false,
+        "title": MWF.LP.authentication.ChangePasswordFormTitle,
+        "draggable": true,
+        "closeAction": true
+    },
+    _createTableContent: function () {
+        var self = this;
+
+        this.actions = MWF.Actions.get("x_organization_assemble_personal");
+
+        var html = "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable'>" +
+            "<tr><td styles='formTableValueTop20' item='password'></td></tr>" +
+            "<tr><td styles='formTableValueTop20' item='newPassword'></td>" +
+            "<tr><td styles='formTableValue'><div item='passwordTip'></div></td></tr>" +
+            "<tr><td styles='formTableValueTop20' item='confirmPassword'></td>" +
+            "<tr><td styles='formTableValueTop20' item='submitAction'></td></tr>" +
+            "<tr><td><div item='forgetPassword'></div><div item='gotoLoginAction'></div></td></tr>"+
+            "<tr><td  styles='formTableValue' item='errorArea'></td></tr>" +
+            "</table>";
+
+        this.formTableArea.set("html", html);
+
+        this.errorArea = this.formTableArea.getElement("[item=errorArea]");
+
+        MWF.xDesktop.requireApp("Template", "MForm", function () {
+            this.form = new MForm(this.formTableArea, this.data, {
+                style: this.options.popupStyle,
+                verifyType: "single",	//batch一起校验,或alert弹出
+                isEdited: this.isEdited || this.isNew,
+                onPostLoad: function () {
+                    var form = this.form;
+                    form.getItem("password").tipNode = this.errorArea;
+                    form.getItem("newPassword").tipNode = this.errorArea;
+                    form.getItem("confirmPassword").tipNode = this.errorArea;
+                }.bind(this),
+                itemTemplate: {
+                    password: {
+                        text: this.lp.oldPassword,
+                        type: "password",
+                        className: "inputPassword",
+                        notEmpty: true,
+                        defaultValueAsEmpty: true,
+                        emptyTip: this.lp.inputYourOldPassword,
+                        attr: {"placeholder": this.lp.oldPassword},
+                        event: {
+                            focus: function (it) {
+                                if ("password" === it.getValue()) it.setValue("");
+                                if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
+                            }.bind(this),
+                            blur: function (it) {
+                                // it.verify(true);
+                                if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputPassword);
+                            }.bind(this),
+                            keyup: function (it, ev) {
+                                if (ev.event.keyCode === 13) this.ok();
+                            }.bind(this)
+                        },
+                        onEmpty: function (it) {
+                            it.getElements()[0].setStyles(this.css.inputEmpty);
+                        }.bind(this),
+                        onUnempty: function (it) {
+                            it.getElements()[0].setStyles(this.css.inputPassword);
+                        }.bind(this)
+                    },
+                    newPassword: {
+                        text: this.lp.newPassword,
+                        type: "password",
+                        className: "inputPassword",
+                        notEmpty: true,
+                        defaultValueAsEmpty: true,
+                        emptyTip: this.lp.inputYourNewPassword,
+                        attr: {"placeholder": this.lp.newPassword},
+                        validRule: {
+                            passwordIsWeak: function (value, it) {
+                                return !this.getPasswordRule(it.getValue());
+                            }.bind(this)
+                        },
+                        validMessage: {
+                            passwordIsWeak: function () {
+                                return self.getPasswordRule(this.getValue());
+                            }
+                        },
+                        event: {
+                            focus: function (it) {
+                                if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
+                            }.bind(this),
+                            blur: function (it) {
+                                // it.verify(true);
+                            }.bind(this),
+                            keyup: function (it, ev) {
+                                if (ev.event.keyCode === 13)this.ok();
+                            }.bind(this)
+                        },
+                        onEmpty: function (it) {
+                            it.getElements()[0].setStyles(this.css.inputEmpty);
+                        }.bind(this),
+                         onUnempty: function (it) {
+                            it.getElements()[0].setStyles(this.css.inputPassword);
+                        }.bind(this)
+                    },
+                    confirmPassword: {
+                        text: this.lp.confirmNewPassword,
+                        type: "password",
+                        className: "inputComfirmPassword",
+                        notEmpty: true,
+                        defaultValueAsEmpty: true,
+                         emptyTip: this.lp.inputComfirmPassword,
+                        attr: {"placeholder": this.lp.confirmPassword},
+                        validRule: {
+                            passwordNotEqual: function (value, it) {
+                                if (it.getValue() === this.form.getItem("newPassword").getValue()) return true;
+                            }.bind(this)
+                        },
+                        validMessage: {passwordNotEqual: this.lp.passwordNotEqual},
+                        event: {
+                            focus: function (it) {
+                                if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputActive);
+                            }.bind(this),
+                            blur: function (it) {
+                                // it.verify(true);
+                                if (!it.warningStatus) it.getElements()[0].setStyles(this.css.inputComfirmPassword);
+                            }.bind(this),
+                            keyup: function (it, ev) {
+                                if (ev.event.keyCode === 13)this.ok();
+                            }.bind(this)
+                        },
+                        onEmpty: function (it) {
+                            it.getElements()[0].setStyles(this.css.inputEmpty);
+                        }.bind(this),
+                         onUnempty: function (it) {
+                            it.getElements()[0].setStyles(this.css.inputComfirmPassword);
+                        }.bind(this)
+                    },
+
+                    forgetPassword: {
+                        value: this.lp.forgetPassword,
+                        type: "innerText",
+                        className: "forgetPassword",
+                        event: {
+                            click: function () {
+                                this.gotoResetPassword();
+                            }.bind(this)
+                        }
+                    },
+                    gotoLoginAction: {
+                        value: this.lp.loginAction,
+                        type: "innerText",
+                        className: "signUpAction",
+                        event: {
+                            click: function () { this.gotoLogin() }.bind(this)
+                        }
+                    },
+                    passwordTip: {
+                        type: "innerText",
+                        className: "forgetPassword",
+                        defaultValue: layout.config.passwordRegexHint || ""
+                    },
+                    submitAction: {
+                        value: this.lp.submitAction,
+                        type: "button",
+                        className: "inputLogin",
+                        event: {
+                            click: function () {
+                                this.ok();
+                            }.bind(this)
+                        }
+                    }
+                }
+            }, this.app, this.css);
+            this.form.load();
+        }.bind(this), true);
+
+    },
+    gotoLogin: function () {
+        this.explorer.openLoginForm({}, function () { window.location.reload(); });
+        this.close();
+    },
+    getPasswordRule: function (password) {
+        var str = "";
+        this.actions.checkRegisterPassword(password, function (json) {
+            str = json.data.value || "";
+        }.bind(this), null, false);
+        return str;
+    },
+    gotoResetPassword: function () {
+        this.explorer.openResetPasswordForm();
+        this.close();
+    },
+    ok: function () {
+        this.fireEvent("queryOk");
+        this.errorArea.empty();
+        var data = this.form.getResult(true, ",", true, false, true);
+        if (data) {
+            this._ok(data, function (json) {
+                if (json.type === "error") {
+                    if (this.app) this.app.notice(json.message, "error");
+                } else {
+
+                    this._close();
+                    if (this.formMaskNode) this.formMaskNode.destroy();
+                    this.formAreaNode.destroy();
+                    if (this.explorer && this.explorer.view) this.explorer.view.reload();
+                    if (this.app) this.app.notice(this.lp.changePasswordSuccess, "success");
+                    this.fireEvent("postOk", json);
+                }
+            }.bind(this));
+        }
+    },
+    setWarning: function (text) {
+        this.errorArea.empty();
+        new Element("div", {
+            "text": text,
+            "styles": this.css.warningMessageNode
+        }).inject(this.errorArea);
+    },
+    _ok: function (data, callback) {
+        debugger;
+        var d = {
+            oldPassword : data.password,
+            newPassword : data.newPassword,
+            confirmPassword : data.confirmPassword
+        }
+        o2.Actions.load("x_organization_assemble_personal").PasswordAction.changePassword( d, function (json) {
+            if (callback) callback(json);
+            //this.fireEvent("postOk")
+        }.bind(this), function (errorObj) {
+            var error = JSON.parse(errorObj.responseText);
+            this.setWarning(error.message);
+        }.bind(this) )
+    }
+});

+ 3 - 1
o2web/source/o2_core/o2/xDesktop/Common.js

@@ -303,7 +303,7 @@ MWF.xDesktop.confirm = function(type, e, title, text, width, height, ok, cancel,
         }
         var dlg = new MWF.xDesktop.Dialog({
             "title": title,
-            "style": style || "flat",
+            "style": style || "o2",
             "top": y,
             "left": x-20,
             "fromTop":y,
@@ -316,10 +316,12 @@ MWF.xDesktop.confirm = function(type, e, title, text, width, height, ok, cancel,
             "maskNode": mask,
             "buttonList": [
                 {
+                    "type": "ok",
                     "text": MWF.LP.process.button.ok,
                     "action": ok
                 },
                 {
+                    "type": "cancel",
                     "text": MWF.LP.process.button.cancel,
                     "action": cancel
                 }

+ 12 - 2
o2web/source/x_component_Calendar/Common.js

@@ -1232,8 +1232,18 @@ MWFCalendar.CalendarForm = new Class({
             form.load();
         }.bind(this), true);
     },
-    deleteCalendar : function(){
-
+    deleteCalendar : function( e ){
+        var _self = this;
+        _self.app.confirm("warn", e,  "删除确认", "删除后无法恢复,确定要删除“"+ _self.data.name +"”?", 300, 120, function(){
+            _self.app.actions.deleteCalendar( _self.data.id, function( json ){
+                _self.close();
+                _self.app.notice("删除成功");
+                _self.app.leftNavi.reload();
+            }.bind(this));
+            this.close();
+        }, function(){
+            this.close();
+        }, null);
     },
     editCalendar : function(){
         this.formTopNode = null;

+ 1 - 0
o2web/source/x_component_Org/UnitExplorer.js

@@ -591,6 +591,7 @@ MWF.xApplication.Org.UnitExplorer.UnitContent = new Class({
                         var _dutyData = this.data;
                         this.data.woIdentityList.each(function(identity, i){
                             new MWF.widget.O2Identity(identity, contentNode, {
+                                "lazy" : true,
                                 "canRemove": _self.data.control.allowEdit,
                                 "onRemove": function(O2Identity, e){
                                     _self.deleteDutyIdentity(_dutyData, e, O2Identity);

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

@@ -1748,10 +1748,8 @@ MWF.xApplication.Selector.Person.Item = new Class({
         }else{
             if (this.isSelected){
                 this.unSelected();
-                this.selector.fireEvent("unselectItem",[this])
             }else{
                 this.selected();
-                this.selector.fireEvent("selectItem",[this])
             }
         }
     },
@@ -1804,6 +1802,9 @@ MWF.xApplication.Selector.Person.Item = new Class({
                 if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single_selected  ){
                     this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
                 }
+
+                this.selector.fireEvent("selectItem",[this])
+
             }.bind(this));
         }else {
             this.unSelectedSingle();
@@ -1825,6 +1826,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         if( this.selector.options.count.toInt() === 1 && this.selector.css.selectorItemActionNode_single  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
         }
+        this.selector.fireEvent("unselectItem",[this])
     },
     selected: function(){
         var count = this.selector.options.maxCount || this.selector.options.count;
@@ -1849,6 +1851,8 @@ MWF.xApplication.Selector.Person.Item = new Class({
             this.selectedItem = this.selector._newItemSelected(this.data, this.selector, this);
             this.selectedItem.check();
             this.selector.selectedItems.push(this.selectedItem);
+
+            this.selector.fireEvent("selectItem",[this])
         }else{
             MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
         }
@@ -1917,6 +1921,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
             this.selectedItem.destroy();
             this.selectedItem = null;
         }
+        this.selector.fireEvent("unselectItem",[this])
     },
     postLoad : function(){},
     getParentCategoryByLevel : function( level ){

+ 3 - 2
o2web/source/x_component_process_Application/WorkExplorer.js

@@ -1468,10 +1468,11 @@ MWF.xApplication.process.Application.WorkExplorer.Task = new Class({
     flow: function(e){
         this.node.setStyles(this.css.taskItemNode_action);
         this.processNode = new Element("div", {"styles": this.css.taskItemFlowNode}).inject(this.explorer.app.content);
+        this.processNode.setStyles({"overflow":"auto"});
 
         MWF.require("MWF.xDesktop.Dialog", function(){
-            var width = 540;
-            var height = 260;
+            var width = 560;
+            var height = 400;
             var size = this.explorer.app.content.getSize();
             var x = size.x/2-width/2;
             var y = size.y/2-height/2;

+ 15 - 1
o2web/source/x_component_process_FormDesigner/Module/Form.js

@@ -913,6 +913,21 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({
             MWF.FormImport.create("office", this);
         }.bind(this));
     },
+	deletePropertiesOrStyles: function(name, key){
+		if (name=="styles"){
+			try{
+				if( key && this.json.styles[key] ){
+					delete this.json.styles[key];
+				}
+				this.setCustomStyles();
+			}catch(e){}
+		}
+		if (name=="properties"){
+			try{
+				this.node.removeProperty(key);
+			}catch(e){}
+		}
+	},
 	setPropertiesOrStyles: function(name){
 		if (name=="styles"){
 			this.setCustomStyles();
@@ -1082,7 +1097,6 @@ MWF.xApplication.process.FormDesigner.Module.Form = MWF.FCForm = new Class({
             }
         }
     },
-
     setAllStyles: function(){
         this.setPropertiesOrStyles("styles");
         this.setPropertiesOrStyles("properties");

+ 7 - 7
o2web/source/x_component_process_FormDesigner/Module/Subform.js

@@ -246,14 +246,14 @@ MWF.xApplication.process.FormDesigner.Module.Subform = MWF.FCSubform = new Class
 		this.iconNode.getFirst("div").setStyles(this.css.iconNodeIcon);
 		this.iconNode.getLast("div").setStyles(this.css.iconNodeText);
 	},
-    _setEditStyle: function(name, input, oldValue){
-		if (name==="subformSelected"){
-			if (this.json.subformSelected!==oldValue){
+    _setEditStyle_custom : function(name, input, oldValue){
+        if (name==="subformSelected"){
+            if (this.json.subformSelected!==oldValue){
                 this.redoSelectedSubform(name, input, oldValue);
-			}
-		}
+            }
+        }
         if (name==="subformType"){
-		    if (this.json.subformType!==oldValue){
+            if (this.json.subformType!==oldValue){
                 if (this.json.subformType !== "script"){
                     this.redoSelectedSubform(name, $(this.property.data.pid+"selectSubform").getElement("select"), "");
                 }
@@ -265,7 +265,7 @@ MWF.xApplication.process.FormDesigner.Module.Subform = MWF.FCSubform = new Class
                 }
             }
         }
-	},
+    },
     redoSelectedSubform: function(name, input, oldValue){
         if (this.json.subformSelected==="none") this.json.subformSelected="";
         if (this.json.subformSelected && this.json.subformSelected!=="none"){

+ 1 - 0
o2web/source/x_component_process_Work/Processor.js

@@ -669,6 +669,7 @@ MWF.xApplication.process.Work.Processor = new Class({
     setIdeaList: function(ideas){
         var _self = this;
         ideas.each(function(idea){
+            if( !idea )return;
             new Element("div", {
                 "styles": this.css.selectIdeaItemNode,
                 "text": idea,