WYB
2021-03-22 91b8cdad021ab052e4991f3d41834a6f0ddc36b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<template>
  <el-form
    ref="editForm"
    :model="editForm"
    :rules="editFormRules"
    label-width="80px"
    @submit.prevent="onSubmit"
    style="margin:20px;width:60%;min-width:600px;"
   
  >
    <el-form-item label="我的昵称" prop="uRealName">
      <el-input v-model="editForm.uRealName"></el-input>
    </el-form-item>
 
    <el-form-item label="旧密码" prop="uLoginPWD">
      <el-input v-model="editForm.uLoginPWD" type="text" auto-complete="off"></el-input>
    </el-form-item>
    <el-form-item label="新密码" prop="uLoginPWDNew">
      <el-input v-model="editForm.uLoginPWDNew" show-password auto-complete="off"></el-input>
    </el-form-item>
    <el-form-item label="确认密码" prop="uLoginPWDConfirm">
      <el-input v-model="editForm.uLoginPWDConfirm" show-password auto-complete="off"></el-input>
    </el-form-item>
<!-- 
    <el-form-item label="头像">
      <el-upload
        class="avatar-uploader"
        action="/images/Upload/Pic"
        :show-file-list="false"
        :headers="token"
        :data="ruleForm"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload"
      >
        <img v-if="editForm.tdLogo" :src="editForm.tdLogo" class="avatar" />
        <i v-else class="el-icon-plus avatar-uploader-icon plus-sign"></i>
      </el-upload>
    </el-form-item> -->
 
    <el-form-item label="留言/备注">
      <el-input type="textarea" v-model="editForm.uRemark"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button @click.native="onSubmit" type="primary"  :loading="editLoading">更新</el-button>
      <el-button @click.native.prevent>取消</el-button>
    </el-form-item>
  </el-form>
</template>
 
<script>
import {
editUserPWD,//修改用户密码接口
} from "../../api/api";
export default {
  data() {
       var validatePass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请再次输入密码'));
        } else if (value !== this.editForm.uLoginPWDNew) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
      };
    return {
      editLoading: false,
      editForm: {
        id: 0,
        uID: 0,
        RID: 0,
        uLoginName: "",
        uRealName: "",
        uLoginPWDNew:"",
        uLoginPWD:"",
       
      },
      editFormRules:{
        uRealName:[{ required: true, message: "请输入昵称", trigger: "blur" }],
        uLoginPWD:[{required: true, message: "请输入旧密码", trigger: "blur"}],
        uLoginPWDNew:[{required: true, message: "请输入新密码", trigger: "blur"}],
        uLoginPWDConfirm:[ { validator: validatePass2, trigger: 'blur' }],
      },
      token: {
        Authorization: "Bearer "
      },
      ruleForm: {
        max_ver: "",
        min_ver: "",
        enable: ""
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === "image/jpeg";
        const isLt1M = file.size / 1024 / 1024 < 1;
 
        // if (!isJPG) {
        //   this.$message.error('上传头像图片只能是 JPG 格式!')
        // }
        if (!isLt1M) {
          this.$message.error("上传头像图片大小不能超过 1MB!");
        }
        return isLt1M;
      }
    };
  },
  methods: {
    onSubmit:function() {
      this.$refs.editForm.validate((valid) => {
        if(valid){ this.$confirm("确认提交吗?", "提示", {}).then(() => {
 
      let para = Object.assign({}, this.editForm);
      editUserPWD(para).then((res) => {
            
              if (res.data.success) {
                this.editLoading = false;
                //NProgress.done();
                this.$message({
                  message: res.data.msg,
                  type: "success",
                });
                this.$refs["editForm"].resetFields();
                this.editFormVisible = false;
                // this.getUsers();
              } else {
                this.$message({
                  message: res.data.msg,
                  type: "error",
                });
                this.editLoading = false;
              }
            });
        });
        }
      });
      // this.$message({
      //   message: "失败!该操作无权限",
      //   type: "error"
      // });
    },
    handleAvatarSuccess(res, file) {
      this.editForm.tdLogo = "/" + res.response;
    }
  },
  mounted() {
    let tokenStr = window.localStorage.Token;
    this.token = {
      Authorization: "Bearer " + tokenStr
    };
 
    var user = JSON.parse(window.localStorage.user);
    this.editForm.uRealName = user ? user.uRealName : "";
  }
};
</script>
 
<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
 
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
 
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 120px;
    height: 120px;
    text-align: center;
  }
  .plus-sign{
    line-height: 120px !important;
  }
  .avatar {
    width: 120px;
    height: 120px;
    display: block;
  }
 
  .markdown-body{
    height: 500px !important;
  }
</style>