Commit 2209307c authored by 张伯涛's avatar 张伯涛

课程管理接口初步调整

parent 4349254d
import request from '@/utils/request'
import Qs from "qs";
// 课程管理列表查询
export function queryBLessonsByPagination(query) {
......@@ -16,3 +17,119 @@ export function queryBChaptersWithoutAuth(query) {
params: query
})
}
// 查询课程方向下拉
export function queryDirectionsList(query) {
return request({
url: '/bdirection/queryDirectionsList',
method: 'get',
params: query
})
}
// 课程管理新增
export function blessonAdd(data) {
data = Qs.stringify(data)
return request({
url: '/blesson/add',
method: 'post',
data,
headers: {}
})
}
// 课程管理删除
export function blessonRemove(data) {
data = Qs.stringify(data)
return request({
url: '/blesson/remove',
method: 'post',
data,
headers: {}
})
}
// 课程管理导入
export function excelImport(data) {
return request({
url: '/blesson/excelImport',
method: 'post',
headers: {
'Content-Type': 'multipart/form-data'
},
transformRequest: [(data) => {
return data
}],
data
})
}
// 课程管理恢复封面
export function defaultUrl(data) {
data = Qs.stringify(data)
return request({
url: '/blesson/defaultUrl',
method: 'post',
data,
headers: {}
})
}
// 课程管理修改封面
export function picImport(data) {
data = Qs.stringify(data)
return request({
url: '/blesson/picImport',
method: 'post',
data,
headers: {}
})
}
// 课程管理-目录添加章
export function bchapterAdd(data) {
data = Qs.stringify(data)
return request({
url: '/bchapter/add',
method: 'post',
data,
headers: {}
})
}
// 课程管理-目录删除节
export function bchapterRemove(data) {
data = Qs.stringify(data)
return request({
url: '/bchapter/remove',
method: 'post',
data,
headers: {}
})
}
// 课程管理-目录章节上移
export function updateTopChapter(data) {
data = Qs.stringify(data)
return request({
url: '/bchapter/updateTopChapter',
method: 'post',
data,
headers: {}
})
}
// 课程管理-目录章节下移
export function updateDownChapter(data) {
data = Qs.stringify(data)
return request({
url: '/bchapter/updateDownChapter',
method: 'post',
data,
headers: {}
})
}
// 6.导入
export function uploadVideo(data) {
return request({
url: '/bvideo/uploadVideo',
method: 'post',
headers: {
'Content-Type': 'multipart/form-data'
},
transformRequest: [(data) => {
return data
}],
data
})
}
......@@ -227,7 +227,13 @@ import EduVideo from '@/components/Tools/EduVideo'
import EduPpt from '@/components/Tools/EduPpt'
import EduPdf from '@/components/Tools/EduPdf'
import EduFile from '@/components/Tools/EduFile'
import {queryBChaptersWithoutAuth, queryBLessonsByPagination} from '@/api/courseManagement/indexApi'
import {
queryBChaptersWithoutAuth,
blessonAdd,
bchapterAdd,
bchapterRemove,
updateTopChapter, updateDownChapter, uploadVideo
} from '@/api/courseManagement/indexApi'
export default {
name: "courseCatalogues",
components:{
......@@ -426,16 +432,14 @@ export default {
console.log('修改目录标题');
let bid = $this.attr('data-bid');
let chapterName = $this.val();
_this.eduUtil.ajaxPostUtil(
'BChapter/add',
{
const params = {
businessId: bid,
pid: -1,
lessonOrSl: '1',
lessonId: _this.lessonId,
chapterName: chapterName
},
function (res) {
}
bchapterAdd(params).then(res => {
if (res.code === 200) {
_this.$notify({
title: '成功',
......@@ -453,13 +457,13 @@ export default {
$this.val($this.prev('input[type=hidden]').val());
}
$this.prop('disabled',true);
}, function (err) {
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
}).catch((err) => {
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
})
}
}else{
$this.prop('disabled',true);
......@@ -477,16 +481,14 @@ export default {
let bid = $this.attr('data-bid');
let pid = $this.attr('data-pid');
let chapterName = $this.val();
_this.eduUtil.ajaxPostUtil(
'BChapter/add',
{
const params = {
businessId: bid,
pid: pid,
lessonOrSl: '1',
lessonId: _this.lessonId,
chapterName: chapterName
},
function (res) {
}
bchapterAdd(params).then(res => {
if (res.code === 200) {
_this.$notify({
title: '成功',
......@@ -503,13 +505,13 @@ export default {
$this.val($this.prev('input[type=hidden]').val());
}
$this.prop('disabled',true);
}, function (err) {
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
}).catch((err) => {
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
})
}
}else{
$this.prop('disabled',true);
......@@ -563,11 +565,11 @@ export default {
//关闭loading
loading.close();
}).catch(function() {
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
loading.close();
})
}
......@@ -584,15 +586,13 @@ export default {
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.5)',
});
const url = 'BChapter/add';
this.eduUtil.ajaxPostUtil(url,
{
const params = {
lessonId: this.lessonId,
lessonOrSl: '1',
chapterName: this.chapterForm.text,
pid: -1
},
function (res) {
}
bchapterAdd(params).then(res => {
loading.close();
_this.$notify({
title: '成功',
......@@ -600,15 +600,14 @@ export default {
type: 'success'
});
_this.loadCatalog(_this.lessonId, _this.classHours);
}
, function (err) {
}).catch((err) => {
loading.close();
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
})
this.viewSwitch.chapterForm = false;
this.formClear();
}else{
......@@ -670,22 +669,18 @@ export default {
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.5)',
});
this.eduUtil.ajaxPostUtil(
'BLesson/add',
{
const params = {
businessId:_this.lessonId,
classHour:_this.classHours,
lessonName:_this.lessonName,
code:_this.code,
directionId:_this.directionId
},res =>{
//console.log(res);
}
blessonAdd(params).then(res => {
loading.close();
},err =>{
//console.log(err);
}).catch((err) => {
loading.close();
}
);
})
}).catch(() => {
return false;
});
......@@ -700,8 +695,7 @@ export default {
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.5)',
});
_this.eduUtil.ajaxPostUtil('BChapter/add',
{
const params = {
lessonId:_this.lessonId,
lessonOrSl:'1',
pid:_this.sectionForm.chapterId,
......@@ -709,8 +703,8 @@ export default {
isTest:_this.sectionForm.stuMeansValue,
classHour:_this.sectionForm.classHours,
experimentType:_this.sectionForm.stuMeansFile
},
function(res){
}
bchapterAdd(params).then(res => {
loading.close();
_this.$notify({
title: '成功',
......@@ -719,16 +713,15 @@ export default {
});
_this.viewSwitch.sectionForm = false;
_this.loadCatalog(_this.lessonId);
},
function(err){
}).catch((err) => {
loading.close();
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
_this.viewSwitch.sectionForm = false;
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
_this.viewSwitch.sectionForm = false;
})
}
} else {
......@@ -781,14 +774,11 @@ export default {
background: 'rgba(0, 0, 0, 0.5)',
customClass: 'myLoading'
});
this.eduUtil.ajaxPostUtil(
'BChapter/remove',
{
const params = {
id:_this.currentChapterId,
lessonOrSl:1
},
function(res){
}
bchapterRemove(params).then(res => {
loading.close();
if(res.code === 200) {
_this.$notify({
......@@ -805,15 +795,14 @@ export default {
type: 'warning'
});
}
},function(err){
}).catch((err) => {
loading.close();
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
}
);
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
})
}).catch(() => {
//无操作
})
......@@ -821,15 +810,13 @@ export default {
//章节上移
chapterUp(bid,pid,sort){
let _this = this;
this.eduUtil.ajaxPostUtil(
'BChapter/updateTopChapter',
{
const params = {
businessId:bid,
pid:pid,
sort:sort,
lessonId:_this.lessonId
},
function(res){
}
updateTopChapter(params).then(res => {
if(res.code === 200) {
_this.$notify({
title: '成功',
......@@ -844,28 +831,24 @@ export default {
type: 'warning'
});
}
},
function(err){
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
}
);
}).catch((err) => {
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
})
},
//章节下移
chapterDown(bid,pid,sort){
let _this = this;
this.eduUtil.ajaxPostUtil(
'BChapter/updateDownChapter',
{
const params = {
businessId:bid,
pid:pid,
sort:sort,
lessonId:_this.lessonId
},
function(res){
}
updateDownChapter(params).then(res => {
if(res.code === 200) {
_this.$notify({
title: '成功',
......@@ -880,15 +863,13 @@ export default {
type: 'warning'
});
}
},
function(err){
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'error'
// });
}
);
}).catch((err) => {
_this.$notify({
title: '失败',
message: '网络错误',
type: 'error'
});
})
},
//更改课时
changeHour(secHour,bid,pid,chapterName,index,indexChild){
......@@ -905,20 +886,18 @@ export default {
_this.classHours = parseInt(_this.classHours);
_this.classHours += 1;
//更新总课时
_this.eduUtil.ajaxPostUtil(
'BLesson/add',
{
const params ={
businessId:_this.lessonId,
classHour:_this.classHours,
lessonName:_this.lessonName,
code:_this.code,
directionId:_this.directionId
},res =>{
// console.log(res);
},err =>{
console.log(err);
}
);
blessonAdd(params).then(res => {
}).catch((err) => {
console.log(err);
})
}).catch(() => {
if (secHour == 1){
this.chapterList[index].childList[indexChild].classHour = "0"
......@@ -931,17 +910,15 @@ export default {
//请求更新课时
function updateClassHours(){
if (!_this.updateCancel){
_this.eduUtil.ajaxPostUtil(
'BChapter/add',
{
const params ={
businessId:bid,
pid:pid,
lessonOrSl:1,
lessonId:_this.lessonId,
chapterName:chapterName,
classHour:secHour
},
function(res){
}
bchapterAdd(params).then(res => {
if(res.code===200){
_this.$notify({
title: '成功',
......@@ -958,15 +935,14 @@ export default {
duration:'1200'
});
}
},function(err){
// _this.$notify({
// title: '失败',
// message: '网络错误',
// type: 'err',
// duration:'1200'
// });
}
)
}).catch((err) => {
_this.$notify({
title: '失败',
message: '网络错误',
type: 'err',
duration:'1200'
});
})
}else{
_this.updateCancel = false
}
......@@ -1109,14 +1085,14 @@ export default {
});
let bid = this.teaMeans.businessId;
let _this = this;
_this.eduUtil.ajaxPostUtil(
'BChapter/add',{
const params ={
businessId:bid,
experimentType:_this.teaMeans.expType,
lessonOrSl:1,
isTest:_this.teaMeans.stuMeans,
chapterName:_this.teaMeans.chapterName
},res=>{
}
bchapterAdd(params).then(res => {
loading.close();
if(res.code===200){
_this.$notify({
......@@ -1134,15 +1110,14 @@ export default {
'type':'warning'
});
}
},err=>{
}).catch((err) => {
loading.close();
// _this.$notify({
// 'title':'失败',
// 'message':'网络错误',
// 'type':'error'
// });
}
);
_this.$notify({
'title':'失败',
'message':'网络错误',
'type':'error'
});
})
},
confirmUpload(){
let type = this.resForm.type;
......@@ -1223,12 +1198,12 @@ export default {
background: 'rgba(0, 0, 0, 0.5)',
customClass: 'myLoading'
});
_this.eduUtil.ajaxPostFileUtil(_this,'BVideo/uploadVideo',{
type:type,
chapterId:_this.resForm.businessId,
file:file,
lessonId:_this.lessonId
},res =>{
var formData = new FormData() // 当前为空
formData.append('type', type)
formData.append('chapterId', _this.resForm.businessId)
formData.append('file', file)
formData.append('lessonId', _this.lessonId)
uploadVideo(formData).then(res => {
loading.close();
if(res.code===200&&_this.progress===100){
_this.success(res);
......@@ -1238,11 +1213,10 @@ export default {
}else{
_this.warning(res);
}
},err =>{
}).catch((err) => {
loading.close();
_this.error(err);
}
);
})
}
},
//ajax成功的提示
......@@ -1263,11 +1237,11 @@ export default {
},
//ajax错误的提示
error(err){
// this.$notify({
// title: '失败',
// message: '网络错误',
// type: "error"
// });
this.$notify({
title: '失败',
message: '网络错误',
type: "error"
});
},
//返回
goBack(){
......
......@@ -228,7 +228,14 @@
<script>
import CurCat from '../courseManagement/courseCatalogues.vue'
import {queryBLessonsByPagination} from '@/api/courseManagement/indexApi'
import {
queryBLessonsByPagination,
queryDirectionsList,
blessonAdd,
blessonRemove,
excelImport,
defaultUrl, picImport,
} from '@/api/courseManagement/indexApi'
import commonField from "@/utils/commonField";
export default {
name: "index",
......@@ -400,8 +407,7 @@ export default {
getCourseDirection() {
let that = this;
that.fullscreenLoading=true;
that.eduUtil.ajaxGetUtil('BDirection/queryDirectionsList', {},
function (res) {
queryDirectionsList().then(res => {
for (let i = 0; i < res.data.length; i++) {
let obj = {};
obj.value = res.data[i].id;
......@@ -409,15 +415,14 @@ export default {
that.courseDirection[i] = obj;
}
that.fullscreenLoading=false;
}, function (err) {
}).catch((err) => {
that.fullscreenLoading=false;
that.$notify({
title: '失败',
message: '网络错误,课程方向获取失败',
type: 'error'
})
}
)
});
},
/** 重置按钮操作 */
resetQuery() {
......@@ -489,14 +494,14 @@ export default {
if (valid) {
that.fullscreenLoading = true;
that.dialogFormVisible = false;
that.eduUtil.ajaxPostUtil('BLesson/add', {
'code': that.form.id,
'lessonName': that.form.name,
'classHour': that.form.totalStuHours,
'directionId': that.form.couDire,
'credits': that.form.credit
},
function (res) {
const params = {
code: that.form.id,
lessonName: that.form.name,
classHour: that.form.totalStuHours,
directionId: that.form.couDire,
credits: that.form.credit
}
blessonAdd(params).then(res => {
let type = res.code;
let message = res.message;
type = (type == 200) ? "success" : "warning";
......@@ -509,8 +514,7 @@ export default {
if(type=='success') {
that.loadData();
}
}, function (err) {
}).catch((err) => {
that.fullscreenLoading = false;
console.log(err);
})
......@@ -560,10 +564,9 @@ export default {
dom.value=''
_this.fullscreenLoading = false;
}else{
_this.eduUtil.ajaxPostUtil(
'BLesson/excelImport',
{importFile:dom.files[0]},
function (res){
var formData = new FormData() // 当前为空
formData.append('importFile', dom.files[0])
excelImport(formData).then(res => {
console.log(res);
dom.value=''
_this.fullscreenLoading = false;
......@@ -581,8 +584,7 @@ export default {
type: 'error'
});
}
},
function (err) {
}).catch((err) => {
dom.value=''
_this.$notify({
title: '失败',
......@@ -590,8 +592,7 @@ export default {
type: 'error'
});
_this.fullscreenLoading = false;
}
);
})
}
}
,
......@@ -633,9 +634,10 @@ export default {
// alert(index);
this.fullscreenLoading = true;
var that = this;
this.eduUtil.ajaxPostUtil('BLesson/defaultUrl', {
const params = {
code: that.tableData[index].tcode
}, function (res) {
}
defaultUrl(params).then(res => {
that.fullscreenLoading = false;
if (res.code) {
that.$notify({
......@@ -651,10 +653,9 @@ export default {
type: 'warning'
});
}
}, function (err) {
}).catch((err) => {
console.log(err)
});
})
},
......@@ -677,10 +678,11 @@ export default {
});
}else {
_this.fullscreenLoading = true;
_this.eduUtil.ajaxPostUtil('BLesson/picImport', {
const params = {
importFile: cover,
code: _this.teacode,
}, res => {
}
picImport(params).then(res => {
_this.fullscreenLoading = false;
_this.dialogVisible = false;
let type = res.code;
......@@ -693,8 +695,7 @@ export default {
});
_this.loadData();
_this.filelist = [];
}, err => {
}).catch((err) => {
_this.fullscreenLoading = false;
console.log(err);
})
......@@ -729,14 +730,15 @@ export default {
});
}else{
that.fullscreenLoading = true;
that.eduUtil.ajaxPostUtil('BLesson/add', {
const params = {
businessId: that.bussid[index],
code: that.formLabelAlign.id,
lessonName: that.formLabelAlign.region,
credits: that.formLabelAlign.credit,
directionId: that.formLabelAlign.couDire,
classHour: that.formLabelAlign.totalStuHours
}, (function (response) {
}
blessonAdd(params).then(response => {
that.fullscreenLoading = false;
// alert(JSON.stringify(response));
let type = response.code;
......@@ -750,11 +752,9 @@ export default {
});
that.loadData();
$('.el-popover').css("display", "none");
})
, (function (err) {
}).catch((err) => {
console.log(err);
})
)
}
} else {
that.fullscreenLoading = false;
......@@ -792,12 +792,10 @@ export default {
type: 'warning'
}).then(() => {
that.fullscreenLoading = true;
that.eduUtil.ajaxPostUtil('BLesson/remove',
{
const params = {
id: that.bussid[index]
}
, (function (response) {
blessonRemove(params).then(response => {
that.fullscreenLoading = false;
// alert(JSON.stringify(response));
var type = response.code;
......@@ -809,12 +807,10 @@ export default {
type: type
});
that.loadData();
})
, (function (err) {
}).catch((err) => {
that.fullscreenLoading = false;
console.log(err);
})
);
}).catch((err) => {
that.$notify({
title: '失败',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment