diff --git a/src/App.vue b/src/App.vue index 63fa31ce..f6028c22 100644 --- a/src/App.vue +++ b/src/App.vue @@ -89,6 +89,7 @@ export default defineComponent({ }); }; orgTree(); + return { routes, name: currentRouteName, diff --git a/src/api/config.js b/src/api/config.js index c045783a..00e5b12e 100644 --- a/src/api/config.js +++ b/src/api/config.js @@ -2,11 +2,12 @@ * @Author: lixg lixg@dongwu-inc.com * @Date: 2022-11-21 14:32:52 * @LastEditors: lixg lixg@dongwu-inc.com - * @LastEditTime: 2022-11-23 09:59:26 + * @LastEditTime: 2022-11-25 15:05:34 * @FilePath: /fe-manage/src/api/config.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import axios from "axios"; +// import { getCookie } from '../api/method' // const Qs = require("qs"); // axios.defaults.headers.post["Content-Type"] = @@ -24,8 +25,9 @@ const http = axios.create({ http.interceptors.request.use( (config) => { const token = localStorage.getItem("token"); + // const token = getCookie('token') + // console.log('token', token) if (token) { - // config.headers.token = token; config.headers.token = token; //测试1111 } else { console.log("当前请求页面无token,请执行操作!!!"); @@ -44,12 +46,15 @@ http.interceptors.request.use( http.interceptors.response.use( (response) => { + // console.log('response', response) const { data: { code, msg }, } = response; + // console.log('code', code) if (code === 0 || code === 200) { return response; } else { + // window.open("https://u-pre.boe.com/web/", '_self'); console.log("api %o", msg); } return response; diff --git a/src/api/index1.js b/src/api/index1.js index be062ef2..43c80689 100644 --- a/src/api/index1.js +++ b/src/api/index1.js @@ -2,13 +2,13 @@ * @Author: lixg lixg@dongwu-inc.com * @Date: 2022-11-04 22:45:31 * @LastEditors: lixg lixg@dongwu-inc.com - * @LastEditTime: 2022-11-24 15:11:25 + * @LastEditTime: 2022-11-25 14:56:59 * @FilePath: /fe-manage/src/api/index1.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import http from "./config"; import qs from "qs"; - +// import { getCookie } from '../api/method' /** * 接口传参数方式(get) * axios.get('/user', { @@ -104,7 +104,8 @@ export const getMemberInfo = (obj) => http.post('/admin/orgStruct/getMemberInfo' export const getAudienceInfo = (obj) => http.post('/admin/orgStruct/getAudienceInfo', obj) //获取授权(修改版) export const optionAuthPerm = (obj) => http.post('/admin/AuthPerm/optionAuthPerm', obj) - +//获取用户登录 +export const getUser = () => http.post('/admin/CheckUser/login') // 获取组织结构树 diff --git a/src/api/method.js b/src/api/method.js index ef5ccc81..cee18bff 100644 --- a/src/api/method.js +++ b/src/api/method.js @@ -162,11 +162,47 @@ function autoComma(number) { return 0; } } + +//把token存到cookie +//name 字段名 value 字段值 perpetual 有效期 +const setCookie = (name, value, perpetual) => { + console.log('存储token到cookie') + let exdate = new Date() + exdate.setDate(perpetual * 24 * 60 * 60 * 1000) //exdate.setDate(exdate.getDate() + 365) + document.cookie = name + '=' + value + ';expires=' + exdate.toGMTString() + //永久有效 + //document.cookie = name + '=' + value + ';expires=' + 'Fri, 31 Dec 9999 23:59:59 GMT' +} +//获取cookie数据 + +//先写一个方法 +function getCookie(name) { + //1.获取cookie字符串 + var cookies = document.cookie; + //通过;来分割字符串 + var cookie = cookies.split("; "); + // console.log('cookie', cookie) + //遍历,使键值对匹配上 + for (var i = 0; i < cookie.length; i++) { + var arr = cookie[i].split("token="); + // console.log('arr', arr) + console.log('name', name) + // if (arr[0] == name) { + // console.log('arr[1]', arr[1]) + // return arr[1]; + // } + // console.log('arr[1]', arr[1]) + return arr[1] + } + return ""; +} +//最后通 + + //新建延迟 const commonData = { - timeout: 50 + timeout: 50, } - // const organizationalTree = [ // { // title: "京东方", @@ -376,6 +412,8 @@ export { getWeek, autoComma, formatNumber, + setCookie, + getCookie, commonData, organizationalTree, iframeUrl, diff --git a/src/components/NavTop.vue b/src/components/NavTop.vue index d1c19f19..0f58df47 100644 --- a/src/components/NavTop.vue +++ b/src/components/NavTop.vue @@ -31,7 +31,7 @@ " src="../assets/images/img.jpg" /> -
李玉冰
+
{{ username }}
import { reactive, toRefs } from "vue"; import DownLoad from "../components/drawers/DownLoad"; +import * as api from "../api/index1"; export default { name: "NavTop", components: { @@ -67,6 +68,7 @@ export default { setup() { const state = reactive({ selectRole: "管理员", + username: "", roleList: [ { id: 1, @@ -91,6 +93,21 @@ export default { state.visible = true; console.log("点击下载", state.visible); }; + + const getUser = () => { + api + .getUser() + .then((res) => { + console.log("获取登录信息成功", res); + if (res.data.code === 200) { + state.username = res.data.data.realName; + } + }) + .catch((err) => { + console.log("获取登录信息失败", err); + }); + }; + getUser(); return { ...toRefs(state), changeRole, diff --git a/src/components/drawers/ProjectOwn.vue b/src/components/drawers/ProjectOwn.vue index fa4e3672..3a3c76c7 100644 --- a/src/components/drawers/ProjectOwn.vue +++ b/src/components/drawers/ProjectOwn.vue @@ -559,8 +559,6 @@ export default { //获取选中部门的人员信息 const getPeoples = () => { let obj = { - keyWord: "", - id: 0, org: state.selectedKeys[0], pageNo: state.currentPage, pageSize: state.pageSize, @@ -569,7 +567,7 @@ export default { state.tableDataTotal = 0; return; } - // console.log("obj", obj); + console.log("obj", obj); api .getMemberInfo(obj) .then((res) => { diff --git a/src/views/learningpath/LearningPath.vue b/src/views/learningpath/LearningPath.vue index 7e7a1fed..545f4ec3 100644 --- a/src/views/learningpath/LearningPath.vue +++ b/src/views/learningpath/LearningPath.vue @@ -646,7 +646,11 @@ import QueryRight from "../../components/drawers/QueryRight"; import ManageRight from "../../components/drawers/ManageRight"; import * as api from "../../api/index1"; import { message } from "ant-design-vue"; -import { toDate, commonData } from "../../api/method"; +import { + toDate, + commonData, + // setCookie +} from "../../api/method"; import { storage } from "../../api/storage"; export default { name: "learningPath", @@ -1642,6 +1646,9 @@ export default { onMounted(() => { // console.log("执行"); getLearnPath(); + // let cookie = + // "eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NjkzNTU0MjQsImV4cCI6MTY2OTM2MjYyNCwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.a565952d942ac41a6258a187be48a9269a75d0bfc50c6f13eb42362fe2f3d76a"; + // setCookie("token", cookie, 10); }); return { diff --git a/src/views/projectcenter/ProjectAdd.vue b/src/views/projectcenter/ProjectAdd.vue index 9979a4ce..fa3dfd24 100644 --- a/src/views/projectcenter/ProjectAdd.vue +++ b/src/views/projectcenter/ProjectAdd.vue @@ -195,7 +195,7 @@ tree-default-expand-all :tree-data="classifyList2" :fieldNames="{ - children: 'children', + children: 'treeChildList', label: 'name', value: 'id', }" @@ -769,6 +769,7 @@ export default { { value: 2, label: "将小米" }, { value: 3, label: "刘孟君" }, ]); + //获取 //选择处理项目经理 let manager = "";