From 3d41233538c06622686fec3e613f61411f320b2b Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 19 一月 2026 13:57:58 +0800
Subject: [PATCH] 测试完成

---
 src/views/login.vue |  135 +++++++++++++++++++++++++++++++-------------
 1 files changed, 94 insertions(+), 41 deletions(-)

diff --git a/src/views/login.vue b/src/views/login.vue
index ce46604..1260bd7 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -6,7 +6,7 @@
       :rules="loginRules"
       class="login-form"
     >
-      <h3 class="title">娴欎腑鍖诲ぇ浜岄櫌鏅烘収闅忚骞冲彴</h3>
+      <h3 class="title">鏅烘収闅忚绯荤粺</h3>
       <el-form-item prop="username">
         <el-input
           v-model="loginForm.username"
@@ -35,6 +35,22 @@
             class="el-input__icon input-icon"
           />
         </el-input>
+      </el-form-item>
+      <!-- 涓�===================姘� -->
+      <el-form-item prop="orgid">
+        <el-select
+          style="width: 100%"
+          v-model="loginForm.orgid"
+          placeholder="璇烽�夋嫨闄㈠尯"
+        >
+          <el-option
+            v-for="item in options"
+            :label="item.label"
+            :value="item.value"
+          >
+          </el-option>
+          <i slot="prefix" class="el-icon-mobile"></i>
+        </el-select>
       </el-form-item>
       <!-- <el-form-item prop="code" v-if="captchaEnabled">
         <el-input
@@ -88,6 +104,7 @@
 import { getCodeImg } from "@/api/login";
 import Cookies from "js-cookie";
 import { encrypt, decrypt } from "@/utils/jsencrypt";
+import { getorganization } from "@/api/AiCentre/index";
 
 export default {
   name: "Login",
@@ -99,8 +116,10 @@
         password: "",
         rememberMe: false,
         code: "",
-        uuid: "",
+        orgid: "H41010500003",
       },
+      options: [
+      ],
       loginRules: {
         username: [
           { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勮处鍙�" },
@@ -108,7 +127,7 @@
         password: [
           { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勫瘑鐮�" },
         ],
-        // code: [{ required: true, trigger: "change", message: "璇疯緭鍏ラ獙璇佺爜" }],
+        orgid: [{ required: true, trigger: "blur", message: "璇烽�夋嫨闄㈠尯" }],
       },
       loading: false,
       // 楠岃瘉鐮佸紑鍏�
@@ -127,18 +146,31 @@
     },
   },
   created() {
+    this.getorganization();
     this.getCode();
     this.getCookie();
+    // if (localStorage.getItem('orgid')) {
+    //   this.loginForm.orgid = localStorage.getItem('orgid');
+    // }
   },
   methods: {
     getCode() {
       getCodeImg().then((res) => {
-        console.log(res);
         this.captchaEnabled =
           res.captchaEnabled === undefined ? true : res.captchaEnabled;
         if (this.captchaEnabled) {
           this.codeUrl = "data:image/gif;base64," + res.img;
           this.loginForm.uuid = res.uuid;
+        }
+      });
+    },
+    getorganization() {
+      getorganization().then((res) => {
+        if (res.code == 200) {
+          this.options = res.rows.map((item) => ({
+            value: item.orgid,
+            label: item.organizationName,
+          }));
         }
       });
     },
@@ -154,36 +186,56 @@
       };
     },
     handleLogin() {
-      this.$refs.loginForm.validate((valid) => {
-        if (valid) {
-          this.loading = true;
-          if (this.loginForm.rememberMe) {
-            Cookies.set("username", this.loginForm.username, { expires: 30 });
-            Cookies.set("password", encrypt(this.loginForm.password), {
-              expires: 30,
-            });
-            Cookies.set("rememberMe", this.loginForm.rememberMe, {
-              expires: 30,
-            });
-          } else {
-            Cookies.remove("username");
-            Cookies.remove("password");
-            Cookies.remove("rememberMe");
-          }
-          this.$store
-            .dispatch("Login", this.loginForm)
-            .then(() => {
-              this.$router.push({ path: this.redirect || "/" }).catch(() => {});
-            })
-            .catch(() => {
-              this.loading = false;
-              if (this.captchaEnabled) {
-                this.getCode();
-              }
-            });
+  this.$refs.loginForm.validate((valid) => {
+    if (valid) {
+      this.loading = true;
+
+      if (this.loginForm.rememberMe) {
+        Cookies.set("username", this.loginForm.username, { expires: 30 });
+        Cookies.set("password", encrypt(this.loginForm.password), {
+          expires: 30,
+        });
+        Cookies.set("rememberMe", this.loginForm.rememberMe, {
+          expires: 30,
+        });
+      } else {
+        Cookies.remove("username");
+        Cookies.remove("password");
+        Cookies.remove("rememberMe");
+      }
+
+      // 鍔ㄦ�佽缃� campusid 鍙傛暟
+      const selectedOrg = this.options.find(item => item.value === this.loginForm.orgid);
+      if (selectedOrg) {
+        if (selectedOrg.label.includes('婀栨花')) {
+          this.loginForm.campusid = 1;
+        } else if (selectedOrg.label.includes('鍚村北')) {
+          this.loginForm.campusid = 2;
+        } else {
+          this.loginForm.campusid = 1; // 榛樿鍊兼垨鍏朵粬澶勭悊
         }
-      });
-    },
+      }
+
+      this.$store
+        .dispatch("Login", this.loginForm)
+        .then((res) => {
+          if (this.loginForm.username == "admin") {
+            this.$router.push({ path: "/index" }).catch(() => {});
+          } else {
+            this.$router
+              .push({ path: "/followvisit/discharge" })
+              .catch(() => {});
+          }
+        })
+        .catch(() => {
+          this.loading = false;
+          if (this.captchaEnabled) {
+            this.getCode();
+          }
+        });
+    }
+  });
+}
   },
 };
 </script>
@@ -194,17 +246,17 @@
   justify-content: center;
   align-items: center;
   height: 100%;
-  overflow:hidden !important;
+  overflow: hidden !important;
   background-position: center center;
 
   /* 鑳屾櫙鍥句笉骞抽摵 */
-background-repeat: no-repeat;
-/* 褰撳唴瀹归珮搴﹀ぇ浜庡浘鐗囬珮搴︽椂锛岃儗鏅浘鍍忕殑浣嶇疆鐩稿浜巚iewport鍥哄畾 */
-background-attachment: fixed;
-/* 璁╄儗鏅浘鍩轰簬瀹瑰櫒澶у皬浼哥缉 */
-background-size: cover;
-/* 璁剧疆鑳屾櫙棰滆壊锛岃儗鏅浘鍔犺浇杩囩▼涓細鏄剧ず鑳屾櫙鑹� */
-background-color: #464646;
+  background-repeat: no-repeat;
+  /* 褰撳唴瀹归珮搴﹀ぇ浜庡浘鐗囬珮搴︽椂锛岃儗鏅浘鍍忕殑浣嶇疆鐩稿浜巚iewport鍥哄畾 */
+  background-attachment: fixed;
+  /* 璁╄儗鏅浘鍩轰簬瀹瑰櫒澶у皬浼哥缉 */
+  background-size: cover;
+  /* 璁剧疆鑳屾櫙棰滆壊锛岃儗鏅浘鍔犺浇杩囩▼涓細鏄剧ず鑳屾櫙鑹� */
+  background-color: #464646;
   background-image: url("../assets/images/login-background.jpg");
   background-size: cover;
 }
@@ -257,6 +309,7 @@
   font-size: 12px;
   letter-spacing: 1px;
 }
+
 .login-code-img {
   height: 38px;
 }

--
Gitblit v1.9.3