实训案例管理页面 增删改查

zqqdev
CherrysChang 5 years ago
parent 2f2f95f550
commit 67ff9dad4c
  1. 15
      src/api/server.js
  2. 1
      src/common/js/interceptor.js
  3. 251
      src/views/train/case-detail.vue
  4. 89
      src/views/train/case-list.vue

@ -35,10 +35,10 @@ export const FILE_URL = app.FILE_URL_APP;
export const Train = new (class {
constructor() {
this.getCaseListApi = trainApi + "/trainCaseManage/list"; //实训管理列表
this.insertCaseApi = trainApi + "/trainCaseManage/add";//添加
this.updCaseApi = trainApi + "/trainCaseManage/edit";//修改
this.delCaseApi = trainApi + "/trainCaseManage/remove";//删除
this.insertCaseApi = trainApi + "/trainCaseManage/add";//添加实训案例
this.updCaseApi = trainApi + "/trainCaseManage/edit";//修改实训案例
this.delCaseApi = trainApi + "/trainCaseManage/remove";//删除实训案例
this.getCaseDetailApi = trainApi + "/trainCaseManage/detail";//获取实训案例详情
this.getTargetListApi = trainApi + "/trainCaseManage/targetList";//量化指标列表
}
@ -67,6 +67,13 @@ export const Train = new (class {
.then(res => res.data);
}
//实训案例详情
getCaseDetail(params) {
return axios
.get(this.getCaseDetailApi, {params: params})
.then(res => res.data);
}
//量化指标列表
getTargetList(params) {
return axios

@ -29,7 +29,6 @@ axios.interceptors.request.use(
axios.interceptors.response.use(
function(response){
debugger;
let location = window.location.href.split("#")[0]+'#/login';
let code = response.data.code;
if(parseInt(code) === 101||parseInt(code) === 10){//token无效

@ -19,13 +19,12 @@
<el-card class="box-card">
<div slot="header">
<span class="item-title-font"><i class="el-icon-minus icon-minus-rotated"></i>判分设置</span>
<!--<span style="float: right;vertical-align: middle;line-height: 29px;">合计{{dataForm.totalScore}} </span>-->
</div>
<div class="target-set">
<el-row :gutter="20" type="flex">
<el-col :span="1" style="text-align:center;padding-top: 182px;width: 88px;" class="item-required">量化指标</el-col>
<el-col :span="7">
<el-table ref="leftTable" :data="leftListData.filter(data => !searchName || data.name.toLowerCase().includes(searchName.toLowerCase()))"
<el-table ref="leftTable" :data="leftDictTargetList.filter(data => !searchName || data.name.toLowerCase().includes(searchName.toLowerCase()))"
height="400" border highlight-current-row tooltip-effect="dark" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column header-align="right" label="未选择 10/10">
@ -42,7 +41,7 @@
<el-button @click="removeStaff" size="mini" type="primary" icon="el-icon-arrow-left" circle style="margin:10px 0 0 0;"></el-button>
</el-col>
<el-col :span="14" class="rightTable">
<el-table ref="rightTable" :data="tableData" height="400" border highlight-current-row tooltip-effect="dark" @selection-change="handleSelectionChange">
<el-table ref="rightTable" :data="tableData" height="400" border highlight-current-row tooltip-effect="dark" :summary-method="getScoreSummaries" show-summary @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column header-align="right" label="已选择 0/10,剩余可配置分数 90 分">
<el-table-column prop="name" label="名称"></el-table-column>
@ -51,7 +50,8 @@
<el-form-item :prop="'tradeList.'+scope.$index+'.score'" :rules="dataRule.score" class="score-input" >
<el-select size="small" style="width: 100px;">
<el-option label="大于" value="1"></el-option>
<el-option label="小于" value="2"></el-option>
<el-option label="等于" value="2"></el-option>
<el-option label="小于" value="3"></el-option>
</el-select>
<el-input size="small" v-model.trim="scope.row.score" :disabled="formAction == 2" style="width: 100px;">
<i slot="suffix">%</i>
@ -69,7 +69,6 @@
<el-table-column fixed="right" label="操作" width="50">
<template slot-scope="scope">
<el-button @click.native.prevent="deleteRow(scope.$index, tableData)" type="text" size="small">移除</el-button>
<!--<el-button type="danger" size="mini" icon="el-icon-delete" circle @click.native.prevent="deleteRow(scope.$index, tableData)"></el-button>-->
</template>
</el-table-column>
</el-table-column>
@ -80,7 +79,7 @@
</el-card>
<div class="form-btn" style="text-align: center;">
<el-form-item>
<el-button type="primary" @click="doAddCaseData()">确定</el-button>
<el-button type="primary" @click="submitForm()">确定</el-button>
<el-button @click="goBackList">取消</el-button>
</el-form-item>
</div>
@ -114,7 +113,7 @@
}
};
return {
leftListData: [],
leftDictTargetList: [],
tableData: [{
name: '王小虎',
}, {
@ -138,66 +137,51 @@
}, {
name: '王小虎',
}],
isShowData: false,
tradeDialogVisible: false,
isShowTradeDelBtn: false,
formAction: 0, // 0add,1:edit,2:view
dataForm: {
id: '',
type: '',
name: '',
content: '',
totalScore: 0,
caseDataList: [],
tradeList: [],
taskList: [],
isAdmin: 1, //
},
totalScore: 0,//
dataRule: {
name: [
{ required: true, message: '请输入项目名称', trigger: 'blur' },
{ required: true, message: '请输入实训名称', trigger: 'blur' },
{ min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
],
type: [
{ required: true, message: '请选择项目权限', trigger: 'change' }
],
content: [
{validator: validateContent, trigger: 'blur'}
],
score: [
{validator: validateScore, trigger: 'blur'}
{ required: true, message: '请选择实训用途', trigger: 'change' }
],
// content: [
// {validator: validateContent, trigger: 'blur'}
// ],
// score: [
// {validator: validateScore, trigger: 'blur'}
// ],
},
dictCaseDataList: [],
selectedItemRows: [],
selectedTradeItems: [],
delTradeItems: [],
tradeNotInIds: [],
}
},
created() {
if (this.$route.query.id) {
this.dataForm.id = this.$route.query.id;
this.$http.get('/authapi/bs_projectManage/getDetail?id=' + this.dataForm.id).then(response => {
this.dataForm = response;
Train.getCaseDetail({id: this.dataForm.id}).then((res) => {
this.dataForm = res.data;
//
this.dataForm.type = String(response.type);
//
this.selectedItemRows = this.dataForm.caseDataList;
//
this.selectedTradeItems = this.dataForm.tradeList;
this.dataForm.type = String(res.type);
if (this.$route.query.isEdit === 1) {
//
this.formAction = 1;
if (this.selectedTradeItems && this.selectedTradeItems.length > 0) {
this.isShowTradeDelBtn = true;//
}
} else {
//
this.formAction = 2;
}
});
})
}
//
this.initTargetList();
},
methods: {
@ -208,148 +192,12 @@
initTargetList(searchObj) {
Train.getTargetList(searchObj).then(res => {
if (res.code == 200) {
this.leftListData = res.data;
this.leftDictTargetList = res.data;
}
}).catch(error => {
console.info(error)
});
},
goBackAdd() {
this.isShowData = false;
},
toAddCaseData() {
//
window.scrollTo(0, 0);
this.isShowData = true;
this.getCaseData(null);
},
getCaseData(condition) {
this.$http.get('/authapi/bs_projectManage/getDictCaseDataList', {params: condition}).then(response => {
this.dictCaseDataList = response;
//
if (this.selectedItemRows && this.selectedItemRows.length > 0) {
let selectedItemIds = this.selectedItemRows.map(function (row) {
return row.id;
});
this.dictCaseDataList.forEach(p => {
if (selectedItemIds.indexOf(p.id) > -1) {
p.checked = true;
}
});
}
});
},
handleItemSelectionChange(val) {
this.selectedItemRows = val;
},
doAddCaseData() {
if (!this.selectedItemRows || this.selectedItemRows.length === 0) {
this.$notify.warning({
title: '系统提示',
message: '您没选择任何数据,请先选择!',
duration: 2000,
});
return;
}
this.isShowData = false;
this.dataForm.caseDataList = this.selectedItemRows;
},
cancelAddCaseData() {
this.isShowData = false;
this.selectedItemRows = this.dataForm.caseDataList;
},
getFileUrl(file) {
return window.SITE_CONFIG['serverUrl'] + file.imgUrl;
},
toAddTrade() { //
this.tradeDialogVisible = true;
// id
this.tradeNotInIds = this.selectedTradeItems.map(item => {
return item.id;
});
},
doAddSelectTrade(val) {//
if (this.selectedTradeItems && this.selectedTradeItems.length > 0) {
// val
this.selectedTradeItems.push.apply(this.selectedTradeItems, val);
} else {
this.selectedTradeItems = val;
}
this.dataForm.tradeList = this.selectedTradeItems;
this.dataForm.tradeList.forEach(item => {
this.$set(item, 'score', '');
// this.$set(item, 'tradeId', item.id);
});
this.isShowTradeDelBtn = true;//
},
closeTradeDialog() { //
this.tradeDialogVisible = false;
},
handleTradeSelectionChange(val) {
this.delTradeItems = val;
},
checkboxIsEnabled() { //
if (this.formAction === 2) {
return false;
} else {
return true;
}
},
removeTradeItemBatch() { //
if (!this.delTradeItems || this.delTradeItems.length === 0) {
this.$notify.warning({
title: '系统提示',
message: '您没选择任何数据,请先选择!',
duration: 2000,
});
return;
}
//
this.delTradeItems.forEach(item => {
if (this.selectedTradeItems.indexOf(item) > -1) {
//
this.selectedTradeItems.splice(this.selectedTradeItems.indexOf(item), 1);
// this.dataForm.tradeList.splice(this.dataForm.tradeList.indexOf(item), 1);
}
});
if (this.selectedTradeItems.length === 0) {
this.isShowTradeDelBtn = false; //
}
},
removeTradeItem(row) { //
let index = this.selectedTradeItems.findIndex(item => {
return item.id == row.id;
});
if (index > -1) {
this.selectedTradeItems.splice(this.selectedTradeItems.indexOf(row), 1);
}
},
moveUpTradeItem(index,row) { //
let that = this;
// console.log('', index, row);
// console.log(that.dataForm.tradeList[index]);
if (index > 0) {
let upDate = that.dataForm.tradeList[index - 1];
that.dataForm.tradeList.splice(index - 1, 1);
that.dataForm.tradeList.splice(index, 0, upDate);
} else {
alert('已经是第一条,不可上移');
}
},
moveDownTradeItem(index,row) { //
let that = this;
// console.log('', index, row);
if ((index + 1) === that.dataForm.tradeList.length) {
alert('已经是最后一条,不可下移');
} else {
// console.log(index);
let downDate = that.dataForm.tradeList[index + 1];
that.dataForm.tradeList.splice(index + 1, 1);
that.dataForm.tradeList.splice(index, 0, downDate);
}
},
getScoreSummaries(param) { //
const { columns, data } = param;
const sums = [];
@ -360,7 +208,7 @@
return;
}
if (index === 6) { //
if (index === 3) { //
values = data.map(item => Number(item['score']));
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
@ -380,60 +228,39 @@
return sums;
},
submitForm(formName) {
submitForm() {
let self = this;
self.$refs[formName].validate((valid) => {
self.$refs['dataForm'].validate((valid) => {
if (valid) {
let totalScore = self.dataForm.totalScore;
let totalScore = self.totalScore;
if (totalScore === 0) {
self.$notify.error({
title: '错误提示',
message: '判分设置模块没有添加计分点!',
duration: 2000,
});
self.$message.error("判分设置模块没有添加计分点!");
return;
} else if (totalScore > 100) {
self.$notify.error({
title: '错误提示',
message: '判分设置模块总分超过100分!',
duration: 2000,
});
self.$message.error("判分设置模块总分超过100分!");
return;
} else if (totalScore < 100) {
self.$notify.error({
title: '错误提示',
message: '判分设置模块总分不足100分!',
duration: 2000,
});
self.$message.error("判分设置模块总分不足100分!");
return;
}
// userType 0 1 2
if (self.formAction == 0 && self.$store.state.app.user.userType) {
self.dataForm.isAdmin = self.$store.state.app.user.userType == 1 ? 0 : 1;
}
self.$http.post('/authapi/bs_projectManage/addOrUpdateProject', self.dataForm).then(response => {
if(response.status==1) {
self.dataForm = Object.assign({}, self.dataForm, response.id);
// if (self.formAction == 0 && self.$store.state.app.user.userType) {
// self.dataForm.isAdmin = self.$store.state.app.user.userType == 1 ? 0 : 1;
// }
Train.insertCase(self.dataForm).then(res => {
if (res.code == 200) {
// self.dataForm = Object.assign({}, self.dataForm, response.id);
self.formAction = 1;
self.$notify.success({
title: '操作成功!',
message: '新增项目成功!',
duration: 2000,
});
self.$message.success("操作成功!");
self.goBackList();
} else {
self.$message.error(response.msg);
self.$message.error(res.msg);
}
}).catch(error => {
self.$message.error(error);
})
} else {
self.$notify.error({
title: '错误提示',
message: '系统输入验证失败!',
duration: 2000,
});
} else {
self.$message.error('系统输入验证失败!');
return false;
}
});

@ -14,7 +14,7 @@
<el-select v-model="searchObj.isAdmin" placeholder="创建人">
<el-option label="全部" value=""></el-option>
<el-option label="管理员" value="1"></el-option>
<el-option label="教师" value="2"></el-option>
<el-option label="教师" value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item label="实训名称">
@ -26,15 +26,11 @@
<el-form-item>
<el-button type="primary" icon="el-icon-circle-plus-outline" @click="doNew">创建</el-button>
</el-form-item>
<!--<el-form-item>
<el-button type="danger" @click="doBatchDel">批量删除</el-button>
</el-form-item>-->
</el-form>
</el-col>
</el-row>
<el-row style="padding: 20px;background-color: #FFFFFF;">
<el-table ref="multipleTable" :data="listData" @selection-change="handleProjectSelectionChange" border style="width: 100%">
<!-- <el-table-column type="selection" width="55"></el-table-column>-->
<el-table ref="caseListTable" :data="listData" border style="width: 100%">
<el-table-column type="index" label="序号" width="100"></el-table-column>
<el-table-column prop="name" label="实训名称" width="400"></el-table-column>
<el-table-column prop="type" label="实训用途" width="160">
@ -53,12 +49,8 @@
<el-table-column label="操作">
<template slot-scope="scope">
<el-button @click="toInputForm(scope.row,0)" type="text" size="small">查看</el-button>
<el-button @click="toInputForm(scope.row,1)" type="text" size="small"
v-if="isShowEditOrDelBtn(scope.row)">编辑
</el-button>
<el-button @click="doSingleDel(scope.row)" type="text" size="small" v-if="isShowEditOrDelBtn(scope.row)">
删除
</el-button>
<el-button @click="toInputForm(scope.row,1)" type="text" size="small" v-if="isShowEditOrDelBtn(scope.row)">编辑</el-button>
<el-button @click="doSingleDel(scope.row)" type="text" size="small" v-if="isShowEditOrDelBtn(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -87,7 +79,6 @@
name: ''
},
listData: [],
delProjectItems: [],
totalCount: 0,
currentPage: 1,
pageSize: 10,
@ -109,81 +100,35 @@
});
},
isShowEditOrDelBtn(row) {
let userType = this.$store.state.app.user.userType;
let projectType = row.isAdmin;
if (userType == 1 && projectType == 1) {//
return false;
}
if(userType==2 && projectType==0 ) {//
return false;
}
// let userType = this.$store.state.user.userType;
// let projectType = row.isAdmin;
// if (userType == 1 && projectType == 1) {//
// return false;
// }
// if(userType==2 && projectType==0 ) {//
// return false;
// }
return true;
},
doNew() {//
this.toInputForm();
},
handleProjectSelectionChange(val) {
this.delProjectItems = val;
},
doBatchDel() {//
if (!this.delProjectItems || this.delProjectItems.length === 0) {
this.$notify.warning({
title: '系统提示',
message: '您没选择任何行,无法操作!',
duration: 2000,
});
return;
}
let ids = this.delProjectItems.map(function (row) {
return row.id;
});
this.$confirm('确认要删除这 ' + ids.length + ' 项数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http.post('/authapi/bs_projectManage/batchDeleteProjects', ids).then(response => {
if (response.status==1) {
this.$notify.success({
title: '系统删除成功',
message: '系统批量删除成功!',
});
this.initList();
} else {
this.$notify.error({
title: '错误提示',
message: response.msg,
});
}
}).catch(error => {
console.info(error)
})
}).catch(() => {
});
},
doSingleDel(row) { //
this.$confirm('确认要删除这项数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http.post('/authapi/bs_projectManage/singleDeleteProject', {id: row.id}).then(response => {
if (response.status==1) {
this.$notify.success({
title: '系统删除成功',
message: '系统删除成功!',
});
Train.delCase({id: row.id}).then((res) => {
if (res.code == 200) {
this.$message.success('删除成功!');
this.initList();
} else {
this.$notify.error({
title: '错误提示',
message: response.msg,
});
this.$message.error(res.msg);
}
}).catch(error => {
console.info(error)
})
});
}).catch(() => {
});
},

Loading…
Cancel
Save