|
|
@@ -5,7 +5,7 @@
|
|
|
代码作业列表
|
|
|
</template>
|
|
|
<template slot="content">
|
|
|
- 共有{{ codeData.length }}份代码作业
|
|
|
+ 共有{{ codeData.length }}份作业
|
|
|
</template>
|
|
|
<template slot="action">
|
|
|
<b-field>
|
|
|
@@ -13,40 +13,39 @@
|
|
|
</b-field>
|
|
|
</template>
|
|
|
</page-header>
|
|
|
+
|
|
|
<page-body>
|
|
|
<div class="data-table">
|
|
|
<b-table :data="codeData" detailed detail-key="id">
|
|
|
<template slot-scope="props">
|
|
|
- <b-table-column field="id" label="作业ID" numeric sortable centered>
|
|
|
+ <b-table-column field="id" label="ID" numeric sortable centered>
|
|
|
{{ props.row.id }}
|
|
|
</b-table-column>
|
|
|
|
|
|
<b-table-column label="作业名称" centered>
|
|
|
<router-link
|
|
|
:to="{
|
|
|
- path: `/course-teacher/:courseId/code/detail`,
|
|
|
- query: { assignmentInfo: props.row }
|
|
|
+ path: `code/${props.row.id}`,
|
|
|
+ query: {
|
|
|
+ assignmentInfo: props.row.problem,
|
|
|
+ title: props.row.name
|
|
|
+ }
|
|
|
}"
|
|
|
>
|
|
|
{{ props.row.name }}
|
|
|
</router-link>
|
|
|
</b-table-column>
|
|
|
- <b-table-column label="作业状态" centered>
|
|
|
+ <b-table-column label="状态" centered>
|
|
|
{{ props.row.status }}
|
|
|
</b-table-column>
|
|
|
|
|
|
<b-table-column label="开始时间" centered>
|
|
|
- {{ new Date(props.row.startAt * 1000).getFullYear() }}-{{
|
|
|
- new Date(props.row.startAt * 1000).getMonth() + 1
|
|
|
- }}-{{ new Date(props.row.startAt * 1000).getDate() }}
|
|
|
+ {{ displayUnixTime(props.row.startAt) }}
|
|
|
</b-table-column>
|
|
|
|
|
|
<b-table-column label="结束时间" centered>
|
|
|
- {{ new Date(props.row.endAt * 1000).getFullYear() }}-{{
|
|
|
- new Date(props.row.endAt * 1000).getMonth() + 1
|
|
|
- }}-{{ new Date(props.row.endAt * 1000).getDate() }}
|
|
|
+ {{ displayUnixTime(props.row.endAt) }}
|
|
|
</b-table-column>
|
|
|
-
|
|
|
<b-table-column label="修改" centered>
|
|
|
<a @click="updateInfo(props.row.id)">修改</a>
|
|
|
</b-table-column>
|
|
|
@@ -73,34 +72,77 @@
|
|
|
</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="作业名称">
|
|
|
- <b-input v-model="codeAssignment.name"></b-input>
|
|
|
+ <div v-if="display">
|
|
|
+ <b-field label="查找题目"></b-field>
|
|
|
+ <b-field :type="$v.params.problem.$error ? 'is-danger' : ''">
|
|
|
+ <b-input
|
|
|
+ placeholder="输入ID查找题目"
|
|
|
+ type="search"
|
|
|
+ icon="magnify"
|
|
|
+ :value="searchContent"
|
|
|
+ v-model="$v.params.problem.$model"
|
|
|
+ expanded
|
|
|
+ >
|
|
|
+ </b-input>
|
|
|
+ <p class="control">
|
|
|
+ <button class="button is-link" @click="search(searchContent)">
|
|
|
+ 查找
|
|
|
+ </button>
|
|
|
+ </p>
|
|
|
+ </b-field>
|
|
|
+ </div>
|
|
|
+ <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="作业描述">
|
|
|
- <b-input v-model="codeAssignment.description"></b-input>
|
|
|
+ <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="开始时间">
|
|
|
- <b-datepicker
|
|
|
- v-model="codeAssignment.startAt"
|
|
|
+ <b-field
|
|
|
+ label="开始时间"
|
|
|
+ :type="$v.params.startAt.$error ? 'is-danger' : ''"
|
|
|
+ :message="$v.params.startAt.$error ? '请填写作业开始时间' : ''"
|
|
|
+ >
|
|
|
+ <flat-pickr
|
|
|
placeholder="Click to select..."
|
|
|
- icon="calendar-today"
|
|
|
- >
|
|
|
- </b-datepicker>
|
|
|
+ class="input"
|
|
|
+ v-model="$v.params.startAt.$model"
|
|
|
+ :config="startAtConfig"
|
|
|
+ ></flat-pickr>
|
|
|
</b-field>
|
|
|
- <b-field label="结束时间">
|
|
|
- <b-datepicker
|
|
|
- v-model="codeAssignment.endAt"
|
|
|
+ <b-field
|
|
|
+ label="结束时间"
|
|
|
+ :type="$v.params.endAt.$error ? 'is-danger' : ''"
|
|
|
+ :message="$v.params.endAt.$error ? '请填写作业结束时间' : ''"
|
|
|
+ >
|
|
|
+ <flat-pickr
|
|
|
placeholder="Click to select..."
|
|
|
- icon="calendar-today"
|
|
|
- >
|
|
|
- </b-datepicker>
|
|
|
+ class="input"
|
|
|
+ v-model="$v.params.endAt.$model"
|
|
|
+ :config="endAtConfig"
|
|
|
+ ></flat-pickr>
|
|
|
</b-field>
|
|
|
- <a class="button is-link" @click="createCodeAssignment">{{
|
|
|
+
|
|
|
+ <a class="button is-link" @click="createDocAssignment()">{{
|
|
|
modal.submit
|
|
|
}}</a>
|
|
|
</div>
|
|
|
@@ -113,11 +155,20 @@
|
|
|
import PageHeader from "@/components/PageHeader";
|
|
|
import PageBody from "@/components/PageBody/index";
|
|
|
import { getCodeAssignmentListByTeacher } from "@/api/assignment";
|
|
|
+import { getQuestionDetail } from "@/api/question";
|
|
|
+import { postCodeAssignment } from "@/api/assignment";
|
|
|
+import { putCodeAssignment } from "@/api/assignment";
|
|
|
+import { delCodeAssignment } from "@/api/assignment";
|
|
|
+import timeMixins from "@/mixins/time";
|
|
|
+import { required } from "vuelidate/lib/validators";
|
|
|
+import pathMixins from "@/mixins/path";
|
|
|
+
|
|
|
export default {
|
|
|
components: {
|
|
|
PageBody,
|
|
|
PageHeader
|
|
|
},
|
|
|
+ mixins: [timeMixins, pathMixins],
|
|
|
mounted() {
|
|
|
getCodeAssignmentListByTeacher(123).then(res => {
|
|
|
this.codeData = res.data;
|
|
|
@@ -125,82 +176,204 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ searchContent: null,
|
|
|
+ question: {},
|
|
|
codeData: [],
|
|
|
- codeAssignment: {
|
|
|
- id: -1,
|
|
|
- name: "",
|
|
|
- description: "",
|
|
|
- startAt: new Date(),
|
|
|
- endAt: new Date()
|
|
|
+ params: {
|
|
|
+ name: null,
|
|
|
+ description: null,
|
|
|
+ startAt: null,
|
|
|
+ endAt: null,
|
|
|
+ problem: null //选择题目编号
|
|
|
},
|
|
|
+ // 返回的代码作业信息
|
|
|
isCardModalActive: false,
|
|
|
modal: {
|
|
|
- title: "新建文档作业",
|
|
|
+ title: "新建代码作业",
|
|
|
submit: "确认创建"
|
|
|
+ },
|
|
|
+ flag: -1, //区分创建还是修改
|
|
|
+ display: true,
|
|
|
+ startAtConfig: {
|
|
|
+ ...this.getDefaultConfig(),
|
|
|
+ minDate: "today",
|
|
|
+ maxDate: null
|
|
|
+ },
|
|
|
+ endAtConfig: {
|
|
|
+ ...this.getDefaultConfig(),
|
|
|
+ minDate: "today",
|
|
|
+ maxDate: null
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
+ validations: {
|
|
|
+ params: {
|
|
|
+ name: {
|
|
|
+ required
|
|
|
+ },
|
|
|
+ description: {
|
|
|
+ required
|
|
|
+ },
|
|
|
+ startAt: {
|
|
|
+ required
|
|
|
+ },
|
|
|
+ endAt: {
|
|
|
+ required
|
|
|
+ },
|
|
|
+ problem: {
|
|
|
+ required
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ isCardModalActive(newValue) {
|
|
|
+ if (newValue === false) {
|
|
|
+ this.$v.$reset();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ /**
|
|
|
+ * 搜索题目
|
|
|
+ * @param content
|
|
|
+ * @return {Promise<void>}
|
|
|
+ */
|
|
|
+ async searchAssis(content) {
|
|
|
+ console.log(content);
|
|
|
+ await getQuestionDetail().then(res => {
|
|
|
+ this.question = res.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ search(content) {
|
|
|
+ this.searchAssis(content).then(() => {
|
|
|
+ console.log(this.question);
|
|
|
+ this.params.problem = this.question.id;
|
|
|
+ this.searchContent = this.question.name;
|
|
|
+ this.$dialog.alert({
|
|
|
+ title: "题目信息",
|
|
|
+ message: this.searchContent,
|
|
|
+ confirmText: "OK"
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 确定删除
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
confirmDelete(id) {
|
|
|
this.$dialog.confirm({
|
|
|
message: "确认删除?",
|
|
|
confirmText: "删除",
|
|
|
type: "is-danger",
|
|
|
onConfirm: () => {
|
|
|
- for (var item of this.codeData) {
|
|
|
- if (item.id === id) {
|
|
|
- this.codeData.pop(item);
|
|
|
+ delCodeAssignment(id).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.err === 0) {
|
|
|
+ //删除成功
|
|
|
+ for (let item of this.codeData) {
|
|
|
+ if (item.id === id) {
|
|
|
+ this.codeData.pop(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$toast.open("删除成功");
|
|
|
+ } else {
|
|
|
+ this.$dialog.alert({
|
|
|
+ title: "删除失败",
|
|
|
+ message: res.msg,
|
|
|
+ type: "is-danger",
|
|
|
+ hasIcon: true,
|
|
|
+ icon: "times-circle",
|
|
|
+ iconPack: "fa"
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
- this.$toast.open("删除成功");
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 准备新建或者修改
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
updateInfo(id) {
|
|
|
this.isCardModalActive = true;
|
|
|
- if (id !== -1) {
|
|
|
+ if (id === -1) {
|
|
|
+ // 准备新建
|
|
|
+ this.display = true;
|
|
|
+ this.modal.title = "新建代码作业";
|
|
|
+ this.modal.submit = "确认创建";
|
|
|
+ this.flag = -1;
|
|
|
+ } else {
|
|
|
+ this.display = false;
|
|
|
+ // 准备修改
|
|
|
+ this.modal.title = "修改代码作业";
|
|
|
this.modal.submit = "确认修改";
|
|
|
- this.modal.title = "修改文档作业";
|
|
|
for (let item of this.codeData) {
|
|
|
if (item.id === id) {
|
|
|
- this.codeAssignment.id = id;
|
|
|
- this.codeAssignment.name = item.name;
|
|
|
- this.codeAssignment.description = item.description;
|
|
|
- this.codeAssignment.startAt = new Date(item.startAt);
|
|
|
- this.codeAssignment.endAt = new Date(item.endAt);
|
|
|
+ this.params.name = item.name;
|
|
|
+ this.params.description = item.description;
|
|
|
+ // 以下两项无效
|
|
|
+ this.params.startAt = item.startAt;
|
|
|
+ this.params.endAt = item.endAt;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- this.modal.title = "新建文档作业";
|
|
|
- this.modal.submit = "确认创建";
|
|
|
- this.codeAssignment.id = -1;
|
|
|
- this.codeAssignment.name = "";
|
|
|
- this.codeAssignment.description = "";
|
|
|
- this.codeAssignment.startAt = new Date();
|
|
|
- this.codeAssignment.endAt = new Date();
|
|
|
+ this.flag = 0;
|
|
|
}
|
|
|
},
|
|
|
- createCodeAssignment() {
|
|
|
- this.isCardModalActive = false;
|
|
|
- if (this.codeAssignment.id === -1) {
|
|
|
- var itemsCount = this.codeData.length;
|
|
|
- this.codeData.push({
|
|
|
- id: itemsCount + 1,
|
|
|
- name: this.codeAssignment.name,
|
|
|
- description: this.codeAssignment.description,
|
|
|
- startAt: this.codeAssignment.startAt.getTime(),
|
|
|
- endAt: this.codeAssignment.endAt.getTime()
|
|
|
- });
|
|
|
- } else {
|
|
|
- for (var item of this.codeData) {
|
|
|
- if (item.id === this.codeAssignment.id) {
|
|
|
- item.name = this.codeAssignment.name;
|
|
|
- item.description = this.codeAssignment.description;
|
|
|
- item.startAt = this.codeAssignment.startAt.getTime();
|
|
|
- item.endAt = this.codeAssignment.endAt.getTime();
|
|
|
- break;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 确认新建或者修改
|
|
|
+ */
|
|
|
+ createDocAssignment() {
|
|
|
+ this.$v.$touch();
|
|
|
+ if (!this.$v.$invalid) {
|
|
|
+ this.isCardModalActive = false;
|
|
|
+ if (this.flag === -1) {
|
|
|
+ // 确认新建作业
|
|
|
+ this.params["type"] = "DOCUMENT";
|
|
|
+ postCodeAssignment(this.params).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.err === 0) {
|
|
|
+ //创建成功
|
|
|
+ this.codeData.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,
|
|
|
+ icon: "times-circle",
|
|
|
+ iconPack: "fa"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 确认修改作业
|
|
|
+ putCodeAssignment(this.params).then(res => {
|
|
|
+ if (res.err === 0) {
|
|
|
+ let id = res.data.id;
|
|
|
+ for (let item of this.codeData) {
|
|
|
+ if (item.id === id) {
|
|
|
+ item = res.data;
|
|
|
+ console.log("修改成功");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$dialog.alert({
|
|
|
+ title: "修改失败",
|
|
|
+ message: res.msg,
|
|
|
+ type: "is-danger",
|
|
|
+ hasIcon: true,
|
|
|
+ icon: "times-circle",
|
|
|
+ iconPack: "fa"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|