新增题目管理路由
This commit is contained in:
82
src/components/admin/challagne/chal.vue
Normal file
82
src/components/admin/challagne/chal.vue
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<template>
|
||||||
|
<el-row class="row-bg" justify="center">
|
||||||
|
<el-col :span="20">
|
||||||
|
<el-table :data="data" row-key="id" style="width: 100%">
|
||||||
|
<el-table-column label="id" prop="id" column-key="id"/>
|
||||||
|
<el-table-column label="名称" prop="name"/>
|
||||||
|
<el-table-column label="分类" prop="category" :filters="getfilterCategory()" :filter-method="filterCategory"/>
|
||||||
|
<el-table-column label="flag" prop="flag"/>
|
||||||
|
<el-table-column label="分数" prop="score"/>
|
||||||
|
<el-table-column label="是否可见" prop="visible"
|
||||||
|
:filters="[
|
||||||
|
{text:'可见',value:1},
|
||||||
|
{text:'不可见',value:0},
|
||||||
|
]"
|
||||||
|
:filter-method="filterVisible"
|
||||||
|
/>
|
||||||
|
<el-table-column fixed="right" label="Operations" width="200">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" size="small" @click="handleEdit(scope.row)"
|
||||||
|
>编辑</el-button>
|
||||||
|
<el-button link type="primary" size="small" @click="handleClick(scope.row)"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
export default{
|
||||||
|
data(){
|
||||||
|
return{
|
||||||
|
data:[],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted(){
|
||||||
|
axios.get('/api/v1/admin/challenges').then(res => {
|
||||||
|
if (res.data.code === 200) {
|
||||||
|
this.data = res.data.data;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
// 通过请求分类api获取分类数据
|
||||||
|
getfilterCategory() {
|
||||||
|
let apiArr=[
|
||||||
|
{ text: "Misc", value: "Misc" },
|
||||||
|
{ text: "Web", value: "Web" },
|
||||||
|
{ text: "Pwn", value: "Pwn" },
|
||||||
|
{ text: "Crypto", value: "Crypto" },
|
||||||
|
{ text: "Reverse", value: "Reverse" },
|
||||||
|
]
|
||||||
|
return apiArr
|
||||||
|
},
|
||||||
|
//分类筛选
|
||||||
|
filterCategory(value, row) {
|
||||||
|
return row.category === value;
|
||||||
|
},
|
||||||
|
//是否可见筛选
|
||||||
|
filterVisible(value, row) {
|
||||||
|
return row.visible === value;
|
||||||
|
},
|
||||||
|
|
||||||
|
handleClick(row){
|
||||||
|
|
||||||
|
axios.delete('/api/v1/admin/challenge/'+row.id).then(res => {
|
||||||
|
if (res.data.code === 200) {
|
||||||
|
this.$message({
|
||||||
|
message: '删除成功',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.data.splice(this.data.indexOf(row),1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
@@ -71,10 +71,9 @@ export default {
|
|||||||
axios.post('/api/v1/admin/notice',this.formData).then(res => {
|
axios.post('/api/v1/admin/notice',this.formData).then(res => {
|
||||||
if (res.data.code === 200) {
|
if (res.data.code === 200) {
|
||||||
this.dialogTableVisible = false;
|
this.dialogTableVisible = false;
|
||||||
ElNotification.success({
|
this.$message({
|
||||||
title: '成功',
|
|
||||||
message: '添加成功',
|
message: '添加成功',
|
||||||
duration: 2000
|
type: 'success'
|
||||||
});
|
});
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
@@ -84,10 +83,9 @@ export default {
|
|||||||
axios.delete('/api/v1/admin/notice/'+row.id).then(res => {
|
axios.delete('/api/v1/admin/notice/'+row.id).then(res => {
|
||||||
if (res.data.code === 200) {
|
if (res.data.code === 200) {
|
||||||
this.data.splice(this.data.indexOf(row),1);
|
this.data.splice(this.data.indexOf(row),1);
|
||||||
ElNotification.success({
|
this.$message({
|
||||||
title: '成功',
|
|
||||||
message: '删除成功',
|
message: '删除成功',
|
||||||
duration: 2000
|
type: 'success'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -62,8 +62,14 @@ const router = createRouter({
|
|||||||
path:'notification',
|
path:'notification',
|
||||||
name:'AdminNotification',
|
name:'AdminNotification',
|
||||||
component : () => import('../views/admin/AdminNotice.vue'),
|
component : () => import('../views/admin/AdminNotice.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path:'challenges',
|
||||||
|
name:'AdminChallenges',
|
||||||
|
component: ()=> import('../views/admin/AdminChal.vue'),
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path:'/404',
|
path:'/404',
|
||||||
|
12
src/views/admin/AdminChal.vue
Normal file
12
src/views/admin/AdminChal.vue
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<AdminChal></AdminChal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import AdminChal from '../../components/admin/challagne/chal.vue'
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AdminChal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Reference in New Issue
Block a user