Browse Source

按照要求修改

Johnson 7 years ago
parent
commit
60124c8f28

+ 43 - 29
src/components/AssignmentCRUD/CreateAssignment/index.vue

@@ -58,7 +58,13 @@
             ></flat-pickr>
           </b-field>
 
-          <a class="button is-link" @click="createAssignment()"> 确认新建 </a>
+          <a
+            class="button is-link"
+            :class="{ 'is-loading': submitting }"
+            @click="createAssignment()"
+          >
+            确认新建
+          </a>
         </div>
       </div>
     </b-modal>
@@ -78,13 +84,13 @@
               v-model="$v.searchContent.$model"
               expanded
             >
-              <b-loading
-                :is-full-page="false"
-                :active.sync="isLoading"
-              ></b-loading>
             </b-input>
             <p class="control">
-              <button class="button is-link" @click="search(searchContent)">
+              <button
+                class="button is-link"
+                :class="{ 'is-loading': submitting }"
+                @click="search(searchContent)"
+              >
                 查找
               </button>
             </p>
@@ -95,8 +101,11 @@
 
     <!--题目列表展示框-->
     <b-modal :active.sync="isProblemListModalActive">
+      <b-notification type="is-danger" :active.sync="isServerError">
+        {{ errorMassage }}
+      </b-notification>
       <div class="card">
-        <div class="title">点击选择题目</div>
+        <div class="title">选择题目</div>
         <div class="content">
           <div class="question-list">
             <b-table :data="questions" detailed detail-key="id">
@@ -144,13 +153,7 @@
                 </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>
+                <div>{{ props.row.description }}</div>
               </template>
             </b-table>
           </div>
@@ -205,7 +208,6 @@ export default {
       isCreateModalActive: false,
       isSearchModalActive: false,
       isProblemListModalActive: false,
-      isLoading: false,
       startAtConfig: {
         ...this.getDefaultConfig(),
         minDate: "today",
@@ -215,31 +217,41 @@ export default {
         ...this.getDefaultConfig(),
         minDate: "today",
         maxDate: null
-      }
+      },
+      errorMassage: null,
+      isServerError: false,
+      submitting: false
     };
   },
   methods: {
     /**
-     * 准备新建或者修改
+     * 准备新建
      */
     startCreation() {
+      if (this.submitting) return;
       this.isSearchModalActive = true;
     },
     /**
      * 搜索题目
-     * @param content
-     * @return {Promise<void>}
      */
     async search(content) {
+      if (this.submitting) return;
+      this.isServerError = false;
       this.$v.searchContent.$touch();
       if (!this.$v.searchContent.$invalid) {
-        this.isLoading = true;
-        await getTeacherKeywordQuestions(content).then(res => {
-          this.questions = res.data;
-        });
-        this.isLoading = false;
-        this.isSearchModalActive = false;
-        this.isProblemListModalActive = true;
+        this.submitting = true;
+        try {
+          await getTeacherKeywordQuestions(content).then(res => {
+            this.questions = res.data;
+          });
+          this.isSearchModalActive = false;
+          this.isProblemListModalActive = true;
+        } catch (e) {
+          this.errorMassage = e.message;
+          this.isServerError = true;
+        } finally {
+          this.submitting = false;
+        }
       }
     },
     selectAndCreate(problem) {
@@ -249,11 +261,13 @@ export default {
       this.isCreateModalActive = true;
     },
     /**
-     * 确认新建或者修改
+     * 确认新建
      */
     createAssignment() {
+      if (this.submitting) return;
       this.$v.params.$touch();
       if (!this.$v.params.$invalid) {
+        this.submitting = true;
         this.isCreateModalActive = false;
         this.params["type"] = this.postParam;
         this.parseParams();
@@ -288,8 +302,7 @@ export default {
             });
           }
         });
-      } else {
-        console.log("参数太少");
+        this.submitting = false;
       }
     },
     getDifficultyType(level) {
@@ -340,6 +353,7 @@ export default {
 
 <style lang="scss" scoped>
 .card {
+  text-align: left;
   padding: 30px;
   .title {
     font-size: 1.25rem;

+ 5 - 1
src/components/AssignmentCRUD/DeleteAssignment/index.vue

@@ -17,11 +17,14 @@ export default {
   },
   data() {
     return {
-      myPromise: null
+      myPromise: null,
+      submitting: false
     };
   },
   methods: {
     confirmDelete() {
+      if (this.submitting) return;
+      this.submitting = true;
       this.$dialog.confirm({
         message: "确认删除?",
         confirmText: "删除",
@@ -47,6 +50,7 @@ export default {
           });
         }
       });
+      this.submitting = false;
     }
   }
 };

+ 6 - 1
src/components/AssignmentCRUD/UpdateAssignment/index.vue

@@ -100,7 +100,8 @@ export default {
         ...this.getDefaultConfig(),
         minDate: "today",
         maxDate: null
-      }
+      },
+      submitting: false
     };
   },
   methods: {
@@ -116,8 +117,10 @@ export default {
      * 确认修改
      */
     updateAssignment() {
+      if (this.submitting) return;
       this.$v.params.$touch();
       if (!this.$v.params.$invalid) {
+        this.submitting = true;
         this.isUpdateModalActive = false;
         this.parseParams();
         if (this.assignType === 1) {
@@ -137,6 +140,7 @@ export default {
             });
           }
         });
+        this.submitting = true;
       }
     },
     parseParams() {
@@ -172,6 +176,7 @@ export default {
 
 <style lang="scss" scoped>
 .card {
+  text-align: left;
   padding: 30px;
   .title {
     font-size: 1.25rem;

+ 4 - 0
src/router/routes.js

@@ -97,6 +97,10 @@ export default [
         path: "document/:documentId",
         component: () => import("@/views/teacher/Document/detail")
       },
+      {
+        path: "document/:documentId/content",
+        component: () => import("@/views/teacher/Document/docContent")
+      },
       {
         path: "review",
         component: () => import("@/views/teacher/Review")

+ 0 - 0
src/views/student/Code/detail.vue


+ 1 - 1
src/views/student/Document/detail.vue

@@ -3,7 +3,7 @@
     <page-header
       :routes="[
         { name: '文档作业', path: 'document' },
-        { name: `${assignmentInfo.name}`, path: 'document/123' }
+        { name: `作业 `, path: $route.path }
       ]"
     >
       <template slot="title">

+ 2 - 15
src/views/teacher/Code/detail.vue

@@ -3,7 +3,7 @@
     <page-header
       :routes="[
         { name: '代码作业', path: 'code' },
-        { name: `${assignmentInfo.name}`, path: 'code/${assignmentInfo.id}' }
+        { name: '作业详情', path: 'code/${assignmentInfo.id}' }
       ]"
     >
       <template slot="title">
@@ -16,19 +16,6 @@
 
     <page-body>
       <div class="data-table">
-        <!--下拉框&搜索框-->
-        <div class="form-group">
-          <!--搜索框-->
-          <b-field>
-            <b-input
-              placeholder="输入关键字查找小组"
-              type="search"
-              icon="magnify"
-            >
-            </b-input>
-          </b-field>
-        </div>
-        <!---->
         <b-tabs type="is-boxed">
           <b-tab-item label="已提交">
             <b-table :data="codeProcedureList" detailed detail-key="id">
@@ -107,7 +94,7 @@
           </b-tab-item>
 
           <b-tab-item :label="submitInfo.no">
-            <b-table :data="unsubmitedGroups" paginated per-page="5">
+            <b-table :data="unsubmitedGroups">
               <template slot-scope="props">
                 <b-table-column
                   field="id"

+ 1 - 2
src/views/teacher/Code/index.vue

@@ -29,8 +29,7 @@
                 :to="{
                   path: `code/${props.row.id}`,
                   query: {
-                    assignmentInfo: props.row.problem,
-                    title: props.row.name
+                    assignmentInfo: props.row.problem
                   }
                 }"
               >

+ 4 - 69
src/views/teacher/Code/test.vue

@@ -3,8 +3,8 @@
     <page-header
       :routes="[
         { name: '代码作业', path: 'code' },
-        { name: '购物车web项目', path: `code/${assignmentInfo.id}` },
-        { name: '测试信息', path: 'code/detail/test' }
+        { name: '作业详情', path: `code/${assignmentInfo.id}` },
+        { name: '测试信息', path: `${$route.path}` }
       ]"
     >
       <template slot="title">
@@ -16,30 +16,7 @@
     </page-header>
 
     <page-body>
-      <div class="data-table">
-        <b-collapse
-          :open="false"
-          class="collapseeeeeee"
-          v-for="item in testResult"
-          :key="item.id"
-        >
-          <button class="button is-primary " slot="trigger">
-            测试时间:2019-1-18 23:02{{ item.id }}
-          </button>
-          <div class="notification card">
-            <div class="content">
-              <h3>Build Info</h3>
-              <p>{{ item.buildResult }}</p>
-              <h3>Deploy Info</h3>
-              <p>{{ item.deployResult }}</p>
-              <h3>Unit Test Info</h3>
-              <p>{{ item.unitTestResult }}</p>
-              <h3>Functional Test Info</h3>
-              <p>{{ item.functionTestResult }}</p>
-            </div>
-          </div>
-        </b-collapse>
-      </div>
+      <div class="data-table">和学生代码作业的测试信息的显示格式和接口相同</div>
     </page-body>
   </div>
 </template>
@@ -48,45 +25,6 @@
 import PageHeader from "@/components/PageHeader";
 import PageBody from "@/components/PageBody/index";
 
-const testResult = [
-  {
-    id: "1547130528000",
-    buildResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    deployResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    unitTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    functionTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS"
-  },
-  {
-    id: "1547130722000",
-    buildResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    deployResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    unitTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    functionTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS"
-  },
-  {
-    id: "1547123230722000",
-    buildResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    deployResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    unitTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    functionTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS"
-  },
-  {
-    id: "154712320722000",
-    buildResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    deployResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    unitTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    functionTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS"
-  },
-  {
-    id: "1547130434722000",
-    buildResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    deployResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    unitTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS",
-    functionTestResult: "SUCCESSSUCCESSSUCCESSSUCCESSSUCCESSSUCCESS"
-  }
-];
-const showResult = [];
-
 export default {
   components: {
     PageBody,
@@ -94,13 +32,10 @@ export default {
   },
   mounted() {
     this.assignmentInfo = this.$route.query.assignmentInfo;
-    console.log(this.assignmentInfo);
   },
   data() {
     return {
-      assignmentInfo: {},
-      showResult,
-      testResult
+      assignmentInfo: {}
     };
   }
 };

+ 27 - 34
src/views/teacher/Document/detail.vue

@@ -1,38 +1,25 @@
 <template>
   <div>
     <page-header
+      :loading="isLoading"
       :routes="[
         { name: '文档作业', path: 'document' },
-        { name: `${title}`, path: 'document/:documentId' }
+        { name: `作业详情`, path: `document` }
       ]"
     >
       <template slot="title">
-        {{ assignmentInfo.problem ? assignmentInfo.problem.name : "" }}
+        {{ question.name }}
       </template>
       <template slot="content">
-        题目描述:{{
-          assignmentInfo.problem ? assignmentInfo.problem.description : ""
-        }}
-        <br />
+        题目描述:{{ question.description }}
+      </template>
+      <template slot="extraContent">
         题目进行阶段:{{ status }}
       </template>
     </page-header>
 
     <page-body>
       <div class="data-table">
-        <!--下拉框&搜索框-->
-        <div class="form-group">
-          <!--搜索框-->
-          <b-field>
-            <b-input
-              placeholder="输入关键字查找小组"
-              type="search"
-              icon="magnify"
-            >
-            </b-input>
-          </b-field>
-        </div>
-
         <b-tabs>
           <b-tab-item :label="submitInfo.yes">
             <b-table :data="submittedData" detailed detail-key="id">
@@ -61,7 +48,13 @@
                   {{ props.row.result }}
                 </b-table-column>
                 <b-table-column field="difficulty" label="详情" centered
-                  ><a :href="props.row.url" target="_blank">查看详情</a>
+                  ><router-link
+                    :to="{
+                      path: `${$route.path}/content`,
+                      query: { assignId: docId }
+                    }"
+                    >查看详情</router-link
+                  >
                 </b-table-column>
               </template>
 
@@ -89,7 +82,7 @@
           </b-tab-item>
 
           <b-tab-item :label="submitInfo.no">
-            <b-table :data="unsubmitedGroups" paginated per-page="5">
+            <b-table :data="unsubmitedGroups">
               <template slot-scope="props">
                 <b-table-column
                   field="id"
@@ -125,12 +118,6 @@ import { getSubmittedDocResultListByDocId } from "@/api/assignment";
 import { getUnsubmittedDocGroupsByDocId } from "@/api/assignment";
 import { mapState } from "vuex";
 
-const assignmentInfo = {
-  id: 0,
-  name: "",
-  description: ""
-};
-
 export default {
   computed: {
     ...mapState({
@@ -141,30 +128,36 @@ export default {
     PageBody,
     PageHeader
   },
+  created() {
+    this.docId = this.$route.query.docId;
+    this.question = this.$route.query.question;
+  },
   mounted() {
-    this.assignmentInfo = this.$route.query.assignmentInfo;
-    this.title = this.$route.query.title;
-    getSubmittedDocResultListByDocId(this.assignmentInfo.id).then(res => {
+    this.isLoading = true;
+    getSubmittedDocResultListByDocId(this.docId).then(res => {
       this.status = res.data.status;
       this.submittedData = res.data.result;
       this.submitInfo.yes = "已提交:" + this.submittedData.length;
+      this.isLoading = false;
     });
-    getUnsubmittedDocGroupsByDocId(this.assignmentInfo.id).then(res => {
+    getUnsubmittedDocGroupsByDocId(this.docId).then(res => {
       this.unsubmitedGroups = res.data;
       this.submitInfo.no = "未提交:" + this.unsubmitedGroups.length;
+      this.isLoading = false;
     });
   },
   data() {
     return {
-      title: "",
       submittedData: [],
       unsubmitedGroups: [],
       status: "",
-      assignmentInfo,
+      question: null,
+      docId: null,
       submitInfo: {
         yes: "",
         no: ""
-      }
+      },
+      isLoading: false
     };
   }
 };

+ 39 - 0
src/views/teacher/Document/docContent.vue

@@ -0,0 +1,39 @@
+<template>
+  <div>
+    <page-header
+      :routes="[
+        { name: '文档作业', path: 'document' },
+        {
+          name: `作业详情`,
+          path: `document/${docId}`
+        },
+        { name: `文档内容`, path: `${$route.path}` }
+      ]"
+    >
+      <template slot="title">
+        文档内容
+      </template>
+    </page-header>
+    <page-body> <div class="data-table">文档内容</div> </page-body>
+  </div>
+</template>
+
+<script>
+import PageHeader from "@/components/PageHeader";
+import PageBody from "@/components/PageBody/index";
+export default {
+  components: {
+    PageBody,
+    PageHeader
+  },
+  data() {
+    return {
+      docId: null
+    };
+  },
+  created() {
+    this.docId = this.$route.query.assignId;
+  },
+  mounted() {}
+};
+</script>

+ 0 - 9
src/views/teacher/Document/docList.vue

@@ -1,9 +0,0 @@
-<template>
-  <div>显示该组的文档</div>
-</template>
-
-<script>
-export default {
-  name: "docList"
-};
-</script>

+ 2 - 5
src/views/teacher/Document/index.vue

@@ -27,11 +27,8 @@
             <b-table-column label="作业名称" centered>
               <router-link
                 :to="{
-                  path: `document/${props.row.id}`,
-                  query: {
-                    assignmentInfo: props.row,
-                    title: props.row.name
-                  }
+                  path: `${$route.path}/${props.row.id}`,
+                  query: { docId: props.row.id, question: props.row.problem }
                 }"
               >
                 {{ props.row.name }}