buzhi пре 1 година
родитељ
комит
bf08ae6da2
1 измењених фајлова са 116 додато и 34 уклоњено
  1. 116 34
      src/views/Login/Login.vue

+ 116 - 34
src/views/Login/Login.vue

@@ -1,55 +1,92 @@
1
 <template>
1
 <template>
2
   <div class="content flex space-x-4">
2
   <div class="content flex space-x-4">
3
     <div class="flex-1 basis-1/2 flex items-center justify-center">
3
     <div class="flex-1 basis-1/2 flex items-center justify-center">
4
-
5
       <div
4
       <div
6
-        class="w-[50%] h-[50%] min-w-[450px] min-h-[450px] pl-120px  font-size-34px  border-rd-[12px]">
7
-        <img alt="" class="w-[400px] h-50px" src="@/assets/system/logo.png"/>
5
+        class="w-[50%] h-[50%] min-w-[450px] min-h-[450px] pl-120px font-size-34px border-rd-[12px]"
6
+      >
7
+        <img alt="" class="w-[400px] h-50px" src="@/assets/system/logo.png" />
8
       </div>
8
       </div>
9
     </div>
9
     </div>
10
     <div class="flex-1 basis-1/2 flex items-center justify-center">
10
     <div class="flex-1 basis-1/2 flex items-center justify-center">
11
-      <div
12
-        class="w-[50%]  min-w-[450px]  pl-40px pr-40px font-size-34px bg-[#fff] border-rd-[12px]">
11
+      <div class="w-[50%] min-w-[450px] pl-40px pr-40px font-size-34px bg-[#fff] border-rd-[12px]">
13
         <div
12
         <div
14
-          class="w-full lh-130px h-[25%] "
15
-          style="font-family: 'SourceHanSansCN-Medium', '思源黑体' ,'黑体',serif">
13
+          class="w-full lh-130px h-[25%]"
14
+          style="font-family: 'SourceHanSansCN-Medium', '思源黑体', '黑体', serif"
15
+        >
16
           欢迎登录
16
           欢迎登录
17
         </div>
17
         </div>
18
         <el-form>
18
         <el-form>
19
           <el-row>
19
           <el-row>
20
-            <el-col :span="24" class="mb-30px">
20
+            <el-col :span="24" class="mb-30px" v-if="isQuick">
21
+              <el-form-item class="mb-0" label="">
22
+                <el-select
23
+                  v-model="selectValue"
24
+                  filterable
25
+                  placeholder="请选择登录账号"
26
+                  class="h-50px"
27
+                  @change="handlerChange"
28
+                  @visible-change="handlerVisibleChange"
29
+                >
30
+                  <template #prefix>
31
+                    <Icon icon="ep:user-filled" />
32
+                  </template>
33
+                  <el-option
34
+                    v-for="item in options"
35
+                    :key="item.value"
36
+                    :label="item.label"
37
+                    :value="item.value"
38
+                  />
39
+                </el-select>
40
+              </el-form-item>
41
+            </el-col>
42
+            <el-col :span="24" class="mb-30px" v-if="!isQuick">
21
               <el-form-item class="mb-0" label="">
43
               <el-form-item class="mb-0" label="">
22
                 <el-input
44
                 <el-input
23
-                  v-model="loginData.loginForm.username" class="h-50px"
24
-                  placeholder="请输入登录账号">
45
+                  v-model="loginData.loginForm.username"
46
+                  class="h-50px"
47
+                  placeholder="请输入登录账号"
48
+                >
25
                   <template #prefix>
49
                   <template #prefix>
26
-
27
-                    <Icon icon="ep:user-filled"/>
50
+                    <Icon icon="ep:user-filled" />
28
                   </template>
51
                   </template>
29
                 </el-input>
52
                 </el-input>
30
               </el-form-item>
53
               </el-form-item>
31
             </el-col>
54
             </el-col>
32
-            <el-col :span="24" class="0px">
55
+            <el-col :span="24" class="0px" v-if="!isQuick">
33
               <el-form-item class="mb-0" label="">
56
               <el-form-item class="mb-0" label="">
34
                 <el-input
57
                 <el-input
35
                   v-model="loginData.loginForm.password"
58
                   v-model="loginData.loginForm.password"
36
                   class="h-50px"
59
                   class="h-50px"
37
-                  placeholder="请输入登录密码" show-password
38
-                  type="password">
60
+                  placeholder="请输入登录密码"
61
+                  show-password
62
+                  type="password"
63
+                >
39
                   <template #prefix>
64
                   <template #prefix>
40
-                    <Icon icon="ep:lock"/>
65
+                    <Icon icon="ep:lock" />
41
                   </template>
66
                   </template>
42
                 </el-input>
67
                 </el-input>
43
               </el-form-item>
68
               </el-form-item>
44
             </el-col>
69
             </el-col>
45
             <el-col :span="24" class="mt-10px">
70
             <el-col :span="24" class="mt-10px">
46
               <div class="float-left font-size-16px color-[#6B6E73]">忘记密码?</div>
71
               <div class="float-left font-size-16px color-[#6B6E73]">忘记密码?</div>
47
-              <div class="float-right font-size-16px color-[#295FBA]">注册</div>
72
+              <!-- <div class="float-right font-size-16px color-[#295FBA]">注册</div> -->
73
+              <div
74
+                class="float-right font-size-16px color-[#295FBA]"
75
+                @click="handClick"
76
+                v-if="!isQuick"
77
+              >
78
+                快速登录
79
+              </div>
80
+              <div class="float-right font-size-16px color-[#295FBA]" @click="handBack" v-else>
81
+                取消快速登录
82
+              </div>
48
             </el-col>
83
             </el-col>
49
             <el-col :span="24" class="mt-45px">
84
             <el-col :span="24" class="mt-45px">
50
               <el-button
85
               <el-button
51
-                class="w-full h-50px! font-size-22px! font-700 " type="primary"
52
-                @click="getCode">
86
+                class="w-full h-50px! font-size-22px! font-700"
87
+                type="primary"
88
+                @click="getCode"
89
+              >
53
                 登 录
90
                 登 录
54
               </el-button>
91
               </el-button>
55
             </el-col>
92
             </el-col>
@@ -71,22 +108,21 @@
71
   </div>
108
   </div>
72
 </template>
109
 </template>
73
 <script lang="ts" setup>
110
 <script lang="ts" setup>
74
-import {ElLoading} from 'element-plus'
75
-import type {RouteLocationNormalizedLoaded} from 'vue-router'
76
-import {useIcon} from '@/hooks/web/useIcon'
111
+import { ElLoading } from 'element-plus'
112
+import type { RouteLocationNormalizedLoaded } from 'vue-router'
113
+import { useIcon } from '@/hooks/web/useIcon'
77
 import * as authUtil from '@/utils/auth'
114
 import * as authUtil from '@/utils/auth'
78
-import {usePermissionStore} from '@/store/modules/permission'
115
+import { usePermissionStore } from '@/store/modules/permission'
79
 import * as LoginApi from '@/api/login'
116
 import * as LoginApi from '@/api/login'
80
-import {LoginStateEnum, useLoginState} from './components/useLogin'
81
-
117
+import { LoginStateEnum, useLoginState } from './components/useLogin'
82
 
118
 
83
-defineOptions({name: 'LoginForm'})
119
+defineOptions({ name: 'LoginForm' })
84
 
120
 
85
-const {t} = useI18n()
121
+const { t } = useI18n()
86
 const message = useMessage()
122
 const message = useMessage()
87
-const iconHouse = useIcon({icon: 'ep:house'})
88
-const {getLoginState} = useLoginState()
89
-const {currentRoute, push} = useRouter()
123
+const iconHouse = useIcon({ icon: 'ep:house' })
124
+const { getLoginState } = useLoginState()
125
+const { currentRoute, push } = useRouter()
90
 const permissionStore = usePermissionStore()
126
 const permissionStore = usePermissionStore()
91
 const redirect = ref<string>('')
127
 const redirect = ref<string>('')
92
 const loginLoading = ref(false)
128
 const loginLoading = ref(false)
@@ -110,6 +146,25 @@ const loginData = reactive({
110
     rememberMe: true // 默认记录我。如果不需要,可手动修改
146
     rememberMe: true // 默认记录我。如果不需要,可手动修改
111
   }
147
   }
112
 })
148
 })
149
+
150
+const options = ref([
151
+  {
152
+    value: 'admin123',
153
+    label: 'admin'
154
+  },
155
+  {
156
+    value: '111111',
157
+    label: 'test111'
158
+  },
159
+  {
160
+    value: '222222',
161
+    label: 'test222'
162
+  }
163
+])
164
+const isQuick = ref(false)
165
+const selectValue = ref('')
166
+const selectLabel = ref('')
167
+
113
 // 获取验证码
168
 // 获取验证码
114
 const getCode = async () => {
169
 const getCode = async () => {
115
   // 情况一,未开启:则直接登录
170
   // 情况一,未开启:则直接登录
@@ -149,7 +204,7 @@ const loading = ref() // ElLoading.service 返回的实例
149
 const handleLogin = async (params: any) => {
204
 const handleLogin = async (params: any) => {
150
   loginLoading.value = true
205
   loginLoading.value = true
151
   try {
206
   try {
152
-    const loginDataLoginForm = {...loginData.loginForm}
207
+    const loginDataLoginForm = { ...loginData.loginForm }
153
     loginDataLoginForm.captchaVerification = params.captchaVerification
208
     loginDataLoginForm.captchaVerification = params.captchaVerification
154
     const res = await LoginApi.login(loginDataLoginForm)
209
     const res = await LoginApi.login(loginDataLoginForm)
155
     console.log(1113)
210
     console.log(1113)
@@ -173,18 +228,39 @@ const handleLogin = async (params: any) => {
173
       redirect.value = '/'
228
       redirect.value = '/'
174
     }
229
     }
175
 
230
 
176
-
177
     // 判断是否为SSO登录
231
     // 判断是否为SSO登录
178
     if (redirect.value.indexOf('sso') !== -1) {
232
     if (redirect.value.indexOf('sso') !== -1) {
179
       window.location.href = window.location.href.replace('/login?redirect=', '')
233
       window.location.href = window.location.href.replace('/login?redirect=', '')
180
     } else {
234
     } else {
181
-      await push({path: redirect.value || permissionStore.addRouters[0].path})
235
+      await push({ path: redirect.value || permissionStore.addRouters[0].path })
182
     }
236
     }
183
   } finally {
237
   } finally {
184
     loginLoading.value = false
238
     loginLoading.value = false
185
     loading.value.close()
239
     loading.value.close()
186
   }
240
   }
187
 }
241
 }
242
+// 快速登录
243
+const handClick = () => {
244
+  isQuick.value = true
245
+}
246
+// 取消快速登录
247
+const handBack = () => {
248
+  isQuick.value = false
249
+}
250
+// 选择登录账号
251
+const handlerChange = (data: any) => {
252
+  selectLabel.value = options.value.filter((item) => item.value == data)[0].label
253
+  loginData.loginForm.username = selectLabel.value
254
+  loginData.loginForm.password = selectValue.value
255
+  isQuick.value = false
256
+}
257
+// 取消选择
258
+const handlerVisibleChange = (data: any) => {
259
+  console.log(data, 'handlerVisibleChange-===')
260
+  if (!data) {
261
+    isQuick.value = false
262
+  }
263
+}
188
 
264
 
189
 watch(
265
 watch(
190
   () => currentRoute.value,
266
   () => currentRoute.value,
@@ -205,12 +281,18 @@ onMounted(() => {
205
 .content {
281
 .content {
206
   width: 100vw;
282
   width: 100vw;
207
   height: 100vh;
283
   height: 100vh;
208
-  background: url("@/assets/system/login-bg.jpg") no-repeat;
284
+  background: url('@/assets/system/login-bg.jpg') no-repeat;
209
   background-size: 100% 100%;
285
   background-size: 100% 100%;
210
 }
286
 }
211
 
287
 
212
 :deep(.el-form-item) {
288
 :deep(.el-form-item) {
213
   margin-bottom: 0;
289
   margin-bottom: 0;
214
 }
290
 }
291
+.float-right {
292
+  cursor: pointer;
293
+}
294
+:deep(.el-select__selection) {
295
+  height: 42px;
296
+}
215
 </style>
297
 </style>
216
 
298