| | |
| | | code: "", |
| | | orgid: "H41010500003", |
| | | }, |
| | | options: [ |
| | | ], |
| | | options: [], |
| | | loginRules: { |
| | | username: [ |
| | | { required: true, trigger: "blur", message: "请输入您的账号" }, |
| | |
| | | }); |
| | | }, |
| | | getorganization() { |
| | | getorganization().then((res) => { |
| | | getorganization({ pageSize: 30 }).then((res) => { |
| | | if (res.code == 200) { |
| | | this.options = res.rows.map((item) => ({ |
| | | value: item.orgid, |
| | |
| | | }; |
| | | }, |
| | | handleLogin() { |
| | | this.$refs.loginForm.validate((valid) => { |
| | | if (valid) { |
| | | this.loading = true; |
| | | 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(() => {}); |
| | | 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 { |
| | | this.$router |
| | | .push({ path: "/followvisit/discharge" }) |
| | | .catch(() => {}); |
| | | Cookies.remove("username"); |
| | | Cookies.remove("password"); |
| | | Cookies.remove("rememberMe"); |
| | | } |
| | | }) |
| | | .catch(() => { |
| | | this.loading = false; |
| | | if (this.captchaEnabled) { |
| | | this.getCode(); |
| | | |
| | | // 动态设置 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> |