gaoluyang
4 天以前 2f3b2e7a2acd7f8962635367851dec28f81d27ab
src/views/login.vue
@@ -10,7 +10,7 @@
          size="large"
          auto-complete="off"
          placeholder="账号"
          @input="deptListSearch"
          @input="getUserLoginFacotryList"
        >
          <template #prefix><el-icon><User /></el-icon></template>
        </el-input>
@@ -77,7 +77,7 @@
import Cookies from "js-cookie"
import { encrypt, decrypt } from "@/utils/jsencrypt"
import useUserStore from '@/store/modules/user'
import {userDeptList} from "@/api/system/user.js"
import {userLoginFacotryList} from "@/api/system/user.js"
const title = import.meta.env.VITE_APP_TITLE
const userStore = useUserStore()
@@ -86,8 +86,8 @@
const { proxy } = getCurrentInstance()
const loginForm = ref({
  username: "admin",
  password: "admin123",
  username: "",
  password: "",
  rememberMe: false,
  currentFatoryId:'',
})
@@ -118,16 +118,9 @@
    if (valid) {
      loading.value = true
      // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
      if (loginForm.value.rememberMe) {
        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 })
      } else {
        // 否则移除
        Cookies.remove("username")
        Cookies.remove("password")
        Cookies.remove("rememberMe")
      }
      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) => {
@@ -169,20 +162,20 @@
  }
}
function deptListSearch() {
function getUserLoginFacotryList() {
  if(loginForm.value.username){
    userDeptList({userName:loginForm.value.username}).then(res => {
    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>
@@ -211,6 +204,7 @@
  height: 500px;
  padding: 40px;
  z-index: 1;
   box-shadow: 0 0 5px 1px #ccc;
  .el-input {
    height: 40px;
    input {