testrule
This commit is contained in:
parent
19633cd6e8
commit
01be8f6c30
|
@ -0,0 +1,29 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getTestRuleAll() {
|
||||||
|
return request({
|
||||||
|
url: '/examtest/testrule/',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createTestRule(data) {
|
||||||
|
return request({
|
||||||
|
url: '/examtest/testrule/',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function updateTestRule(id, data) {
|
||||||
|
return request({
|
||||||
|
url: `/examtest/testrule/${id}/`,
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function deleteTestRule(id) {
|
||||||
|
return request({
|
||||||
|
url: `/examtest/testrule/${id}/`,
|
||||||
|
method: 'delete',
|
||||||
|
})
|
||||||
|
}
|
|
@ -51,9 +51,10 @@ export const constantRoutes = [
|
||||||
path: 'dashboard',
|
path: 'dashboard',
|
||||||
name: 'Dashboard',
|
name: 'Dashboard',
|
||||||
component: () => import('@/views/dashboard/index'),
|
component: () => import('@/views/dashboard/index'),
|
||||||
meta: { title: '首页', icon: 'dashboard' }
|
meta: { title: '首页', icon: '' }
|
||||||
}]
|
}]
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -67,19 +68,19 @@ export const asyncRoutes = [
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/crm/',
|
redirect: '/crm/',
|
||||||
name: 'Crm',
|
name: 'Crm',
|
||||||
meta: { title: '客户管理', icon: 'example', perms: ['custom_manage'] },
|
meta: { title: '客户管理', icon: '', perms: ['custom_manage'] },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'company',
|
path: 'company',
|
||||||
name: 'Company',
|
name: 'Company',
|
||||||
component: () => import('@/views/crm/company.vue'),
|
component: () => import('@/views/crm/company.vue'),
|
||||||
meta: { title: '客户企业', icon: 'user', perms: ['company_manage'] }
|
meta: { title: '客户企业', icon: '', perms: ['company_manage'] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'consumer',
|
path: 'consumer',
|
||||||
name: 'Consumer',
|
name: 'Consumer',
|
||||||
component: () => import('@/views/crm/consumer.vue'),
|
component: () => import('@/views/crm/consumer.vue'),
|
||||||
meta: { title: '学员列表', icon: 'user', perms: ['consumer_list'] }
|
meta: { title: '学员列表', icon: '', perms: ['consumer_list'] }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -88,19 +89,26 @@ export const asyncRoutes = [
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/sjmanage/',
|
redirect: '/sjmanage/',
|
||||||
name: 'Sjmanage',
|
name: 'Sjmanage',
|
||||||
meta: { title: '试卷管理', icon: 'example'},
|
meta: { title: '试卷管理', icon: ''},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'testrule',
|
path: 'testrule',
|
||||||
name: 'testrule',
|
name: 'TestRule',
|
||||||
component: () => import('@/views/question/questioncat.vue'),
|
component: () => import('@/views/examtest/rule.vue'),
|
||||||
meta: { title: '模考规则', icon: 'user', perms: ['questioncat_manage'] }
|
meta: { title: '模考规则', icon: '', perms: ['testrule_manage'] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'testpaper',
|
path: 'testpaper',
|
||||||
name: 'testpaper',
|
name: 'testpaper',
|
||||||
component: () => import('@/views/question/question.vue'),
|
component: () => import('@/views/question/question.vue'),
|
||||||
meta: { title: '押题试卷', icon: 'user', perms: ['question_manage'] }
|
meta: { title: '押题试卷', icon: '', perms: ['question_manage'] }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'testrule/create',
|
||||||
|
name: 'CreateRule',
|
||||||
|
component: () => import('@/views/examtest/rulecreate.vue'),
|
||||||
|
meta: { title: '新建模考规则', noCache: true, icon: '', perms: ['testrule_add']},
|
||||||
|
hidden: true
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -109,19 +117,19 @@ export const asyncRoutes = [
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/djmanage/',
|
redirect: '/djmanage/',
|
||||||
name: 'Djmanage',
|
name: 'Djmanage',
|
||||||
meta: { title: '答卷管理', icon: 'example'},
|
meta: { title: '答卷管理', icon: ''},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'testrule',
|
path: 'testrule',
|
||||||
name: 'testrule',
|
name: 'testrule',
|
||||||
component: () => import('@/views/question/questioncat.vue'),
|
component: () => import('@/views/question/questioncat.vue'),
|
||||||
meta: { title: '答卷列表', icon: 'user', perms: ['questioncat_manage'] }
|
meta: { title: '答卷列表', icon: '', perms: ['questioncat_manage'] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'testpaper',
|
path: 'testpaper',
|
||||||
name: 'testpaper',
|
name: 'testpaper',
|
||||||
component: () => import('@/views/question/question.vue'),
|
component: () => import('@/views/question/question.vue'),
|
||||||
meta: { title: '答卷统计', icon: 'user', perms: ['question_manage'] }
|
meta: { title: '答卷统计', icon: '', perms: ['question_manage'] }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -130,25 +138,25 @@ export const asyncRoutes = [
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/Qmanage/',
|
redirect: '/Qmanage/',
|
||||||
name: 'Qmanage',
|
name: 'Qmanage',
|
||||||
meta: { title: '题库管理', icon: 'example'},
|
meta: { title: '题库管理', icon: ''},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'subject',
|
path: 'subject',
|
||||||
name: 'subject',
|
name: 'subject',
|
||||||
component: () => import('@/views/question/subject.vue'),
|
component: () => import('@/views/question/subject.vue'),
|
||||||
meta: { title: '学科分类', icon: 'user', perms: ['subject_manage'] }
|
meta: { title: '学科分类', icon: '', perms: ['subject_manage'] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'questioncat',
|
path: 'questioncat',
|
||||||
name: 'questioncat',
|
name: 'questioncat',
|
||||||
component: () => import('@/views/question/questioncat.vue'),
|
component: () => import('@/views/question/questioncat.vue'),
|
||||||
meta: { title: '题库分类', icon: 'user', perms: ['questioncat_manage'] }
|
meta: { title: '题库分类', icon: '', perms: ['questioncat_manage'] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'question',
|
path: 'question',
|
||||||
name: 'question',
|
name: 'question',
|
||||||
component: () => import('@/views/question/question.vue'),
|
component: () => import('@/views/question/question.vue'),
|
||||||
meta: { title: '题目列表', icon: 'user', perms: ['question_manage'] }
|
meta: { title: '题目列表', icon: '', perms: ['question_manage'] }
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -157,25 +165,25 @@ export const asyncRoutes = [
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: '/system/user',
|
redirect: '/system/user',
|
||||||
name: 'System',
|
name: 'System',
|
||||||
meta: { title: '系统管理', icon: 'example', perms: ['system_manage'] },
|
meta: { title: '系统管理', icon: '', perms: ['system_manage'] },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'user',
|
path: 'user',
|
||||||
name: 'User',
|
name: 'User',
|
||||||
component: () => import('@/views/system/user.vue'),
|
component: () => import('@/views/system/user.vue'),
|
||||||
meta: { title: '用户管理', icon: 'user', perms: ['user_manage'] }
|
meta: { title: '用户管理', icon: '', perms: ['user_manage'] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'organization',
|
path: 'organization',
|
||||||
name: 'Organization',
|
name: 'Organization',
|
||||||
component: () => import('@/views/system/organization'),
|
component: () => import('@/views/system/organization'),
|
||||||
meta: { title: '部门管理', icon: 'tree', perms: ['organization_manage'] }
|
meta: { title: '部门管理', icon: '', perms: ['organization_manage'] }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'role',
|
path: 'role',
|
||||||
name: 'Role',
|
name: 'Role',
|
||||||
component: () => import('@/views/system/role'),
|
component: () => import('@/views/system/role'),
|
||||||
meta: { title: '角色管理', icon: 'lock', perms: ['role_manage'] }
|
meta: { title: '角色管理', icon: '', perms: ['role_manage'] }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<div style="margin-top:10px">
|
||||||
|
<el-input
|
||||||
|
v-model="search"
|
||||||
|
placeholder="输入规则名称进行搜索"
|
||||||
|
style="width: 200px;"
|
||||||
|
class="filter-item"
|
||||||
|
/>
|
||||||
|
<el-button type="primary" @click="handleAdd" icon="el-icon-plus">新增</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
:data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
|
||||||
|
style="width: 100%;margin-top:10px;"
|
||||||
|
border
|
||||||
|
fit
|
||||||
|
v-loading="listLoading"
|
||||||
|
highlight-current-row
|
||||||
|
max-height="600"
|
||||||
|
row-key="id"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" width="50"></el-table-column>
|
||||||
|
<el-table-column align="center" label="名称">
|
||||||
|
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建日期">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.create_time }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="操作">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="handleEdit(scope)"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
:disabled="!checkPermission(['testrule_update'])"
|
||||||
|
></el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
@click="handleDelete(scope)"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
:disabled="!checkPermission(['testrule_delete'])"
|
||||||
|
></el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getTestRuleAll,
|
||||||
|
createTestRule,
|
||||||
|
delteTestRule,
|
||||||
|
updateTestRule
|
||||||
|
} from "@/api/examtest";
|
||||||
|
import checkPermission from "@/utils/permission";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
search: "",
|
||||||
|
tableData: [],
|
||||||
|
listLoading: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
checkPermission,
|
||||||
|
getList() {
|
||||||
|
this.listLoading = true;
|
||||||
|
getTestRuleAll().then(response => {
|
||||||
|
this.tableData = response.data;
|
||||||
|
this.listLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
resetFilter() {
|
||||||
|
this.search = ""
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
handleAdd() {
|
||||||
|
this.$router.push({path:"/sjmanage/testrule/create"})
|
||||||
|
},
|
||||||
|
handleEdit(scope) {
|
||||||
|
|
||||||
|
},
|
||||||
|
handleDelete(scope) {
|
||||||
|
this.$confirm("确认删除该分类吗?将丢失数据!", "警告", {
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "error"
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
await delteTestRule(scope.row.id);
|
||||||
|
this.getList();
|
||||||
|
this.$message({
|
||||||
|
type: "success",
|
||||||
|
message: "成功删除!"
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
// console.error(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -0,0 +1,138 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form
|
||||||
|
:model="ruleForm"
|
||||||
|
:rules="rules"
|
||||||
|
ref="ruleForm"
|
||||||
|
label-width="100px"
|
||||||
|
class="demo-ruleForm"
|
||||||
|
>
|
||||||
|
<el-form-item label="规则名称" prop="name">
|
||||||
|
<el-input v-model="ruleForm.name" style="width:400px"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="所属学科" prop="subject">
|
||||||
|
<el-select v-model="ruleForm.subject" placeholder="请选择所属学科" style="width:400px">
|
||||||
|
<el-option
|
||||||
|
v-for="item in subjectData"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="题库范围" prop="questioncat">
|
||||||
|
<el-select v-model="ruleForm.questioncat" multiple placeholder="请选择题库范围" style="width:400px">
|
||||||
|
<el-option label="区域一" value="shanghai"></el-option>
|
||||||
|
<el-option label="区域二" value="beijing"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="单选题">
|
||||||
|
共有<span style="color:orange;font-weight:bold">0</span>道,选取
|
||||||
|
<el-input v-model="ruleForm.detail.danxuan.num" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||||
|
<el-input v-model="ruleForm.detail.danxuan.score" style="width:60px" @input="calScore()"></el-input>分
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="多选题">
|
||||||
|
共有<span style="color:orange;font-weight:bold">0</span>道,选取
|
||||||
|
<el-input v-model="ruleForm.detail.duoxuan.num" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||||
|
<el-input v-model="ruleForm.detail.duoxuan.score" style="width:60px" @input="calScore()"></el-input>分
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="判断题">
|
||||||
|
共有<span style="color:orange;font-weight:bold">0</span>道,选取
|
||||||
|
<el-input v-model="ruleForm.detail.panduan.num" style="width:60px" @input="calScore()"></el-input>道,每道
|
||||||
|
<el-input v-model="ruleForm.detail.panduan.score" style="width:60px" @input="calScore()"></el-input>分
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="时间限制" prop="duration">
|
||||||
|
<el-input v-model="ruleForm.detail.panduan.duration" style="width:60px"></el-input>分钟
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="当前总分">
|
||||||
|
<span style="color:orange;font-weight:bold">{{ruleForm.detail.score}}分</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="及格分数" prop="passscore">
|
||||||
|
<el-input v-model="ruleForm.detail.panduan.passscore" style="width:60px"></el-input>分
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
|
||||||
|
<el-button @click="resetForm('ruleForm')">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { createTestRule } from "@/api/examtest";
|
||||||
|
import { getSubjectAll, getQuestioncatList } from "@/api/question";
|
||||||
|
import { genTree } from "@/utils";
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
ruleForm: {
|
||||||
|
name: "",
|
||||||
|
subject: null,
|
||||||
|
questioncat: [],
|
||||||
|
detail: {
|
||||||
|
danxuan: {
|
||||||
|
num: 0,
|
||||||
|
score: 0
|
||||||
|
},
|
||||||
|
duoxuan: {
|
||||||
|
num: 0,
|
||||||
|
score: 0
|
||||||
|
},
|
||||||
|
panduan: {
|
||||||
|
num: 0,
|
||||||
|
score: 0
|
||||||
|
},
|
||||||
|
duration: 0,
|
||||||
|
score: 0,
|
||||||
|
passscore: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
subjectData:[],
|
||||||
|
questioncatData:[],
|
||||||
|
rules: {
|
||||||
|
name: [
|
||||||
|
{ required: true, message: "请输入名称", trigger: "blur" }
|
||||||
|
// { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
questioncat: [
|
||||||
|
{ required: true, message: "请选择题库范围", trigger: "change" }
|
||||||
|
],
|
||||||
|
duration: [
|
||||||
|
{ type: 'number', required: true, message: "请填写时间限制", trigger: "blur" }
|
||||||
|
],
|
||||||
|
passscore: [
|
||||||
|
{ type: 'number', required: true, message: "请填写及格分数", trigger: "blur" }
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getSubjectAll();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submitForm(formName) {
|
||||||
|
this.$refs[formName].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
alert("submit!");
|
||||||
|
} else {
|
||||||
|
console.log("error submit!!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getSubjectAll() {
|
||||||
|
getSubjectAll().then(response => {
|
||||||
|
this.subjectData = genTree(response.data) ;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
calScore() {
|
||||||
|
let detail = this.ruleForm.detail
|
||||||
|
let score = detail.danxuan.num * detail.danxuan.score + detail.duoxuan.num * detail.duoxuan.score + detail.panduan.num * detail.panduan.score
|
||||||
|
this.ruleForm.detail.score = score
|
||||||
|
},
|
||||||
|
resetForm(formName) {
|
||||||
|
this.$refs[formName].resetFields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -0,0 +1,187 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<div style="margin-top:10px">
|
||||||
|
<el-input
|
||||||
|
v-model="search"
|
||||||
|
placeholder="输入分类名称进行搜索"
|
||||||
|
style="width: 200px;"
|
||||||
|
class="filter-item"
|
||||||
|
/>
|
||||||
|
<el-button type="primary" @click="handleAdd" icon="el-icon-plus">新增</el-button>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
:data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
|
||||||
|
style="width: 100%;margin-top:10px;"
|
||||||
|
border
|
||||||
|
fit
|
||||||
|
v-loading="listLoading"
|
||||||
|
highlight-current-row
|
||||||
|
max-height="600"
|
||||||
|
row-key="id"
|
||||||
|
>
|
||||||
|
<el-table-column type="index" width="50"></el-table-column>
|
||||||
|
<el-table-column align="center" label="名称">
|
||||||
|
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建日期">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.create_time }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="操作">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
@click="handleEdit(scope)"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
:disabled="!checkPermission(['testrule_update'])"
|
||||||
|
></el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
@click="handleDelete(scope)"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
:disabled="!checkPermission(['testrule_delete'])"
|
||||||
|
></el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<el-dialog :visible.sync="dialogVisible" :title="dialogType==='edit'?'编辑分类':'新增分类'">
|
||||||
|
<el-form
|
||||||
|
:model="testrule"
|
||||||
|
label-width="80px"
|
||||||
|
label-position="right"
|
||||||
|
:rules="rule1"
|
||||||
|
ref="commonForm"
|
||||||
|
>
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input v-model="testrule.name" placeholder="名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div style="text-align:right;">
|
||||||
|
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="confirm('commonForm')">确认</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getTestRuleAll,
|
||||||
|
createTestRule,
|
||||||
|
delteTestRule,
|
||||||
|
updateTestRule
|
||||||
|
} from "@/api/examtest";
|
||||||
|
import { deepClone } from "@/utils";
|
||||||
|
import checkPermission from "@/utils/permission";
|
||||||
|
|
||||||
|
const defaultObj = {
|
||||||
|
id: "",
|
||||||
|
name: ""
|
||||||
|
};
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
testrule: defaultObj,
|
||||||
|
search: "",
|
||||||
|
tableData: [],
|
||||||
|
listLoading: true,
|
||||||
|
dialogVisible: false,
|
||||||
|
dialogType: "new",
|
||||||
|
rule1: {
|
||||||
|
name: [{ required: true, message: "请输入名称", trigger: "blur" }]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
checkPermission,
|
||||||
|
getList() {
|
||||||
|
this.listLoading = true;
|
||||||
|
getTestRuleAll().then(response => {
|
||||||
|
this.tableData = response.data;
|
||||||
|
this.listLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
resetFilter() {
|
||||||
|
this.search = ""
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
handleAdd() {
|
||||||
|
this.testrule = Object.assign({}, defaultObj);
|
||||||
|
this.dialogType = "new";
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs["commonForm"].clearValidate();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleEdit(scope) {
|
||||||
|
this.testrule = Object.assign({}, scope.row); // copy obj
|
||||||
|
this.dialogType = "edit";
|
||||||
|
this.dialogVisible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs["commonForm"].clearValidate();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleDelete(scope) {
|
||||||
|
this.$confirm("确认删除该分类吗?将丢失数据!", "警告", {
|
||||||
|
confirmButtonText: "确认",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "error"
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
await delteTestRule(scope.row.id);
|
||||||
|
this.getList();
|
||||||
|
this.$message({
|
||||||
|
type: "success",
|
||||||
|
message: "成功删除!"
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
// console.error(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async confirm(form) {
|
||||||
|
this.$refs[form].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
const isEdit = this.dialogType === "edit";
|
||||||
|
if (isEdit) {
|
||||||
|
updateTestRule(this.testrule.id, this.testrule).then(
|
||||||
|
() => {
|
||||||
|
this.getList();
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.$notify({
|
||||||
|
title: "成功",
|
||||||
|
message: "编辑成功",
|
||||||
|
type: "success",
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
createTestRule(this.testrule).then(res => {
|
||||||
|
// this.testrule = res.data
|
||||||
|
// this.tableData.unshift(this.testrule)
|
||||||
|
this.getList();
|
||||||
|
this.dialogVisible = false;
|
||||||
|
this.$notify({
|
||||||
|
title: "成功",
|
||||||
|
message: "新增成功",
|
||||||
|
type: "success",
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ExamtestConfig(AppConfig):
|
||||||
|
name = 'examtest'
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Generated by Django 3.0.4 on 2020-03-17 07:04
|
||||||
|
|
||||||
|
import django.contrib.postgres.fields.jsonb
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('question', '0006_auto_20200317_1445'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TestRule',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')),
|
||||||
|
('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')),
|
||||||
|
('is_delete', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
|
||||||
|
('name', models.CharField(max_length=200, unique=True, verbose_name='名称')),
|
||||||
|
('detail', django.contrib.postgres.fields.jsonb.JSONField(verbose_name='试卷结构')),
|
||||||
|
('questioncat', models.ManyToManyField(to='question.Questioncat', verbose_name='所选题库')),
|
||||||
|
('subject', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subject', to='question.Questioncat', verbose_name='所属学科')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,11 @@
|
||||||
|
from django.db import models
|
||||||
|
from rbac.models import CommonModel
|
||||||
|
from django.contrib.postgres.fields import JSONField, ArrayField
|
||||||
|
from question.models import Questioncat
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class TestRule(CommonModel):
|
||||||
|
name = models.CharField(max_length=200, unique=True, verbose_name="名称")
|
||||||
|
subject = models.ForeignKey(Questioncat, blank=True, null=True, on_delete=models.CASCADE, verbose_name="所属学科", related_name="subject")
|
||||||
|
questioncat = models.ManyToManyField(Questioncat, verbose_name="所选题库")
|
||||||
|
detail = JSONField(verbose_name="试卷结构")
|
|
@ -0,0 +1,19 @@
|
||||||
|
from rest_framework import serializers
|
||||||
|
from question.models import Questioncat
|
||||||
|
from .models import TestRule
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TestRuleSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
学科分类序列化
|
||||||
|
"""
|
||||||
|
create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
|
||||||
|
update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
|
||||||
|
class Meta:
|
||||||
|
model = TestRule
|
||||||
|
fields = '__all__'
|
||||||
|
depth = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1,11 @@
|
||||||
|
from django.urls import path,include
|
||||||
|
from .views import TestRuleViewSet
|
||||||
|
from rest_framework import routers
|
||||||
|
|
||||||
|
|
||||||
|
router = routers.DefaultRouter()
|
||||||
|
router.register('testrule', TestRuleViewSet, basename="testrule")
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', include(router.urls)),
|
||||||
|
]
|
|
@ -0,0 +1,33 @@
|
||||||
|
from rest_framework.filters import SearchFilter, OrderingFilter
|
||||||
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
from rest_framework.views import APIView
|
||||||
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
from rest_framework.generics import GenericAPIView
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from rest_framework import status
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
from openpyxl import Workbook, load_workbook
|
||||||
|
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
|
||||||
|
|
||||||
|
from utils.custom import CommonPagination
|
||||||
|
from rbac.permission import RbacPermission
|
||||||
|
from .models import TestRule
|
||||||
|
from .serializers import TestRuleSerializer
|
||||||
|
from server import settings
|
||||||
|
from crm.authentication import ConsumerTokenAuthentication
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
class TestRuleViewSet(ModelViewSet):
|
||||||
|
"""
|
||||||
|
模考规则:增删改查
|
||||||
|
"""
|
||||||
|
perms_map = (
|
||||||
|
{'*': 'admin'}, {'*': 'TestRule_all'}, {'get': 'TestRule_list'}, {'post': 'TestRule_create'},
|
||||||
|
{'put': 'TestRule_update'}, {'delete': 'TestRule_delete'})
|
||||||
|
pagination_class = None
|
||||||
|
queryset = TestRule.objects.filter(is_delete=0).all().order_by("id")
|
||||||
|
serializer_class = TestRuleSerializer
|
||||||
|
ordering_fields = ('id',)
|
||||||
|
ordering = ['id']
|
||||||
|
search_fields = ('^name',)
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 3.0.4 on 2020-03-17 06:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('question', '0005_auto_20200316_1056'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='question',
|
||||||
|
name='questioncat',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questioncat', to='question.Questioncat', verbose_name='所属题库'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='questioncat',
|
||||||
|
name='pid',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='questioncatpid', to='question.Questioncat', verbose_name='父'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,7 +4,6 @@ from rest_framework.views import APIView
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet
|
||||||
from rest_framework.generics import GenericAPIView
|
from rest_framework.generics import GenericAPIView
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.permissions import IsAuthenticated
|
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
@ -26,7 +25,7 @@ class SubjectViewSet(ModelViewSet):
|
||||||
perms_map = (
|
perms_map = (
|
||||||
{'*': 'admin'}, {'*': 'Subject_all'}, {'get': 'Subject_list'}, {'post': 'Subject_create'},
|
{'*': 'admin'}, {'*': 'Subject_all'}, {'get': 'Subject_list'}, {'post': 'Subject_create'},
|
||||||
{'put': 'Subject_update'}, {'delete': 'Subject_delete'})
|
{'put': 'Subject_update'}, {'delete': 'Subject_delete'})
|
||||||
queryset = Questioncat.objects.filter(is_subject=True).all().order_by("id")
|
queryset = Questioncat.objects.filter(is_subject=True,is_delete=0).all().order_by("id")
|
||||||
serializer_class = SubjectSerializer
|
serializer_class = SubjectSerializer
|
||||||
pagination_class = None
|
pagination_class = None
|
||||||
ordering_fields = ('id',)
|
ordering_fields = ('id',)
|
||||||
|
|
Binary file not shown.
|
@ -42,9 +42,10 @@ INSTALLED_APPS = [
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'corsheaders',
|
'corsheaders',
|
||||||
"django_filters",
|
"django_filters",
|
||||||
"rbac",
|
'rbac',
|
||||||
"crm",
|
'crm',
|
||||||
"question"
|
'question',
|
||||||
|
'examtest',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -27,6 +27,7 @@ urlpatterns = [
|
||||||
path('api/rbac/', include('rbac.urls')),
|
path('api/rbac/', include('rbac.urls')),
|
||||||
path('api/crm/', include('crm.urls')),
|
path('api/crm/', include('crm.urls')),
|
||||||
path('api/question/', include('question.urls')),
|
path('api/question/', include('question.urls')),
|
||||||
|
path('api/examtest/', include('examtest.urls')),
|
||||||
path('api/token/', obtain_jwt_token),
|
path('api/token/', obtain_jwt_token),
|
||||||
path('api/token/refresh/', refresh_jwt_token),
|
path('api/token/refresh/', refresh_jwt_token),
|
||||||
path('api/token/verify/', verify_jwt_token),
|
path('api/token/verify/', verify_jwt_token),
|
||||||
|
|
Loading…
Reference in New Issue