烟花爆竹批发企业仓库安全风险监测前端
zhouwx
2025-04-03 15c3a0082b51422801f1985e5d9e68eef76c3039
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<template>
  <el-row class="login-panel">
    <el-col :sm="24" :md="12" class="login-img">
      烟花爆竹批发企业<br/>仓库安全风险监测预警系统
    </el-col>
    <el-col :sm="24" :md="12" class="login-box">
      <div class="login-card">
        <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
          <h3 class="title">登录系统</h3>
          <el-form-item prop="username">
            <el-input
              v-model="loginForm.username"
              type="text"
              size="large"
              auto-complete="off"
              placeholder="账号"
            >
              <template #prefix><svg-icon icon-class="user" class="el-input__icon input-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="密码"
              @keyup.enter="handleLogin"
              show-password
            >
              <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
            </el-input>
          </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>-->
          <div style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 25px">
            <div class="btn-cont">
              <button class="login-btn" @click.prevent="handleLogin" v-preReClick>
                <span v-if="!loading">登 录</span>
                <span v-else>登 录 中...</span>
              </button>
            </div>
  <!--          <div v-if="isRegister">-->
  <!--            <el-button link type="primary" @click="openRegist">立即注册</el-button>-->
  <!--          </div>-->
          </div>
        </el-form>
      </div>
    </el-col>
  </el-row>
<!--  <register ref="regRef"/>-->
</template>
 
<script setup>
import {onMounted, ref, watch, defineAsyncComponent, nextTick, computed} from "vue"
import menu from "@/layout/components/Sidebar/menu";
import { getCodeImg } from "@/api/login";
import {getSettings} from "@/api/backManage/evaluate";
import Cookies from "js-cookie";
import { encrypt, decrypt } from "@/utils/jsencrypt";
import useUserStore from '@/store/modules/user'
import { Register } from "@/layout/components";
import { Base64 } from 'js-base64'
// import ExpertForm from "../safetyReview/expertManage/applyRecords/components/expertForm";
import usePermissionStore from '@/store/modules/permission'
import {ElMessage} from "element-plus";
const permissionStore = usePermissionStore()
const sidebarRouters = ref([])
const userStore = useUserStore()
const route = useRoute();
const router = useRouter();
const { proxy } = getCurrentInstance();
 
const loginForm = ref({
  username: "",
  password: "",
  code: "",
  uuid: ""
});
 
const loginRules = {
  username: [{ required: true, trigger: "blur", message: "请输入您的账号" }],
  password: [{ required: true, trigger: "blur", message: "请输入您的密码" }],
};
 
const codeUrl = ref("");
const loading = ref(false);
const regRef = ref(null)
// 验证码开关
const captchaEnabled = ref(true);
const applyStatus = ref('1')
// 注册开关
const isRegister = ref(true);
const redirect = ref(undefined);
 
onMounted(()=>{
 
})
 
const openRegist = ()=>{
  regRef.value.openApply();
}
 
watch(route, (newRoute) => {
    redirect.value = newRoute.query && newRoute.query.redirect;
}, { immediate: true });
 
 
const expertFormRef = ref()
 
const getApplyStatus = async ()=>{
  const res = await getSettings()
  if(res.code == 200){
    return res.data
  }else{
    ElMessage.warning(res.msg)
    return '0'
  }
}
 
function handleLogin() {
  proxy.$refs.loginRef.validate(valid => {
    if (valid) {
      loading.value = true;
      // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
      // if (loginForm.value.rememberMe) {
        Cookies.set("username", loginForm.value.username, { expires: 30 });
        Cookies.set("password", loginForm.value.password, { expires: 30 });
        // Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 });
      //   Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 });
      // } else {
        // 否则移除
      //   Cookies.remove("username");
      //   Cookies.remove("password");
      //   Cookies.remove("rememberMe");
      // }
      // 调用action的登录方法
      // loginForm.value.password = Base64.encode(loginForm.value.password)
        const param = {
            username: loginForm.value.username,
            password: loginForm.value.password,
        }
      userStore.login(param).then(() => {
        // const query = route.query;
        // const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
        //   if (cur !== "redirect") {
        //     acc[cur] = query[cur];
        //   }
        //   return acc;
        // }, {});
        const userInfo = JSON.parse(Cookies.get('userInfo'))
        sidebarRouters.value =  menu.adminMenu
        Cookies.set('routers',JSON.stringify(sidebarRouters.value))
        let path = ""
        if(sidebarRouters.value[0].children && sidebarRouters.value[0].children.length > 0){
          path = sidebarRouters.value[0].path + '/'+ sidebarRouters.value[0].children[0].path
        }else {
          path = sidebarRouters.value[0].path
        }
        router.push({
          path: path
        })
      }).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")
  loginForm.value = {
    username: username === undefined ? loginForm.value.username : username,
    password: password === undefined ? loginForm.value.password : decrypt(password),
  };
}
 
// getCode();
// getCookie();
</script>
 
<style lang='scss' scoped>
@font-face {
  font-family: "AliMa";
  src: url("@/assets/styles/font/AlimamaShuHeiTi-Bold.ttf");
  font-style: normal;
  font-weight: normal;
}
.login-panel{
  width: 100%;
  height: 100%;
  background: url("@/assets/images/bg.jpg") no-repeat center;
  background-size: cover;
  justify-content: center;
  align-items: center;
 
}
.login-img{
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'AliMa';
  color: #fff;
  font-size: clamp(3.125rem, 2.411rem + 1.12vw, 3.75rem);
  text-align: center;
  line-height: 1.5;
  transform: translateY(-80px);
  letter-spacing: 2px;
  text-shadow: -10px 10px 20px rgba(0,0,0,.4);
}
.login-box{
  display: flex;
  justify-content: center;
  align-items: center;
  transform: translateY(-40px);
  .login-card{
    width: 500px;
    padding: 30px;
    border-radius: 16px;
    background-color: rgba(255,255,255,.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,.4);
    max-width: 100%;
    box-sizing: border-box;
    box-shadow: 0 10px 20px rgba(0,0,0,.05);
  }
  .login-form {
    width: 100%;
    box-sizing: border-box;
 
    .title{
      margin: 0 0 30px;
      text-align: center;
      color: #fff
    }
 
    .el-form-item{
      margin-bottom: 30px;
    }
 
    .el-input {
      height: 48px;
      input {
        height: 48px;
      }
    }
    .input-icon {
      height: 39px;
      width: 14px;
      margin-left: 0px;
    }
  }
  .other-btns{
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
}
 
.login-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.login-code {
  width: 33%;
  height: 48px;
  float: right;
  .login-code-img {
    display: inline-block;
    width: 100%;
    padding-left: 12px;
    cursor: pointer;
    vertical-align: middle;
  }
}
 
.el-form-item--default{
  margin-bottom: 15px;
}
 
::v-deep(.el-form-item__content){
  display: flex;
  justify-content: space-between;
}
 
.login-btn {
  width: 100%;
  font-size: 1.2em;
  padding: 0.6em 0.8em;
  border-radius: 0.5em;
  border: none;
  background-color: #2563EB;
  color: #fff;
  cursor: pointer;
  box-shadow: 2px 2px 3px #000000b4;
}
 
.btn-cont {
  width: 100%;
  position: relative;
  padding: 3px;
  background: #03a9f4;
  border-radius: 0.9em;
  transition: all 0.3s ease;
}
 
.btn-cont::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  border-radius: 0.9em;
  z-index: -10;
  filter: blur(0);
  transition: filter 0.4s ease;
}
 
.btn-cont:hover::before {
  background: #2559c9;
  filter: blur(0.6em);
}
.btn-cont:active::before {
  filter: blur(0.1em);
}
 
</style>