完成登录功能。

This commit is contained in:
2023-04-28 17:46:54 +08:00
parent 6869294c26
commit 0fb93d0ccd
10 changed files with 187 additions and 80 deletions

View File

@@ -1,6 +1,6 @@
/*
* @Author: Kane
* @Date: 2023-03-02 15:48:44
* @Date: 2023-04-27 15:29:10
* @LastEditors: Kane
* @FilePath: /task_schedule/src/test/test.ts
* @Description:
@@ -8,33 +8,6 @@
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import { queryDepartmentArchievement } from "../utils/archievement.js";
import { loginTestCaller } from "./requestTest.js";
interface Cat
{
name: string;
purrs: boolean;
}
interface Dog
{
// name: string;
barks: true;
wags: true;
}
type CatOrDog = Cat | Dog;
const animal: CatOrDog =
{
name: "kaka",
purrs: true,
barks: true,
wags: true,
};
console.log( "test" );
const gainers: Array<string | number> = ["kane", 588,];
const kane = { a: 100, b: 200, };
loginTestCaller();

View File

@@ -23,6 +23,32 @@ interface LoginInfo
password: string;
}
interface LoginCallerInfo
{
telsaler_code: string;
}
interface RequestResult
{
success: boolean;
message: string;
}
interface LoginCallerResult extends RequestResult
{
tele_saler_code: string;
tele_saler_name: string;
team_code: string;
team_name: string;
department_code: string;
department_name: string;
}
/**
* 内勤员工登录
* @param data 内勤员工登录信息
* @returns 返回一个Promise对象用于给调用者添加链式处理。
*/
async function login( data: LoginInfo ): Promise<AxiosResponse<any, any>>
{
return await instance.request(
@@ -30,10 +56,27 @@ async function login( data: LoginInfo ): Promise<AxiosResponse<any, any>>
method: "post",
url: API_URL.URL_LOGIN,
data,
}
);
});
}
/**
* 坐席登录函数
* @param data 坐席登录信息
* @returns 返回一个Promise对象用于给调用者添加链式处理。
*/
async function loginCaller( data: LoginCallerInfo ): Promise<AxiosResponse<any, any>>
{
return await instance.request(
{
method: "post",
url: API_URL.URL_LOGIN_CALLER,
data,
});
}
/**
* 退出登录
*/
function logout(): void
{
cleanStaffInfo();
@@ -42,4 +85,11 @@ function logout(): void
void router.push( "/login" );
}
export { type LoginInfo, login, logout };
export {
type LoginInfo,
type LoginCallerInfo,
type LoginCallerResult,
login,
loginCaller,
logout
};

View File

@@ -10,6 +10,7 @@
export const API_URL = {
// URL_LOGIN: import.meta.env.VITE_URL_LOGIN,
URL_LOGIN: "http://222.76.244.118:11101/admin-system/account/p13_account_check",
URL_LOGIN_CALLER: "http://localhost:8080/desktop_archievement_backend/account/query_telsaler_info.do",
// URL_DEPARTMENT_ARCHIEVEMENT: import.meta.env.VITE_URL_DEPARTMENT_ARCHIEVEMENT,
URL_DEPARTMENT_ARCHIEVEMENT: "http://222.76.244.118:11101/desktop_archievement_backend/archievement/query_department_archievement.do",

View File

@@ -7,7 +7,7 @@
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import { StaffInfo } from "@/data/cpicxim/StaffInfo.js";
import { StaffInfo } from "../../data/cpicxim/StaffInfo.js";
const STUFF_ITEM = "stuff_info";
const CALLER_ITEM = "call_info";

View File

@@ -68,7 +68,7 @@
import { reactive, onBeforeMount } from "vue";
import { useRouter } from "vue-router";
import { saveStaffInfo, getUserType, saveUserType, getCallerInfo, saveCallerInfo } from "@/utils/api/localStorage";
import { login } from "@/utils/account";
import { login, loginCaller, type LoginCallerInfo, type LoginCallerResult } from "@/utils/account";
import { ElMessage } from "element-plus";
import { StaffInfo } from "@/data/cpicxim/StaffInfo";
@@ -120,7 +120,7 @@ export default {
if ( data.success === true )
{
// 提示登录成功并保存到localStorage然后路由跳转
// 提示登录成功并保存到localStorage然后路由跳转
ElMessage({
message: data.message,
type: "success",
@@ -161,11 +161,45 @@ export default {
}
else if ( ui.currentMenu === "tele_saler" )
{
// 是坐席,将坐席工号保存到本地,然后跳转
saveCallerInfo( ui.account );
// 是坐席
const loginInfo: LoginCallerInfo = {
telsaler_code: ui.account,
};
// 跳转路由
router.push( "/desktop_archievement" );
// 登录
loginCaller( loginInfo )
// 调用接口成功
.then(( response ) =>
{
const data:LoginCallerResult = response.data ?? { success: false, };
// 查看標志位
if ( data.success === true )
{
// 查询成功,显示一个提示,保存工号,并跳转路由
ElMessage({
message: `验证成功,登录用户 ${data.tele_saler_name}`,
type: "success",
});
saveCallerInfo( ui.account );
router.push( "/desktop_archievement" );
}
else
{
// 查詢失敗
ElMessage({
message: "验证失败,请检查输入的工号。",
type: "error",
});
}
})
// 调用接口失败
.catch(( error ) =>
{
console.log( `登录失败,返回信息:${error}` );
});
}
};
@@ -268,25 +302,25 @@ export default {
}
.menu-tab {
text-align: center;
margin-bottom: 15px;
margin-top: 25px;
text-align: center;
margin-bottom: 15px;
margin-top: 25px;
li {
display: inline-block;
padding: 10px 24px;
margin: 0 10px;
// background-color: #fff;
color: #1d6ddc;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
li {
display: inline-block;
padding: 10px 24px;
margin: 0 10px;
// background-color: #fff;
color: #1d6ddc;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
&.current {
background-color: #1d6ddc;
color: #fff;
&.current {
background-color: #1d6ddc;
color: #fff;
}
}
}
}
.form-label {