feat: edu页面基本完成

This commit is contained in:
caoqianming 2024-06-05 08:37:48 +08:00
parent 1e77723d6f
commit b4ffe30ca2
4 changed files with 1093 additions and 79 deletions

View File

@ -1,5 +1,264 @@
<template>
<div>
<h2>question</h2>
</div>
</template>
<el-container>
<el-header>
<div class="left-panel">
<el-button
type="primary"
icon="el-icon-plus"
@click="table_add"
v-auth="'exam.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="name"
min-width="300"
></el-table-column>
<el-table-column
label="进行中"
prop="can_attend"
width="80"
>
<template #default="scope">
<el-icon v-if="scope.row.can_attend" color="green"
><CircleCheckFilled
/></el-icon>
</template>
</el-table-column>
<el-table-column
label="开启时间"
prop="open_time"
></el-table-column>
<el-table-column
label="关闭时间"
prop="close_time"
></el-table-column>
<el-table-column
label="考试机会"
prop="chance"
width="80"
></el-table-column>
<el-table-column
label="试卷名"
prop="paper_name"
></el-table-column>
<el-table-column
label="是否公开"
width="80"
>
<template #default="scope">
<el-icon v-if="scope.row.is_public" color="green"
><CircleCheckFilled
/></el-icon>
</template>
</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-button
link
size="small"
@click="row_detail(scope.row)"
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-dialog v-model="examDialog" title="新增/编辑考试">
<el-form
:model="examForm"
label-width="100px"
ref="questioncatForm"
>
<el-form-item label="名称" prop="name" required>
<el-input
v-model="examForm.name"
clearable
></el-input>
</el-form-item>
<el-row>
<el-col :span="8">
<el-form-item label="开启时间" prop="open_time" required>
<el-date-picker
v-model="examForm.open_time"
type="datetime"
style="width:100%"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="关闭时间" prop="close_time">
<el-date-picker
v-model="examForm.close_time"
type="datetime"
style="width:100%"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="考试机会"
prop="chance"
required
>
<el-input-number
v-model="examForm.chance"
controls-position="right"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="所用试卷" prop="paper" required>
<el-select
v-model="examForm.paper"
filterable
reserve-keyword
style="width: 100%"
>
<el-option
v-for="item in paperOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="是否公开"
prop="is_public"
required
>
<el-switch v-model="examForm.is_public"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button
type="primary"
:loading="examSaving"
@click="examSubmit()"
> </el-button
>
</template>
</el-dialog>
</el-container>
</template>
<script>
const defaultExam = {chance: 1, is_public:false}
export default {
data() {
return {
paperOptions:[],
examDialog: false,
apiObj: this.$API.edu.exam.list,
query: {
search: "",
},
examForm: Object.assign({}, defaultExam),
};
},
mounted() {
this.getPaperOptions();
},
methods: {
getPaperOptions() {
this.$API.edu.paper.list.req({
page: 0
}).then(res => {
this.paperOptions = res;
});
},
handleQuery() {
this.$refs.table.queryData(this.query);
},
table_add() {
this.examForm = Object.assign({}, defaultExam);
this.examDialog = true;
},
table_edit(row) {
this.examForm = Object.assign({}, row);
this.examDialog = true;
},
table_del(row) {
this.$API.edu.exam.delete.req(row.id).then(() => {
this.handleQuery();
});
},
examSubmit() {
this.examSaving = true;
if (this.examForm.id){
this.$API.edu.exam.update.req(this.examForm.id, this.examForm).then(res=>{
this.$message.success("更新成功");
this.examSaving = false;
this.examDialog = false;
this.handleQuery();
}).catch(e=>{this.examSaving=false})
}else{
this.$API.edu.exam.create.req(this.examForm).then(res=>{
this.$message.success("创建成功");
this.examSaving = false;
this.examDialog = false;
this.handleQuery();
}).catch(err=>{
this.examSaving = false;
})
}
}
},
};
</script>

View File

@ -1,5 +1,133 @@
<template>
<div>
<h2>question</h2>
</div>
</template>
<el-container>
<el-header>
<div class="left-panel">
<el-button
type="primary"
icon="el-icon-plus"
@click="table_add"
v-auth="'paper.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="name" min-width="300"></el-table-column>
<el-table-column
label="限时(分钟)"
prop="limit"
></el-table-column>
<el-table-column
label="满分"
prop="total_score"
></el-table-column>
<el-table-column
label="通过分"
prop="pass_score"
></el-table-column>
<el-table-column
label="单选题数"
prop="danxuan_count"
></el-table-column>
<el-table-column
label="多选题数"
prop="duoxuan_count"
></el-table-column>
<el-table-column
label="判断题数"
prop="panduan_count"
></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="'paper.update'"
type="primary"
>编辑</el-button
>
<el-popconfirm
title="确定删除吗?"
@confirm="table_del(scope.row, scope.$index)"
>
<template #reference>
<el-button
link
size="small"
v-auth="'paper.delete'"
type="danger"
>删除</el-button
>
</template>
</el-popconfirm>
</template>
</el-table-column>
</scTable>
</el-main>
<paperDg
v-if="paperVisiable"
ref="paperDg"
@paperSubmit="handleQuery"
></paperDg>
</el-container>
</template>
<script>
import paperDg from "./paper_form";
export default {
components: { paperDg },
data() {
return {
paperVisiable: false,
apiObj: this.$API.edu.paper.list,
query: {
search: "",
},
};
},
mounted() {},
methods: {
handleQuery() {
this.$refs.table.queryData(this.query);
},
table_add() {
this.paperVisiable = true;
this.$nextTick(() => {
this.$refs.paperDg.open("add");
});
},
table_edit(row) {
this.paperVisiable = true;
this.$API.edu.paper.item.req(row.id).then((res) => {
this.$nextTick(() => {
this.$refs.paperDg.open("edit", res);
});
});
},
table_del(row) {
this.$API.edu.paper.delete.req(row.id).then(() => {
this.handleQuery();
});
},
},
};
</script>

View File

@ -0,0 +1,363 @@
<template>
<el-drawer v-model="drawVisible" size="60%" title="创建/编辑试卷">
<el-container>
<el-header style="height: 200px">
<el-form
:model="paperForm"
label-width="100px"
ref="paperFormRef"
>
<el-row>
<el-col :span="24">
<el-form-item label="试卷名" prop="name" required>
<el-input
v-model="paperForm.name"
clearable
></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="总分数"
prop="total_score"
required
>
<el-input-number
v-model="paperForm.total_score"
controls-position="right"
:min="0"
style="width: 100%"
disabled
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="通过分数"
prop="pass_score"
required
>
<el-input-number
v-model="paperForm.pass_score"
controls-position="right"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="限时"
prop="limit"
required
>
<el-input-number
v-model="paperForm.limit"
controls-position="right"
placeholder="分钟"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="单选分数"
prop="danxuan_score"
required
>
<el-input-number
v-model="paperForm.danxuan_score"
controls-position="right"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="多选分数"
prop="duoxuan_score"
required
>
<el-input-number
v-model="paperForm.duoxuan_score"
controls-position="right"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="判断分数"
prop="panduan_score"
required
>
<el-input-number
v-model="paperForm.panduan_score"
controls-position="right"
:min="1"
style="width: 100%"
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="单选数量"
prop="danxuan_count"
required
>
<el-input-number
v-model="paperForm.danxuan_count"
controls-position="right"
:min="0"
style="width: 100%"
disabled
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="多选数量"
prop="duoxuan_count"
required
>
<el-input-number
v-model="paperForm.duoxuan_count"
controls-position="right"
:min="0"
style="width: 100%"
disabled
></el-input-number>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item
label="判断数量"
prop="panduan_count"
required
>
<el-input-number
v-model="paperForm.panduan_count"
controls-position="right"
:min="0"
style="width: 100%"
disabled
></el-input-number>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-header>
<el-main class="nopadding">
<el-container>
<el-header>
<div class="left-panel">
<el-button type="primary" @click="choseQuestion"
>批量选择</el-button
>
</div>
</el-header>
<el-main class="nopadding">
<scFormTable
ref="table"
v-model="paperForm.detail"
row-key="id"
hideAdd
dragSort
@update:modelValue = "computeDetail"
>
<el-table-column
label="题型"
>
<template #default="scope"
>{{ qTypeEnum[scope.row.question_type]?.text }}
</template></el-table-column>
<el-table-column
label="题目"
prop="question_name"
min-width="600px"
></el-table-column>
<el-table-column
label="满分"
prop="total_score"
></el-table-column>
<!-- <el-table-column label="操作">
<template #default="scope">
<el-button
link
size="small"
@click="delQuestion(scope.row, scope.$index)"
type="danger"
icon="el-icon-delete"
></el-button>
</template>
</el-table-column> -->
</scFormTable>
</el-main>
</el-container>
</el-main>
<el-footer>
<el-button
type="primary"
:loading="isSaving"
@click="paperSubmit()"
> </el-button
>
</el-footer>
<el-dialog title="选择题目" v-model="questionCVisible" width="90%">
<Question
style="height: 500px"
ref="QuestionChoseRef"
></Question>
<template #footer>
<el-button type="primary" @click="choseConfirm"
>选择</el-button
>
</template>
</el-dialog>
</el-container>
</el-drawer>
</template>
<script>
import Question from "./question";
import { qTypeEnum, qLevelEnum } from "@/utils/enum";
const defaultForm = {
name: "",
danxuan_score: 2,
duoxuan_score: 4,
panduan_score: 2,
danxuan_count: 0,
duoxuan_count: 0,
panduan_count: 0,
total_score: 0,
detail: [],
limit: 10
};
export default {
components: {
Question,
},
data() {
return {
qTypeEnum, qLevelEnum,
mode: "add",
isSaving: false,
questionCVisible: false,
drawVisible: false,
paperForm: Object.assign({}, defaultForm),
};
},
mounted() {},
methods: {
open(mode = "add", data) {
if (mode == "add") {
this.paperForm = Object.assign({}, defaultForm);
this.paperForm.detail = [];
this.drawVisible = true;
} else {
this.paperForm = Object.assign({}, data);
this.drawVisible = true;
}
},
choseQuestion() {
this.questionCVisible = true;
this.$nextTick(() => {
this.$refs.QuestionChoseRef.initChose();
});
},
computeDetail() {
let danxuan_count = 0;
let duoxuan_count = 0;
let panduan_count = 0;
this.paperForm.detail.forEach((item) => {
if (item.question_type == 10) {
danxuan_count++;
} else if (item.question_type == 20) {
duoxuan_count++;
} else if (item.question_type == 30) {
panduan_count++;
}
});
this.paperForm.danxuan_count = danxuan_count;
this.paperForm.duoxuan_count = duoxuan_count;
this.paperForm.panduan_count = panduan_count;
this.paperForm.total_score =
this.paperForm.danxuan_score * this.paperForm.danxuan_count +
this.paperForm.duoxuan_score * this.paperForm.duoxuan_count +
this.paperForm.panduan_score * this.paperForm.panduan_count;
},
delQuestion(row, index){
console.log(index)
this.paperForm.detail.splice(index,1);
this.computeDetail();
},
choseConfirm() {
let sdata = this.$refs.QuestionChoseRef.checkList;
if (sdata.length == 0) {
this.$message.error("请选择题目");
return;
}
// sort
let sort = 1;
if (this.paperForm.detail.length > 0) {
sort =
this.paperForm.detail[this.paperForm.detail.length - 1]
.sort;
}
//
let data = [];
sdata.forEach((item, index) => {
var total_score = 0;
if (item.type == 10) {
total_score = this.paperForm.danxuan_score;
} else if (item.type == 20) {
total_score = this.paperForm.duoxuan_score;
} else if (item.type == 30) {
total_score = this.paperForm.panduan_score;
}
data.push({
question: item.id,
question_name: item.name,
question_type: item.type,
total_score: total_score,
sort: sort + index,
});
});
this.paperForm.detail.push(...data);
this.questionCVisible = false;
this.computeDetail();
},
paperSubmit() {
this.$refs.paperFormRef.validate((valid) => {
if (valid) {
//
this.paperForm.detail.forEach((item, index) => {
item.sort = index + 1;
});
this.isSaving = true;
if(this.paperForm.id){
this.$API.edu.paper.update.req(this.paperForm.id, this.paperForm).then((res) => {
this.isSaving = false;
this.$message.success("修改成功");
this.drawVisible = false;
this.$emit("paperSubmit");
}).catch(e=>{this.isSaving = false;})
}else{
this.$API.edu.paper.create.req(this.paperForm).then((res) => {
this.isSaving = false;
this.$message.success("保存成功");
this.drawVisible = false;
this.$emit("paperSubmit");
}).catch(e=>{this.isSaving = false;})
}
}
});
},
},
};
</script>

View File

@ -21,21 +21,18 @@
:apiObj="apiObj0"
row-key="id"
:query="query"
:isTree="true"
stripe
default-expand-all
:isTree="true"
stripe
default-expand-all
hidePagination
@dataChange="dataChange0"
@dataChange="dataChange0"
@row-click="cateClick"
>
<el-table-column
label="分类名"
prop="name"
></el-table-column>
<el-table-column
label="操作"
fixed="right"
width="80"
>
<el-table-column label="操作" fixed="right" width="80">
<template #default="scope">
<el-button
link
@ -79,6 +76,14 @@
></el-button>
</div>
<div class="right-panel">
<el-select v-model="query.type" @change="handleQuery" clearable placeholder="题型">
<el-option
v-for="e in qTypeEnum.values"
:key="e.key"
:value="e.key"
:label="e.text"
></el-option>
</el-select>
<el-input
style="margin-right: 5px"
v-model="query.search"
@ -89,6 +94,7 @@
type="primary"
icon="el-icon-search"
@click="handleQuery"
v-auth="'question.create'"
></el-button>
</div>
</el-header>
@ -98,11 +104,16 @@
:apiObj="apiObj"
row-key="id"
:query="query"
@selection-change="choseChange"
>
<el-table-column v-if="mode==='chose'" type="selection" width="50"></el-table-column>
<el-table-column
label="题型"
prop="type"
></el-table-column>
>
<template #default="scope"
>{{ qTypeEnum[scope.row.type]?.text }}
</template></el-table-column>
<el-table-column
label="题目"
prop="name"
@ -111,18 +122,27 @@
<el-table-column
label="分类"
width="180"
prop="questioncat"
prop="questioncat_name"
></el-table-column>
<el-table-column
label="难度"
prop="level"
width="80"
></el-table-column>
>
<template #default="scope"
>{{ qLevelEnum[scope.row.level]?.text }}
</template>
</el-table-column>
<el-table-column
label="启用"
prop="enabled"
width="80"
></el-table-column>
>
<template #default="scope">
<el-icon v-if="scope.row.enabled" color="green"
><CircleCheckFilled
/></el-icon>
</template>
</el-table-column>
<el-table-column
label="操作"
fixed="right"
@ -134,7 +154,7 @@
link
size="small"
@click="table_edit(scope.row)"
v-auth="'exam.update'"
v-auth="'question.update'"
type="primary"
>编辑</el-button
>
@ -148,7 +168,7 @@
<el-button
link
size="small"
v-auth="'exam.delete'"
v-auth="'question.delete'"
type="danger"
>删除</el-button
>
@ -161,7 +181,11 @@
</el-container>
</el-main>
<el-dialog v-model="questioncatDialog" title="新增/编辑分类">
<el-form :model="questioncatForm" label-width="100px" ref="questioncatForm">
<el-form
:model="questioncatForm"
label-width="100px"
ref="questioncatForm"
>
<el-form-item label="名称" prop="name" required>
<el-input
v-model="questioncatForm.name"
@ -172,8 +196,8 @@
<el-cascader
v-model="questioncatForm.parent"
:options="questioncatOptions"
:show-all-levels="false"
:props="groupsProps"
:show-all-levels="true"
:props="groupsProps"
clearable
style="width: 100%"
></el-cascader>
@ -187,86 +211,326 @@
></el-input-number>
</el-form-item>
</el-form>
<template #footer>
<el-button type="primary" :loading="questioncatSaving" @click="questioncatSubmit()"
> </el-button>
</template>
<template #footer>
<el-button
type="primary"
:loading="questioncatSaving"
@click="questioncatSubmit()"
> </el-button
>
</template>
</el-dialog>
<el-dialog v-model="questionDialog" title="新增/编辑题目">
<el-form
:model="questionForm"
label-width="100px"
ref="questionForm"
>
<el-row>
<el-col :span="8">
<el-form-item label="题型" prop="type" required>
<el-select v-model="questionForm.type" @change="setOptions">
<el-option
v-for="e in qTypeEnum.values"
:key="e.key"
:value="e.key"
:label="e.text"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="难度" prop="level" required>
<el-select v-model="questionForm.level">
<el-option
v-for="e in qLevelEnum.values"
:key="e.key"
:value="e.key"
:label="e.text"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="是否启用" prop="enabled" required>
<el-switch v-model="questionForm.enabled">
</el-switch>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="所属分类">
<el-cascader
v-model="questionForm.questioncat"
:options="questioncatOptions"
:show-all-levels="false"
:props="groupsProps"
clearable
style="width: 100%"
></el-cascader>
</el-form-item>
<el-form-item label="题目" prop="name" required>
<el-input
v-model="questionForm.name"
clearable
:rows="3"
type="textarea"
></el-input>
</el-form-item>
<el-form-item label="选项A" required>
<el-input
v-model="questionForm.options.A"
clearable
:disabled="questionForm.type==30"
></el-input>
</el-form-item>
<el-form-item label="选项B" required>
<el-input
v-model="questionForm.options.B"
clearable
:disabled="questionForm.type==30"
></el-input>
</el-form-item>
<el-form-item label="选项C" v-show="questionForm.type != 30">
<el-input
v-model="questionForm.options.C"
clearable
></el-input>
</el-form-item>
<el-form-item label="选项D" v-show="questionForm.type != 30">
<el-input
v-model="questionForm.options.D"
clearable
></el-input>
</el-form-item>
<el-form-item label="选项E" v-show="questionForm.type != 30">
<el-input
v-model="questionForm.options.E"
clearable
></el-input>
</el-form-item>
<el-form-item label="选项F" v-show="questionForm.type != 30">
<el-input
v-model="questionForm.options.F"
clearable
></el-input>
</el-form-item>
<el-form-item label="正确答案" v-if="questionForm.type == 20">
<el-checkbox-group v-model="questionForm.right">
<el-checkbox label="A"></el-checkbox>
<el-checkbox label="B"></el-checkbox>
<el-checkbox label="C"></el-checkbox>
<el-checkbox label="D"></el-checkbox>
<el-checkbox label="E"></el-checkbox>
<el-checkbox label="F"></el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="正确答案" v-else-if="questionForm.type == 10">
<el-radio-group v-model="questionForm.right">
<el-radio label="A"></el-radio>
<el-radio label="B"></el-radio>
<el-radio label="C"></el-radio>
<el-radio label="D"></el-radio>
<el-radio label="E"></el-radio>
<el-radio label="F"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="正确答案" v-else>
<el-radio-group v-model="questionForm.right">
<el-radio label="A"></el-radio>
<el-radio label="B"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="解析" prop="resolution">
<el-input
v-model="questionForm.resolution"
clearable
:rows="3"
type="textarea"
></el-input>
</el-form-item>
</el-form>
<template #footer>
<el-button
type="primary"
:loading="questionSaving"
@click="questionSubmit()"
> </el-button
>
</template>
</el-dialog>
</el-container>
</template>
<script>
import { genTree } from "@/utils/verificate";
import { qTypeEnum, qLevelEnum } from "@/utils/enum";
const defaultQuestionForm = {
"type": 30,
"level": 20,
"enabled": false,
"options": {}
}
export default {
data() {
return {
qTypeEnum,qLevelEnum,
inputDisable: false,
questioncatDialog: false,
questioncatForm: {},
questioncatOptions: [],
questioncatSaving: false,
groupsProps: {
multiple: false,
emitPath: false,
},
questioncatSaving: false,
questionDialog: false,
questionForm: Object.assign({}, defaultQuestionForm),
questionOptions: [],
questionSaving: false,
groupsProps: {
multiple: false,
emitPath: false,
},
checkList:[],
apiObj0: this.$API.edu.questioncat.list,
apiObj: this.$API.edu.exam.list,
apiObj: this.$API.edu.question.list,
query: {
search: "",
},
};
},
mounted() {},
mounted() {
},
methods: {
dataChange0(res, tableData) {
this.questioncatOptions = genTree(tableData);
initChose(){
this.mode = "chose";
this.$refs.table.clearSelection();
},
cateClick(row){
this.query.questioncat = row.id;
this.handleQuery()
},
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;
setOptions() {
if (this.questionForm.type == 30) {
this.questionForm.options = {
A: '对',
B: '错'
}
});
} else {
this.questionForm.options = {
A: '',
B: ''
}
}
if (this.questionForm.type == 20) {
this.questionForm.right = []
} else {
this.questionForm.right = ''
}
},
dataChange0(res, tableData) {
this.questioncatOptions = 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()
});
this.$nextTick(() => {
this.$refs.questioncatForm.resetFields();
});
},
table_edit0(row, index){
this.questioncatForm = {...row};
this.questioncatDialog = true;
table_edit0(row, index) {
this.questioncatForm = row;
this.questioncatDialog = true;
},
table_add() {
this.questionDialog = true;
this.questionForm = Object.assign({}, defaultQuestionForm)
this.$nextTick(() => {
this.setOptions();
});
},
table_edit(row, index) {
this.questionForm = Object.assign({}, row);
this.questionDialog = true;
},
questionSubmit() {
this.questionSaving = true;
this.$refs.questionForm.validate((valid) => {
if (valid) {
if (this.questionForm.id) {
this.$API.edu.question.update
.req(this.questionForm.id, this.questionForm)
.then(() => {
this.questionSaving = false;
this.$message.success("操作成功");
this.questionDialog = false;
this.$refs.table.refresh();
})
.catch((e) => {
this.questionSaving = false;
});
} else {
this.$API.edu.question.create
.req(this.questionForm)
.then(() => {
this.questionSaving = false;
this.$message.success("操作成功");
this.questionDialog = false;
this.$refs.table.refresh();
})
.catch((e) => {
this.questionSaving = false;
});
}
} else {
this.questionSaving = false;
}
});
},
table_del() {
},
table_add() {},
table_edit() {},
table_del() {},
choseChange(rows) {
this.checkList = rows;
},
},
};
</script>