Commit a2bbdc18 authored by 耿迪迪's avatar 耿迪迪

承包商和访客培训 gengdidi

parent 17da3762
<template> <template>
<div class="form-wrapper"> <div class="form-wrapper">
<div style="width: 100%;height:100%;"> <div style="width: 100%;height:100%;">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> <el-form :model="contractTrainForm" :rules="rules" ref="contractTrainForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="培训名称" prop="name"> <el-form-item label="培训名称" prop="courseName">
<el-input v-model="ruleForm.name"></el-input> <el-input v-model="contractTrainForm.courseName"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="培训内容" prop="region"> <el-form-item label="培训内容" prop="courseConent">
<el-input type="textarea" v-model="ruleForm.region" rows="5"></el-input> <el-input type="textarea" v-model="contractTrainForm.courseConent" rows="5"></el-input>
</el-form-item> </el-form-item>
</el-form>
</div>
<el-form>
<div class="flex"> <div class="flex">
<el-form-item label="视频上传" v-if="!readOnly" prop="video"> <el-form-item label="视频上传" v-if="!readOnly" prop="video">
<FileUpload <FileUpload
...@@ -21,7 +18,7 @@ ...@@ -21,7 +18,7 @@
:fileSize="500" :fileSize="500"
:fileType="['mp4']" :fileType="['mp4']"
/> />
<el-input v-show="false" disabled v-model="form.video"></el-input> <el-input v-show="false" disabled v-model="contractTrainForm.video"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="附件上传" v-if="!readOnly" prop="enclosure"> <el-form-item label="附件上传" v-if="!readOnly" prop="enclosure">
<FileUpload <FileUpload
...@@ -30,27 +27,25 @@ ...@@ -30,27 +27,25 @@
@remove="listRemoveFile" @remove="listRemoveFile"
:fileArr="fileListFile" :fileArr="fileListFile"
/> />
<el-input v-show="false" disabled v-model="form.enclosure"></el-input> <el-input v-show="false" disabled v-model="contractTrainForm.enclosure"></el-input>
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
<visitorQuestion></visitorQuestion> </div>
<visitorQuestion ref="visitorQuestion"></visitorQuestion>
</div> </div>
</template> </template>
<script> <script>
import FileUpload from "@/components/FileUpload";
import FileUpload from "@/components/FileUpload"; import uploadfile from "@/assets/uploadfile.png";
import uploadfile from "@/assets/uploadfile.png"; import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQuestion";
import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQuestion"; import {listCourse} from "@/api/contractTrain/contractTrain";
// import visitorDia from "@/views/educationPlanExam/visitorProgram/visitorDia";
export default { export default {
data() { data() {
return { return {
ruleForm: { contractTrainForm: {
name: '', courseName: '',
region: '', courseConent: '',
},
form: {
video: "", video: "",
enclosure: "", enclosure: "",
}, },
...@@ -70,7 +65,7 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue ...@@ -70,7 +65,7 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue
enclosure: [ enclosure: [
{ required: true, trigger: "blur", message: "附件不能为空" }, { required: true, trigger: "blur", message: "附件不能为空" },
], ],
} },
}; };
}, },
components: { components: {
...@@ -78,11 +73,32 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue ...@@ -78,11 +73,32 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue
visitorQuestion, visitorQuestion,
}, },
created() { created() {
if (this.courseId) { this.getContractTrainList();
this.getLessonById();
}
}, },
methods: { methods: {
getContractTrainList(){
listCourse().then(res =>{
this.contractTrainForm = res.rows[0];
if(this.contractTrainForm.video){
this.fileListVideo = [
{
name: this.contractTrainForm.courseName + "视频",
url: uploadfile,
},
];
}
if(this.contractTrainForm.enclosure){
this.fileListFile = [
{
name: this.contractTrainForm.courseName + "附件",
url: uploadfile,
},
];
}
this.$refs.visitorQuestion.rightNum = this.contractTrainForm.qualifiedNum;
this.$refs.visitorQuestion.getContractTopicList(this.contractTrainForm.contractorCourseId)
})
},
submitForm(formName) { submitForm(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
...@@ -95,8 +111,7 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue ...@@ -95,8 +111,7 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue
}, },
getFileInfoVideo(res) { getFileInfoVideo(res) {
this.form.video = res.url; this.contractTrainForm.video = res.url;
// this.form.videoName = res.fileName;
this.fileListVideo = [ this.fileListVideo = [
{ {
name: res.fileName, name: res.fileName,
...@@ -106,12 +121,11 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue ...@@ -106,12 +121,11 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue
}, },
listRemoveVideo(e) { listRemoveVideo(e) {
this.fileListVideo = []; this.fileListVideo = [];
this.form.video = ""; this.contractTrainForm.video = "";
// this.form.videoName = null; // this.form.videoName = null;
}, },
getFileInfoFile(res) { getFileInfoFile(res) {
this.form.enclosure = res.url; this.contractTrainForm.enclosure = res.url;
// this.form.enclosureName = res.fileName;
this.fileListFile = [ this.fileListFile = [
{ {
name: res.fileName, name: res.fileName,
...@@ -121,12 +135,12 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue ...@@ -121,12 +135,12 @@ import visitorQuestion from "@/views/educationPlanExam/visitorProgram/visitorQue
}, },
listRemoveFile(e) { listRemoveFile(e) {
this.fileListFild = []; this.fileListFild = [];
this.form.enclosure = ""; this.contractTrainForm.enclosure = "";
// this.form.fileName = null; // this.form.fileName = null;
}, },
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.form-wrapper { .form-wrapper {
padding-top: 30px; padding-top: 30px;
......
...@@ -116,8 +116,6 @@ ...@@ -116,8 +116,6 @@
</div> </div>
</el-form> </el-form>
</div> </div>
</div>
</template> </template>
<script> <script>
...@@ -132,16 +130,9 @@ ...@@ -132,16 +130,9 @@
export default { export default {
name: "AnswerLesson", name: "AnswerLesson",
props: { props: {
// visible: {
// type: Boolean,
// default: false,
// },
courseId: { courseId: {
type: Number, type: Number,
}, },
topicId: {
type: Number,
},
}, },
components: {}, components: {},
data() { data() {
...@@ -159,23 +150,7 @@ ...@@ -159,23 +150,7 @@
}, },
created() { created() {
// 如果存在就是修改
// if (this.topicId) {
// checkQuestion(this.topicId).then((res) => {
// console.log(res.data);
// const data = res.data;
// this.form = {
// topicTitle: data.topicTitle,
// questions: JSON.parse(data.topicOption),
// };
// this.answerNum = data.answer;
// });
// }
// 查询是第几道题
// this.getQuestion();
// 获取课程标题
// this.getLessonById(this.courseId);
}, },
methods: { methods: {
getQuestion() { getQuestion() {
...@@ -215,48 +190,6 @@ ...@@ -215,48 +190,6 @@
// 新增选项 // 新增选项
add(addValue) { add(addValue) {
this.form.questions.push({ value: addValue }); this.form.questions.push({ value: addValue });
console.log();
},
save(num = 2) {
return new Promise((resove) => {
if (!this.answerNum && this.answerNum !== 0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
});
return resove(false);
}
this.$refs.form.validate((valid) => {
if (valid) {
const data = {};
data.topicTitle = this.form.topicTitle;
data.topicOption = JSON.stringify(this.form.questions);
data.answer = this.answerNum;
this.addQuestion(data).then((res) => {
if (res.code == 200) {
// 把修改的这个归位,变成正常添加
this.$emit("update:topicId", null);
this.$message({
message: "添加题目成功",
type: "success",
});
this.$parent.$parent.componentsNumChange(num);
this.$parent.$parent.$parent.getList();
resove(true);
}
});
}
});
});
},
saveAndNext() {
this.save(3).then((res) => {
if (res) {
this.reset();
this.questionNextNum++;
}
});
}, },
reset() { reset() {
this.form = { this.form = {
...@@ -359,4 +292,3 @@ ...@@ -359,4 +292,3 @@
} }
} }
</style> </style>
\ No newline at end of file
...@@ -11,21 +11,52 @@ ...@@ -11,21 +11,52 @@
<div style="color: #1890ff;">题目管理</div> <div style="color: #1890ff;">题目管理</div>
<div class="text flex"> <div class="text flex">
<div class="left"> <div class="left">
<el-button type="primary" plain @click="dialogVisible = true">{{ <el-button type="primary" plain @click="enterContractTrainTopic">录入考题</el-button>
saveNextText 目前有<span>{{questionNum}}</span>道题
}}</el-button>
目前有<span></span>道题
<span class="warn">温馨提示:发布课程前需要进行考试设置</span> <span class="warn">温馨提示:发布课程前需要进行考试设置</span>
</div> </div>
<!-- <div class="right">{{courseName}}</div> --> <!-- <div class="right">{{courseName}}</div> -->
</div> </div>
<!-- 试题列表 -->
<div class="table flex"> <div class="table flex">
<div class="th flex"> <div class="th flex">
<div class="left">序号</div> <div class="left">序号</div>
<div class="middle">题目名称</div> <div class="middle">题目名称</div>
<div class="right">操作</div> <div class="right">操作</div>
</div> </div>
<div class="td-wrapper">
<div
v-for="(item, index) in questionList"
:key="item.topicId"
class="td flex"
>
<div class="left">{{ index + 1 }}</div>
<div class="middle zzz">
{{ item.topicTitle }}
</div>
<div class="right">
<div>
<el-button
@click="editContractTrainTopic(item.topicId)"
icon="el-icon-edit"
type="text"
>修改</el-button
>
<el-button
@click="deleteContractTrainTopic(item.topicId)"
icon="el-icon-delete"
type="text"
>删除</el-button
>
</div>
</div>
</div>
</div>
</div> </div>
<!-- 底部 -->
<div class="d3"> <div class="d3">
<div class="rightNum flex"> <div class="rightNum flex">
<div class="left">考试设置</div> <div class="left">考试设置</div>
...@@ -53,6 +84,7 @@ ...@@ -53,6 +84,7 @@
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button <el-button
type="primary" type="primary"
@click="saveContractTrian"
>{{ "确认" }}</el-button >{{ "确认" }}</el-button
> >
<el-button>取消</el-button> <el-button>取消</el-button>
...@@ -63,25 +95,15 @@ ...@@ -63,25 +95,15 @@
title="录入题目" title="录入题目"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
> >
<visitorAdd></visitorAdd> <visitorAdd ref="visitorAdd" :key="next"/>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<!-- <el-button>保存</el-button>
<el-button type="primary" @click="dialogVisible = false">确 定</el-button> -->
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button <el-button
type="primary" type="primary"
@click="save" @click="save"
>保存</el-button >保存</el-button
> >
<el-button type="primary" @click="saveAndNext">保存并录入下一题</el-button>
<el-button type="primary" @click="saveAndNext">{{
saveNextText
}}</el-button>
<el-button
v-if="this.componentsNum == 2"
type="primary"
>{{ "确认" }}</el-button
>
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
</div> </div>
</span> </span>
...@@ -91,20 +113,15 @@ ...@@ -91,20 +113,15 @@
<script> <script>
import visitorAdd from "@/views/educationPlanExam/visitorProgram/visitorAdd"; import visitorAdd from "@/views/educationPlanExam/visitorProgram/visitorAdd";
import {updateCourse} from "@/api/contractTrain/contractTrain";
import { addTopic,listTopic,getTopic,delTopic,updateTopic } from "@/api/contractTrain/contractTrainTopic";
export default { export default {
name: "AnswerLesson", name: "AnswerLesson",
props: { props: {
courseId: {
type: Number,
},
visible: { visible: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
componentsNum: {
type: Number,
default: 1,
},
}, },
components: { components: {
visitorAdd, visitorAdd,
...@@ -113,43 +130,148 @@ ...@@ -113,43 +130,148 @@
return { return {
dialogVisible: false, dialogVisible: false,
rightNum: 0, rightNum: 0,
next: 0,
questionList: [],
questionNum: null,
courseId: ""
}; };
}, },
methods: {
//获取考题列表
getContractTopicList(contractorCourseId){
this.courseId = contractorCourseId;
listTopic({contractorCourseId:contractorCourseId}).then(res =>{
this.questionList = res.rows.map((item) => {
return {
topicId: item.topicId,
topicTitle: item.topicTitle,
};
});
this.questionNum = res.total;
})
},
//录入考题
enterContractTrainTopic(){
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs.visitorAdd.questionNextNum = this.questionNum + 1;
})
},
//保存试题
save(next) {
new Promise((resove) => {
if (!this.$refs.visitorAdd.answerNum && this.$refs.visitorAdd.answerNum !== 0) {
this.$message({
message: "警告,请设置一个正确答案",
type: "warning",
});
return resove(false);
}
computed: { this.$refs.visitorAdd.$refs.form.validate((valid) => {
saveNextText() { if (valid) {
let text; const data = {};
if (this.componentsNum == 1) { data.contractorCourseId = this.courseId;
text = "保存并录入题目"; data.topicTitle = this.$refs.visitorAdd.form.topicTitle;
} else if (this.componentsNum == 2) { data.topicOption = JSON.stringify(this.$refs.visitorAdd.form.questions);
text = "录入考题"; data.answer = this.$refs.visitorAdd.answerNum;
} else { this.addContractTrainTopic(data).then((res) => {
text = "保存并录入下一题"; if (res.code == 200) {
// 把修改的这个归位,变成正常添加
this.$emit("update:topicId", null);
this.$message({
message: "添加题目成功",
type: "success",
});
if(next != 1){
this.dialogVisible = false;
this.getContractTopicList(this.courseId)
}else{
this.next++;
}
resove(true);
}
});
} }
return text; });
});
}, },
//保存并录入下一题
saveAndNext() {
this.save(1);
}, },
created() { //新增试题
console.log("this.courseId", this.courseId); addContractTrainTopic(data){
if (this.$refs.visitorAdd.form.topicId) {
return updateTopic({ topicId: this.$refs.visitorAdd.form.topicId, ...data });
} else {
return addTopic({ contractorCourseId: this.courseId, ...data });
}
}, },
methods: { //试题修改
handleClose(done) { editContractTrainTopic(topicId){
this.$confirm('确认关闭?') this.dialogVisible = true;
.then(_ => { getTopic(topicId).then(res =>{
done(); const data = res.data;
this.$refs.visitorAdd.form = {
topicId: data.topicId,
topicTitle: data.topicTitle,
questions: JSON.parse(data.topicOption),
};
this.$refs.visitorAdd.answerNum = data.answer;
}) })
.catch(_ => {});
}, },
save() { //试题删除
// this.answerClear(); deleteContractTrainTopic(topicId){
this.$refs.current.save(); this.$confirm("请确定删除该题", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(() => {
return delTopic(topicId);
}).then((res) => {
if (res.code == 200) {
this.$message({
message: "删除成功",
type: "success",
});
}
return this.getContractTopicList(this.courseId);
})
}, },
saveRightNum() { saveRightNum() {
if (this.rightNum > this.questionList.length) {
this.$message({
message: "答对题目数应小于等于考试题目总数",
type: "warning",
});
return;
}
updateCourse({ contractorCourseId: this.courseId, qualifiedNum: this.rightNum }).then((res) => {
if (res.code == 200) {
this.$message({
message: "答题合格数修改成功",
type: "success",
});
}
}
);
}, },
saveAndNext() {
this.$refs.current.saveAndNext(); //保存承包商信息
}, saveContractTrian(){
updateCourse(this.$parent.contractTrainForm).then(res =>{
if(res.code == 200){
this.$message({
message: "培训信息修改成功",
type: "success",
});
this.$parent.getContractTrainList();
}
})
}
}, },
}; };
</script> </script>
...@@ -287,4 +409,3 @@ ...@@ -287,4 +409,3 @@
} }
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment