Переглянути джерело

fix:新增加密方式插件,机构管理编辑回显地址

刘恒 2 роки тому
батько
коміт
ae8def6d17
4 змінених файлів з 268 додано та 165 видалено
  1. 5 0
      package-lock.json
  2. 1 0
      package.json
  3. 248 163
      src/views/Login.vue
  4. 14 2
      src/views/Sys/Deptall.vue

+ 5 - 0
package-lock.json

@@ -2645,6 +2645,11 @@
         "randomfill": "^1.0.3"
       }
     },
+    "crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    },
     "css-color-names": {
       "version": "0.0.4",
       "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz",

+ 1 - 0
package.json

@@ -21,6 +21,7 @@
     "base-64": "^1.0.0",
     "bignumber.js": "^9.1.2",
     "cross-env": "^7.0.3",
+    "crypto-js": "^4.2.0",
     "echarts": "^4.9.0",
     "element-china-area-data": "^6.1.0",
     "element-ui": "^2.15.14",

+ 248 - 163
src/views/Login.vue

@@ -1,65 +1,133 @@
 <template>
   <div class="wavy-line">
-
-    <div id="content" style="height: 100%;">
+    <div id="content" style="height: 100%">
       <div id="Login">
-
         <div class="log_on">
           <div class="left_content"></div>
           <div class="right_content">
-            <img v-if="toggleQrCode" class="img1" src="../assets//image/log_code.png" alt="" @click="switchLogin">
-            <img v-else class="img1" src="../assets//image/QR_code.png" alt="" @click="switchCode">
-            <div style="padding:15% 20% ">
-              <img class="img2" src="../assets//image/logo_img.png" alt="">
-              <div v-show="toggleQrCode" style="text-align: center;">
-                <div class="img3" v-loading="loadingCode" id="qrcode" ref="qrcode">
+            <img
+              v-if="toggleQrCode"
+              class="img1"
+              src="../assets//image/log_code.png"
+              alt=""
+              @click="switchLogin"
+            />
+            <img
+              v-else
+              class="img1"
+              src="../assets//image/QR_code.png"
+              alt=""
+              @click="switchCode"
+            />
+            <div style="padding: 15% 20%">
+              <img class="img2" src="../assets//image/logo_img.png" alt="" />
+              <div v-show="toggleQrCode" style="text-align: center">
+                <div
+                  class="img3"
+                  v-loading="loadingCode"
+                  id="qrcode"
+                  ref="qrcode"
+                >
                   <transition name="el-fade-in">
-                    <el-result v-if="tipVisibility" class="scanSuccess" icon="success" title="扫码成功"></el-result>
+                    <el-result
+                      v-if="tipVisibility"
+                      class="scanSuccess"
+                      icon="success"
+                      title="扫码成功"
+                    ></el-result>
                   </transition>
                 </div>
-                <el-button icon="el-icon-refresh-right" size="small" style="margin-top: 10px;"
-                  @click="refresh">刷新二维码</el-button>
+                <el-button
+                  icon="el-icon-refresh-right"
+                  size="small"
+                  style="margin-top: 10px"
+                  @click="refresh"
+                  >刷新二维码</el-button
+                >
                 <p class="code_word">打开<b>客户端APP</b>扫描二维码</p>
               </div>
-              <el-form v-show="!toggleQrCode" size="medium" :model="loginForm" :rules="fieldRules" ref="loginForm"
-                label-position="left" label-width="0">
+              <el-form
+                v-show="!toggleQrCode"
+                size="medium"
+                :model="loginForm"
+                :rules="fieldRules"
+                ref="loginForm"
+                label-position="left"
+                label-width="0"
+              >
                 <el-form-item prop="account" label="">
-                  <el-input type="text" prefix-icon="el-icon-user" v-model="loginForm.account" auto-complete="off"
-                    placeholder="账号"></el-input>
+                  <el-input
+                    type="text"
+                    prefix-icon="el-icon-user"
+                    v-model="loginForm.account"
+                    auto-complete="off"
+                    placeholder="账号"
+                  ></el-input>
                 </el-form-item>
                 <el-form-item prop="password" label="">
-                  <el-input type="password" prefix-icon="el-icon-lock" v-model="loginForm.password" auto-complete="off"
-                    placeholder="密码"></el-input>
+                  <el-input
+                    type="password"
+                    prefix-icon="el-icon-lock"
+                    v-model="loginForm.password"
+                    auto-complete="off"
+                    placeholder="密码"
+                  ></el-input>
                 </el-form-item>
                 <el-row>
                   <el-col :span="14">
                     <el-form-item prop="captcha" label="">
-                      <el-input type="test" prefix-icon="el-icon-success" v-model="loginForm.captcha" auto-complete="off"
-                        placeholder="验证码">
+                      <el-input
+                        type="test"
+                        prefix-icon="el-icon-success"
+                        v-model="loginForm.captcha"
+                        auto-complete="off"
+                        placeholder="验证码"
+                      >
                       </el-input>
                     </el-form-item>
                   </el-col>
                   <el-col class="line" :span="1">&nbsp;</el-col>
                   <el-col :span="9">
-                    <img style="width: 100%;height: 32px;margin: 2px;" class="pointer" :src="loginForm.src"
-                      @click="refreshCaptcha">
+                    <img
+                      style="width: 100%; height: 32px; margin: 2px"
+                      class="pointer"
+                      :src="loginForm.src"
+                      @click="refreshCaptcha"
+                    />
                   </el-col>
                 </el-row>
-                <el-row style="width:100%;margin-top: 15px;">
-                  <el-button size="medium" type="primary" plain style="width:48%;float: left;"
-                    @click.native.prevent="reset">重
-                    置</el-button>
-                  <el-button size="medium" type="primary" style="width:48%;float: right;"
-                    @click.native.prevent="login('loginForm')" :loading="loading">登 录</el-button>
+                <el-row style="width: 100%; margin-top: 15px">
+                  <el-button
+                    size="medium"
+                    type="primary"
+                    plain
+                    style="width: 48%; float: left"
+                    @click.native.prevent="reset"
+                    >重 置</el-button
+                  >
+                  <el-button
+                    size="medium"
+                    type="primary"
+                    style="width: 48%; float: right"
+                    @click.native.prevent="login('loginForm')"
+                    :loading="loading"
+                    >登 录</el-button
+                  >
                 </el-row>
               </el-form>
             </div>
           </div>
         </div>
         <div class="L_footer">
-          <div class="w1100" style="padding-top: 15px;">
-            <p style="font-weight: bold;">版权所有©1994-2014山西掌柜科技有限公司 未经许可不得复制转载或者摘编</p>
-            <p style="font-weight: bold;">copyright 1994-2014 ZhangGui Property Insurance Co.Lid All rights reserved</p>
+          <div class="w1100" style="padding-top: 15px">
+            <p style="font-weight: bold">
+              版权所有©1994-2014山西掌柜科技有限公司
+              未经许可不得复制转载或者摘编
+            </p>
+            <p style="font-weight: bold">
+              copyright 1994-2014 ZhangGui Property Insurance Co.Lid All rights
+              reserved
+            </p>
           </div>
         </div>
       </div>
@@ -68,20 +136,20 @@
 </template>
 
 <script>
-import { mapState } from 'vuex'
-import Cookies from "js-cookie"
+import { mapState } from "vuex";
+import Cookies from "js-cookie";
 import QRCode from "qrcodejs2";
-import { md5 } from "@/utils/md5"
-import ThemePicker from "@/components/ThemePicker"
-import LangSelector from "@/components/LangSelector"
-import { login } from '@/api/user'
-
+import { md5 } from "@/utils/md5";
+import ThemePicker from "@/components/ThemePicker";
+import LangSelector from "@/components/LangSelector";
+import { login } from "@/api/user";
+import CryptoJS from "crypto-js";
 export default {
-  name: 'Login',
+  name: "Login",
   inject: ["reload"],
   components: {
     ThemePicker,
-    LangSelector
+    LangSelector,
   },
   data() {
     return {
@@ -90,107 +158,119 @@ export default {
       rememberPassword: false,
       loading: false,
       loginForm: {
-        account: '',
-        password: '',
-        captcha: '',
-        src: ''
+        account: "",
+        password: "",
+        captcha: "",
+        src: "",
       },
       fieldRules: {
-        account: [
-          { required: true, message: '请输入账号', trigger: 'blur' },
-        ],
-        password: [
-          { required: true, message: '请输入密码', trigger: 'blur' },
-        ],
-        captcha: [
-          { required: true, message: '请输入验证码', trigger: 'blur' }
-        ]
+        account: [{ required: true, message: "请输入账号", trigger: "blur" }],
+        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
+        captcha: [{ required: true, message: "请输入验证码", trigger: "blur" }],
       },
       checked: true,
       toggleQrCode: false,
-      uuid: '',
+      uuid: "",
       polling: null,
       tipVisibility: false,
-    }
+    };
   },
   created() {
     // 记住密码
-    if (Cookies.get('accountInfo')) {
-      const accountInfo = JSON.parse(Cookies.get('accountInfo'));
-      this.loginForm.account = accountInfo.account
-      this.loginForm.password = accountInfo.password
-      this.rememberPassword = true
+    if (Cookies.get("accountInfo")) {
+      const accountInfo = JSON.parse(Cookies.get("accountInfo"));
+      this.loginForm.account = accountInfo.account;
+      this.loginForm.password = accountInfo.password;
+      this.rememberPassword = true;
     }
-    this.enterEvent()//初始化回车事件
+    this.enterEvent(); //初始化回车事件
   },
   methods: {
     enterEvent() {
-      if (this.$route.name === '登录') {
+      if (this.$route.name === "登录") {
         document.onkeydown = (e) => {
-          const url = e.target.baseURI.match(/login/)
-          if (e.keyCode == 13 && url.includes('login')) {
+          const url = e.target.baseURI.match(/login/);
+          if (e.keyCode == 13 && url.includes("login")) {
             this.login();
           }
-        }
+        };
       }
     },
     login(formName) {
+      // let token = CryptoJS.AES.encrypt(
+      //   "2856c49f-7b34-4e83-b3c8-2c37dba7cb3b",
+      //   "token"
+      // ).toString();
+      // console.log(token);
+      // window.location.href =
+      //   "http://localhost:8080/#/form/agreement?token=" + token;
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          this.loading = true
+          this.loading = true;
           let userInfo = {
             account: this.loginForm.account,
             password: this.loginForm.password,
             captcha: this.loginForm.captcha.toLowerCase(),
-            captchaId: this.loginForm.captchaId
-          }
-
-          // this.$store.dispatch('login', userInfo)
-          //     .then(() => {
-          //       if (this.rememberPassword) { //是否保存密码
-          //       Cookies.set('accountInfo', { 'account': this.loginForm.account, 'password': this.loginForm.password, })
-          //     } else {
-          //       Cookies.remove('accountInfo')
-          //     }
-          //     Cookies.set('user', userInfo.account) /
-          //     sessionStorage.setItem('user', userInfo.account) // 保存用户到本地会话
-          //     this.$store.commit('menuRouteLoaded', false) // 要求重新加载导航菜单
-          //     this.$router.push('/')
-          //     this.loading = false
-          //   })
-          //   .catch(() => {
-          //     this.loading = false
-          //   })
+            captchaId: this.loginForm.captchaId,
+          };
 
-          this.$api.login.login2(userInfo).then((res) => {
-            if (res.code != 200) {
-              this.$message({
-                message: res.msg,
-                type: 'error',
-                duration: 2000
-              })
-              if (res.code == 500 && res.msg == '验证码不正确') {
-                this.refreshCaptcha()
+          this.$store
+            .dispatch("login", userInfo)
+            .then(() => {
+              if (this.rememberPassword) {
+                //是否保存密码
+                Cookies.set("accountInfo", {
+                  account: this.loginForm.account,
+                  password: this.loginForm.password,
+                });
+              } else {
+                Cookies.remove("accountInfo");
               }
-            }
-            else {
-              if (this.rememberPassword) { //是否保存密码
-                Cookies.set('accountInfo', { 'account': this.loginForm.account, 'password': this.loginForm.password, })
+              Cookies.set("user", userInfo.account) /
+                sessionStorage.setItem("user", userInfo.account); // 保存用户到本地会话
+              this.$store.commit("menuRouteLoaded", false); // 要求重新加载导航菜单
+              this.$router.push("/");
+              this.loading = false;
+            })
+            .catch(() => {
+              this.loading = false;
+            });
+
+          this.$api.login
+            .login2(userInfo)
+            .then((res) => {
+              if (res.code != 200) {
+                this.$message({
+                  message: res.msg,
+                  type: "error",
+                  duration: 2000,
+                });
+                if (res.code == 500 && res.msg == "验证码不正确") {
+                  this.refreshCaptcha();
+                }
               } else {
-                Cookies.remove('accountInfo')
+                if (this.rememberPassword) {
+                  //是否保存密码
+                  Cookies.set("accountInfo", {
+                    account: this.loginForm.account,
+                    password: this.loginForm.password,
+                  });
+                } else {
+                  Cookies.remove("accountInfo");
+                }
+                Cookies.set("token", res.data); // 放置token到Cookie
+                this.getDictItems();
+                this.getUser();
               }
-              Cookies.set('token', res.data) // 放置token到Cookie
-              this.getDictItems()
-              this.getUser();
-            }
-            this.loading = false
-          }).catch((res) => {
-            this.$message({
-              message: res.message,
-              type: 'error',
-              duration: 2000
+              this.loading = false;
             })
-          });
+            .catch((res) => {
+              this.$message({
+                message: res.message,
+                type: "error",
+                duration: 2000,
+              });
+            });
         } else {
           return false;
         }
@@ -199,75 +279,82 @@ export default {
     getDictItems() {
       //--数据字典--
       // 性别
-      this.$api.dict
-        .findByLableName('sex')
-        .then((response) => {
-          localStorage.setItem('sexOptions', JSON.stringify(response.data)) // 保存用户到本地会话
-        })
+      this.$api.dict.findByLableName("sex").then((response) => {
+        localStorage.setItem("sexOptions", JSON.stringify(response.data)); // 保存用户到本地会话
+      });
       // 状态
-      this.$api.dict
-        .findByLableName('user_status')
-        .then((response) => {
-          localStorage.setItem('user_statusoptions', JSON.stringify(response.data)) // 保存用户到本地会话
-        })
+      this.$api.dict.findByLableName("user_status").then((response) => {
+        localStorage.setItem(
+          "user_statusoptions",
+          JSON.stringify(response.data)
+        ); // 保存用户到本地会话
+      });
     },
     // 用户信息
     getUser() {
       this.$api.user.getLoginUser().then((response) => {
         if (response.code == 200) {
           //头像地址拼接
-          if (response.data.headSculpture != '' && response.data.headSculpture != null && response.data.headSculpture != undefined) {
-            response.data.headSculpture = process.env.BASE_URL + response.data.headSculpture
+          if (
+            response.data.headSculpture != "" &&
+            response.data.headSculpture != null &&
+            response.data.headSculpture != undefined
+          ) {
+            response.data.headSculpture =
+              process.env.BASE_URL + response.data.headSculpture;
           }
-          localStorage.setItem('user_data', JSON.stringify(response.data))
+          localStorage.setItem("user_data", JSON.stringify(response.data));
           this.$store.commit("SET_USER", response.data);
-          sessionStorage.setItem('user', response.data.id)
-          Cookies.set('user', response.data.id)
-          localStorage.setItem('routerId', '420');
-          this.$store.commit('menuRouteLoaded', false);
-          this.$router.push('/');
+          sessionStorage.setItem("user", response.data.id);
+          Cookies.set("user", response.data.id);
+          localStorage.setItem("routerId", "420");
+          this.$store.commit("menuRouteLoaded", false);
+          this.$router.push("/");
           this.loadingCode = false;
+        } else {
+          this.$message.error(response.msg);
         }
-        else {
-          this.$message.error(response.msg)
-        }
-      })
+      });
       this.$api.role.findAll().then((res) => {
-        localStorage.setItem('find_all', JSON.stringify(res.data))
-      })
+        localStorage.setItem("find_all", JSON.stringify(res.data));
+      });
     },
     refreshCaptcha() {
-      let randnum = Math.floor(Math.random() * (1000000 - 1 + 1)) + 1
-      this.loginForm.src = process.env.BASE_URL + "/captchaById?t=" + new Date().getTime() + '&captchaId=' + randnum;
-      this.loginForm.captchaId = randnum
-
+      let randnum = Math.floor(Math.random() * (1000000 - 1 + 1)) + 1;
+      this.loginForm.src =
+        process.env.BASE_URL +
+        "/captchaById?t=" +
+        new Date().getTime() +
+        "&captchaId=" +
+        randnum;
+      this.loginForm.captchaId = randnum;
     },
     reset() {
-      this.$refs.loginForm.resetFields()
+      this.$refs.loginForm.resetFields();
     },
     // 切换主题
     onThemeChange: function (themeColor) {
-      this.$store.commit('setThemeColor', themeColor)
+      this.$store.commit("setThemeColor", themeColor);
     },
     switchLogin() {
       this.toggleQrCode = !this.toggleQrCode;
-      this.stopPolling()
+      this.stopPolling();
     },
     switchCode() {
       this.toggleQrCode = !this.toggleQrCode;
-      this.generateQrCode();//获取二维码
+      this.generateQrCode(); //获取二维码
     },
     generateQrCode() {
       let randnum = new Date().getTime();
-      let uuid = md5(randnum)
-      let url = process.env.BASE_URL + '/scanQrCode?uuid=' + uuid;
+      let uuid = md5(randnum);
+      let url = process.env.BASE_URL + "/scanQrCode?uuid=" + uuid;
       this.$nextTick(() => {
-        this.creatQrCode(url)
+        this.creatQrCode(url);
         this.$api.login.getQRCode(uuid).then((res) => {
           this.uuid = res.data.uuid;
           this.startPolling();
         });
-      })
+      });
     },
     checkScanStatus() {
       this.$api.login.QrCodeStatusQuery(this.uuid).then((res) => {
@@ -275,8 +362,8 @@ export default {
           this.tipVisibility = true;
           this.loadingCode = true;
           setTimeout(() => {
-            this.CodeLoginSuccess(res.data.token)
-          }, 1500)
+            this.CodeLoginSuccess(res.data.token);
+          }, 1500);
         }
       });
     },
@@ -291,8 +378,8 @@ export default {
       this.polling = null;
     },
     CodeLoginSuccess(token) {
-      Cookies.set('token', token) // 放置token到Cookie
-      this.getDictItems()//获取字典
+      Cookies.set("token", token); // 放置token到Cookie
+      this.getDictItems(); //获取字典
       this.getUser();
     },
 
@@ -311,12 +398,10 @@ export default {
           height: 200,
           colorDark: "#000000",
           colorLight: "#ffffff",
-          correctLevel: QRCode.CorrectLevel.H
+          correctLevel: QRCode.CorrectLevel.H,
         });
       }
     },
-
-
   },
 
   beforeDestroy() {
@@ -324,18 +409,18 @@ export default {
     this.stopPolling();
   },
   mounted() {
-    this.refreshCaptcha()
+    this.refreshCaptcha();
   },
   computed: {
     ...mapState({
-      themeColor: state => state.app.themeColor
-    })
+      themeColor: (state) => state.app.themeColor,
+    }),
   },
   //销毁函数
   destroyed() {
     document.onkeydown = null;
-  }
-}
+  },
+};
 </script>
 
 <style lang="scss" scoped>
@@ -359,7 +444,7 @@ export default {
   padding: 30px;
   box-sizing: border-box;
 
-  &>div {
+  & > div {
     width: 176px;
     height: 176px;
     border: 1px solid var(--themeColor);
@@ -435,12 +520,12 @@ export default {
         display: block;
         margin-left: auto;
         margin-right: auto;
-        border: 1px solid #EAEDF1;
+        border: 1px solid #eaedf1;
         position: relative;
       }
 
       .el-form-item {
-        margin-bottom: 30px
+        margin-bottom: 30px;
       }
 
       .code_word {
@@ -449,7 +534,7 @@ export default {
         margin-top: 20px;
 
         b {
-          color: #B20404;
+          color: #b20404;
         }
       }
     }
@@ -458,7 +543,7 @@ export default {
   .L_footer {
     height: 64px;
     bottom: 0;
-    color: #EAEDF1;
+    color: #eaedf1;
     font-size: 12px;
 
     p {

+ 14 - 2
src/views/Sys/Deptall.vue

@@ -313,8 +313,8 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8"> </el-col>
         </el-row>
+
         <el-row>
           <el-col :span="8">
             <el-form-item label="机构类型" prop="comtype">
@@ -536,7 +536,16 @@
           </el-col>
         </el-row>
         <el-row>
-          <el-col :span="12">
+          <el-col :span="16">
+            <el-form-item label="机构地址" prop="address">
+              <el-input
+                v-model="deptDataForm.address"
+                placeholder="机构地址"
+              ></el-input>
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="8">
             <el-form-item label="排序" prop="orderNum">
               <el-input-number
                 v-model="deptDataForm.orderNum"
@@ -977,6 +986,9 @@ export default {
       this.operType = "ADD";
       this.dialogTitle = "新增部门";
       this.deptDataForm.deptType = "D"; //类型是机构(C是机构,D是部门)
+      this.deptDataForm.address = ""; //
+      this.deptDataForm.name = ""; //
+      this.deptDataForm.orderNum = "0"; //
       this.deptDataForm.parentId = this.currentTreeNode.id;
       this.$api.dept.findMaxDeptId(this.currentTreeNode.id).then((res) => {
         let newId = parseInt(res.data) + 1;