feat: questioncat 页面
This commit is contained in:
parent
210eef9e9d
commit
2a4a6e4924
|
@ -0,0 +1,173 @@
|
||||||
|
import config from "@/config"
|
||||||
|
import http from "@/utils/request"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
questioncat: {
|
||||||
|
list: {
|
||||||
|
name: "列表",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/questioncat/`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
name: "获取详情",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/questioncat/${id}/`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
name: "更新",
|
||||||
|
req: async function(id, data){
|
||||||
|
return await http.put(
|
||||||
|
`${config.API_URL}/edu/questioncat/${id}/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
name: "创建",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.post(
|
||||||
|
`${config.API_URL}/edu/questioncat/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
name: "删除",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.delete(
|
||||||
|
`${config.API_URL}/edu/questioncat/${id}/`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
question: {
|
||||||
|
list: {
|
||||||
|
name: "列表",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/question/`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
name: "获取详情",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/question/${id}/`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
name: "更新",
|
||||||
|
req: async function(id, data){
|
||||||
|
return await http.put(
|
||||||
|
`${config.API_URL}/edu/question/${id}/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
name: "创建",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.post(
|
||||||
|
`${config.API_URL}/edu/question/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
name: "删除",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.delete(
|
||||||
|
`${config.API_URL}/edu/question/${id}/`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paper: {
|
||||||
|
list: {
|
||||||
|
name: "列表",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/paper/`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
name: "获取详情",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/paper/${id}/`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
name: "更新",
|
||||||
|
req: async function(id, data){
|
||||||
|
return await http.put(
|
||||||
|
`${config.API_URL}/edu/paper/${id}/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
name: "创建",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.post(
|
||||||
|
`${config.API_URL}/edu/paper/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
name: "删除",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.delete(
|
||||||
|
`${config.API_URL}/edu/paper/${id}/`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exam: {
|
||||||
|
list: {
|
||||||
|
name: "列表",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/exam/`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
name: "获取详情",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.get(
|
||||||
|
`${config.API_URL}/edu/exam/${id}/`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
name: "更新",
|
||||||
|
req: async function(id, data){
|
||||||
|
return await http.put(
|
||||||
|
`${config.API_URL}/edu/exam/${id}/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
name: "创建",
|
||||||
|
req: async function(data){
|
||||||
|
return await http.post(
|
||||||
|
`${config.API_URL}/edu/exam/`,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
name: "删除",
|
||||||
|
req: async function(id){
|
||||||
|
return await http.delete(
|
||||||
|
`${config.API_URL}/edu/exam/${id}/`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,272 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<el-container>
|
||||||
<h2>question</h2>
|
<el-aside width="20%">
|
||||||
</div>
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<div class="left-panel">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="table_add0"
|
||||||
|
v-auth="'questioncat.create'"
|
||||||
|
></el-button>
|
||||||
|
</div>
|
||||||
|
<div class="right-panel">
|
||||||
|
<span style="font-size: 14px">题库分类</span>
|
||||||
|
</div>
|
||||||
|
</el-header>
|
||||||
|
<el-main class="nopadding">
|
||||||
|
<scTable
|
||||||
|
ref="table0"
|
||||||
|
:apiObj="apiObj0"
|
||||||
|
row-key="id"
|
||||||
|
:query="query"
|
||||||
|
:isTree="true"
|
||||||
|
stripe
|
||||||
|
default-expand-all
|
||||||
|
hidePagination
|
||||||
|
@dataChange="dataChange0"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
label="分类名"
|
||||||
|
prop="name"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="操作"
|
||||||
|
fixed="right"
|
||||||
|
width="80"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
@click="table_edit0(scope.row)"
|
||||||
|
v-auth="'questioncat.update'"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
></el-button>
|
||||||
|
<el-popconfirm
|
||||||
|
title="确定删除吗?"
|
||||||
|
@confirm="
|
||||||
|
table_del0(scope.row, scope.$index)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
v-auth="'questioncat.delete'"
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
></el-button>
|
||||||
|
</template>
|
||||||
|
</el-popconfirm>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</scTable>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</el-aside>
|
||||||
|
<el-main class="nopadding">
|
||||||
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<div class="left-panel">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="table_add"
|
||||||
|
v-auth="'question.create'"
|
||||||
|
></el-button>
|
||||||
|
</div>
|
||||||
|
<div class="right-panel">
|
||||||
|
<el-input
|
||||||
|
style="margin-right: 5px"
|
||||||
|
v-model="query.search"
|
||||||
|
placeholder="题目"
|
||||||
|
clearable
|
||||||
|
></el-input>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-search"
|
||||||
|
@click="handleQuery"
|
||||||
|
></el-button>
|
||||||
|
</div>
|
||||||
|
</el-header>
|
||||||
|
<el-main class="nopadding">
|
||||||
|
<scTable
|
||||||
|
ref="table"
|
||||||
|
:apiObj="apiObj"
|
||||||
|
row-key="id"
|
||||||
|
:query="query"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
label="题型"
|
||||||
|
prop="type"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="题目"
|
||||||
|
prop="name"
|
||||||
|
min-width="440px"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="分类"
|
||||||
|
width="180"
|
||||||
|
prop="questioncat"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="难度"
|
||||||
|
prop="level"
|
||||||
|
width="80"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="启用"
|
||||||
|
prop="enabled"
|
||||||
|
width="80"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="操作"
|
||||||
|
fixed="right"
|
||||||
|
align="center"
|
||||||
|
width="150"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
@click="table_edit(scope.row)"
|
||||||
|
v-auth="'exam.update'"
|
||||||
|
type="primary"
|
||||||
|
>编辑</el-button
|
||||||
|
>
|
||||||
|
<el-popconfirm
|
||||||
|
title="确定删除吗?"
|
||||||
|
@confirm="
|
||||||
|
table_del(scope.row, scope.$index)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
v-auth="'exam.delete'"
|
||||||
|
type="danger"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
</el-popconfirm>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</scTable>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</el-main>
|
||||||
|
<el-dialog v-model="questioncatDialog" title="新增/编辑分类">
|
||||||
|
<el-form :model="questioncatForm" label-width="100px" ref="questioncatForm">
|
||||||
|
<el-form-item label="名称" prop="name" required>
|
||||||
|
<el-input
|
||||||
|
v-model="questioncatForm.name"
|
||||||
|
clearable
|
||||||
|
></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="上级分类">
|
||||||
|
<el-cascader
|
||||||
|
v-model="questioncatForm.parent"
|
||||||
|
:options="questioncatOptions"
|
||||||
|
:show-all-levels="false"
|
||||||
|
:props="groupsProps"
|
||||||
|
clearable
|
||||||
|
style="width: 100%"
|
||||||
|
></el-cascader>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" required>
|
||||||
|
<el-input-number
|
||||||
|
v-model="questioncatForm.sort"
|
||||||
|
controls-position="right"
|
||||||
|
:min="1"
|
||||||
|
style="width: 100%"
|
||||||
|
></el-input-number>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" :loading="questioncatSaving" @click="questioncatSubmit()"
|
||||||
|
>保 存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
|
<script>
|
||||||
|
import { genTree } from "@/utils/verificate";
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
questioncatDialog: false,
|
||||||
|
questioncatForm: {},
|
||||||
|
questioncatOptions: [],
|
||||||
|
questioncatSaving: false,
|
||||||
|
groupsProps: {
|
||||||
|
multiple: false,
|
||||||
|
emitPath: false,
|
||||||
|
},
|
||||||
|
apiObj0: this.$API.edu.questioncat.list,
|
||||||
|
apiObj: this.$API.edu.exam.list,
|
||||||
|
query: {
|
||||||
|
search: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
methods: {
|
||||||
|
dataChange0(res, tableData) {
|
||||||
|
this.questioncatOptions = genTree(tableData);
|
||||||
|
},
|
||||||
|
questioncatAdd() {
|
||||||
|
this.questioncatForm = {};
|
||||||
|
this.questioncatDialog = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.questioncatForm.resetFields()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
questioncatSubmit() {
|
||||||
|
this.questioncatSaving = true;
|
||||||
|
this.$refs.questioncatForm.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if(this.questioncatForm.id){
|
||||||
|
this.$API.edu.questioncat.update.req(this.questioncatForm.id, this.questioncatForm).then(() => {
|
||||||
|
this.questioncatSaving = false;
|
||||||
|
this.$message.success("操作成功");
|
||||||
|
this.questioncatDialog = false;
|
||||||
|
this.$refs.table0.refresh();
|
||||||
|
}).catch(e=>{this.questioncatSaving = false;});
|
||||||
|
}else{
|
||||||
|
this.$API.edu.questioncat.create.req(this.questioncatForm).then(() => {
|
||||||
|
this.questioncatSaving = false;
|
||||||
|
this.$message.success("操作成功");
|
||||||
|
this.questioncatDialog = false;
|
||||||
|
this.$refs.table0.refresh();
|
||||||
|
}).catch(e=>{this.questioncatSaving = false;});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
this.questioncatSaving = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.$refs.table.queryData(this.query);
|
||||||
|
},
|
||||||
|
table_add0() {
|
||||||
|
this.questioncatDialog = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.questioncatForm.resetFields()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
table_edit0(row, index){
|
||||||
|
this.questioncatForm = {...row};
|
||||||
|
this.questioncatDialog = true;
|
||||||
|
},
|
||||||
|
table_add() {},
|
||||||
|
table_edit() {},
|
||||||
|
table_del() {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue