--demand 面授课

This commit is contained in:
yuping
2023-03-17 03:08:28 +08:00
parent fa431338c8
commit e68aeb246b
20 changed files with 3670 additions and 3599 deletions

View File

@@ -1,10 +1,25 @@
export const STUDENT_LIST = '/admin/student/getStudent';
export const ONLINE_COURSE_PAGE = '/onlineClasses/queryOnlineList';
export const ASSESSMENT_PAGE = '/assessment/queryAssessmentDetailList post';
export const PROJECT_AUDIT_PAGE = '/admin/project/auditedlistV2 post';
export const ROUTER_DETAIL_MODIFY = '/admin/router/routerInfoTemp post';
export const PROJECT_DETAIL_MODIFY = '/admin/project/projectInfoTemp post';
export const PROJECT_TEMPLATE_DETAIL_MODIFY = '/admin/project/template/editStageAndTask post';
export const PROJECT_RELEASE = '/admin/project/realease';
export const ASYNC_STUDENT_STATUS = '/admin/cache/getStudentAsyncStatus';
export const ONLINE_COURSE_TEACHER = '/admin/offcourse/getTeacherNamesByCourseId';
export const STUDENT_LIST = "/admin/student/getStudent";
export const TASK_STUDENT_LIST = "/admin/student/getTaskStudent";
export const ONLINE_COURSE_PAGE = "/onlineClasses/queryOnlineList";
export const ASSESSMENT_PAGE = "/assessment/queryAssessmentDetailList post";
export const PROJECT_AUDIT_PAGE = "/admin/project/auditedlistV2 post";
export const ROUTER_DETAIL_MODIFY = "/admin/router/routerInfoTemp post";
export const PROJECT_DETAIL_MODIFY = "/admin/project/projectInfoTemp post";
export const PROJECT_TEMPLATE_DETAIL_MODIFY = "/admin/project/template/editStageAndTask post";
export const PROJECT_RELEASE = "/admin/project/realease";
export const ASYNC_STUDENT_STATUS = "/admin/cache/getStudentAsyncStatus";
export const ONLINE_COURSE_TEACHER = "/admin/offcourse/getTeacherNamesByCourseId";
//开课列表
export const COURSE_PLAN_PAGE = "/admin/offcourse/planList post";
//开课所有列表
export const COURSE_PLAN_LIST = "/admin/offcourse/allPlanList post";
//开课保存/编辑
export const COURSE_PLAN_EDIT = "/admin/offcourse/editPlan post";
//删除开课
export const DEL_PLAN = id => `/admin/offcourse/deletePlan?offcoursePlanId=${id} delete`;
//作业详情
export const WORK_DETAIL = "/work/queryWorkDetailById post";
//考试
export const EXAM_DETAIL = "/examination/queryExaminationDetailById post";
//评估
export const ASSESSMENT_DETAIL = "/assessment/queryAssessmentDetailById post";

View File

@@ -1,298 +1,350 @@
import {isRef, reactive, ref, toRefs, unref, watch, watchEffect} from "vue";
import {getCookieForName, throttle} from "@/api/method";
import JSONBigInt from 'json-bigint';
import JSONBigInt from "json-bigint";
const JSONBigIntStr = JSONBigInt({storeAsString: true});
const JSONBigIntStr = JSONBigInt({ storeAsString: true });
export function useBoeApiAuditPage(_url, params = {}) {
return useBoeApiPage(_url, params, {
init: true,
result: (res) => res.result.audienceList.map((e) => ({ ...e, id: e.id + "" })),
totalPage: (res) => res.result.totalPage,
total: (res) => res.result.totalElement,
});
}
export function useBoeApiUserInfoPage(_url, params = {}) {
return useBoeApiPage(_url, params, {
init: false,
result: (res) => res.result.userInfoList,
totalPage: (res) => res.result.totalPage,
total: (res) => res.result.totalElement,
});
}
export function useBoeApiPage(_url, params = {}, config = {
init: true,
result: res => res.result,
totalPage: res => res.result.totalPage,
total: res => res.result.totalElement
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
})
const state = reactive({
data: [],
loading: false,
page: 1,
pageSize: 10,
totalPage: 0,
total: 0
});
if (isRef(params)) {
watch(params.value, () => {
fetch()
})
}
if (isRef(params)) {
watch(params.value, () => {
fetch();
});
}
if (isRef(_url)) {
watchEffect(fetch)
} else {
fetch()
}
if (isRef(_url)) {
watchEffect(fetch);
} else {
fetch();
}
function fetch() {
state.loading = true
return boeRequest(unref(_url), unref(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
})
}
function fetch() {
state.loading = true;
return boeRequest(unref(_url), unref(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;
});
}
function reset() {
state.data = []
state.loading = false
state.page = 1
state.totalPage = 0
state.total = 0
}
function reset() {
state.data = [];
state.loading = false;
state.page = 1;
state.totalPage = 0;
state.total = 0;
}
config.init && fetch()
return {
...toRefs(state),
fetch,
reset
};
config.init && fetch();
return {
...toRefs(state),
fetch,
reset
};
}
export function useBoeApi(_url, params = {}, config = {
init: true,
result: res => res.result,
init: true,
result: res => res.result,
}) {
const state = reactive({
data: [],
loading: false,
})
watch(() => params, () => {
fetch()
})
const state = reactive({
data: [],
loading: false,
});
watch(() => params, () => {
fetch();
});
function fetch() {
state.loading = true
return boeRequest(_url, params).then(r => {
state.data = config.result(r)
state.loading = false
})
}
function fetch() {
state.loading = true;
return boeRequest(_url, params).then(r => {
state.data = config.result(r);
state.loading = false;
});
}
config.init && fetch()
return {
...toRefs(state),
fetch,
};
config.init && fetch();
return {
...toRefs(state),
fetch,
};
}
export function useBoeUserListPage(_url, params = {}, init = true) {
const state = reactive({
data: [],
loading: false,
total: 0,
totalPage: 0,
page: 1,
...params
})
const state = reactive({
data: [],
loading: false,
total: 0,
totalPage: 0,
page: 1,
...params
});
watch(() => params.keyword, throttle(fetch, 600))
watch(() => params.page, fetch)
watch(() => params.keyword, throttle(fetch, 600));
watch(() => params.page, fetch);
function fetch() {
state.loading = true
if (!params.keyword) {
state.loading = false
return
}
return boeRequest(_url, params).then(r => {
state.data = params.page === 1 ? r.result.userInfoList : [...state.data, ...r.result.userInfoList]
state.totalPage = r.result.totalPage
state.total = r.result.totalElement
state.loading = false
})
function fetch() {
state.loading = true;
if (!params.keyword) {
state.loading = false;
return;
}
return boeRequest(_url, params).then(r => {
state.data = params.page === 1 ? r.result.userInfoList : [...state.data, ...r.result.userInfoList];
state.totalPage = r.result.totalPage;
state.total = r.result.totalElement;
state.loading = false;
});
}
init && fetch()
return {
...toRefs(state),
fetch,
};
init && fetch();
return {
...toRefs(state),
fetch,
};
}
export function useRowsPageNoInit(_url, params) {
const state = reactive({
data: [],
total: 1,
current: 1,
pages: 1,
loading: false
});
function reset() {
state.data = [];
state.loading = false;
}
function fetch() {
state.loading = true;
return request(unref(_url), unref(params)).then(r => {
state.data = r.data.rows || r.data.records;
state.current = r.data.current || r.data.current;
state.pages = r.data.pages;
state.total = r.data.total;
state.loading = false;
});
}
return {
...toRefs(state),
fetch,
reset,
};
}
export function useRowsPage(_url, params, init = true) {
const state = reactive({
data: [],
total: 1,
current: 1,
pages: 1,
loading: false
})
const state = reactive({
data: [],
total: 1,
current: 1,
pages: 1,
loading: false
});
if (isRef(params)) {
watch(params.value, () => {
fetch()
})
}
if (isRef(params)) {
watch(params.value, () => {
fetch();
});
}
if (isRef(_url)) {
watchEffect(fetch)
} else {
init && fetch()
}
if (isRef(_url)) {
watchEffect(fetch);
} else {
init && fetch();
}
function reset() {
state.data = []
state.loading = false
}
function reset() {
state.data = [];
state.loading = false;
}
function fetch() {
state.loading = true
return request(unref(_url), unref(params)).then(r => {
state.data = r.data.rows
state.current = r.data.current
state.pages = r.data.pages
state.total = r.data.total
state.loading = false
})
}
function fetch() {
state.loading = true;
return request(unref(_url), unref(params)).then(r => {
state.data = r.data.rows;
state.current = r.data.current;
state.pages = r.data.pages;
state.total = r.data.total;
state.loading = false;
});
}
return {
...toRefs(state),
fetch,
reset,
};
return {
...toRefs(state),
fetch,
reset,
};
}
export function usePage(_url, params, init = true) {
const state = reactive({
data: [],
total: 1,
current: 1,
pages: 1,
loading: false
})
const state = reactive({
data: [],
total: 1,
current: 1,
pages: 1,
loading: false
});
if (isRef(params)) {
watch(params.value, () => {
fetch()
})
}
if (isRef(params)) {
watch(params.value, () => {
fetch();
});
}
if (isRef(_url)) {
watchEffect(fetch)
} else {
init && fetch()
}
if (isRef(_url)) {
watchEffect(fetch);
} else {
init && fetch();
}
function reset() {
state.data = []
state.loading = false
}
function reset() {
state.data = [];
state.loading = false;
}
function fetch() {
state.loading = true
return request(unref(_url), unref(params)).then(r => {
state.data = r.data.records
state.current = r.data.current
state.pages = r.data.pages
state.total = r.data.total
state.loading = false
})
}
function fetch() {
state.loading = true;
return request(unref(_url), unref(params)).then(r => {
state.data = r.data.records;
state.current = r.data.current;
state.pages = r.data.pages;
state.total = r.data.total;
state.loading = false;
});
}
return {
...toRefs(state),
fetch,
reset,
};
return {
...toRefs(state),
fetch,
reset,
};
}
export function useRequest(_url, params = {}, init = true) {
export function useRequest(_url, params, init = true) {
const data = ref({})
const loading = ref(false)
const data = ref({});
const loading = ref(false);
watch(params, () => {
fetchData()
})
if (isRef(params)) {
watch(params.value, () => {
fetchData();
});
}
function fetchData() {
loading.value = true
request(_url, params).then(r => {
data.value = r
loading.value = false
})
}
function fetchData() {
loading.value = true;
request(_url, unref(params)).then(r => {
data.value = r.data;
loading.value = false;
});
}
init && fetchData()
return {
data,
loading,
fetchData,
};
init && fetchData();
return {
data,
loading,
fetchData,
};
}
export async function boeRequest(_url, params = {}) {
const s = _url.split(' ')
let url = s[0]
const method = s[1]?.toLowerCase() || 'get'
if (method === 'get') {
url.includes('?') ? (url.endsWith('&') || (url += '&')) : (url += '?')
url += Object.keys(params).map(key => key + '=' + params[key]).join('&')
}
const body = method !== 'get' ? s[2] === 'formData' ? formatFormData(params) : params : {}
url = process.env.NODE_ENV === 'development' ? url : window.location.protocol + process.env.VUE_APP_BOE_API_URL + url
return fetch(url, {
method,
headers: {
token: getCookieForName('token'),
...method !== 'get' && s[2] !== 'formData' ? {'Content-Type': 'application/json'} : {}
},
...method !== 'get' ? {body: s[2] === 'formData' ? body : JSON.stringify(body)} : {}
}).then(res => {
return res.text()
}).then(res => {
return JSONBigIntStr.parse(res)
})
const s = _url.split(" ");
let url = s[0];
const method = s[1]?.toLowerCase() || "get";
if (method === "get") {
url.includes("?") ? (url.endsWith("&") || (url += "&")) : (url += "?");
url += Object.keys(params).map(key => key + "=" + params[key]).join("&");
}
const body = method !== "get" ? s[2] === "formData" ? formatFormData(params) : params : {};
url = process.env.NODE_ENV === "development" ? url : window.location.protocol + process.env.VUE_APP_BOE_API_URL + url;
return fetch(url, {
method,
headers: {
token: getCookieForName("token"),
...method !== "get" && s[2] !== "formData" ? { "Content-Type": "application/json" } : {}
},
...method !== "get" ? { body: s[2] === "formData" ? body : JSON.stringify(body) } : {}
}).then(res => {
return res.text();
}).then(res => {
return JSONBigIntStr.parse(res);
});
}
function formatFormData(data) {
const formData = new FormData();
Object.keys(data).forEach(k => formData.append(k, data[k]))
return formData
const formData = new FormData();
Object.keys(data).forEach(k => formData.append(k, data[k]));
return formData;
}
export async function request(_url, params) {
const s = _url.split(' ')
let url = s[0]
const method = s[1]?.toLowerCase() || '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 s = _url.split(" ");
let url = s[0];
const method = s[1]?.toLowerCase() || "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 || {} : {}
return fetch(process.env.VUE_APP_BASE_API + url, {
method,
headers: {
token: getCookieForName('token'),
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
},
...method !== 'get' ? {body: JSON.stringify(body)} : {}
}).then(res => {
return res.text()
}).then(res => {
return JSONBigIntStr.parse(res)
})
}
const body = method !== "get" ? params || {} : {};
return fetch(process.env.VUE_APP_BASE_API + url, {
method,
headers: {
token: getCookieForName("token"),
...method !== "get" ? { "Content-Type": "application/json" } : {}
},
...method !== "get" ? { body: JSON.stringify(body) } : {}
}).then(res => {
return res.text();
}).then(res => {
return JSONBigIntStr.parse(res);
});
}