From 39f8bd9830cfc801e31be3f15c9cbb1ffa7ce447 Mon Sep 17 00:00:00 2001
From: yuping <82253452@qq.com>
Date: Sat, 10 Dec 2022 14:49:53 +0800
Subject: [PATCH] =?UTF-8?q?--=20=E6=96=B0=E5=BB=BA=E5=AD=A6=E5=91=98?=
=?UTF-8?q?=E7=AE=A1=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/ThirdApi.js | 8 +
src/api/index1.js | 32 +-
src/api/method.js | 40 +--
src/api/request.js | 169 ++++++++++
src/components/student/Student.vue | 481 +++++++++++++++++++++++++++++
5 files changed, 696 insertions(+), 34 deletions(-)
create mode 100644 src/api/ThirdApi.js
create mode 100644 src/api/request.js
create mode 100644 src/components/student/Student.vue
diff --git a/src/api/ThirdApi.js b/src/api/ThirdApi.js
new file mode 100644
index 00000000..ae3a197a
--- /dev/null
+++ b/src/api/ThirdApi.js
@@ -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'
\ No newline at end of file
diff --git a/src/api/index1.js b/src/api/index1.js
index d6390d53..ade98239 100644
--- a/src/api/index1.js
+++ b/src/api/index1.js
@@ -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'
diff --git a/src/api/method.js b/src/api/method.js
index 8571f54e..a10dafa0 100644
--- a/src/api/method.js
+++ b/src/api/method.js
@@ -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 = {
diff --git a/src/api/request.js b/src/api/request.js
new file mode 100644
index 00000000..818d666e
--- /dev/null
+++ b/src/api/request.js
@@ -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'})
+ })
+}
\ No newline at end of file
diff --git a/src/components/student/Student.vue b/src/components/student/Student.vue
new file mode 100644
index 00000000..38dbd4ad
--- /dev/null
+++ b/src/components/student/Student.vue
@@ -0,0 +1,481 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+ 重置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+ 重置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+ 重置
+
+
+
+
+
+
+
+
+
+
快速选人
+
+ {{ item.realName }}
+
+
+
+
组织添加
+
+ {{ item.name }}
+
+
+
+
受众添加
+
+ {{ item.audienceName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file