|
|
@@ -5,12 +5,13 @@
|
|
|
文档作业列表
|
|
|
</template>
|
|
|
<template slot="content">
|
|
|
- 共有{{ docData.length }}份作业
|
|
|
+ 共有 {{ docData.length }} 份作业
|
|
|
</template>
|
|
|
<template slot="action">
|
|
|
- <b-field>
|
|
|
- <a class="button is-link" @click="updateInfo(-1)">新建文档作业</a>
|
|
|
- </b-field>
|
|
|
+ <create-assignment
|
|
|
+ @sendCreatedAssignment="pushNewAssignment($event)"
|
|
|
+ :course-id="course.id"
|
|
|
+ ></create-assignment>
|
|
|
</template>
|
|
|
</page-header>
|
|
|
|
|
|
@@ -27,7 +28,7 @@
|
|
|
:to="{
|
|
|
path: `document/${props.row.id}`,
|
|
|
query: {
|
|
|
- assignmentInfo: props.row.problem,
|
|
|
+ assignmentInfo: props.row,
|
|
|
title: props.row.name
|
|
|
}
|
|
|
}"
|
|
|
@@ -47,12 +48,16 @@
|
|
|
{{ displayUnixTime(props.row.endAt) }}
|
|
|
</b-table-column>
|
|
|
<b-table-column label="修改" centered>
|
|
|
- <a @click="updateInfo(props.row.id)">修改</a>
|
|
|
+ <update-assignment
|
|
|
+ :update-item="props.row"
|
|
|
+ v-on:updateDocData="modifyDocData($event)"
|
|
|
+ ></update-assignment>
|
|
|
</b-table-column>
|
|
|
<b-table-column label="删除" centered>
|
|
|
- <a style="color:#b34141" @click="confirmDelete(props.row.id)"
|
|
|
- >删除</a
|
|
|
- >
|
|
|
+ <delete-assignment
|
|
|
+ :del-id="props.row.id"
|
|
|
+ @del="deleteAssignment(props.row.id)"
|
|
|
+ ></delete-assignment>
|
|
|
</b-table-column>
|
|
|
</template>
|
|
|
|
|
|
@@ -71,159 +76,6 @@
|
|
|
</b-table>
|
|
|
</div>
|
|
|
</page-body>
|
|
|
-
|
|
|
- <!--新建文档作业模态框-->
|
|
|
- <b-modal :active.sync="isCardModalActive" :width="640" scroll="keep">
|
|
|
- <div class="card">
|
|
|
- <div class="title">{{ modal.title }}</div>
|
|
|
- <div class="content">
|
|
|
- <b-field label="题目名称" v-if="display">
|
|
|
- <b-input v-model="$v.problemName.$model"></b-input>
|
|
|
- </b-field>
|
|
|
- <b-field
|
|
|
- label="作业名称"
|
|
|
- :type="$v.params.name.$error ? 'is-danger' : ''"
|
|
|
- :message="$v.params.name.$error ? '请填写作业名称' : ''"
|
|
|
- >
|
|
|
- <b-input
|
|
|
- placeholder="请填写作业名称"
|
|
|
- v-model="$v.params.name.$model"
|
|
|
- ></b-input>
|
|
|
- </b-field>
|
|
|
- <b-field
|
|
|
- label="作业描述"
|
|
|
- :type="$v.params.description.$error ? 'is-danger' : ''"
|
|
|
- :message="$v.params.description.$error ? '请填写作业描述' : ''"
|
|
|
- >
|
|
|
- <b-input
|
|
|
- type="textarea"
|
|
|
- placeholder="请填写作业描述"
|
|
|
- v-model="$v.params.description.$model"
|
|
|
- ></b-input>
|
|
|
- </b-field>
|
|
|
- <b-field
|
|
|
- label="开始时间"
|
|
|
- :type="$v.params.startAt.$error ? 'is-danger' : ''"
|
|
|
- :message="$v.params.startAt.$error ? '请填写作业开始时间' : ''"
|
|
|
- >
|
|
|
- <flat-pickr
|
|
|
- placeholder="Click to select..."
|
|
|
- class="input"
|
|
|
- v-model="$v.params.startAt.$model"
|
|
|
- :config="startAtConfig"
|
|
|
- ></flat-pickr>
|
|
|
- </b-field>
|
|
|
- <b-field
|
|
|
- label="结束时间"
|
|
|
- :type="$v.params.endAt.$error ? 'is-danger' : ''"
|
|
|
- :message="$v.params.endAt.$error ? '请填写作业结束时间' : ''"
|
|
|
- >
|
|
|
- <flat-pickr
|
|
|
- placeholder="Click to select..."
|
|
|
- class="input"
|
|
|
- v-model="$v.params.endAt.$model"
|
|
|
- :config="endAtConfig"
|
|
|
- ></flat-pickr>
|
|
|
- </b-field>
|
|
|
-
|
|
|
- <a class="button is-link" @click="createDocAssignment()">
|
|
|
- {{ modal.submit }}
|
|
|
- </a>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </b-modal>
|
|
|
-
|
|
|
- <!--选择题目模态框-->
|
|
|
- <b-modal :active.sync="isProblemModalActive">
|
|
|
- <div class="card">
|
|
|
- <div class="title">请先查找题目</div>
|
|
|
- <div class="content">
|
|
|
- <b-field :type="$v.searchContent.$error ? 'is-danger' : ''">
|
|
|
- <b-input
|
|
|
- placeholder="输入关键字模糊查找"
|
|
|
- type="search"
|
|
|
- v-model="$v.searchContent.$model"
|
|
|
- expanded
|
|
|
- >
|
|
|
- </b-input>
|
|
|
- <p class="control">
|
|
|
- <button class="button is-link" @click="search(searchContent)">
|
|
|
- 查找
|
|
|
- </button>
|
|
|
- </p>
|
|
|
- </b-field>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </b-modal>
|
|
|
-
|
|
|
- <!--搜索题目展示框-->
|
|
|
- <b-modal :active.sync="isProblemListModalActive">
|
|
|
- <div class="card">
|
|
|
- <div class="title">点击选择题目</div>
|
|
|
- <div class="content">
|
|
|
- <div class="question-list">
|
|
|
- <b-table :data="questions" detailed detail-key="id">
|
|
|
- <template slot-scope="props">
|
|
|
- <b-table-column
|
|
|
- field="id"
|
|
|
- label="ID"
|
|
|
- width="40"
|
|
|
- numeric
|
|
|
- sortable
|
|
|
- >
|
|
|
- {{ props.row.id }}
|
|
|
- </b-table-column>
|
|
|
-
|
|
|
- <b-table-column label="题目名称">
|
|
|
- <a @click="selectAndCreate(props.row)">{{
|
|
|
- props.row.name
|
|
|
- }}</a>
|
|
|
- </b-table-column>
|
|
|
-
|
|
|
- <b-table-column label="题目描述" width="400">
|
|
|
- <div class="description">{{ props.row.description }}</div>
|
|
|
- </b-table-column>
|
|
|
-
|
|
|
- <b-table-column
|
|
|
- field="difficulty"
|
|
|
- label="题目难度"
|
|
|
- sortable
|
|
|
- centered
|
|
|
- >
|
|
|
- <span
|
|
|
- :class="[
|
|
|
- 'tag',
|
|
|
- `${getDifficultyClass(props.row.difficulty)}`
|
|
|
- ]"
|
|
|
- >
|
|
|
- {{ getDifficultyType(props.row.difficulty) }}
|
|
|
- </span>
|
|
|
- </b-table-column>
|
|
|
-
|
|
|
- <b-table-column
|
|
|
- label="平均时长"
|
|
|
- field="expectTime"
|
|
|
- sortable
|
|
|
- centered
|
|
|
- >
|
|
|
- {{ props.row.expectTime }}分钟
|
|
|
- </b-table-column>
|
|
|
- </template>
|
|
|
-
|
|
|
- <template slot="detail" slot-scope="props">
|
|
|
- <article class="media">
|
|
|
- <div class="media-content">
|
|
|
- <div class="content">
|
|
|
- <p class="detail-content">{{ props.row.description }}</p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </article>
|
|
|
- </template>
|
|
|
- </b-table>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </b-modal>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -231,16 +83,11 @@
|
|
|
import PageHeader from "@/components/PageHeader";
|
|
|
import PageBody from "@/components/PageBody/index";
|
|
|
import { getDocAssignmentListTeacherByCrs } from "@/api/assignment";
|
|
|
-import { getTeacherKeywordQuestions } from "@/api/question";
|
|
|
-import { postDocAssignment } from "@/api/assignment";
|
|
|
-import { putDocAssignment } from "@/api/assignment";
|
|
|
-import { delDocAssignment } from "@/api/assignment";
|
|
|
import timeMixins from "@/mixins/time";
|
|
|
-import { required } from "vuelidate/lib/validators";
|
|
|
-import pathMixins from "@/mixins/path";
|
|
|
import { mapState } from "vuex";
|
|
|
-import { difficultyType } from "@/data/questionDifficulty";
|
|
|
-import { difficultyClass } from "@/data/questionDifficulty";
|
|
|
+import DeleteAssignment from "./components/DeleteAssignment";
|
|
|
+import UpdateAssignment from "./components/UpdateAssignment";
|
|
|
+import CreateAssignment from "./components/CreateAssignment";
|
|
|
|
|
|
export default {
|
|
|
computed: {
|
|
|
@@ -250,9 +97,12 @@ export default {
|
|
|
},
|
|
|
components: {
|
|
|
PageBody,
|
|
|
- PageHeader
|
|
|
+ PageHeader,
|
|
|
+ DeleteAssignment,
|
|
|
+ UpdateAssignment,
|
|
|
+ CreateAssignment
|
|
|
},
|
|
|
- mixins: [timeMixins, pathMixins],
|
|
|
+ mixins: [timeMixins],
|
|
|
mounted() {
|
|
|
getDocAssignmentListTeacherByCrs(this.course.id).then(res => {
|
|
|
this.docData = res.data;
|
|
|
@@ -260,213 +110,29 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- problemName: "",
|
|
|
- searchContent: "",
|
|
|
- questions: [],
|
|
|
- docData: [],
|
|
|
- params: {
|
|
|
- name: null,
|
|
|
- description: null,
|
|
|
- startAt: null,
|
|
|
- endAt: null,
|
|
|
- problem: null //题目编号
|
|
|
- },
|
|
|
- // 返回的文档作业信息
|
|
|
- isCardModalActive: false,
|
|
|
- isProblemModalActive: false,
|
|
|
- isProblemListModalActive: false,
|
|
|
- modal: {
|
|
|
- title: "新建文档作业",
|
|
|
- submit: "确认创建"
|
|
|
- },
|
|
|
- flag: -1, //区分创建还是修改
|
|
|
- display: false, //展示新建题目的名称
|
|
|
- startAtConfig: {
|
|
|
- ...this.getDefaultConfig(),
|
|
|
- minDate: "today",
|
|
|
- maxDate: null
|
|
|
- },
|
|
|
- endAtConfig: {
|
|
|
- ...this.getDefaultConfig(),
|
|
|
- minDate: "today",
|
|
|
- maxDate: null
|
|
|
- }
|
|
|
+ docData: []
|
|
|
};
|
|
|
},
|
|
|
-
|
|
|
methods: {
|
|
|
- /**
|
|
|
- * 搜索题目
|
|
|
- * @param content
|
|
|
- * @return {Promise<void>}
|
|
|
- */
|
|
|
- async searchAssis(content) {
|
|
|
- await getTeacherKeywordQuestions(content).then(res => {
|
|
|
- this.questions = res.data;
|
|
|
- });
|
|
|
- },
|
|
|
- search(content) {
|
|
|
- this.searchAssis(content).then(() => {
|
|
|
- this.isProblemModalActive = false;
|
|
|
- this.isProblemListModalActive = true;
|
|
|
- });
|
|
|
+ pushNewAssignment(item) {
|
|
|
+ this.docData.push(item);
|
|
|
},
|
|
|
- selectAndCreate(problem) {
|
|
|
- console.log(problem);
|
|
|
- this.modal.title = "新建文档作业";
|
|
|
- this.modal.submit = "确认创建";
|
|
|
- this.params.problem = problem.id;
|
|
|
- this.isProblemListModalActive = false;
|
|
|
- this.display = true;
|
|
|
- this.isCardModalActive = true;
|
|
|
- this.problemName = problem.name;
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 确定删除(模块正常)
|
|
|
- * @param id
|
|
|
- */
|
|
|
- confirmDelete(id) {
|
|
|
- this.$dialog.confirm({
|
|
|
- message: "确认删除?",
|
|
|
- confirmText: "删除",
|
|
|
- type: "is-danger",
|
|
|
- onConfirm: () => {
|
|
|
- delDocAssignment(id).then(res => {
|
|
|
- if (res.err === 0) {
|
|
|
- //删除成功
|
|
|
- for (let item of this.docData) {
|
|
|
- if (item.id === id) {
|
|
|
- this.docData.pop(item);
|
|
|
- }
|
|
|
- }
|
|
|
- this.$toast.open("删除成功");
|
|
|
- } else {
|
|
|
- this.$dialog.alert({
|
|
|
- title: "删除失败",
|
|
|
- message: `${res.msg}`,
|
|
|
- type: "is-danger",
|
|
|
- hasIcon: true
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- /**
|
|
|
- * 准备新建或者修改
|
|
|
- * @param id
|
|
|
- */
|
|
|
- updateInfo(id) {
|
|
|
- if (id === -1) {
|
|
|
- // 准备新建
|
|
|
- this.isProblemModalActive = true;
|
|
|
- this.flag = -1;
|
|
|
- } else {
|
|
|
- this.isCardModalActive = true;
|
|
|
- this.display = false;
|
|
|
- // 准备修改
|
|
|
- this.modal.title = "修改文档作业";
|
|
|
- this.modal.submit = "确认修改";
|
|
|
- for (let item of this.docData) {
|
|
|
- if (item.id === id) {
|
|
|
- this.params.name = item.name;
|
|
|
- this.params.description = item.description;
|
|
|
- break;
|
|
|
- }
|
|
|
+ modifyDocData(modifiedItem) {
|
|
|
+ let length = this.docData.length;
|
|
|
+ for (let i = 0; i < length; i++) {
|
|
|
+ if (modifiedItem.id === this.docData[i].id) {
|
|
|
+ this.docData.splice(i, 1, modifiedItem);
|
|
|
+ break;
|
|
|
}
|
|
|
- this.flag = 0;
|
|
|
}
|
|
|
},
|
|
|
- /**
|
|
|
- * 确认新建或者修改
|
|
|
- */
|
|
|
- createDocAssignment(dd) {
|
|
|
- console.log(dd);
|
|
|
- this.$v.$touch();
|
|
|
- if (!this.$v.params.$invalid) {
|
|
|
- this.isCardModalActive = false;
|
|
|
- if (this.flag === -1) {
|
|
|
- // 确认新建作业
|
|
|
- this.params["type"] = "DOCUMENT";
|
|
|
- postDocAssignment(this.params, this.course.id).then(res => {
|
|
|
- if (res.err === 0) {
|
|
|
- //创建成功
|
|
|
- this.docData.push(res.data);
|
|
|
- this.$router.push({
|
|
|
- path: `${this.prefix}/review?documentHwId=${res.data.id}`
|
|
|
- });
|
|
|
- } else {
|
|
|
- //创建失败
|
|
|
- this.$dialog.alert({
|
|
|
- title: "创建失败",
|
|
|
- message: res.msg,
|
|
|
- type: "is-danger",
|
|
|
- hasIcon: true
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- // 确认修改作业
|
|
|
- putDocAssignment(this.params).then(res => {
|
|
|
- if (res.err === 0) {
|
|
|
- let id = res.data.id;
|
|
|
- for (let item of this.docData) {
|
|
|
- if (item.id === id) {
|
|
|
- item = res.data;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$dialog.alert({
|
|
|
- title: "修改失败",
|
|
|
- message: res.msg,
|
|
|
- type: "is-danger",
|
|
|
- hasIcon: true
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ deleteAssignment(delId) {
|
|
|
+ let length = this.docData.length;
|
|
|
+ for (let i = 0; i < length; i++) {
|
|
|
+ if (this.docData[i].id === delId) {
|
|
|
+ this.docData.splice(i, 1);
|
|
|
+ break;
|
|
|
}
|
|
|
- } else {
|
|
|
- console.log("无效");
|
|
|
- }
|
|
|
- },
|
|
|
- getDifficultyType(level) {
|
|
|
- return difficultyType(level);
|
|
|
- },
|
|
|
- getDifficultyClass(level) {
|
|
|
- return difficultyClass(level);
|
|
|
- }
|
|
|
- },
|
|
|
- validations: {
|
|
|
- params: {
|
|
|
- name: {
|
|
|
- required
|
|
|
- },
|
|
|
- description: {
|
|
|
- required
|
|
|
- },
|
|
|
- startAt: {
|
|
|
- required
|
|
|
- },
|
|
|
- endAt: {
|
|
|
- required
|
|
|
- }
|
|
|
- // problem: {
|
|
|
- // required
|
|
|
- // }
|
|
|
- },
|
|
|
- problemName: {
|
|
|
- required
|
|
|
- },
|
|
|
- searchContent: {
|
|
|
- required
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- isCardModalActive(newValue) {
|
|
|
- if (newValue === false) {
|
|
|
- this.$v.$reset();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -490,4 +156,13 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.description {
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
+ -webkit-line-clamp: 1;
|
|
|
+ word-wrap: break-word;
|
|
|
+ word-break: break-all;
|
|
|
+ display: -webkit-box;
|
|
|
+}
|
|
|
</style>
|