<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<script type="text/javascript">
  var changePassword = {
    actionUrl:"${contextRoot}/user/changePassword",
    init: function () {

      this.initForm();

      this.bindEvents();
    },
    initForm: function () {
      var data;

      $("#div_info_form").ligerAutoForm({
        data:data,
        validate:{
          oldPassword:{
            required:true
          },
          TwoNewPassword:{
            required:true,
            equalTo: "newPassword"
          },
          newPassword:{
            required:true
          }
        },
        message:{
          TwoNewPassword: "密码不一致！"
          }


      });
    },
    bindEvents: function () {
      var me = this;

      $("#btnSave").click(function () {
        if(!$("#div_info_form").ligerAutoForm("validate")){

          return;
        }
        var data = $("#div_info_form").ligerAutoForm("getData");
        $.ajax({ //ajax处理
          type: "POST",
          url : me.actionUrl,
          dataType : "json",
          data:data,
          cache:false,
          success :function(data){
            if(data.successFlg) {
             // $.ligerDialog.success(data.message);
              parent.indexPage.dialogSuccess(data.message);
            }
            else{
              $.ligerDialog.error(data.message);
            }
          },
          error :function(data){
            $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
          }
        });
      });

      $("#btnCancel").click(function(){
        parent.$.ligerDialog.close();
        parent.$(".l-dialog,.l-window-mask").remove();
      });

    }
  };
  $(function () {

    changePassword.init();

  });
</script>