exmatest first ceshi
This commit is contained in:
parent
284100841d
commit
ac1919161a
|
@ -7,6 +7,13 @@ export function getTestRuleAll() {
|
|||
})
|
||||
}
|
||||
|
||||
export function getTestRuleDetail(id){
|
||||
return request({
|
||||
url: `/examtest/testrule/${id}/`,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
export function createTestRule(data) {
|
||||
return request({
|
||||
url: '/examtest/testrule/',
|
||||
|
|
|
@ -137,6 +137,13 @@ export const asyncRoutes = [
|
|||
meta: { title: '新建模考规则', noCache: true, icon: '', perms: ['testrule_add']},
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: 'testrule/update',
|
||||
name: 'UpdateRule',
|
||||
component: () => import('@/views/examtest/ruleupdate.vue'),
|
||||
meta: { title: '编辑模考规则', noCache: true, icon: '', perms: ['testrule_update']},
|
||||
hidden: true
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -90,6 +90,9 @@
|
|||
<el-table-column align="header-center" label="openid">
|
||||
<template slot-scope="scope">{{ scope.row.openid }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="header-center" label="nickname">
|
||||
<template slot-scope="scope">{{ scope.row.nickname }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="header-center" label="单位">
|
||||
<template
|
||||
slot-scope="scope"
|
||||
|
@ -165,7 +168,7 @@
|
|||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="缴费学科" prop="subjects">
|
||||
<el-form-item label="缴费学科" prop="subjects">
|
||||
<el-select v-model="consumer.subjects" placeholder="缴费学科" style="width:100%" multiple>
|
||||
<el-option
|
||||
v-for="item in subjectData"
|
||||
|
@ -175,7 +178,7 @@
|
|||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="text-align:right;">
|
||||
<el-button type="danger" @click="dialogVisible=false">取消</el-button>
|
||||
|
@ -306,9 +309,9 @@ export default {
|
|||
});
|
||||
},
|
||||
getSubjectAll() {
|
||||
// getSubjectAll().then(response => {
|
||||
// this.subjectData = genTree(response.data);
|
||||
// });
|
||||
getSubjectAll().then(response => {
|
||||
this.subjectData = genTree(response.data);
|
||||
});
|
||||
},
|
||||
resetFilter() {
|
||||
this.listQuery = {
|
||||
|
@ -385,7 +388,7 @@ export default {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
createConsumer(consumer).then(res => {
|
||||
createConsumer(this.consumer).then(res => {
|
||||
// this.consumer = res.data
|
||||
// this.consumerList.unshift(this.consumer)
|
||||
this.getList();
|
||||
|
|
|
@ -38,13 +38,13 @@
|
|||
</el-table-column>
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="scope">
|
||||
<!-- <el-button
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleEdit(scope)"
|
||||
icon="el-icon-edit"
|
||||
:disabled="!checkPermission(['testrule_update'])"
|
||||
></el-button> -->
|
||||
:disabled="!checkPermission(['testrule_edit'])"
|
||||
></el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
|
@ -94,7 +94,7 @@ export default {
|
|||
this.$router.push({path:"/sjmanage/testrule/create"})
|
||||
},
|
||||
handleEdit(scope) {
|
||||
|
||||
this.$router.push({path:"/sjmanage/testrule/update",query:{id:scope.row.id}})
|
||||
},
|
||||
handleDelete(scope) {
|
||||
this.$confirm('此操作将永久删除该规则, 是否继续?', '提示', {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<el-input v-model="Form.desc" style="width:400px" type="textarea"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属学科" prop="subject">
|
||||
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px" @change="getQuestioncatAll">
|
||||
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px">
|
||||
<el-option
|
||||
v-for="item in subjectData"
|
||||
:key="item.value"
|
||||
|
@ -25,9 +25,7 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="题库范围" prop="questioncat">
|
||||
<el-select
|
||||
v-model="Form.questioncat" multiple placeholder="请选择题库范围" style="width:400px"
|
||||
@visible-change="getQuestionCount"
|
||||
@remove-tag="getQuestionCount2">
|
||||
v-model="Form.questioncat" multiple placeholder="请选择题库范围" style="width:400px" >
|
||||
<el-option
|
||||
v-for="item in questioncatData"
|
||||
:key="item.value"
|
||||
|
@ -38,18 +36,18 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="单选题">
|
||||
共有<span style="color:darkred;font-weight:bold"> {{typecount.danxuan}} </span>道,选取
|
||||
<el-input-number v-model="Form.danxuan_count" @change="calScore" :min="0" :max="maxDanxuan()"></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.danxuan_score" @change="calScore" :min="0"></el-input-number>分
|
||||
<el-input-number v-model="Form.danxuan_count" :min="0" :max="maxDanxuan()"></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.danxuan_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item label="多选题">
|
||||
共有<span style="color:darkred;font-weight:bold"> {{typecount.duoxuan}} </span>道,选取
|
||||
<el-input-number v-model="Form.duoxuan_count" @change="calScore" :min="0" :max="maxDuoxuan()"></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.duoxuan_score" @change="calScore" :min="0"></el-input-number>分
|
||||
<el-input-number v-model="Form.duoxuan_count" :min="0" :max="maxDuoxuan()"></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.duoxuan_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item label="判断题">
|
||||
共有<span style="color:darkred;font-weight:bold"> {{typecount.panduan}} </span>道,选取
|
||||
<el-input-number v-model="Form.panduan_count" @change="calScore" :min="0" :max="maxPanduan()"></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.panduan_score" @change="calScore" :min="0"></el-input-number>分
|
||||
<el-input-number v-model="Form.panduan_count" :min="0" :max="maxPanduan()"></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.panduan_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item label="时间限制" prop="limit">
|
||||
<el-input-number v-model="Form.limit" :min="0"></el-input-number>分钟
|
||||
|
@ -118,6 +116,14 @@ export default {
|
|||
}
|
||||
};
|
||||
},
|
||||
watch:{
|
||||
Form:{
|
||||
handler:'calScore',
|
||||
deep:true
|
||||
},
|
||||
'Form.subject':'getQuestioncatAll',
|
||||
'Form.questioncat':'getQuestionCount'
|
||||
},
|
||||
created() {
|
||||
this.getSubjectAll();
|
||||
},
|
||||
|
@ -153,19 +159,12 @@ export default {
|
|||
this.subjectData = genTree(response.data) ;
|
||||
});
|
||||
},
|
||||
getQuestioncatAll(val) {
|
||||
getQuestioncatAll({pid:val}).then(response => {
|
||||
getQuestioncatAll() {
|
||||
getQuestioncatAll({pid:this.Form.subject}).then(response => {
|
||||
this.questioncatData = genTree(response.data) ;
|
||||
});
|
||||
},
|
||||
getQuestionCount(val) {
|
||||
if (val==false){
|
||||
getQuestionCount({ids:this.Form.questioncat}).then(response => {
|
||||
this.typecount = response.data
|
||||
});
|
||||
}
|
||||
},
|
||||
getQuestionCount2(val) {
|
||||
getQuestionCount() {
|
||||
getQuestionCount({ids:this.Form.questioncat}).then(response => {
|
||||
this.typecount = response.data
|
||||
});
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
<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,195 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
:model="Form"
|
||||
:rules="rules"
|
||||
ref="Form"
|
||||
label-width="100px"
|
||||
status-icon
|
||||
>
|
||||
<el-form-item label="规则名称" prop="name">
|
||||
<el-input v-model="Form.name" style="width:400px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="规则简述" prop="desc">
|
||||
<el-input v-model="Form.desc" style="width:400px" type="textarea"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属学科" prop="subject">
|
||||
<el-select v-model="Form.subject" placeholder="请选择所属学科" style="width:400px" @change="getQuestioncatAll">
|
||||
<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="Form.questioncat" multiple placeholder="请选择题库范围" style="width:400px" >
|
||||
<el-option
|
||||
v-for="item in questioncatData"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单选题">
|
||||
共有<span style="color:darkred;font-weight:bold"> {{typecount.danxuan}} </span>道,选取
|
||||
<el-input-number v-model="Form.danxuan_count" :min="0" ></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.danxuan_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item label="多选题">
|
||||
共有<span style="color:darkred;font-weight:bold"> {{typecount.duoxuan}} </span>道,选取
|
||||
<el-input-number v-model="Form.duoxuan_count" :min="0" ></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.duoxuan_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item label="判断题">
|
||||
共有<span style="color:darkred;font-weight:bold"> {{typecount.panduan}} </span>道,选取
|
||||
<el-input-number v-model="Form.panduan_count" :min="0" ></el-input-number>道,每道
|
||||
<el-input-number v-model="Form.panduan_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item label="时间限制" prop="limit">
|
||||
<el-input-number v-model="Form.limit" :min="0"></el-input-number>分钟
|
||||
</el-form-item>
|
||||
<el-form-item label="当前总分">
|
||||
<span style="color:darkred;font-weight:bold">{{Form.total_score}} 分</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="及格分数" prop="pass_score">
|
||||
<el-input-number v-model="Form.pass_score" :min="0"></el-input-number>分
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('Form')" :loading="submitLoding">保存</el-button>
|
||||
<el-button @click="resetForm('Form')">重置</el-button>
|
||||
<el-button type="warning" @click="goBack()">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { updateTestRule , getTestRuleDetail} from "@/api/examtest";
|
||||
import { getSubjectAll, getQuestioncatAll, getQuestionCount } from "@/api/question";
|
||||
import { genTree } from "@/utils";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Form: {
|
||||
name: "",
|
||||
desc:"",
|
||||
subject: null,
|
||||
questioncat: [],
|
||||
danxuan_count:0,
|
||||
danxuan_score:0,
|
||||
duoxuan_count:0,
|
||||
duoxuan_score:0,
|
||||
panduan_count:0,
|
||||
panduan_score:0,
|
||||
limit:0,
|
||||
total_score:0,
|
||||
pass_score:0
|
||||
},
|
||||
typecount:{
|
||||
danxuan:0,
|
||||
duoxuan:0,
|
||||
panduan:0
|
||||
},
|
||||
subjectData:[],
|
||||
questioncatData:[],
|
||||
submitLoding:false,
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: "名称不能为空", trigger: "blur" }
|
||||
// { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
|
||||
],
|
||||
questioncat: [
|
||||
{ required: true, message: "题库范围不能为空", trigger: "change" }
|
||||
],
|
||||
limit: [
|
||||
{ required: true, message: "时间限制不能为空"},
|
||||
{ type: "number", message: "时间限制必须是数字"}
|
||||
],
|
||||
pass_score: [
|
||||
{ required: true, message: "及格分数不能为空"},
|
||||
{ type: "number", message: "及格分数必须是数字"}
|
||||
]
|
||||
|
||||
}
|
||||
};
|
||||
},
|
||||
watch:{
|
||||
Form:{
|
||||
handler:'calScore',
|
||||
deep:true
|
||||
},
|
||||
'Form.subject':'getQuestioncatAll',
|
||||
'Form.questioncat':'getQuestionCount'
|
||||
},
|
||||
created() {
|
||||
this.Form.id = this.$route.query.id //接收参数
|
||||
this.getSubjectAll();
|
||||
this.getTestRuleDetail();
|
||||
},
|
||||
methods: {
|
||||
maxDanxuan() {
|
||||
return this.typecount.danxuan
|
||||
},
|
||||
maxDuoxuan() {
|
||||
return this.typecount.duoxuan
|
||||
},
|
||||
maxPanduan() {
|
||||
return this.typecount.panduan
|
||||
},
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate(valid => {
|
||||
if (valid) {
|
||||
this.submitLoding = true
|
||||
updateTestRule(this.Form.id, this.Form).then(response => {
|
||||
this.submitLoding = false
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "保存成功!"
|
||||
});
|
||||
this.goBack()
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
getTestRuleDetail() {
|
||||
getTestRuleDetail(this.Form.id).then(response => {
|
||||
this.Form = response.data ;
|
||||
});
|
||||
},
|
||||
getSubjectAll() {
|
||||
getSubjectAll().then(response => {
|
||||
this.subjectData = genTree(response.data) ;
|
||||
});
|
||||
},
|
||||
getQuestioncatAll() {
|
||||
getQuestioncatAll({pid:this.Form.id}).then(response => {
|
||||
this.questioncatData = genTree(response.data) ;
|
||||
});
|
||||
},
|
||||
getQuestionCount(val) {
|
||||
getQuestionCount({ids:this.Form.questioncat}).then(response => {
|
||||
this.typecount = response.data
|
||||
});
|
||||
},
|
||||
calScore(current,old) {
|
||||
let form = this.Form
|
||||
let score = form.danxuan_count * form.danxuan_score + form.duoxuan_count * form.duoxuan_score + form.panduan_count * form.panduan_score
|
||||
this.Form.total_score = score
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
this.typecount.danxuan = 0;
|
||||
this.typecount.duoxuan = 0;
|
||||
this.typecount.panduan = 0;
|
||||
},
|
||||
goBack() {
|
||||
this.$router.replace('/sjmanage/testrule/')
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -95,6 +95,12 @@
|
|||
</el-table-column>
|
||||
<el-table-column align="center" label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="handleDetail(scope)"
|
||||
icon="el-icon-more"
|
||||
></el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
|
@ -112,6 +118,23 @@
|
|||
:limit.sync="listQuery.limit"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<el-dialog
|
||||
title="题目详情"
|
||||
:visible.sync="dialogVisible"
|
||||
width="30%">
|
||||
<div>{{question.type}}</div>
|
||||
<div>{{question.name}}</div>
|
||||
<ul id="repeat">
|
||||
<li v-for="(value,key,index) in question.options">
|
||||
{{ key }}:{{value}}
|
||||
</li>
|
||||
</ul>
|
||||
<div>正确答案{{question.right}}</div>
|
||||
<div>{{question.resolution}}</div>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -161,10 +184,11 @@ export default {
|
|||
name: [{ required: true, message: "请输入名称", trigger: "blur" }]
|
||||
},
|
||||
typeOptions: [
|
||||
{ key: 1, label: "单选", value: 1 },
|
||||
{ key: 2, label: "多选", value: 2 },
|
||||
{ key: 3, label: "判断", value: 3 }
|
||||
{ key: 1, label: "单选", value: "单选" },
|
||||
{ key: 2, label: "多选", value: "多选"},
|
||||
{ key: 3, label: "判断", value: "判断" }
|
||||
],
|
||||
question:{}
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
|
@ -228,6 +252,10 @@ export default {
|
|||
handleSearch() {
|
||||
this.getList({ search: this.search });
|
||||
},
|
||||
handleDetail(scope) {
|
||||
this.dialogVisible = true
|
||||
this.question = scope.row
|
||||
},
|
||||
// handleAdd() {
|
||||
// this.questioncat = Object.assign({}, defaultObj);
|
||||
// this.dialogType = "new";
|
||||
|
|
|
@ -48,9 +48,9 @@ App({
|
|||
globalData: {
|
||||
userInfo: null,
|
||||
userinfo: null, // 服务器传回的消费者信息
|
||||
// host: 'https://apitest.ctcshe.com/',
|
||||
host: 'https://apitest.ctcshe.com/',
|
||||
mediahost: 'https://apitest.ctcshe.com/',
|
||||
host: 'http://127.0.0.1:8000/',
|
||||
// host: 'http://127.0.0.1:8000/',
|
||||
// mediahost: 'http://127.0.0.1:8000/',
|
||||
token : '',
|
||||
subject:null,
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
|
||||
<view class="weui-media-box__title" wx:if="{{userinfo && userinfo.username}}">账号: {{userinfo.username}}
|
||||
</view>
|
||||
<view class="weui-media-box__title" wx:else>账号: 未登陆
|
||||
<view class="weui-media-box__title" wx:else>账号:
|
||||
<span style="color:red">未登陆</span>
|
||||
</view>
|
||||
<view class="weui-media-box__desc">昵称:
|
||||
<open-data type="userNickName"></open-data>
|
||||
|
@ -38,5 +39,11 @@
|
|||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:if="{{avg_score}}">{{avg_score}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-footer weui-footer_fixed-bottom">
|
||||
<!-- <view class="weui-footer__text" bindtap="intro">点击下载系统/小程序文档介绍</view> -->
|
||||
<view class="weui-footer__text">更多服务请联系顾问师圆:18355135390</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
|
@ -90,13 +90,13 @@ Page({
|
|||
},
|
||||
|
||||
buy: function(e){
|
||||
if(getApp().globalData.userInfo.username == null){
|
||||
if(getApp().globalData.userinfo.username == null){
|
||||
wx.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: '暂未开放微信支付,请联系管理员',
|
||||
title: '暂未开放微信支付,请联系顾问师圆:18355135390',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
<!--pages/lianxi/index.wxml-->
|
||||
<view class="page">
|
||||
<view class="page__bd">
|
||||
<view class="weui-panel weui-panel_access">
|
||||
<view class="weui-panel__hd">所有学科</view>
|
||||
<view class="weui-panel__hd">所有学科</view>
|
||||
<view class="weui-panel__bd">
|
||||
<block wx:for="{{subjectData}}" wx:key="unique">
|
||||
<a class="weui-media-box weui-media-box_appmsg" bindtap="chooseSubject" data-id="{{item.id}}" data-name="{{item.name}}" data-is_paid="{{item.is_paid}}">
|
||||
<view class="weui-media-box weui-media-box_appmsg" bindtap="chooseSubject" data-id="{{item.id}}" data-name="{{item.name}}" data-is_paid="{{item.is_paid}}">
|
||||
<view class="weui-media-box__hd">
|
||||
<image class="weui-media-box__thumb" src="/images/fushe.svg" alt></image>
|
||||
</view>
|
||||
<view class="weui-media-box__bd">
|
||||
<h4 class="weui-media-box__title">{{item.name}}</h4>
|
||||
<view class="weui-media-box__desc">
|
||||
<span style="font-weight:bold;color:darkblue" wx:if="{{item.is_paid}}">已购买</span>
|
||||
<span style="font-weight:bold;color:darkblue" wx:if="{{item.is_paid}}">已购买</span>
|
||||
<a class="weui-btn weui-btn_mini weui-btn_primary" bindtap="buy" id="{{item.id}}" wx:else>购买</a>
|
||||
</view>
|
||||
</view>
|
||||
</a>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.4 on 2020-03-24 08:21
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('question', '0007_auto_20200319_0846'),
|
||||
('crm', '0009_consumer_collects'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='paysubject',
|
||||
unique_together={('consumer', 'subject')},
|
||||
),
|
||||
]
|
|
@ -45,6 +45,11 @@ class PaySubject(CommonModel):
|
|||
'''
|
||||
consumer = models.ForeignKey(Consumer, on_delete=models.CASCADE)
|
||||
subject = models.ForeignKey(Questioncat, on_delete=models.CASCADE)
|
||||
|
||||
class Meta:
|
||||
unique_together=(('consumer','subject'),)
|
||||
|
||||
|
||||
|
||||
class SendCode(CommonModel):
|
||||
'''
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from rest_framework import serializers
|
||||
from .models import Company, Consumer
|
||||
from .models import Company, Consumer, PaySubject
|
||||
from question.models import Question, Questioncat
|
||||
|
||||
|
||||
class CompanySerializer(serializers.ModelSerializer):
|
||||
|
@ -19,9 +20,9 @@ class ConsumerSerializer(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)
|
||||
company_name = serializers.StringRelatedField(source='company')
|
||||
subjects_name = serializers.StringRelatedField(source='subjects', many=True)
|
||||
company_name = serializers.StringRelatedField(source='company', read_only=True)
|
||||
subjects_name = serializers.StringRelatedField(source='subjects', many=True, read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Consumer
|
||||
fields = '__all__'
|
||||
exclude = ('avatar','collects')
|
||||
|
|
|
@ -105,7 +105,31 @@ class ConsumerViewSet(ModelViewSet):
|
|||
filterset_fields = ('company',)
|
||||
search_fields = ('^name',)
|
||||
|
||||
@action(methods=['get'], detail=False, permission_classes=[], authentication_classes=[ConsumerTokenAuthentication],
|
||||
def create(self, request, *args, **kwargs):
|
||||
serializer = self.get_serializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
instance = serializer.save()
|
||||
else:
|
||||
return Response(serializer.errors)
|
||||
if request.data.get('subjects', None):
|
||||
for i in request.data.get('subjects'):
|
||||
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
|
||||
def update(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
serializer = self.get_serializer(instance, data=request.data)
|
||||
if serializer.is_valid():
|
||||
instance = serializer.save()
|
||||
else:
|
||||
return Response(serializer.errors)
|
||||
PaySubject.objects.filter(consumer = instance).delete()
|
||||
if request.data.get('subjects', None):
|
||||
for i in request.data.get('subjects'):
|
||||
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
|
||||
return Response(serializer.data)
|
||||
|
||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated], authentication_classes=[ConsumerTokenAuthentication],
|
||||
url_path='subjectpaid', url_name='subject_paid')
|
||||
def has_paid(self, request):
|
||||
"""
|
||||
|
@ -132,7 +156,7 @@ class ConsumerViewSet(ModelViewSet):
|
|||
else:
|
||||
return Response({'error':result['data']})
|
||||
|
||||
@action(methods=['post','delete','get'], detail=False, permission_classes=[], authentication_classes=[ConsumerTokenAuthentication],
|
||||
@action(methods=['post','delete','get'], detail=False, permission_classes=[IsAuthenticated], authentication_classes=[ConsumerTokenAuthentication],
|
||||
url_path='collects', url_name='create_collects')
|
||||
def collects(self, request):
|
||||
'''
|
||||
|
@ -224,8 +248,8 @@ class ConsumerMPLoginView(APIView):
|
|||
"""
|
||||
小程序登陆颁发token
|
||||
"""
|
||||
authentication_classes=()
|
||||
permission_classes=()
|
||||
authentication_classes=[]
|
||||
permission_classes=[]
|
||||
def post(self, request, *args, **kwargs):
|
||||
code = request.data['code']
|
||||
info = requests.get('https://api.weixin.qq.com/sns/jscode2session?appid='+appid+'&secret='+secret+'&js_code=' +
|
||||
|
@ -250,7 +274,7 @@ class ConsumerRegister(APIView):
|
|||
验证码登陆和注册
|
||||
'''
|
||||
authentication_classes = [ConsumerTokenAuthentication]
|
||||
permission_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
def post(self, request, *args, **kwargs):
|
||||
data = request.data
|
||||
phone = data.get('phone', None)
|
||||
|
|
|
@ -17,16 +17,6 @@ class TestRuleListSerializer(serializers.ModelSerializer):
|
|||
depth = 1
|
||||
|
||||
|
||||
class TestRuleCreateSerializer(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__'
|
||||
|
||||
class TestRuleSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
规则序列化
|
||||
|
@ -36,7 +26,6 @@ class TestRuleSerializer(serializers.ModelSerializer):
|
|||
class Meta:
|
||||
model = TestRule
|
||||
fields = '__all__'
|
||||
depth = 1
|
||||
|
||||
class MoniTestSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
|
|
|
@ -17,7 +17,7 @@ from rbac.permission import RbacPermission
|
|||
from question.models import Question
|
||||
from question.serializers import QuestionSerializer
|
||||
from .models import TestRule, ExamTest, AnswerDetail
|
||||
from .serializers import TestRuleSerializer, TestRuleListSerializer, TestRuleCreateSerializer, MoniTestSerializer, AnswerDetailSerializer, ExamTestListSerializer, AnswerDetailCreateSerializer
|
||||
from .serializers import TestRuleSerializer, TestRuleListSerializer, MoniTestSerializer, AnswerDetailSerializer, ExamTestListSerializer, AnswerDetailCreateSerializer
|
||||
from server import settings
|
||||
from crm.authentication import ConsumerTokenAuthentication
|
||||
from utils.custom import CommonPagination
|
||||
|
@ -26,7 +26,7 @@ from utils.custom import CommonPagination
|
|||
|
||||
class MoniTestView(APIView):
|
||||
authentication_classes = [ConsumerTokenAuthentication]
|
||||
permission_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
def post(self, request, *args, **kwargs):
|
||||
serializer = MoniTestSerializer(data = request.data)
|
||||
if serializer.is_valid():
|
||||
|
@ -57,7 +57,7 @@ class MoniTestView(APIView):
|
|||
|
||||
class MyExamTestView(APIView):
|
||||
authentication_classes = [ConsumerTokenAuthentication]
|
||||
permission_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
def get(self, request, *args, **kwargs):
|
||||
queryset = ExamTest.objects.filter(consumer=request.user)
|
||||
pg = CommonPagination()
|
||||
|
@ -67,7 +67,7 @@ class MyExamTestView(APIView):
|
|||
|
||||
class MyExamTestFxView(APIView):
|
||||
authentication_classes = [ConsumerTokenAuthentication]
|
||||
permission_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
def get(self, request, *args, **kwargs):
|
||||
queryset = ExamTest.objects.filter(consumer=request.user)
|
||||
ret = {}
|
||||
|
@ -108,8 +108,6 @@ class TestRuleViewSet(ModelViewSet):
|
|||
"""
|
||||
if self.action == 'list':
|
||||
serializer_class = TestRuleListSerializer
|
||||
elif self.action == 'create':
|
||||
serializer_class = TestRuleCreateSerializer
|
||||
else:
|
||||
serializer_class = TestRuleSerializer
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
|
|
|
@ -93,7 +93,7 @@ class QuestioncatViewSet(ModelViewSet):
|
|||
serializer = QuestioncatSerializer(instance=queryset,many=True)
|
||||
return Response(serializer.data)
|
||||
|
||||
@action(methods=['get'], detail=False, authentication_classes=[ConsumerTokenAuthentication], permission_classes=[],
|
||||
@action(methods=['get'], detail=False, authentication_classes=[], permission_classes=[],
|
||||
url_path='subject', url_name='questioncat_subject', pagination_class = None)
|
||||
def subject(self, request):
|
||||
"""
|
||||
|
@ -128,7 +128,7 @@ class QuestionViewSet(ModelViewSet):
|
|||
instance.save()
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
@action(methods=['post'], detail=False, permission_classes=[IsAuthenticated],
|
||||
@action(methods=['post'], detail=False, permission_classes=[],
|
||||
url_path='count', url_name='question_count')
|
||||
def count(self, request):
|
||||
ret = {'danxuan':0,'duoxuan':0,'panduan':0}
|
||||
|
@ -141,7 +141,7 @@ class QuestionViewSet(ModelViewSet):
|
|||
return Response(ret)
|
||||
|
||||
|
||||
@action(methods=['post'], detail=False, permission_classes=[IsAuthenticated],
|
||||
@action(methods=['post'], detail=False,
|
||||
url_path='import', url_name='import_question')
|
||||
def import_question(self, request):
|
||||
"""
|
||||
|
@ -257,7 +257,7 @@ class QuestionViewSet(ModelViewSet):
|
|||
|
||||
class ExerciseView(APIView):
|
||||
authentication_classes = [ConsumerTokenAuthentication]
|
||||
permission_classes = []
|
||||
permission_classes = [IsAuthenticated]
|
||||
def post(self, request):
|
||||
questioncat = request.data['questioncat']
|
||||
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat)
|
||||
|
|
|
@ -143,6 +143,7 @@ REST_FRAMEWORK = {
|
|||
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
|
||||
],
|
||||
'DEFAULT_PERMISSION_CLASSES':[
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
'rbac.permission.RbacPermission'
|
||||
],
|
||||
'DEFAULT_RENDERER_CLASSES': ('utils.response.FitJSONRenderer',),
|
||||
|
|
Loading…
Reference in New Issue