Browse Source

修改作业展示页面标题展示两行,其余为省略号

test
ting 5 months ago
parent
commit
81d0094852
  1. 91
      work/src/views/DoHomeworkView.vue
  2. 1
      work/src/views/WorksShowView.vue

91
work/src/views/DoHomeworkView.vue

@ -14,9 +14,7 @@
<div v-for="(answer, index) in question.content" :key="index" class="answer"> <div v-for="(answer, index) in question.content" :key="index" class="answer">
<div class="selected"> <div class="selected">
<input :id="`select-${questionIndex}-${index}`" :name="`radio-group-${questionIndex}`" type="radio" <input :id="`select-${questionIndex}-${index}`" :name="`radio-group-${questionIndex}`" type="radio"
v-model="selectedAnswers[questionIndex]"
:value="answer.text"
>
v-model="selectedAnswers[questionIndex]" :value="answer.text">
<label :for="`select-${questionIndex}-${index}`">{{ answer.text }}</label> <label :for="`select-${questionIndex}-${index}`">{{ answer.text }}</label>
</div> </div>
</div> </div>
@ -30,9 +28,7 @@
<div v-for="(answer, index) in question.content" :key="index" class="answer"> <div v-for="(answer, index) in question.content" :key="index" class="answer">
<div class="selected"> <div class="selected">
<input :id="`checkbox-${questionIndex}-${index}`" name="checkbox" type="checkbox" <input :id="`checkbox-${questionIndex}-${index}`" name="checkbox" type="checkbox"
v-model="selectedAnswers[questionIndex]"
:value="answer.text"
>
v-model="selectedAnswers[questionIndex]" :value="answer.text">
<label :for="`checkbox-${questionIndex}-${index}`">{{ answer.text }}</label> <label :for="`checkbox-${questionIndex}-${index}`">{{ answer.text }}</label>
</div> </div>
</div> </div>
@ -44,31 +40,15 @@
<div class="question"> <div class="question">
{{ questionIndex + 1 }}. {{ question.description }} {{ questionIndex + 1 }}. {{ question.description }}
</div> </div>
<el-input
v-model="editorTitles[questionIndex]"
style="width: 100%; padding: 3.5%"
size="large"
placeholder="请输入标题(5-100字符)"
maxlength="100"
minlength="5"
show-word-limit
/>
<el-input v-model="editorTitles[questionIndex]" style="width: 100%; padding: 3.5%" size="large"
placeholder="请输入标题" />
<div class="editor"> <div class="editor">
<div style="border: 1px solid #ccc"> <div style="border: 1px solid #ccc">
<Toolbar
style="border-bottom: 1px solid #ccc"
:editor="editorRefs[questionIndex]"
:defaultConfig="toolbarConfig"
:mode="mode"
/>
<Editor
style="height: 500px; overflow-y: hidden;"
v-model="editorContents[questionIndex]"
:defaultConfig="editorConfig"
:mode="mode"
@onCreated="editor => handleCreated(editor, questionIndex)"
/>
<Toolbar style="border-bottom: 1px solid #ccc" :editor="editorRefs[questionIndex]"
:defaultConfig="toolbarConfig" :mode="mode" />
<Editor style="height: 500px; overflow-y: hidden;" v-model="editorContents[questionIndex]"
:defaultConfig="editorConfig" :mode="mode"
@onCreated="editor => handleCreated(editor, questionIndex)" />
</div> </div>
</div> </div>
</div> </div>
@ -81,7 +61,7 @@
</div> </div>
<!-- 提交次数 --> <!-- 提交次数 -->
<div class="submit-times"> <div class="submit-times">
<span>您已提交{{sub}}每个作业可以提交3次</span>
<span>您已提交{{ sub }}每个作业可以提交3次</span>
</div> </div>
</div> </div>
</div> </div>
@ -97,12 +77,13 @@ import { ElMessage } from "element-plus";
import '@wangeditor/editor/dist/css/style.css' // css import '@wangeditor/editor/dist/css/style.css' // css
import { onBeforeUnmount } from 'vue' import { onBeforeUnmount } from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue' import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
import {useRoute, useRouter} from "vue-router";
import { useRoute, useRouter } from "vue-router";
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
let groupId = route.params.id; let groupId = route.params.id;
let sub = route.params.sub; let sub = route.params.sub;
// shallowRef // shallowRef
const editorRefs = ref([]); const editorRefs = ref([]);
@ -145,7 +126,7 @@ const toolbarConfig = {
const editorConfig = { const editorConfig = {
placeholder: '请输入内容...', placeholder: '请输入内容...',
toolbarKeys: toolbarConfig.toolbarKeys toolbarKeys: toolbarConfig.toolbarKeys
}
}
// //
onBeforeUnmount(() => { onBeforeUnmount(() => {
@ -163,7 +144,6 @@ const handleCreated = (editor, questionIndex) => {
const questionList = ref([]); const questionList = ref([]);
function getQuestionList() { function getQuestionList() {
console.log("ljghasjkhdjksahjkhsajkhjkasd",groupId);
homeworkApi.getHomeworkQuestion(groupId).then(resp => { homeworkApi.getHomeworkQuestion(groupId).then(resp => {
if (resp.code == 200) { if (resp.code == 200) {
questionList.value = resp.data; questionList.value = resp.data;
@ -194,6 +174,23 @@ questionList.value.forEach(() => {
function submit() { function submit() {
homework.value = []; homework.value = [];
for (let i = 0; i < questionList.value.length; i++) { for (let i = 0; i < questionList.value.length; i++) {
//
if (questionList.value[i].type == 1 || questionList.value[i].type == 2) {
if (selectedAnswers.value[i].length == 0) {
ElMessage.error("您有题目未作答");
return;
}
} else if (questionList.value[i].type == 3) {
//
if (editorTitles.value[i] == '') {
ElMessage.error("标题不能为空");
return;
}
if (editorTitles.value[i] == '') {
ElMessage.error("您有题目未作答");
return;
}
}
if (questionList.value[i].type == 1 || questionList.value[i].type == 2) { if (questionList.value[i].type == 1 || questionList.value[i].type == 2) {
homework.value.push({ homework.value.push({
"id": questionList.value[i].id, "id": questionList.value[i].id,
@ -212,7 +209,7 @@ function submit() {
} }
let groupId = route.params.id; let groupId = route.params.id;
let sub = route.params.sub; let sub = route.params.sub;
if (sub <=2){
if (sub <= 2) {
homeworkApi.submitHomework(homework.value, groupId).then(resp => { homeworkApi.submitHomework(homework.value, groupId).then(resp => {
if (resp.code == 200) { if (resp.code == 200) {
ElMessage.success("提交成功"); ElMessage.success("提交成功");
@ -222,7 +219,7 @@ function submit() {
ElMessage.error("未知错误,请联系管理员"); ElMessage.error("未知错误,请联系管理员");
} }
}); });
}else {
} else {
ElMessage.error("提交失败您,已提交3次,每个作业可以提交3次"); ElMessage.error("提交失败您,已提交3次,每个作业可以提交3次");
} }
} }
@ -267,12 +264,15 @@ function submit() {
} }
.content::-webkit-scrollbar-track { .content::-webkit-scrollbar-track {
background: #f1f1f1; /* 滚动条轨道的背景色 */
background: #f1f1f1;
/* 滚动条轨道的背景色 */
} }
.content::-webkit-scrollbar-thumb { .content::-webkit-scrollbar-thumb {
background: #d9d9d9; /* 滚动条滑块的颜色 */
border-radius: 6px; /* 滑块的圆角 */
background: #d9d9d9;
/* 滚动条滑块的颜色 */
border-radius: 6px;
/* 滑块的圆角 */
} }
.title { .title {
@ -309,25 +309,30 @@ function submit() {
height: 1rem; height: 1rem;
/* 透明度 */ /* 透明度 */
opacity: 0.8; opacity: 0.8;
cursor: pointer; /* 鼠标悬停时变成手的形状 */
cursor: pointer;
/* 鼠标悬停时变成手的形状 */
} }
.selected input[type="radio"]{
.selected input[type="radio"] {
margin-right: 1%; margin-right: 1%;
width: 1.2rem; width: 1.2rem;
height: 1rem; height: 1rem;
/* 透明度 */ /* 透明度 */
opacity: 0.8; opacity: 0.8;
cursor: pointer; /* 鼠标悬停时变成手的形状 */
cursor: pointer;
/* 鼠标悬停时变成手的形状 */
} }
/* 单选按钮选中时的样式 */ /* 单选按钮选中时的样式 */
.selected input[type="radio"]:checked { .selected input[type="radio"]:checked {
accent-color: blue; /* 设置选中时的颜色为蓝色 */
accent-color: blue;
/* 设置选中时的颜色为蓝色 */
} }
/* 多选按钮选中时的样式 */ /* 多选按钮选中时的样式 */
.selected input[type="checkbox"]:checked { .selected input[type="checkbox"]:checked {
accent-color: blue; /* 设置选中时的颜色为蓝色 */
accent-color: blue;
/* 设置选中时的颜色为蓝色 */
} }
.selected label { .selected label {

1
work/src/views/WorksShowView.vue

@ -80,7 +80,6 @@ body {
.ketangzuoye { .ketangzuoye {
margin-top: 2vh; margin-top: 2vh;
margin-left: 2vw; margin-left: 2vw;

Loading…
Cancel
Save