|
|
@@ -1,3 +1,250 @@
|
|
|
<template>
|
|
|
- <div></div>
|
|
|
+ <div>
|
|
|
+ <page-header :routes="[{ name: '代码作业', path: 'code' }]">
|
|
|
+ <template slot="title">
|
|
|
+ 代码作业列表
|
|
|
+ </template>
|
|
|
+ <template slot="content">
|
|
|
+ Here might be a page title
|
|
|
+ </template>
|
|
|
+ <template slot="action">
|
|
|
+ <b-field>
|
|
|
+ <a class="button is-link" @click="updateInfo(-1)">新建代码作业</a>
|
|
|
+ </b-field>
|
|
|
+ </template>
|
|
|
+ </page-header>
|
|
|
+ <page-body>
|
|
|
+ <div>
|
|
|
+ <b-table
|
|
|
+ :data="codeData"
|
|
|
+ paginated
|
|
|
+ per-page="5"
|
|
|
+ detailed
|
|
|
+ detail-key="id"
|
|
|
+ >
|
|
|
+ <template slot-scope="props">
|
|
|
+ <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 }
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ {{ props.row.name }}
|
|
|
+ </router-link>
|
|
|
+ </b-table-column>
|
|
|
+
|
|
|
+ <b-table-column label="开始时间" centered>
|
|
|
+ {{ new Date(props.row.startAt).getFullYear() }}-{{
|
|
|
+ new Date(props.row.startAt).getMonth() + 1
|
|
|
+ }}-{{ new Date(props.row.startAt).getDate() }}
|
|
|
+ </b-table-column>
|
|
|
+
|
|
|
+ <b-table-column label="结束时间" centered>
|
|
|
+ {{ new Date(props.row.endAt).getFullYear() }}-{{
|
|
|
+ new Date(props.row.endAt).getMonth() + 1
|
|
|
+ }}-{{ new Date(props.row.endAt).getDate() }}
|
|
|
+ </b-table-column>
|
|
|
+
|
|
|
+ <b-table-column label="修改" centered>
|
|
|
+ <a @click="updateInfo(props.row.id)">修改</a>
|
|
|
+ </b-table-column>
|
|
|
+ <b-table-column label="删除" centered>
|
|
|
+ <a style="color:#b34141" @click="confirmDelete(props.row.id)"
|
|
|
+ >删除</a
|
|
|
+ >
|
|
|
+ </b-table-column>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template slot="detail" slot-scope="props">
|
|
|
+ <article class="media">
|
|
|
+ <div class="media-content">
|
|
|
+ <div class="content">
|
|
|
+ <p>
|
|
|
+ <strong>作业描述:</strong>
|
|
|
+ <small>{{ props.row.description }}</small> <br />
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </article>
|
|
|
+ </template>
|
|
|
+ </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="作业名称">
|
|
|
+ <b-input v-model="codeAssignment.name"></b-input>
|
|
|
+ </b-field>
|
|
|
+ <b-field label="作业描述">
|
|
|
+ <b-input v-model="codeAssignment.description"></b-input>
|
|
|
+ </b-field>
|
|
|
+ <b-field label="开始时间">
|
|
|
+ <b-datepicker
|
|
|
+ v-model="codeAssignment.startAt"
|
|
|
+ placeholder="Click to select..."
|
|
|
+ icon="calendar-today"
|
|
|
+ >
|
|
|
+ </b-datepicker>
|
|
|
+ </b-field>
|
|
|
+ <b-field label="结束时间">
|
|
|
+ <b-datepicker
|
|
|
+ v-model="codeAssignment.endAt"
|
|
|
+ placeholder="Click to select..."
|
|
|
+ icon="calendar-today"
|
|
|
+ >
|
|
|
+ </b-datepicker>
|
|
|
+ </b-field>
|
|
|
+ <a class="button is-link" @click="createCodeAssignment">{{
|
|
|
+ modal.submit
|
|
|
+ }}</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </b-modal>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import PageHeader from "@/components/PageHeader";
|
|
|
+import PageBody from "@/components/PageBody/index";
|
|
|
+const codeData = [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ name: "购物车web项目",
|
|
|
+ description: "1111111111111这里是文档描述",
|
|
|
+ startAt: 1547107174000,
|
|
|
+ endAt: 1547971174000
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ name: "电影票web项目",
|
|
|
+ description: "222222222222这里是文档描述",
|
|
|
+ startAt: 1547107174000,
|
|
|
+ endAt: 1547971174000
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 3,
|
|
|
+ name: "SEECweb项目",
|
|
|
+ description: "3333333333333333这里是文档描述",
|
|
|
+ startAt: 1547107174000,
|
|
|
+ endAt: 1547971174000
|
|
|
+ }
|
|
|
+];
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ PageBody,
|
|
|
+ PageHeader
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ codeData,
|
|
|
+ codeAssignment: {
|
|
|
+ id: -1,
|
|
|
+ name: "",
|
|
|
+ description: "",
|
|
|
+ startAt: new Date(),
|
|
|
+ endAt: new Date()
|
|
|
+ },
|
|
|
+ isCardModalActive: false,
|
|
|
+ modal: {
|
|
|
+ title: "新建文档作业",
|
|
|
+ submit: "确认创建"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$toast.open("删除成功");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ updateInfo(id) {
|
|
|
+ this.isCardModalActive = true;
|
|
|
+ if (id !== -1) {
|
|
|
+ this.modal.submit = "确认修改";
|
|
|
+ this.modal.title = "修改文档作业";
|
|
|
+ console.log(this.modal.submit);
|
|
|
+ console.log(this.modal.submit);
|
|
|
+ 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);
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.card {
|
|
|
+ padding: 30px;
|
|
|
+ .title {
|
|
|
+ font-size: 1.25rem;
|
|
|
+ small {
|
|
|
+ color: gray;
|
|
|
+ font-size: 1rem;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .content {
|
|
|
+ a {
|
|
|
+ margin-top: 30px;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|