竞赛模块代码备用

This commit is contained in:
joylink_zhaoerwei 2024-02-21 16:38:20 +08:00
parent e48289b953
commit 8c59b44de1
5 changed files with 478 additions and 3 deletions

View File

@ -50,6 +50,84 @@ export function deletePaper(id) {
}); });
} }
/**
* 获取竞赛模块分页列表
* @param {Object} data
* @param {String} data.paperName 试卷名称
* @param {Number} data.paperId 试卷id
* @param {String} data.code 模块名称
*/
export function getModuleList(data) {
return request({
url: '/api/exercise/race/module/page',
method: 'GET',
data
});
}
/**
* 创建模块
* @param {Object} data
* @param {String} data.code 模块名称
* @param {String} data.desc 基础描述
* @param {Number} data.paperId 试卷id
*/
export function createModule(data) {
return request({
url: '/api/exercise/race/module',
method: 'POST',
data
});
}
/**
* @param {Object} data 同创建试卷
* @param {Number} id 模块id
*/
export function editModule(id, data) {
return request({
url: `/api/exercise/race/module/${id}`,
method: 'POST',
data
});
}
/**
* @param {Number} id 模块id
*/
export function deleteModule(id) {
return request({
url: `/api/exercise/race/module/${id}`,
method: 'DELETE'
});
}
/**
* @param {Number} id 模块id
*/
export function getModuleDetail(id) {
return request({
url: `/api/exercise/race/module/${id}`,
method: 'GET'
});
}
/**
* @param {Object} data
* @param {Number} data.taskIds 模块里所有任务id一级任务的id
* @param {Number} data.group 任务分组
* @param {Number} data.group.taskIds 次分组中的任务id
* @param {Number} data.group.name 分组的名字
* @param {Number} data.group.group 次分组的子分组
*/
export function moduleTaskSetting(moudleId, data) {
return request({
url: `/api/exercise/race/module/setting/${moudleId}/task`,
method: 'POST',
data
});
}
/** 查看所有任务数据 */ /** 查看所有任务数据 */
export function getTaskTreeDatas() { export function getTaskTreeDatas() {
return request({ return request({

View File

@ -0,0 +1,128 @@
<template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="500px" :before-close="handleClose" center :close-on-click-modal="false">
<el-form ref="ruleForm" :model="formModel" :rules="rules" label-width="100px">
<el-form-item label="模块名称:" prop="code">
<el-input v-model="formModel.code" style="width: 350px;" />
</el-form-item>
<el-form-item label="模块描述:" prop="desc">
<el-input v-model="formModel.desc" type="textarea" style="width:350px;" />
</el-form-item>
<el-form-item label="试卷:" prop="paperId">
<el-select v-model="formModel.seasonId" placeholder="请选择" style="width:350px;">
<el-option
v-for="item in paperOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button v-loading="loading" type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { createModule, editModule, getPaperList} from '@/api/contest';
export default {
name: 'AddContestTask',
data() {
return {
dialogVisible: false,
formModel: {
id: '',
code: '', //
desc: '', //
paperId: '' // id
},
paperOptions:[],
loading: false
};
},
computed: {
rules() {
const crules = {
code: [
{ required: true, message: '请输入模块名称', trigger: 'blur' }
],
desc: [
{ required: true, message: '请输入模块描述', trigger: 'blur' }
],
paperId: [
{ required: true, message: '请选择所属试卷', trigger: 'blur' }
]
};
return crules;
},
title() {
return this.formModel.id ? '修改模块' : '创建模块';
}
},
methods:{
doShow(row) {
getPaperList().then((res) => {
this.paperOptions = res.data.list;
});
this.dialogVisible = true;
if (row) {
this.formModel.id = row.id;
this.formModel.code = row.code;
this.formModel.desc = row.desc;
this.formModel.paperId = row.paperId;
} else {
this.formModel = {
id: '',
code: '',
desc: '',
paperId: ''
};
this.$nextTick(() => {
this.$refs.ruleForm.resetFields();
});
}
},
handleClose() {
this.formModel = {
id: '',
code: '',
desc: '',
paperId: ''
};
this.$refs.ruleForm.resetFields();
this.dialogVisible = false;
this.loading = false;
},
doSave() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
this.loading = true;
const data = Object.assign({}, this.formModel);
delete data.id;
if (this.formModel.id) {
editModule(data).then(() => {
this.$message.success('修改模块成功!');
this.handleClose();
this.$emit('moduleListRefresh');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
} else {
createModule(data).then(() => {
this.$message.success('创建模块成功!');
this.handleClose();
this.$emit('moduleListRefresh');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
}
}
});
}
}
};
</script>

View File

@ -1,3 +1,175 @@
<template> <template>
<div>竞赛模块管理</div> <div style="width: 100%;">
<QueryListPage
ref="moduleQueryListPage"
:card-padding="10"
:query-form="examQueryForm"
:pager-config="pagerConfig"
:query-list="examQueryList"
/>
<add-edit-module ref="addEditModule" @moduleListRefresh="moduleListRefresh" />
<detail-module ref="detailModule" />
</div>
</template> </template>
<script>
import { getPaperList, deleteModule } from '@/api/contest';
import AddEditModule from './AddEditModule.vue';
import DetailModule from './DetailModule.vue';
export default {
name: 'MoudleManage',
components: { AddEditModule, DetailModule },
data() {
return {
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
seasonlist: [],
examQueryForm: {
leftSpan: 14,
textAlign: 'right',
labelWidth: '90px',
reset: true,
columnNum: 3,
queryObject: {
code: {
type: 'text',
label: '模块名称:'
},
paperName: {
type: 'text',
label: '试卷名称:'
},
paperId: {
type: 'text',
label: '试卷id:'
}
}
},
examQueryList: {
query: obj => this.getListApi(obj),
selectCheckShow: false,
indexShow: false,
columns: [
{
title: '模块名称',
prop: 'code'
},
{
title: '模块描述',
prop: 'desc'
},
{
title: '试卷名称',
prop: 'paperName'
},
{
title: '试卷id',
prop: 'paperId'
},
{
title: '考试时间',
prop: 'duration'
},
{
title: '创建时间',
prop: 'createTime'
},
{
title: '更新时间',
prop: 'updateTime'
},
{
title: '创建者id',
prop: 'creatorId'
},
{
title: '创建者姓名',
prop: 'creatorName'
},
{
title: '更新者id',
prop: 'updaterId'
},
{
title: '更新者姓名',
prop: 'updaterName'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '350',
buttons: [
{
name: '编辑',
handleClick: this.editPaper,
type: 'primary'
},
{
name: '删除',
handleClick: this.handleDelete,
type: 'danger'
},
{
name: '模块详情',
handleClick: this.openDetailDialog,
type: 'info'
}
]
}
],
actions: [{ text: '新建模块', handler: this.creatPaper }]
}
};
},
computed: {
userId() {
return this.$store.state.user.id;
}
},
methods: {
getListApi(obj) {
return getPaperList({ ...obj });
},
editPaper(index, row) {
this.$refs.addEditModule.doShow(row);
},
creatPaper() {
this.$refs.addEditModule.doShow();
},
handleDelete(data) {
this.$confirm('确定删除该试卷吗?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
})
.then(() => deleteModule(data.id))
.then(() => {
this.moduleListRefresh();
this.$message({
type: 'success',
message: '删除成功!'
});
})
.catch(res => {
if (res.code && res.code !== 200) {
this.$message({ type: 'error', message: res.message });
}
});
},
openDetailDialog(index, row) {
this.$refs.detailModule.doShow(row.id);
},
moduleListRefresh() {
this.$nextTick(() => {
this.$refs.moduleQueryListPage.refresh(true);
});
}
}
};
</script>
<style scoped></style>

View File

@ -0,0 +1,97 @@
<template>
<el-dialog v-dialogDrag title="模块详情" :visible.sync="dialogVisible" width="500px" :before-close="handleClose" center :close-on-click-modal="false">
<el-form ref="ruleForm" :model="formModel" :rules="rules" label-width="100px">
<el-form-item label="任务:" prop="paperId">
<el-select v-model="formModel.taskIds" multiple placeholder="请选择" style="width:350px;">
<el-option
v-for="item in taskOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="分组:" prop="paperId">
<el-tree
:data="formModel.group"
:props="defaultProps"
accordion
/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button v-loading="loading" type="primary" @click="doSave">设置模块任务</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { getModuleDetail, getTaskTreeDatas, moduleTaskSetting} from '@/api/contest';
export default {
name: 'DetailModule',
data() {
return {
dialogVisible: false,
formModel: {
taskIds: [], //
group:[{name:'', taskIds: [], group:[] }]//
},
taskOptions:[],
loading: false,
moduleId:'',
defaultProps: {
children: 'children',
label: 'label'
}
};
},
computed: {
rules() {
const crules = {
taskIds: [
{ required: true, message: '请选择模块任务', trigger: 'blur' }
]
};
return crules;
}
},
methods:{
doShow(moduleId) {
getTaskTreeDatas().then((res) => {
this.taskOptions = res.data;
});
getModuleDetail(moduleId).then((res) => {
this.formModel = res.data;
});
this.dialogVisible = true;
this.moduleId = moduleId;
},
handleClose() {
this.formModel = {
taskIds: [], //
group:[{name:'', taskIds: [], group:[] }]//
};
this.$refs.ruleForm.resetFields();
this.dialogVisible = false;
this.loading = false;
},
doSave() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
this.loading = true;
const data = Object.assign({}, this.formModel);
moduleTaskSetting(this.moduleId, data).then(() => {
this.$message.success('模块任务设置成功!');
this.handleClose();
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
}
});
}
}
};
</script>

View File

@ -90,13 +90,13 @@ export default {
getListApi(obj) { getListApi(obj) {
return getPaperList({ ...obj }); return getPaperList({ ...obj });
}, },
editPaper(row) { editPaper(index, row) {
this.$refs.addEditPaper.doShow(row); this.$refs.addEditPaper.doShow(row);
}, },
creatPaper() { creatPaper() {
this.$refs.addEditPaper.doShow(); this.$refs.addEditPaper.doShow();
}, },
handleDelete(data) { handleDelete(index, data) {
this.$confirm('确定删除该试卷吗?', this.$t('global.tips'), { this.$confirm('确定删除该试卷吗?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'), confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'), cancelButtonText: this.$t('global.cancel'),