张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<!-- 动态路由公共组件 -->
<template>
  <el-container class="layout">
    <el-header class="layout_header">
      <img src="../../assets/logo.png">
      <!-- <div class="logo_titles">面向现代制造的混凝土管片智慧工厂</div> -->
      <div class="header_close">
        <el-dropdown @command="quitSystem">
          <span class="el-dropdown-link">
            <i class="el-icon-user"></i> 
            {{realName}}
            <i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="password">
              <i class="el-icon-key"></i>
              修改密码
            </el-dropdown-item>
            <el-dropdown-item command="logout">
              <i class="el-icon-switch-button"></i>
              退出登录
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-container style="overflow: hidden;">
      <el-aside class="layout_sider" width="230px">
        <layout-aside></layout-aside>
      </el-aside>
      <el-main class="layout_content">
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <!-- <template v-for="item in routerList">
            <el-breadcrumb-item :key="item.meta.menuId">{{item.meta.title}}</el-breadcrumb-item>
          </template> -->
        </el-breadcrumb>
        <transition>
          <router-view />
        </transition>
      </el-main>
    </el-container>
    <!-- 修改密码 -->
    <el-dialog
      class="prop_dialog"
      :close-on-click-modal="false"
      title="修改密码"
      :visible.sync="asyncPassword"
      width="35%">
      <el-form ref="form" :model="ruleForm" :rules="rules" label-width="auto" class="rule_form">
        <el-form-item label="旧密码:" prop="oldPassword">
          <el-input v-model="ruleForm.oldPassword" type="password" clearable placeholder="请输入新密码"></el-input>
        </el-form-item>
        <el-form-item label="新密码:" prop="password">
          <el-input v-model="ruleForm.password" type="password" clearable placeholder="请输入新密码"></el-input>
        </el-form-item>
        <el-form-item label="确认新密码:" prop="tpassword">
          <el-input v-model="ruleForm.tpassword" type="password" clearable placeholder="请再次输入新密码"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="asyncPassword = false">取 消</el-button>
        <el-button class="submit_btn" @click="updatePawssword"> 提 交</el-button>
      </div>
    </el-dialog>
  </el-container>
</template>
 
<script>
import { changeSize } from "../../plugins/public";
import LayoutAside from './components/LayoutAside.vue'; // 导航菜单组件
export default {
  components: {
    LayoutAside
  },
  data() {
     const validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'));
      } else {
        // if (this.ruleForm.oldPassword !== '') {
        //   this.$refs.form.validateField('oldPassword');
        // }
        callback();
      }
    };
    const validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入新密码'));
      } else {
        callback();
      }
    };
    const validatePass3 = (rule, value, callback) => {
      if (value !==this.ruleForm.password) {
        callback(new Error('两次输入的密码不一致!!!'));
      }else {
        callback();
      }
    };
    return {
      size: changeSize(),
      realName:sessionStorage.getItem('realName'),
      asyncPassword: false, // 修改密码
       ruleForm: {}, // 修改密码表单
      rules: {
        oldPassword: [{
          required: true, 
          validator: validatePass, 
          trigger: 'blur' 
        }],
        password: [{ 
          required: true,
          validator: validatePass2, 
          trigger: 'blur' 
        }],
        tpassword: [{ 
          required: true,
          validator: validatePass3, 
          trigger: 'blur' 
        }],
      }, // 表单验证
      routerList: [], // 路由信息
    };
  },
  mounted() {
    this.routerList = this.$route.matched.map(item => {
      return {
        path: item.path,
        meta: item.meta
      }
    })
  },
  methods: {
    // 退出登录
    quitSystem(val) {
      if(val === 'logout'){
        this.$confirm("您要退出本系统,是否继续?","提示", {
          confirmButtonText: "确定",
          cancelButtonTexy: "取消",
          type: "warning"
        }).then(() => {
          this.$api.System.logingOut({}).then(res => {
            if(res.statusMsg === 'ok') {
              sessionStorage.clear();
              this.$router.replace('/login');
              this.$message.success('退出成功!');
            }
          })
        })
        .catch(() => {
          this.$message.info('您已取消!');
        })
      }else{
        this.asyncPassword = true
      }
    },
    // 提交修改密码
    updatePawssword() {
      this.$refs.form.validate(valid => {
        if(valid) {
            let params = {
              oldPassword:this.ruleForm.oldPassword,
              password:this.ruleForm.password
            }
            this.$api.System.updatePasswordInfo(params).then((res) => {
              if (res?.statusMsg === 'ok') {
                this.asyncPassword = false;
                this.$message.success('修改成功!')
                this.$router.replace('/login');
              } else {
                this.$message.warning(res?.statusMsg);
              }
            })
        }
      })
    }
  },
  watch: {
    $route() {
      this.routerList = this.$route.matched.map(item => {
        return {
          path: item.path,
          meta: item.meta
        }
      })
    }
  }
};
</script>
 
<style lang="scss" scoped>
@import '../../style/layout-main.scss';
.layout {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(
    150deg,
  rgba(17, 55, 97, 1) 8%,
  rgba(10, 33, 66, 1) 92%);
 
  .layout_header {
    position: relative;
    display: flex;
    align-items: center;
    color: #fff;
    background: transparent;
    .logo_titles{
      color: #39B5FE;
      font-size: 24px;
      font-weight: 900;
      font-family:"Microsoft YaHei";
      -webkit-text-stroke: 0.2px #ffffff;
    }
    img{
      margin-right: 10px;
    }
 
    .header_close {
      position: absolute;
      top: 50%;
      right: 2%;
      transform: translateY(-50%);
    }
  }
 
  .layout_content {
    position: relative;
    padding: 20px 20px 0;
    background: url('../../assets/main_bg.jpg')no-repeat;
    background-size: 100% 100%;
    overflow: hidden;
 
    &::before {
      position: absolute;
      content: '';
      width: calc(100% - 30px);
      height: calc(100% - 15px);
      background: rgba($color: #040D1A, $alpha: .7);
    }
 
    /deep/ .el-breadcrumb__inner {
      color: #14C6CD;
 
      &:last-of-type {
        color: #18F5DB;
      }
    }
  }
 
  .layout_sider {
    margin: 0;
    height: 100%;
    border-right: none;
    background: transparent;
    overflow: hidden;
  }
}
/deep/.el-dropdown{
  color: #fff;
  cursor: pointer;
  &:hover{
    color: #39B5FE;
  }
}
::v-deep .el-input--small .el-input__inner{
  border:1px solid #39B5FE;
  background-color: transparent;
  color: #fff;
}
</style>