This commit is contained in:
joylink_fanyuhong 2024-02-23 11:22:25 +08:00
commit 9949210f89
8 changed files with 465 additions and 52 deletions

View File

@ -175,6 +175,16 @@ export function deleteTask(id) {
}); });
} }
/**
* @param {Number} id 任务id
*/
export function getTaskDetail(id) {
return request({
url: `/api/exercise/race/task/${id}`,
method: 'GET'
});
}
/** /**
* @param {Number} id 任务id * @param {Number} id 任务id
*/ */
@ -186,14 +196,15 @@ export function getchildrenTaskDatas(id) {
} }
/** /**
* @param {Object} data * @param {Array} data
* @param {Number} data.taskId 任务id * @param {Number} taskId 任务id
* @param {Number} data.bindId 绑定id根据bindtype来区分对应的id * @param {Number} data[i].bindId 绑定id根据bindtype来区分对应的id
* @param {String} data.bindType rule =评分规则;scene=场景 * @param {String} data[i].bindType rule =0评分规则;scene=1场景
* @param {Number} data[i].status 0=绑定 1=解绑
*/ */
export function bindTask(data) { export function bindTask(taskId, data) {
return request({ return request({
url: '/api/exercise/race/task/bind', url: `/api/exercise/race/task/${taskId}/bind`,
method: 'POST', method: 'POST',
data data
}); });

View File

@ -11,9 +11,9 @@
<el-select v-model="formModel.seasonId" placeholder="请选择" style="width:350px;"> <el-select v-model="formModel.seasonId" placeholder="请选择" style="width:350px;">
<el-option <el-option
v-for="item in paperOptions" v-for="item in paperOptions"
:key="item.value" :key="item.id"
:label="item.label" :label="item.name"
:value="item.value" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>

View File

@ -14,7 +14,7 @@
<script> <script>
import { getPaperList, deleteModule } from '@/api/contest'; import { getModuleList, deleteModule } from '@/api/contest';
import AddEditModule from './AddEditModule.vue'; import AddEditModule from './AddEditModule.vue';
import DetailModule from './DetailModule.vue'; import DetailModule from './DetailModule.vue';
@ -42,10 +42,6 @@ export default {
paperName: { paperName: {
type: 'text', type: 'text',
label: '试卷名称:' label: '试卷名称:'
},
paperId: {
type: 'text',
label: '试卷id:'
} }
} }
}, },
@ -66,37 +62,21 @@ export default {
title: '试卷名称', title: '试卷名称',
prop: 'paperName' prop: 'paperName'
}, },
{
title: '试卷id',
prop: 'paperId'
},
{ {
title: '考试时间', title: '考试时间',
prop: 'duration' prop: 'duration'
}, },
{ {
title: '创建时间', title: '创建时间',
prop: 'createTime' prop: 'createTime',
type: 'tag',
columnValue: (row) => { return row.modifyInfo.createTime; }
}, },
{ {
title: '更新时间', title: '修改时间',
prop: 'updateTime' prop: 'updateTime',
}, type: 'tag',
{ columnValue: (row) => { return row.modifyInfo.updateTime; }
title: '创建者id',
prop: 'creatorId'
},
{
title: '创建者姓名',
prop: 'creatorName'
},
{
title: '更新者id',
prop: 'updaterId'
},
{
title: '更新者姓名',
prop: 'updaterName'
}, },
{ {
type: 'button', type: 'button',
@ -132,7 +112,7 @@ export default {
}, },
methods: { methods: {
getListApi(obj) { getListApi(obj) {
return getPaperList({ ...obj }); return getModuleList({ ...obj });
}, },
editPaper(index, row) { editPaper(index, row) {
this.$refs.addEditModule.doShow(row); this.$refs.addEditModule.doShow(row);
@ -141,7 +121,7 @@ export default {
this.$refs.addEditModule.doShow(); this.$refs.addEditModule.doShow();
}, },
handleDelete(data) { handleDelete(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'),
type: 'warning' type: 'warning'

View File

@ -11,9 +11,9 @@
<el-select v-model="formModel.seasonId" placeholder="请选择" style="width:350px;"> <el-select v-model="formModel.seasonId" placeholder="请选择" style="width:350px;">
<el-option <el-option
v-for="item in seasonOptions" v-for="item in seasonOptions"
:key="item.value" :key="item.id"
:label="item.label" :label="item.code"
:value="item.value" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -25,7 +25,7 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { createPaper, editPaper} from '@/api/contest'; import { createPaper, editPaper, queryContestSeasonPaged} from '@/api/contest';
export default { export default {
name: 'AddContestTask', name: 'AddContestTask',
data() { data() {
@ -35,15 +35,9 @@ export default {
id: '', id: '',
name: '', // name: '', //
desc: '', // desc: '', //
seasonId: 0 // id seasonId: '' // id
}, },
seasonOptions:[{ seasonOptions:[],
value: 1,
label: '赛季1'
}, {
value: 2,
label: '赛季2'
}],
loading: false loading: false
}; };
}, },
@ -68,6 +62,9 @@ export default {
}, },
methods:{ methods:{
doShow(row) { doShow(row) {
queryContestSeasonPaged().then((res) => {
this.seasonOptions = res.data.list;
});
this.dialogVisible = true; this.dialogVisible = true;
if (row) { if (row) {
this.formModel.id = row.id; this.formModel.id = row.id;

View File

@ -56,6 +56,18 @@ export default {
title: '所属赛季', title: '所属赛季',
prop: 'seasonId' prop: 'seasonId'
}, },
{
title: '创建时间',
prop: 'createTime',
type: 'tag',
columnValue: (row) => { return row.modifyInfo.createTime; }
},
{
title: '修改时间',
prop: 'updateTime',
type: 'tag',
columnValue: (row) => { return row.modifyInfo.updateTime; }
},
{ {
type: 'button', type: 'button',
title: this.$t('global.operate'), title: this.$t('global.operate'),

View File

@ -0,0 +1,142 @@
<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="name">
<el-input v-model="formModel.name" 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="contest">
<el-input v-model="formModel.contest" type="textarea" style="width: 350px;" />
</el-form-item>
<el-form-item label="评价标准:" prop="standards">
<el-input v-model="formModel.standards" type="textarea" style="width: 350px;" />
</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 { createTask, editTask} from '@/api/contest';
export default {
name: 'AddContestTask',
data() {
return {
dialogVisible: false,
formModel: {
id: '',
name: '', //
desc: '', //
contest: '', //
standards: '', //
parentId:''
},
creatSonTask:false,
loading: false
};
},
computed: {
rules() {
const crules = {
name: [
{ required: true, message: '请输入任务名称', trigger: 'blur' }
],
desc: [
{ required: true, message: '请输入任务描述', trigger: 'blur' }
],
contest: [
{ required: true, message: '请输入考核内容', trigger: 'blur' }
],
standards: [
{ required: true, message: '请输入评价标准', trigger: 'blur' }
]
};
return crules;
},
title() {
if (this.creatSonTask) return '添加子任务';
return this.formModel.id ? '修改任务' : '新建任务';
}
},
methods:{
doShow(row, creatSonTask) {
this.dialogVisible = true;
if (creatSonTask) {
this.creatSonTask = true;
}
if (!creatSonTask && row) {
this.formModel.id = row.id;
this.formModel.name = row.label;
this.formModel.contest = row.contest;
this.formModel.standards = row.standards;
} else {
this.formModel = {
id: '',
name: '',
desc: '',
contest: '',
standards:'',
parentId:''
};
if (creatSonTask) {
this.formModel.parentId = row.id;
}
this.$nextTick(() => {
this.$refs.ruleForm.resetFields();
});
}
},
handleClose() {
this.formModel = {
id: '',
name: '',
desc: '',
contest: '',
standards:'',
parentId:''
};
this.$refs.ruleForm.resetFields();
this.creatSonTask = false;
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.parentId == '') {
delete data.parentId;
}
if (this.formModel.id) {
editTask(data).then(() => {
this.$message.success('修改任务成功!');
this.handleClose();
this.$emit('reloadTaskTree');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
} else {
createTask(data).then(() => {
this.$message.success('创建任务成功!');
this.handleClose();
this.$emit('reloadTaskTree');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
}
}
});
}
}
};
</script>

View File

@ -0,0 +1,103 @@
<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" label-width="120px">
<el-form-item label="任务名称:" prop="name">
<el-input v-model="formModel.name" style="width: 320px;" />
</el-form-item>
<el-form-item label="绑定场景:" prop="sceneId">
<el-select v-model="formModel.sceneId" placeholder="请选择" style="width:320px;">
<el-option
v-for="item in bindSceneOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="绑定评分规则:" prop="ruleId">
<el-select v-model="formModel.ruleId" placeholder="请选择" style="width:320px;">
<el-option
v-for="item in bindRuleOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</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 { bindTask, queryContextScorePaged, queryContestSencePaged} from '@/api/contest';
export default {
name: 'AddContestTask',
data() {
return {
dialogVisible: false,
formModel: {
taskId: '',
name:'',
sceneId: '', // id
ruleId: '' // id
},
bindSceneOptions: [],
bindRuleOptions:[],
loading: false
};
},
methods:{
doShow(row) {
queryContextScorePaged().then((res) => {
this.bindRuleOptions = res.data.list;
});
queryContestSencePaged().then((res) => {
this.bindSceneOptions = res.data.list;
});
this.dialogVisible = true;
this.formModel.taskId = row.id;
this.formModel.name = row.label;
this.formModel.sceneId = row.sceneId;
this.formModel.ruleId = row.ruleId;
},
handleClose() {
this.formModel = {
taskId: '',
name: '',
sceneId: '',
ruleId: ''
};
this.$refs.ruleForm.resetFields();
this.dialogVisible = false;
this.loading = false;
},
doSave() {
this.$refs.ruleForm.validate((valid) => {
if (valid) {
this.loading = true;
const data = [];
if ( this.formModel.ruleId) {
data.push({bindType:0, bindId:this.formModel.ruleId, status:0});
}
if (this.formModel.sceneId) {
data.push({bindType:1, bindId:this.formModel.sceneId, status:0});
}
bindTask(this.formModel.taskId, data).then(() => {
this.$message.success('任务绑定成功!');
this.handleClose();
this.$emit('paperListRefresh');
}).catch(error => {
this.$message.error(error.message);
this.loading = false;
});
}
});
}
}
};
</script>

View File

@ -1,3 +1,171 @@
<template> <template>
<div class="taskContainer">
<div style="margin-bottom: 10px;">
<el-card>
<div class="taskTitle">
<div>竞赛任务管理</div> <div>竞赛任务管理</div>
<div>
<el-button
type="primary"
size="small"
@click="creatTask"
>
新建任务
</el-button>
</div>
</div>
</el-card>
</div>
<el-card>
<el-tree
:data="taskDta"
node-key="id"
default-expand-all
:expand-on-click-node="false"
>
<span slot-scope="{ node, data }" class="custom-tree-node">
<span>{{ node.label }}</span>
<span>
<el-button
type="text"
size="mini"
@click="() => editTask(data)"
>
修改任务
</el-button>
<el-button
type="text"
style="color: red;"
size="mini"
@click="() => deleteTaskById(data)"
>
删除任务
</el-button>
<el-button
type="text"
size="mini"
@click="() => creatChildrenTask(data)"
>
添加子任务
</el-button>
<el-button
type="text"
size="mini"
@click="() => bindTask(data)"
>
任务绑定
</el-button>
</span>
</span>
</el-tree>
</el-card>
<add-edit-task ref="addEditTask" @reloadTaskTree="getTreeData" />
<bind-task ref="bindTask" />
</div>
</template> </template>
<script>
import AddEditTask from './AddEditTask';
import BindTask from './BindTask';
import { getTaskTreeDatas, getTaskDetail, deleteTask} from '@/api/contest';
export default {
name:'ContestTaskManage',
components: {
AddEditTask, BindTask
},
data() {
return {
taskDta:[]
};
},
created() {
this.getTreeData();
},
methods: {
getTreeData() {
getTaskTreeDatas().then((res) => {
this.taskDta = this.transformTree(res.data);
}).catch(error => {
this.$message.error(error.message);
});
},
queryChildrenTask() {
console.log(111);
},
creatTask() {
this.$refs.addEditTask.doShow();
},
creatChildrenTask(data) {
this.$refs.addEditTask.doShow(data, true);
},
editTask(data) {
getTaskDetail(data.id).then((res) => {
this.$refs.addEditTask.doShow(res.data);
});
},
bindTask(data) {
this.$refs.bindTask.doShow(data);
},
deleteTaskById(data) {
this.$confirm('确定删除该任务吗?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
})
.then(() => deleteTask(data.id))
.then(() => {
this.getTreeData();
this.$message({
type: 'success',
message: '删除成功!'
});
})
.catch(res => {
if (res.code && res.code !== 200) {
this.$message({ type: 'error', message: res.message });
}
});
},
transformTree(data) {
const result = [];
for (let i = 0; i < data.length; i++) {
const node = data[i];
const item = {
id: node.id,
label: node.name,
parentId:node.parentId
};
if (node.children) {
item.children = this.transformTree(node.children);
}
result.push(item);
}
return result;
}
}
};
</script>
<style lang="scss" scoped>
.taskContainer{
width: 50%;
margin: 0 auto;
.taskTitle {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 16px;
padding-right: 20px;
}
}
</style>