<#macro top>
<div>
  <div id="loadingele"></div>
   <!-- Main Header -->
  <header class="main-header">

    <!-- Logo -->
    <a href="#" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b>A</b>LT</span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg">黔江领导决策管理后台</span>
    </a>

    <!-- Header Navbar -->
    <nav class="navbar navbar-static-top" role="navigation">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>
      <!-- Navbar Right Menu -->
      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown user user-menu" id="user_menu">
              <img src="/images/logo.png" class="img-circle" alt="User Image" style="width: 30px;">
              <span style="color: #fff;" id="loginName"></span>
              <a href="/logout" style="display: inline-block;">退出</a>
              <a href="#" style="display: inline-block;" @click="showDialog1">修改密码</a>
              <!--对话框3 短信验证码验证弹窗-->
              <el-dialog title="修改密码" :visible.sync="dialog1FormVisible">
                  <el-form :rules="rules" :model="dialog1Form" ref="updatePWDdia">
                      <el-form-item label="原密码" :label-width="formLabelWidth" prop="oldPWD">
                          <el-input v-model="dialog1Form.oldPWD" type="password" autocomplete="off"  placeholder="请输入原密码"></el-input>
                      </el-form-item>
                      <el-form-item label="密码" :label-width="formLabelWidth" prop="secretKey1">
                          <el-input autocomplete="new-password" type="password" v-model="dialog1Form.secretKey1" placeholder="请输入密码"></el-input>
                      </el-form-item>

                      <el-form-item label="确认密码" :label-width="formLabelWidth" prop="secretKey2">
                          <el-input autocomplete="new-password" type="password" v-model="dialog1Form.secretKey2" placeholder="请再次输入密码"></el-input>
                      </el-form-item>
                  </el-form>
                  <div slot="footer" class="dialog-footer" >
                      <el-button @click="dialog1FormVisible = false">取 消</el-button>
                      <el-button type="primary" @click="dialog1Submit('updatePWDdia')">确定</el-button>
                  </div>
              </el-dialog>
          </li>
        </ul>
      </div>
    </nav>
  </header>
</div>
<script>
    $.ajax({
        url: '/user/getLoginName',
        success: function (result, status, xhr) {
            $('#loginName').html(result.data)
        }
    });

    var user_menu_option = {
        data() {
            return {
                dialog1FormVisible: false,//对话框1隐藏
                dialog1Form: {},//对话框1 表单数据
                rules: {
                    oldPWD: [
                        {
                            required: true, validator: (rule, value, callback) => {
                            if (value === '' || typeof (value) === 'undefined') {
                                callback(new Error('原密码不能为空'));
                            } else {
                                callback();
                            }
                        }, trigger: 'blur'
                        }
                    ],
                    secretKey1: [
                        {
                            required: true, validator: (rule, value, callback) => {
                            if (value === '' || typeof (value) === 'undefined') {
                                callback(new Error('请输入密码'));
                            } else {
                                if (this.dialog1Form.secretKey1 !== '') {
                                    this.$refs.updatePWDdia.validateField('secretKey2');
                                }
                                callback();
                            }
                        }, trigger: 'blur'
                        }
                    ],
                    secretKey2: [
                        {
                            required: true, validator: (rule, value, callback) => {
                            if (value === '' || typeof (value) === 'undefined') {
                                callback(new Error('请再次输入密码'));
                            } else if (value !== this.dialog1Form.secretKey1) {
                                callback(new Error('两次输入密码不一致!'));
                            } else {
                                callback();
                            }
                        }, trigger: 'blur'
                        }
                    ],
                },//对话框1验证规则
                formLabelWidth: "120px"
            }
        },
        methods: {
            //修改密码弹窗提交
            dialog1Submit(formName) {
                var _this = this;
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        $.dyAjax('/manage/updatePWD', {
                            oldPWD: _this.dialog1Form.oldPWD,
                            newPWD: _this.dialog1Form.secretKey1
                        }, function (data) {
                            _this.dialog1FormVisible = false;
                            _this.$message({ message: '成功', type: 'success' });
                        });
                    } else {
                        return false;
                    }
                });
            },
            //显示修改密码弹窗
            showDialog1(){
                this.dialog1FormVisible = true;
                setTimeout(function () {
                   $('.v-modal').css('z-index',1);
                },0)
            },

        }
    };
    var user_menu_app = Vue.extend(user_menu_option);
    new user_menu_app().$mount('#user_menu');
</script>
</#macro>