From e50eb636e24007ac32b8a6cec18cad13bbfcaf3b Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 18 五月 2026 16:03:58 +0800
Subject: [PATCH] 浪潮 1.权限修改
---
src/views/login.vue | 793 ++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 538 insertions(+), 255 deletions(-)
diff --git a/src/views/login.vue b/src/views/login.vue
index 960f097..2be6a91 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,255 +1,538 @@
-<template>
- <div class="login">
- <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
- <h3 class="title">{{ title }}</h3>
- <el-divider />
- <el-form-item prop="username">
- <el-input
- v-model="loginForm.username"
- type="text"
- size="large"
- auto-complete="off"
- placeholder="璐﹀彿"
- @input="getUserLoginFacotryList"
- >
- <template #prefix><el-icon><User /></el-icon></template>
- </el-input>
- </el-form-item>
- <el-form-item prop="password">
- <el-input
- v-model="loginForm.password"
- type="password"
- size="large"
- auto-complete="off"
- placeholder="瀵嗙爜"
- show-password
- @keyup.enter="handleLogin"
- >
- <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
- </el-input>
- </el-form-item>
- <el-form-item prop="currentFatoryId">
- <el-select v-model="loginForm.currentFatoryId" placeholder="璇烽�夋嫨鍏徃" >
- <el-option v-for="item in factoryList" :key="item.deptId" :label="item.deptName" :value="item.deptId" />
- </el-select>
- </el-form-item>
-<!-- <el-form-item prop="code" v-if="captchaEnabled">-->
-<!-- <el-input-->
-<!-- v-model="loginForm.code"-->
-<!-- size="large"-->
-<!-- auto-complete="off"-->
-<!-- placeholder="楠岃瘉鐮�"-->
-<!-- style="width: 63%"-->
-<!-- @keyup.enter="handleLogin"-->
-<!-- >-->
-<!-- <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>-->
-<!-- </el-input>-->
-<!-- <div class="login-code">-->
-<!-- <img :src="codeUrl" @click="getCode" class="login-code-img"/>-->
-<!-- </div>-->
-<!-- </el-form-item>-->
- <el-form-item style="width:100%;">
- <el-button
- :loading="loading"
- size="large"
- type="primary"
- style="width:100%;"
- @click.prevent="handleLogin"
- >
- <span v-if="!loading">鐧� 褰�</span>
- <span v-else>鐧� 褰� 涓�...</span>
- </el-button>
- <div style="float: right;" v-if="register">
- <router-link class="link-type" :to="'/register'">绔嬪嵆娉ㄥ唽</router-link>
- </div>
- </el-form-item>
- <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">璁颁綇瀵嗙爜</el-checkbox>
- </el-form>
- <!-- 搴曢儴 -->
-<!-- <div class="el-login-footer">-->
-<!-- <span>Copyright 漏 2018-2025 ruoyi.vip All Rights Reserved.</span>-->
-<!-- </div>-->
- </div>
-</template>
-
-<script setup>
-import {getCodeImg} from "@/api/login"
-import Cookies from "js-cookie"
-import { encrypt, decrypt } from "@/utils/jsencrypt"
-import useUserStore from '@/store/modules/user'
-import {userLoginFacotryList} from "@/api/system/user.js"
-
-const title = import.meta.env.VITE_APP_TITLE
-const userStore = useUserStore()
-const route = useRoute()
-const router = useRouter()
-const { proxy } = getCurrentInstance()
-
-const loginForm = ref({
- username: "",
- password: "",
- rememberMe: false,
- currentFatoryId:'',
-})
-
-const loginRules = {
- username: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勮处鍙�" }],
- password: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勫瘑鐮�" }],
- // code: [{ required: true, trigger: "change", message: "璇疯緭鍏ラ獙璇佺爜" }]
-}
-
-const codeUrl = ref("")
-const loading = ref(false)
-// 楠岃瘉鐮佸紑鍏�
-const captchaEnabled = ref(true)
-// 娉ㄥ唽寮�鍏�
-const register = ref(false)
-const redirect = ref(undefined)
-
-const factoryList = ref([])
-const currentFatoryId = ref('')
-
-watch(route, (newRoute) => {
- redirect.value = newRoute.query && newRoute.query.redirect
-}, { immediate: true })
-
-function handleLogin() {
- proxy.$refs.loginRef.validate(valid => {
- if (valid) {
- loading.value = true
- // 鍕鹃�変簡闇�瑕佽浣忓瘑鐮佽缃湪 cookie 涓缃浣忕敤鎴峰悕鍜屽瘑鐮�
- Cookies.set("username", loginForm.value.username, { expires: 30 })
- Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 })
- Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 })
- userStore.loginCheckFactory(loginForm.value).then(res => {
- const query = route.query
- const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
- if (cur !== "redirect") {
- acc[cur] = query[cur]
- }
- return acc
- }, {})
- router.push({ path: redirect.value || "/", query: otherQueryParams })
- }).catch(() => {
- loading.value = false
- // 閲嶆柊鑾峰彇楠岃瘉鐮�
- if (captchaEnabled.value) {
- getCode()
- }
- })
- }
- })
-}
-
-function getCode() {
- getCodeImg().then(res => {
- captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
- if (captchaEnabled.value) {
- codeUrl.value = "data:image/gif;base64," + res.img
- loginForm.value.uuid = res.uuid
- }
- })
-}
-
-function getCookie() {
- const username = Cookies.get("username")
- const password = Cookies.get("password")
- const rememberMe = Cookies.get("rememberMe")
- loginForm.value = {
- username: username === undefined ? loginForm.value.username : username,
- password: password === undefined ? loginForm.value.password : decrypt(password),
- rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
- }
-}
-
-function getUserLoginFacotryList() {
- if(loginForm.value.username){
- userLoginFacotryList({userName:loginForm.value.username}).then(res => {
- console.log('res', res)
- factoryList.value = res.data
- })
- }else {
- factoryList.value = []
- }
-}
-
-getCode()
-getCookie()
-getUserLoginFacotryList()
-</script>
-
-<style lang='scss' scoped>
-.login {
- height: 100%;
- background-image: url("../assets/indexViews/JZYJView.png");
- background-size: cover;
- position: relative;
-}
-.title {
- margin: 20px auto 14px auto;
- text-align: center;
- color: #2C51D9;
- font-size: 28px;
- font-weight: 700;
-}
-
-.login-form {
- position: absolute;
- top: 50%;
- right: 15%;
- transform: translate(0, -50%);
- border-radius: 6px;
- background: #ffffff;
- width: 420px;
- height: 500px;
- padding: 40px;
- z-index: 1;
- box-shadow: 0 0 5px 1px #ccc;
- .el-input {
- height: 40px;
- input {
- height: 40px;
- }
- }
- .input-icon {
- height: 39px;
- width: 14px;
- margin-left: 0px;
- }
-}
-.login-tip {
- font-size: 13px;
- text-align: center;
- color: #bfbfbf;
-}
-.login-code {
- width: 33%;
- height: 40px;
- float: right;
- img {
- cursor: pointer;
- vertical-align: middle;
- }
-}
-.el-login-footer {
- height: 40px;
- line-height: 40px;
- position: fixed;
- bottom: 0;
- width: 100%;
- text-align: center;
- color: #fff;
- font-family: Arial;
- font-size: 12px;
- letter-spacing: 1px;
-}
-.login-code-img {
- height: 40px;
- padding-left: 12px;
-}
-:deep() {
- .el-form-item--default {
- margin-bottom: 36px;
- }
-}
-</style>
+<template>
+ <div class="login-page">
+ <!-- 宸︿晶鎻掔敾鍖� -->
+ <div class="illustration-side">
+ <div class="illustration-content">
+ <div class="scene">
+ <!-- 浠撳簱寤虹瓚 -->
+ <div class="warehouse">
+ <div class="building">
+ <div class="roof"></div>
+ <div class="wall">
+ <div class="window"></div>
+ <div class="window"></div>
+ <div class="window"></div>
+ </div>
+ <div class="door"></div>
+ </div>
+ </div>
+ <!-- 鍗¤溅 -->
+ <div class="truck">
+ <div class="truck-body"></div>
+ <div class="truck-cab"></div>
+ <div class="wheel wheel-1"></div>
+ <div class="wheel wheel-2"></div>
+ </div>
+ <!-- 绠卞瓙 -->
+ <div class="boxes">
+ <div class="box box-1"></div>
+ <div class="box box-2"></div>
+ <div class="box box-3"></div>
+ </div>
+ <!-- 瑁呴グ鍏冪礌 -->
+ <div class="decor-circle c1"></div>
+ <div class="decor-circle c2"></div>
+ <div class="decor-circle c3"></div>
+ </div>
+ <h2>鏅鸿兘渚涘簲閾剧鐞�</h2>
+ <p>楂樻晥鍗忓悓 路 绮惧噯绠℃帶 路 鏁版嵁椹卞姩</p>
+ </div>
+ </div>
+
+ <!-- 鍙充晶鐧诲綍鍖� -->
+ <div class="login-side">
+ <div class="login-form-box">
+ <div class="form-header">
+ <h3>娆㈣繋鍥炴潵</h3>
+ <p>鐧诲綍鎮ㄧ殑璐﹀彿缁х画浣跨敤</p>
+ </div>
+
+ <el-form ref="loginRef" :model="loginForm" :rules="loginRules">
+ <el-form-item prop="username">
+ <el-input
+ v-model="loginForm.username"
+ type="text"
+ size="large"
+ auto-complete="off"
+ placeholder="鐢ㄦ埛鍚�"
+ class="login-input"
+ >
+ <template #prefix>
+ <el-icon><User /></el-icon>
+ </template>
+ </el-input>
+ </el-form-item>
+
+ <el-form-item prop="password">
+ <el-input
+ v-model="loginForm.password"
+ type="password"
+ size="large"
+ auto-complete="off"
+ placeholder="瀵嗙爜"
+ show-password
+ class="login-input"
+ @keyup.enter="handleLogin"
+ >
+ <template #prefix>
+ <el-icon><Lock /></el-icon>
+ </template>
+ </el-input>
+ </el-form-item>
+
+ <div class="form-options">
+ <el-checkbox v-model="loginForm.rememberMe">璁颁綇鎴�</el-checkbox>
+ <a href="#" class="forgot-link">蹇樿瀵嗙爜?</a>
+ </div>
+
+ <el-button
+ :loading="loading"
+ size="large"
+ type="primary"
+ class="login-btn"
+ @click.prevent="handleLogin"
+ >
+ <span v-if="!loading">鐧诲綍</span>
+ <span v-else>鐧诲綍涓�...</span>
+ </el-button>
+ </el-form>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script setup>
+import { getCodeImg } from "@/api/login"
+import Cookies from "js-cookie"
+import { encrypt, decrypt } from "@/utils/jsencrypt"
+import useUserStore from "@/store/modules/user"
+import { User, Lock } from '@element-plus/icons-vue'
+
+const userStore = useUserStore()
+const route = useRoute()
+const router = useRouter()
+const { proxy } = getCurrentInstance()
+
+const loginForm = ref({
+ username: "",
+ password: "",
+ rememberMe: false,
+})
+
+const loginRules = {
+ username: [{ required: true, trigger: "blur", message: "璇疯緭鍏ョ敤鎴峰悕" }],
+ password: [{ required: true, trigger: "blur", message: "璇疯緭鍏ュ瘑鐮�" }],
+}
+
+const loading = ref(false)
+const captchaEnabled = ref(true)
+const redirect = ref(undefined)
+
+watch(
+ route,
+ (newRoute) => {
+ redirect.value = newRoute.query && newRoute.query.redirect
+ },
+ { immediate: true }
+)
+
+function handleLogin() {
+ proxy.$refs.loginRef.validate((valid) => {
+ if (valid) {
+ loading.value = true
+ Cookies.set("username", loginForm.value.username, { expires: 30 })
+ Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 })
+ Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 })
+ userStore
+ .loginCheckFactory(loginForm.value)
+ .then(() => {
+ const query = route.query
+ const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
+ if (cur !== "redirect") {
+ acc[cur] = query[cur]
+ }
+ return acc
+ }, {})
+ router.push({ path: redirect.value || "/", query: otherQueryParams })
+ })
+ .catch(() => {
+ loading.value = false
+ if (captchaEnabled.value) {
+ getCode()
+ }
+ })
+ }
+ })
+}
+
+function getCode() {
+ getCodeImg().then((res) => {
+ captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
+ if (captchaEnabled.value) {
+ loginForm.value.uuid = res.uuid
+ }
+ })
+}
+
+function getCookie() {
+ const username = Cookies.get("username")
+ const password = Cookies.get("password")
+ const rememberMe = Cookies.get("rememberMe")
+ loginForm.value = {
+ username: username === undefined ? loginForm.value.username : username,
+ password: password === undefined ? loginForm.value.password : decrypt(password),
+ rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
+ }
+}
+
+getCode()
+getCookie()
+</script>
+
+<style lang="scss" scoped>
+// 涓婚鑹插彉閲�
+$primary: #1f7a72;
+$primary-light: #2a9d8f;
+$primary-lighter: #3abbae;
+$primary-lightest: #e8f5f3;
+
+.login-page {
+ min-height: 100vh;
+ display: flex;
+}
+
+/* 宸︿晶鎻掔敾鍖� */
+.illustration-side {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: linear-gradient(135deg, $primary-lightest 0%, #d4edea 100%);
+ padding: 60px;
+}
+
+.illustration-content {
+ text-align: center;
+
+ h2 {
+ font-size: 32px;
+ font-weight: 600;
+ color: $primary;
+ margin: 40px 0 12px 0;
+ }
+
+ p {
+ font-size: 16px;
+ color: $primary-light;
+ margin: 0;
+ }
+}
+
+/* CSS 鎻掔敾鍦烘櫙 */
+.scene {
+ position: relative;
+ width: 320px;
+ height: 240px;
+ margin: 0 auto;
+}
+
+/* 浠撳簱 */
+.warehouse {
+ position: absolute;
+ bottom: 40px;
+ left: 50%;
+ transform: translateX(-50%);
+}
+
+.building {
+ position: relative;
+ width: 140px;
+ height: 100px;
+}
+
+.roof {
+ position: absolute;
+ top: 0;
+ left: 50%;
+ transform: translateX(-50%);
+ width: 0;
+ height: 0;
+ border-left: 75px solid transparent;
+ border-right: 75px solid transparent;
+ border-bottom: 40px solid $primary;
+}
+
+.wall {
+ position: absolute;
+ bottom: 0;
+ left: 50%;
+ transform: translateX(-50%);
+ width: 120px;
+ height: 70px;
+ background: #fff;
+ border: 3px solid $primary;
+ border-radius: 0 0 4px 4px;
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ padding: 0 10px;
+}
+
+.window {
+ width: 20px;
+ height: 30px;
+ background: $primary-lightest;
+ border-radius: 2px;
+}
+
+.door {
+ position: absolute;
+ bottom: 0;
+ left: 50%;
+ transform: translateX(-50%);
+ width: 30px;
+ height: 45px;
+ background: $primary-light;
+ border-radius: 4px 4px 0 0;
+}
+
+/* 鍗¤溅 */
+.truck {
+ position: absolute;
+ bottom: 40px;
+ right: 20px;
+ width: 100px;
+ height: 50px;
+}
+
+.truck-body {
+ position: absolute;
+ top: 10px;
+ left: 0;
+ width: 60px;
+ height: 35px;
+ background: $primary;
+ border-radius: 4px;
+}
+
+.truck-cab {
+ position: absolute;
+ top: 18px;
+ right: 0;
+ width: 35px;
+ height: 27px;
+ background: $primary-light;
+ border-radius: 0 8px 4px 0;
+}
+
+.wheel {
+ position: absolute;
+ bottom: 0;
+ width: 16px;
+ height: 16px;
+ background: $primary;
+ border-radius: 50%;
+ border: 3px solid $primary-light;
+}
+
+.wheel-1 {
+ left: 12px;
+}
+
+.wheel-2 {
+ right: 8px;
+}
+
+/* 绠卞瓙 */
+.boxes {
+ position: absolute;
+ bottom: 40px;
+ left: 30px;
+}
+
+.box {
+ position: absolute;
+ border-radius: 3px;
+}
+
+.box-1 {
+ width: 35px;
+ height: 35px;
+ background: $primary;
+ bottom: 0;
+ left: 0;
+}
+
+.box-2 {
+ width: 30px;
+ height: 30px;
+ background: $primary-light;
+ bottom: 0;
+ left: 40px;
+}
+
+.box-3 {
+ width: 28px;
+ height: 28px;
+ background: $primary-lighter;
+ bottom: 38px;
+ left: 5px;
+}
+
+/* 瑁呴グ鍦嗗湀 */
+.decor-circle {
+ position: absolute;
+ border-radius: 50%;
+ opacity: 0.3;
+}
+
+.c1 {
+ width: 80px;
+ height: 80px;
+ background: $primary;
+ top: 20px;
+ left: 30px;
+}
+
+.c2 {
+ width: 50px;
+ height: 50px;
+ background: $primary-light;
+ top: 60px;
+ right: 40px;
+}
+
+.c3 {
+ width: 35px;
+ height: 35px;
+ background: $primary-lighter;
+ bottom: 100px;
+ left: 20px;
+}
+
+/* 鍙充晶鐧诲綍鍖� */
+.login-side {
+ width: 460px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #fff;
+ padding: 40px;
+}
+
+.login-form-box {
+ width: 100%;
+ max-width: 340px;
+}
+
+.form-header {
+ margin-bottom: 32px;
+
+ h3 {
+ font-size: 26px;
+ font-weight: 600;
+ color: $primary;
+ margin: 0 0 8px 0;
+ }
+
+ p {
+ font-size: 14px;
+ color: $primary-light;
+ margin: 0;
+ }
+}
+
+:deep(.login-input .el-input__wrapper) {
+ background: $primary-lightest;
+ border: 1px solid #d0e5e2;
+ border-radius: 10px;
+ box-shadow: none;
+ padding: 0 16px;
+ height: 48px;
+
+ &:hover {
+ border-color: $primary-light;
+ }
+
+ &:focus-within {
+ border-color: $primary;
+ background: #fff;
+ box-shadow: 0 0 0 3px rgba(31, 122, 114, 0.1);
+ }
+}
+
+:deep(.login-input .el-input__inner) {
+ height: 48px;
+ font-size: 15px;
+ color: $primary;
+
+ &::placeholder {
+ color: #8fb5af;
+ }
+}
+
+:deep(.login-input .el-input__prefix) {
+ color: $primary-light;
+ margin-right: 10px;
+}
+
+.form-options {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin: 16px 0 24px;
+
+ :deep(.el-checkbox__label) {
+ font-size: 14px;
+ color: $primary-light;
+ }
+
+ :deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
+ background-color: $primary;
+ border-color: $primary;
+ }
+
+ :deep(.el-checkbox__input.is-checked + .el-checkbox__label) {
+ color: $primary;
+ }
+
+ .forgot-link {
+ font-size: 14px;
+ color: $primary;
+ text-decoration: none;
+ font-weight: 500;
+
+ &:hover {
+ text-decoration: underline;
+ }
+ }
+}
+
+.login-btn {
+ width: 100%;
+ height: 48px;
+ border-radius: 10px;
+ font-size: 16px;
+ font-weight: 500;
+ background: linear-gradient(135deg, $primary 0%, $primary-light 100%);
+ border: none;
+ transition: all 0.2s;
+
+ &:hover {
+ opacity: 0.9;
+ transform: translateY(-1px);
+ box-shadow: 0 6px 20px rgba(31, 122, 114, 0.3);
+ }
+}
+
+/* 鍝嶅簲寮� */
+@media (max-width: 900px) {
+ .illustration-side {
+ display: none;
+ }
+
+ .login-side {
+ width: 100%;
+ }
+}
+</style>
--
Gitblit v1.9.3