mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-17 23:06:47 +08:00
feat:合并
This commit is contained in:
8
src/api/ThirdApi.js
Normal file
8
src/api/ThirdApi.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export const BASE = 'https://pre.boe.com'
|
||||
export const BASE_DEV = 'https://u-pre.boe.com'
|
||||
|
||||
export const USER_LIST = '/userbasic/user/list post'
|
||||
export const ORG_LIST = '/userbasic/org/list post'
|
||||
export const ORG_CHILD_LIST = '/userbasic/org/info post'
|
||||
|
||||
export const AUDIENCE_LIST = '/userbasic/audience/list post'
|
||||
@@ -44,7 +44,7 @@ import qs from "qs";
|
||||
|
||||
//上传文件
|
||||
export const uploadFile = (obj) =>
|
||||
http.post("/test/testRequest", qs.stringify({ obj }));
|
||||
http.post("/test/testRequest", qs.stringify({obj}));
|
||||
|
||||
// 接口-请求
|
||||
|
||||
@@ -56,7 +56,7 @@ export const getLearnPath = (obj) => http.post("/admin/router/list", obj);
|
||||
export const handleLearnPath = (obj) => http.post("/admin/router/handle", obj);
|
||||
//获取路径图统计数据
|
||||
export const getLearnCount = (routerId) =>
|
||||
http.get("/admin/router/getCount", { params: { routerId: routerId } });
|
||||
http.get("/admin/router/getCount", {params: {routerId: routerId}});
|
||||
|
||||
//新建或编辑关卡
|
||||
export const editChapter = (obj) => http.post("/admin/router/editChapter", obj);
|
||||
@@ -66,20 +66,20 @@ export const setConfig = (obj) => http.post("/admin/router/setConfig", obj);
|
||||
export const getStudent = (obj) => http.post("/admin/router/studentList", obj);
|
||||
//获取路径图详情-包含关卡及任务列表
|
||||
export const getRouterDetail = (routerId) =>
|
||||
http.get("/admin/router/detail", {
|
||||
params: {
|
||||
routerId: routerId,
|
||||
},
|
||||
});
|
||||
http.get("/admin/router/detail", {
|
||||
params: {
|
||||
routerId: routerId,
|
||||
},
|
||||
});
|
||||
//添加学员
|
||||
export const addStudent = (obj) => http.post("/admin/router/addStudent", obj);
|
||||
//删除学员
|
||||
export const delStudent = (obj) =>
|
||||
http.post("/admin/router/deleteStudent", obj);
|
||||
http.post("/admin/router/deleteStudent", obj);
|
||||
|
||||
// 获取学员路径图进度明细
|
||||
export const stuProgress = (obj) =>
|
||||
http.post("/admin/router/studentProcess", obj);
|
||||
http.post("/admin/router/studentProcess", obj);
|
||||
//编辑学习路径基本信息
|
||||
export const editLearnInfo = (obj) => http.post('/admin/router/editInfo', obj)
|
||||
|
||||
@@ -92,7 +92,6 @@ export const billboard = (obj) => http.post("/admin/project/billboard", obj);
|
||||
//项目基础信息-----------------------------------
|
||||
|
||||
|
||||
|
||||
//课程----------------------------------------------
|
||||
|
||||
// //提交审核
|
||||
@@ -121,7 +120,7 @@ export const optionAuthPerm = (obj) => http.post('/admin/AuthPerm/optionAuthPerm
|
||||
//获取学员列表
|
||||
export const getStuList = (obj) => http.post('/admin/orgStruct/getStudentRef', obj)
|
||||
//获取用户登录
|
||||
export const getUser = () => http.post('/admin/CheckUser/login', { withCredentials: true })
|
||||
export const getUser = () => http.post('/admin/CheckUser/login', {withCredentials: true})
|
||||
//公共信息---------------------------------------------------
|
||||
|
||||
//添加项目学员
|
||||
@@ -131,14 +130,15 @@ export const addStudentCourse = (obj) => http.post("/admin/offcourse/addStudent"
|
||||
|
||||
// 获取组织结构树
|
||||
export const orgtree = () => http.get("/org/tree");
|
||||
export const saveStu = obj => http.post("/admin/student/addStudent", obj);
|
||||
|
||||
//获取积分列表
|
||||
export const noticeList = (projectId) =>
|
||||
http.post(
|
||||
`/admin/project/noticeList?projectId=` +
|
||||
projectId +
|
||||
``
|
||||
);
|
||||
http.post(
|
||||
`/admin/project/noticeList?projectId=` +
|
||||
projectId +
|
||||
``
|
||||
);
|
||||
|
||||
// 测试方法
|
||||
// import * as api from '../../api/index'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as api from './index1'
|
||||
|
||||
function formatNumber(n) {
|
||||
n = n.toString();
|
||||
return n[1] ? n : "0" + n;
|
||||
@@ -192,31 +193,33 @@ const setCookie = (name, value, perpetual) => {
|
||||
|
||||
//先写一个方法
|
||||
function getCookie(name) {
|
||||
return document.cookie?.split(";").find(e => e.includes(name)).replace(`${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 cookies = document.cookie;
|
||||
// console.log('cookies',cookies)
|
||||
// //通过;来分割字符串
|
||||
// const 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 scrollLoad = (e) => {
|
||||
// console.log("滚动", e, b);
|
||||
const { target } = e;
|
||||
const {target} = e;
|
||||
const scrllHeight = target.scrollHeight - target.scrollTop;
|
||||
const clientHeight = target.clientHeight;
|
||||
// console.log("scrllHeight", scrllHeight, clientHeight);
|
||||
@@ -226,6 +229,7 @@ const scrollLoad = (e) => {
|
||||
return 2
|
||||
}
|
||||
};
|
||||
|
||||
//添加归属权
|
||||
function changeOwnership(classify, selectProjectId, selectPeopleArr) {
|
||||
let obj = {
|
||||
|
||||
169
src/api/request.js
Normal file
169
src/api/request.js
Normal file
@@ -0,0 +1,169 @@
|
||||
import {reactive, ref, toRefs, watch} from "vue";
|
||||
import axios from 'axios';
|
||||
import {getCookie} from "@/api/method";
|
||||
|
||||
|
||||
export function useBoeApiPage(_url, params = {}, config = {
|
||||
init: true,
|
||||
result: res => res.result,
|
||||
totalPage: res => res.result.totalPage,
|
||||
total: res => res.result.totalElement
|
||||
}) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
loading: false,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
total: 0
|
||||
})
|
||||
|
||||
function fetch() {
|
||||
console.log('params', params)
|
||||
state.loading = true
|
||||
return request(_url, params).then(r => {
|
||||
state.data = config.result(r)
|
||||
state.totalPage = config.totalPage(r)
|
||||
state.total = config.total(r)
|
||||
state.loading = false
|
||||
state.page = params.page
|
||||
})
|
||||
}
|
||||
|
||||
config.init && fetch()
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
};
|
||||
}
|
||||
|
||||
export function useBoeApi(_url, params = {}, config = {
|
||||
init: true,
|
||||
result: res => res.result,
|
||||
}) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
loading: false,
|
||||
})
|
||||
watch(() => params, () => {
|
||||
fetch()
|
||||
})
|
||||
|
||||
function fetch() {
|
||||
state.loading = true
|
||||
return request(_url, params).then(r => {
|
||||
state.data = config.result(r)
|
||||
state.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
config.init && fetch()
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
};
|
||||
}
|
||||
|
||||
export function usePage(_url, params = {}, init = true) {
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
loading: false
|
||||
})
|
||||
|
||||
watch(params, () => {
|
||||
fetch()
|
||||
})
|
||||
|
||||
function fetch() {
|
||||
state.loading = true
|
||||
return request(_url, params).then(r => {
|
||||
console.log('fetch')
|
||||
console.log(r)
|
||||
state.data = r.result
|
||||
state.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
init && fetch()
|
||||
return {
|
||||
...toRefs(state),
|
||||
fetch,
|
||||
};
|
||||
}
|
||||
|
||||
export function useRequest(_url, params = {}, init = true) {
|
||||
|
||||
const data = ref({})
|
||||
const loading = ref(false)
|
||||
|
||||
watch(params, () => {
|
||||
fetchData()
|
||||
})
|
||||
|
||||
function fetchData() {
|
||||
loading.value = true
|
||||
request(_url, params).then(r => {
|
||||
data.value = r
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
init && fetchData()
|
||||
return {
|
||||
data,
|
||||
loading,
|
||||
fetchData,
|
||||
};
|
||||
}
|
||||
|
||||
export async function request(_url, params) {
|
||||
const s = _url.split(' ')
|
||||
let url = s[0]
|
||||
const method = s[1] || 'get'
|
||||
if (method === 'get') {
|
||||
let paramsArray = [];
|
||||
//拼接参数
|
||||
if (params) {
|
||||
Object.keys(params).forEach(key => paramsArray.push(key + '=' + params[key]))
|
||||
if (url.search(/\?/) === -1) {
|
||||
url += '?' + paramsArray.join('&')
|
||||
} else {
|
||||
url += '&' + paramsArray.join('&')
|
||||
}
|
||||
}
|
||||
}
|
||||
const body = method !== 'get' ? params || {} : {}
|
||||
console.log('token', getCookie('token'))
|
||||
return axios({
|
||||
url,
|
||||
method,
|
||||
headers: {
|
||||
token: getCookie('token'),
|
||||
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
|
||||
},
|
||||
baseURL: '',
|
||||
...method !== 'get' ? {data: JSON.stringify(body)} : {}
|
||||
}).then(resp => resp.data).then(response => {
|
||||
console.log(response)
|
||||
// if (response.status !== 200 && response.code !== 0) {
|
||||
// if (response.code === 3 || response.code === 4 || response.code === 100) {
|
||||
// router.push({path: '/login'})
|
||||
// return
|
||||
// } else {
|
||||
// response.showMsg && notification.open({
|
||||
// message: response.showMsg,
|
||||
// duration: 2,
|
||||
// });
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
return response
|
||||
}).catch(e => {
|
||||
console.log(2222)
|
||||
console.log(e)
|
||||
// router.push({path: '/login'})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user