2022年5月29日从svn移到git

This commit is contained in:
daihh
2022-05-29 18:56:34 +08:00
commit b050613020
488 changed files with 68444 additions and 0 deletions

662
src/views/exam/Question.vue Normal file
View File

@@ -0,0 +1,662 @@
<template>
<div class="examManger">
<el-container>
<el-header style="height:70px;padding: 12px 20px 10px 20px;" >
<el-row>
<!-- <el-col :span="4">
<el-cascader
:options="resOwnerListMap"
v-model="params.ownership"
placeholder="资源归属"
clearable
:props="resourceProps">
</el-cascader>
</el-col> -->
<el-col :span="4">
<el-select
v-model="params.type"
clearable
placeholder="类型"
>
<el-option
v-for="item in optionsList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-col>
<el-col :span="3">
<el-input style="margin-left:10px"
v-model="params.title"
placeholder="题干"
clearable></el-input>
</el-col>
<el-col :span="14">
<el-button
type="primary"
@click="loadData(1)"
style="margin-left: 20px"
icon="el-icon-search"
>搜索</el-button>
<el-button
icon="el-icon-refresh-right"
type="primary" @click="reset">
重置
</el-button>
<el-button type="primary" @click="addQuestion(1)" style="margin-left: 10px" icon="el-icon-plus"> 添加 </el-button>
<div style="display: inline-block;margin-left: 10px;">
<file-upload
dir="files"
text="导入"
:loading="true"
size="medium"
url="/xboe/m/exam/question/import"
:isShowTip="false"
@success="uploadFile"
@remove="removeFile"
>
</file-upload>
</div>
</el-col>
</el-row>
</el-header>
<el-container style="margin:0 10px;">
<el-main>
<el-table border stripe :data="tableData" style="width: 100%">
<el-table-column label="序号" type="index" width="50"></el-table-column>
<el-table-column prop="title" label="题干" show-overflow-tooltip>
<template slot-scope="scope">
<span class="previewStyle" @click="viewTopic(scope.row)">{{ scope.row.title }}</span>
</template>
</el-table-column>
<!-- <el-table-column prop="resSysId" label="资源归属" width="240px" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{resOwnerName(scope.row.resOwner1)}}</span>
<span v-if="scope.row.resOwner2 != ''">/{{resOwnerName(scope.row.resOwner2)}}</span>
<span v-if="scope.row.resOwner3 != ''">/{{resOwnerName(scope.row.resOwner3)}}</span>
</template>
</el-table-column> -->
<el-table-column prop="type" label="类型" width="70px">
<template slot-scope="scope">
{{ scope.row.type == 1 ? "单选" : scope.row.type == 2 ? "多选" : scope.row.type == 3 ? "判断题" : "" }}
</template>
</el-table-column>
<el-table-column prop="sysCreateBy" label="创建者" width="70px" ></el-table-column>
<el-table-column prop="sysCreateTime" label="创建时间" width="180px" ></el-table-column>
<el-table-column label="操作" width="140px" fixed="right">
<template slot-scope="scope">
<el-button type="text" icon="el-icon-edit" @click="editQuestion(scope.row)" >编辑</el-button>
<el-button type="text" icon="el-icon-delete" @click="deleteQuestion(scope.row)" >删除</el-button>
</template>
</el-table-column>
</el-table>
<div v-if="tableData.length > 0" style="text-align: center;margin-top:70px">
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="count">
</el-pagination>
</div>
</el-main>
<el-dialog :title="isAdd ? '新建试题' : '编辑试题'" :visible.sync="addQuestionDialog">
<span style=" font-weight: 700; font-size: 14px; margin-left: 42px; margin-right: 10px; ">类型</span>
<el-radio-group
v-model="question.type"
:disabled="question.id != null">
<el-radio :label="1">单选</el-radio>
<el-radio :label="2">多选</el-radio>
<el-radio :label="3">判断题</el-radio>
</el-radio-group>
<div v-if="question.type == 1 || question.type == 2">
<div style="padding-top: 10px; overflow: auto">
<div>
<el-form
size="mini"
label-width="80px"
:model="question"
ref="questionForm"
:rules="questionRules">
<!-- <el-form-item label="资源归属">
<el-cascader v-model="ownership" :options="resOwnerListMap" :props="resourceProps"></el-cascader>
</el-form-item> -->
<el-form-item label="题干" prop="title">
<el-input
type="textarea"
:rows="3"
maxlength="500"
show-word-limit
v-model="question.title"
placeholder="请输入题干"></el-input>
</el-form-item>
<div v-for="(o, i) in question.optionList" :key="i">
<el-form-item :label="'选项' + (i + 1)">
<el-input
style="width: 300px; margin-right: 10px"
v-model="question.optionList[i].content"
placeholder="填写选择题的选项内容"></el-input>
<!-- <el-input
v-if="question.type == 2"
style="width: 80px; margin-right: 10px"
v-model="question.optionList[i].score"
placeholder="得分"></el-input> -->
<!-- v-else -->
<el-radio v-if="question.type == 1" v-model="question.optionList[i].isAnswer" @change="radioChange(i)" :label="true">正确</el-radio>
<el-checkbox
v-else
v-model="question.optionList[i].isAnswer"
style="width: 80px; margin-right: 10px"
>正确</el-checkbox>
<el-button type="text" @click="removeOption(i)"
>删除</el-button>
</el-form-item>
</div>
<center>
<el-button type="text" @click="addOption"
>添加选项</el-button>
</center>
<el-form-item label="难度">
<el-select
v-model="question.difficulty"
placeholder="请选择">
<el-option
v-for="item in difficultyOptions"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="默认分" prop="defaultScore">
<el-input
type="number"
v-model="question.defaultScore"
placeholder="请输入默认分"></el-input>
</el-form-item>
<el-form-item label="解析">
<el-input
v-model="question.analysis"
placeholder="请输入解析"
type="textarea"
maxlength="200"
show-word-limit
:rows="3"></el-input>
</el-form-item>
</el-form>
</div>
<div style="text-align: right">
<el-button @click="handleAdd" type="primary">提交</el-button>
</div>
</div>
</div>
<div v-if="question.type == 3">
<div style="padding-top: 10px; overflow: auto">
<div>
<el-form
size="mini"
label-width="80px"
:model="question"
ref="questionForm"
:rules="questionRules"
>
<el-form-item label="资源归属">
<el-cascader
v-model="ownership"
:options="resOwnerListMap"
:props="resourceProps"
></el-cascader>
</el-form-item>
<el-form-item label="题干" prop="title"
><el-input
type="textarea"
:rows="3"
v-model="question.title"
placeholder="请输入题干"
maxlength="500"
show-word-limit
></el-input
></el-form-item>
<el-form-item label="正确/错误">
<el-radio v-model="question.answer" :label="true"
>正确</el-radio>
<el-radio v-model="question.answer" :label="false"
>错误</el-radio>
</el-form-item>
<el-form-item label="难度">
<el-select
v-model="question.difficulty"
placeholder="请选择">
<el-option
v-for="item in difficultyOptions"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="知识点"><el-input v-model="question.dian" placeholder="请输入知识点"></el-input></el-form-item> -->
<el-form-item label="默认分" prop="defaultScore"
><el-input
type="number"
v-model="question.defaultScore"
placeholder="请输入默认分"
></el-input
></el-form-item>
<el-form-item label="解析"
><el-input
v-model="question.analysis"
placeholder="请输入解析"
type="textarea"
:rows="3"
maxlength="200"
show-word-limit
></el-input
></el-form-item>
</el-form>
</div>
<div style="text-align: right">
<el-button @click="handleAdd" type="primary">提交</el-button>
</div>
</div>
</div>
</el-dialog>
<el-dialog title="查看试题" append-to-body :visible.sync="viewVolumeShow" width="40%" custom-class="g-dialog">
<div style="padding: 10px; font-size: 20px">
<div v-if="question.type == 1">
<div>单选题{{question.title}}{{question.defaultScore}}</div>
<div v-for="(item, i) in question.optionList" :key="i">
<el-radio disabled :value="item.isAnswer" :label="true" style="margin-right: 0px;">&nbsp;</el-radio>
<span>{{numberToLetter(i + 1)}}</span>
<span>{{question.optionList[i].content}}</span>
</div>
</div>
<div v-if="question.type == 2">
<div>多选题{{question.title}}{{question.defaultScore}}</div>
<div v-for="(item, i) in question.optionList" :key="i">
<el-checkbox v-if="item.isAnswer == true" :value="true" disabled>&nbsp;</el-checkbox>
<el-checkbox v-else disabled >&nbsp;</el-checkbox>
<span>{{numberToLetter(i + 1)}}</span>
<span>{{item.content}}</span>
</div>
</div>
<div v-if="question.type == 3">
<div>判断题{{question.title}}{{question.defaultScore}}</div>
<el-radio disabled :value="question.answer" :label="true" style="margin-right: 0px;">&nbsp;</el-radio><span style="margin-right: 30px;">正确</span>
<el-radio disabled :value="question.answer" :label="false" style="margin-right: 0px;">&nbsp;</el-radio><span>错误</span>
</div>
</div>
<span slot="footer" class="dialog-footer"><el-button @click="viewVolumeShow = false">关闭</el-button></span>
</el-dialog>
</el-container>
</el-container>
<!-- <div style="display:none"> -->
<!-- </div> -->
</div>
</template>
<script>
// import { resourceAttribution } from '../../data/resource';
import resSysApi from "@/api/modules/resowner";
// import examQuestionApi from "@/api/modules/examquestion";
import examQuestionApi from "@/api/modules/question";
import { numberToLetter} from "../../utils/tools.js";
import { mapGetters,mapActions} from 'vuex';
import fileUpload from '@/components/FileUpload/index.vue';
import { setTimeout } from 'timers';
// import {resOwnerIndexName} from '@/utils/type.js';
const questionData = {
type: 1,
type: "", // 类型
code: "1",
title: "",
project: "",
createPerson: "",
moduel: "",
statue: 0,
optionList: [
{ content: "", score: "", isAnswer: false },
{ content: "", score: "", isAnswer: false },
{ content: "", score: "", isAnswer: false },
{ content: "", score: "", isAnswer: false },
],
// resSysId: [], // 试题目录
difficulty: "", // 难度
defaultScore: "", // 默认分
analysis: "", // 解析
};
export default {
components: {fileUpload},
computed: {
...mapGetters(['resOwnerMap','sysTypeMap']),
},
data() {
return {
resOwnerListMap: [],
// resOwnerName: resOwnerIndexName,
ownership: [],
pageSize: 10,
testRadio: "",
viewVolumeShow: false,
isAdd: false,
optionsList: [
{
value: "1",
label: "单选",
},
{
value: "2",
label: "多选",
},
{
value: "3",
label: "判断",
},
],
inputValue: "",
params: { type: "", resSysId: "", title: "", ownership: [] },
defaultProps: { children: "children", label: "label" },
tableData: [],
count: 0,
pageIndex: 1,
url: `${this.webBaseUrl}/temp/exam.png`,
resourceProps: {
value: "code",
label: "name",
},
question: questionData,
difficultyOptions: [
{
value: 1,
label: "容易",
},
{
value: 2,
label: "中等",
},
{
value: 3,
label: "困难",
},
],
addQuestionDialog: false,
questionRules: {
type: [{ required: true, message: "请选择类型", trigger: "blur" }],
title: [{ required: true, message: "请输入题干", trigger: "blur" }],
},
};
},
created() {
// this.question = questionData;
//this.initResSys();
this.loadData(1);
},
mounted() {
this.getResOwnerTree().then(rs=>{
this.resOwnerListMap=rs;
});
},
methods: {
uploadFile(file) {
this.loadData(1);
setTimeout(this.$message.warning('请耐心等待片刻,正在导入'), 2000 );
},
removeFile(file) {
},
radioChange(i) {
this.question.optionList.forEach((item, index)=>{
item.isAnswer = false;
if(i == index) {
item.isAnswer = true;
}
})
},
reset(){
this.params.ownership = []
this.params.type = ''
this.params.title = ''
this.loadData(1)
},
...mapActions({
getResOwnerTree:'resOwner/getResOwnerTree',
loadResOwners:'resOwner/loadResOwners',
getSysTypeTree:'sysType/getSysTypeTree',
loadSysTypes:'sysType/loadSysTypes'
}),
resOwnerName(code){
if(code==''){return '';}
return this.resOwnerMap.get(code);
},
numberToLetter(x){
return numberToLetter(x);
},
handleSizeChange(val) {
this.pageSize = val;
this.pageIndex = 1;
this.loadData(1);
},
handleCurrentChange(val) {
this.pageIndex = val;
this.loadData(this.pageIndex);
},
loadData(pageIndex) {
this.pageIndex = pageIndex;
let ownership = [];
if (this.params.ownership.length != 0) {
ownership = this.params.ownership;
} else {
ownership = [];
}
examQuestionApi
.querylist({
pageIndex: this.pageIndex,
pageSize: this.pageSize,
title: this.params.title,
type: this.params.type,
resOwner1: ownership[0],
resOwner2: ownership[1],
resOwner3: ownership[2],
})
.then((res) => {
if (res.status == 200) {
const result = res.result;
this.tableData = result.list;
this.count = result.count;
}
})
.catch((err) => {
this.$message({ type: "error", message: "查询数据错误:" + err });
});
},
handleAdd() {
let isOk = true;
if(this.question.type == 3) {
if(this.question.answer != undefined) {
isOk = false;
}
} else {
this.question.optionList.forEach(item=>{
if(item.isAnswer == true) {
isOk = false;
}
})
}
if(isOk) {
this.$message.warning('请选择正确选项!');
return;
}
this.$refs.questionForm.validate((valid) => {
if (valid) {
this.question.resOwner1 = this.ownership[0];
this.question.resOwner2 = this.ownership[1];
this.question.resOwner3 = this.ownership[2];
if (this.question.id != null && this.question.id != "") {
examQuestionApi
.update(this.question)
.then((res) => {
if (res.status == 200) {
this.$message({ type: "success", message: "保存成功" });
this.addQuestionDialog = false;
this.loadData(1);
}
})
.catch((err) => {
this.$message({ type: "error", message: err });
});
} else {
if (this.question.type == 3) {
// 判断题没有optionList
this.question.optionList = [];
}
examQuestionApi
.save(this.question)
.then((res) => {
if (res.status == 200) {
this.$message({ type: "success", message: "保存成功" });
this.addQuestionDialog = false;
this.loadData(1);
}
})
.catch((err) => {
this.$message({ type: "error", message: err });
});
}
}
});
},
viewTopic(row) {
examQuestionApi
.detail(row.id)
.then((res) => {
if (res.status == 200) {
this.viewVolumeShow = true;
this.question = res.result;
if (res.result.answer === "false") this.question.answer = false;
if (res.result.answer === "true") this.question.answer = true;
if (this.question.optionList == null) {
this.question.optionList = [];
}
}
})
.catch((err) => {
this.$message({ type: "error", message: err });
});
},
deleteQuestion(row) {
this.$confirm("此操作将数据永久删除, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
examQuestionApi
.del(row.id)
.then((res) => {
if (res.status == 200) {
this.loadData(this.pageIndex);
this.$message({
type: "success",
message: "删除成功!",
});
}
})
.catch((err) => {
this.$message({ type: "error", message: err });
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
editQuestion(row) {
this.isAdd = false;
examQuestionApi
.detail(row.id)
.then((res) => {
if (res.status == 200) {
this.addQuestionDialog = true;
this.question = res.result;
if (res.result.resOwner3) {
this.ownership = [
res.result.resOwner1,
res.result.resOwner2,
res.result.resOwner3,
];
} else {
this.ownership = [res.result.resOwner1, res.result.resOwner2];
}
if (res.result.answer === "false") this.question.answer = false;
if (res.result.answer === "true") this.question.answer = true;
if (this.question.optionList == null) {
this.question.optionList = [];
}
}
})
.catch((err) => {
this.$message({ type: "error", message: err });
});
},
addQuestion(type) {
this.isAdd = true;
this.question = JSON.parse(JSON.stringify(questionData));
this.ownership = [];
this.addQuestionDialog = true;
this.question.type = type;
},
addOption() {
if (this.question.optionList.length < 10) {
this.question.optionList.push({ content: "", score: "", isAnswer: 0 });
}
},
removeOption(i) {
if (this.question.optionList.length > 2) {
this.question.optionList.splice(i, 1);
}
},
},
};
</script>
<style scoped lang="scss">
.svg-icon {
margin-right: 8px;
font-size: 19px;
padding-top: 0px;
// line-height: 36px;
// margin-top: 20px;
}
.el-aside {
padding: 0px 2px 10px 0px;
}
.el-main {
padding: 0px 10px;
}
.examManger {
// height: 430px;
// width: 100px;
display: flex;
justify-content: flex-start;
.left {
flex: 3;
margin-right: 10px;
}
.right {
flex: 12;
}
}
</style>