Sfoglia il codice sorgente

新增员工第一次登陆修改密码

wucl 2 anni fa
parent
commit
2fefce50e5

+ 80 - 5
src/views/home/index.vue

@@ -1,6 +1,25 @@
 <template>
   <div class="home">
     <div class="menu-box"></div>
+    <el-dialog class="dialog" title="请先修改密码,再进入系统." :visible.sync="dialogFormVisible" :close-on-click-modal="false" :show-close="false" width="600px">
+      <el-form :model="dialogForm" :rules="rules" ref="dialogForm" label-position="right"
+               label-width="110px"
+               style="width: 400px; margin-left:50px;">
+        <el-form-item label="原密码" prop="originalPassword" :rules="{required: true, message: '请输入原密码', trigger: 'blur'}">
+          <el-input v-model="dialogForm.originalPassword" type="password" autocomplete="off"/>
+        </el-form-item>
+        <el-form-item label="新密码" prop="currentPassword" :rules="{required: true, message: '请输入新密码', trigger: 'blur'}">
+          <el-input v-model="dialogForm.currentPassword" type="password" autocomplete="off"/>
+        </el-form-item>
+        <el-form-item label="确认密码" prop="repeatPassword" :rules="{required: true, message: '请输入确认密码', trigger: 'blur'}">
+          <el-input v-model="dialogForm.repeatPassword" type="password" autocomplete="off"/>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button divided @click.native="logout">取 消</el-button>
+        <el-button type="primary" @click="savePass('dialogForm')">修 改</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -12,13 +31,16 @@
     components: {},
     data() {
       return {
-        activeItem: {}
+        activeItem: {},
+        dialogFormVisible:false,
+        dialogForm:{},
+        rules:{}
       }
     },
     computed: {
       ...mapGetters([
         'permission_menus'
-      ])
+      ]),
     },
     watch: {
       permission_menus: {
@@ -26,11 +48,15 @@
         deep: true,
         handler(newv) {
           if (newv && newv.length) {
-            this.activeItem = newv[0]
-            this.jumpMenu(this.activeItem)
+            const pswState = this.$store.getters.userInfo.passwordState;
+            this.dialogFormVisible = pswState;
+            this.activeItem = newv[0];
+            if (!this.dialogFormVisible){
+              this.jumpMenu(this.activeItem)
+            }
           }
         }
-      }
+      },
     },
     created() {
     },
@@ -90,6 +116,52 @@
           console.error(new Error('一级未找到菜单'))
         }
       },
+      savePass(formName) {
+        this.$refs[formName].validate((valid) => {
+          if (valid) {
+            if (this.dialogForm.currentPassword.length!=8){
+              this.$notify({
+                title: '错误',
+                message: '新密码必须是8位字符',
+                type: 'error',
+                duration: 3000
+              });
+              return
+            }
+            if (this.dialogForm.currentPassword != this.dialogForm.repeatPassword){
+              this.$notify({
+                title: '错误',
+                message: '两次输入的密码不一致,请检查。',
+                type: 'error',
+                duration: 3000
+              });
+              return
+            }
+            this.$api.user.modifyPass(this.dialogForm).then(res => {
+              if (res.code === 200) {
+                this.$notify({
+                  title: '成功',
+                  message: '密码修改成功,请重新登录.',
+                  type: 'success',
+                  duration: 10000
+                });
+                this.dialogFormVisible = false;
+                setTimeout(() => {
+                    this.logout();
+                }, 3000);
+              }
+            })
+          } else {
+            console.log('error submit!!')
+            return false
+          }
+        })
+      },
+      async logout() {
+        await this.$store.dispatch('user/logout');
+        // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
+        this.$router.push(`/login`);
+      },
     }
   }
 </script>
@@ -182,4 +254,7 @@
       }
     }
   }
+  .dialog{
+     border-radius: 20px;
+   }
 </style>

+ 1 - 1
src/views/item/itemIndex.vue

@@ -25,7 +25,7 @@
     </div>
     <div id="main" >
       <el-steps v-for="(s ,index) in stages" :key="index" finish-status="process " simple style="margin-top: 10px">
-        <el-tag class="tag">{{s[0].itemName}}</el-tag>
+        <el-tag class="tag">{{ s[0].itemName }}</el-tag>
         <div class="sta" v-for="(ss,index) in s" :key="index" :style="bgColor(ss.state)">
           {{ss.name}}
         </div>

+ 4 - 4
src/views/profile/profile.vue

@@ -265,7 +265,7 @@
         </el-tabs>
       </div>
     </y-detail-page-layout>
-    <el-dialog id="dialog" title="修改密码" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="600px">
+    <el-dialog class="dialog" title="修改密码" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="600px">
       <el-form :model="dialogForm" :rules="rules" ref="dialogForm" label-position="right"
                label-width="110px"
                style="width: 400px; margin-left:50px;">
@@ -412,8 +412,8 @@
     }
   }
 </script>
-<style lang="css" scoped>
-  #dialog{
-    border-radius: 10px;
+<style lang="scss" scoped>
+  .dialog{
+    border-radius: 20px;
   }
 </style>

+ 21 - 3
src/views/staff/detail.vue

@@ -225,13 +225,14 @@
                       </el-form-item>
                     </el-col>
                     <el-col :xs="24" :sm="12" :lg="6" :span="6">
-                      <el-form-item label="入职日期:" label-width="120px" class="postInfo-container-item">
+                      <el-form-item label="入职日期:" :rules="{required: true, message: '请选择入职日期', trigger: 'blur'}" label-width="120px" class="postInfo-container-item">
                         <el-date-picker
                           v-model="postForm.hireDate"
                           type="date"
                           value-format="yyyy-MM-dd"
                           style="width: 100%"
                           placeholder="选择日期"
+                          :disabled="ifAble"
                         />
                       </el-form-item>
                     </el-col>
@@ -295,6 +296,7 @@
         listQuery:{},
         postOptions:[],
         userPosts:[],
+        disable: false,
       }
     },
     created() {
@@ -302,6 +304,15 @@
       this.getOptions();
       this.getDetail();
     },
+    computed:{
+      ifAble(){
+        if (this.dataId){
+          return true;
+        }else {
+          return false;
+        }
+      }
+    },
     methods: {
       initPassword() {
         this.$confirm('确认初始密码, 是否继续?', '提示', {
@@ -351,8 +362,6 @@
         }
       },
       handleCreate() {
-        console.log(this.postForm, 'xxx');
-
         if (!this.postForm.userType) {
           this.$notify({
             title: '错误',
@@ -409,6 +418,15 @@
           return
         }
 
+        if (!this.postForm.hireDate) {
+          this.$notify({
+            title: '错误',
+            message: '请选择入职日期',
+            type: 'error',
+            duration: 2000
+          });
+          return
+        }
         this.vLoading = true;
 
         this.$refs.postForm.validate(valid => {