dusenyao 3 yıl önce
ebeveyn
işleme
dbd621e6e0

+ 30 - 0
src/api/course.js

@@ -421,3 +421,33 @@ export function RemarkTaskStudentExecuteInfo_Teacher(data) {
     data
   });
 }
+
+/**
+ * 删除任务
+ * @param {Object} data
+ */
+export function DeleteTask(data) {
+  let params = getRequestParams('teaching-task_manager-DeleteTask');
+
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params,
+    data
+  });
+}
+
+/**
+ * 删除课程
+ * @param {Object} data
+ */
+export function DeleteCourse(data) {
+  let params = getRequestParams('teaching-course_manager-DeleteCourse');
+
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params,
+    data
+  });
+}

+ 1 - 1
src/components/select/SelectCourse.vue

@@ -31,7 +31,7 @@
       </div>
     </div>
 
-    <div slot="footer" class="dialog-footer">
+    <div slot="footer">
       <el-button size="mini" @click="dialogClose">取 消</el-button>
       <el-button type="primary" size="mini" @click="confirm">确 定</el-button>
     </div>

+ 1 - 1
src/components/select/SelectTeacher.vue

@@ -48,7 +48,7 @@
       @size-change="changePageSize"
     />
 
-    <div slot="footer" class="dialog-footer">
+    <div slot="footer">
       <el-button size="mini" @click="dialogClose">取 消</el-button>
       <el-button type="primary" size="mini" @click="confirmTeacher">确 定</el-button>
     </div>

+ 133 - 0
src/components/select/SelectTemplate.vue

@@ -0,0 +1,133 @@
+<template>
+  <el-dialog
+    :visible="dialogVisible"
+    width="900px"
+    title="选择模板"
+    :close-on-click-modal="false"
+    @close="dialogClose"
+  >
+    <!-- 查询条件 -->
+    <div class="query-criteria">
+      <el-form :inline="true" :model="searchForm" size="mini">
+        <el-form-item label="模板名称">
+          <el-input v-model.trim="searchForm.name" @keyup.enter.native="queryCourseList" />
+        </el-form-item>
+
+        <el-form-item class="search-button">
+          <el-button type="primary" @click="queryCourseList">
+            <i class="el-icon-search" /> 搜索
+          </el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+
+    <el-table
+      ref="templateTable"
+      :data="courseList"
+      height="40vh"
+      highlight-current-row
+      @current-change="handleCurrentChange"
+    >
+      <el-table-column prop="name" label="用户名" width="320" />
+      <el-table-column label="课程周期">
+        <template slot-scope="{ row }">
+          <i class="el-icon-date" /> {{ row.begin_date }} - {{ row.end_date }}
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <el-pagination
+      background
+      :page-sizes="[10, 20, 30, 40, 50]"
+      :page-size="page_capacity"
+      layout="prev, pager, next, total, sizes, jumper"
+      :total="total_count"
+      :current-page="cur_page"
+      @prev-click="changePage"
+      @next-click="changePage"
+      @current-change="changePage"
+      @size-change="changePageSize"
+    />
+
+    <div slot="footer">
+      <el-button size="mini" @click="dialogClose">取 消</el-button>
+      <el-button type="primary" size="mini" @click="confirmTemplate">确 定</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { PageQueryCourseList } from '@/api/table';
+
+export default {
+  props: {
+    dialogVisible: {
+      default: false,
+      type: Boolean
+    }
+  },
+  data() {
+    return {
+      cur_page: 1,
+      total_count: 0,
+      page_capacity: 10,
+      searchForm: {
+        name: ''
+      },
+      courseList: [],
+      currentRow: null
+    };
+  },
+  created() {
+    this.queryCourseList();
+  },
+  methods: {
+    queryCourseList() {
+      const queryCriteria = {
+        is_template: true,
+        name: this.searchForm.name,
+        page_capacity: this.page_capacity,
+        cur_page: this.cur_page,
+        release_status: 1
+      };
+      PageQueryCourseList(queryCriteria).then(({ course_list, total_count }) => {
+        this.courseList = course_list;
+        this.total_count = total_count;
+      });
+    },
+    changePage(newPage) {
+      this.cur_page = newPage;
+      this.queryCourseList();
+    },
+    changePageSize(pageSize) {
+      this.page_capacity = pageSize;
+      this.queryCourseList();
+    },
+    handleCurrentChange(val) {
+      this.currentRow = val;
+    },
+    dialogClose() {
+      this.$emit('dialogClose');
+      this.$refs.templateTable.clearSelection();
+    },
+    confirmTemplate() {
+      if (!this.currentRow) {
+        return this.$message.warning('请选择模板');
+      }
+      this.$emit('confirmTemplate', this.currentRow.id);
+    }
+  }
+};
+</script>
+
+<style lang="scss">
+@import '~@/styles/mixin.scss';
+
+@include dialog;
+@include pagination;
+
+.query-criteria .el-form {
+  display: flex;
+  justify-content: space-between;
+}
+</style>

+ 4 - 5
src/views/live/teacher/index.vue

@@ -190,7 +190,8 @@
       <el-select v-model="group_count">
         <el-option v-for="i in groupNumList" :key="i" :label="i" :value="i" />
       </el-select>
-      <span slot="footer" class="dialog-footer">
+
+      <span slot="footer">
         <el-button size="small" @click="closeGroup">取 消</el-button>
         <el-button size="small" type="primary" @click="dialogGroup">确 定</el-button>
       </span>
@@ -594,9 +595,7 @@ export default {
 
     // 分组讨论
     startGroup() {
-      let num = Math.ceil(this.student_list.length / 2);
-      num = num < 2 ? 2 : num;
-      for (let i = 1; i <= num; i++) {
+      for (let i = 1; i <= this.student_list.length; i++) {
         this.groupNumList.push(i);
       }
       this.dialogVisibleGroup = true;
@@ -619,7 +618,7 @@ export default {
     closeGroup() {
       this.dialogVisibleGroup = false;
       this.groupNumList = [];
-      this.group_count = 2;
+      this.group_count = 1;
     },
 
     dialogClose() {

+ 15 - 3
src/views/main/TemplateList.vue

@@ -28,7 +28,10 @@
     <div class="template-container">
       <div class="template-container-title">
         <span>模板库</span>
-        <el-button class="create" @click="$router.push('/create_course?isTemplate=true')">
+        <el-button
+          class="create"
+          @click="$router.push('/create_course_step_table/course_info?is_template=true')"
+        >
           <div><svg-icon icon-class="create" /><span>创建模板</span></div>
         </el-button>
       </div>
@@ -64,6 +67,9 @@
                   <el-dropdown-item v-else @click.native="releaseCourse(row.id, false)">
                     <svg-icon icon-class="undo" /> 取消发布
                   </el-dropdown-item>
+                  <el-dropdown-item @click.native="deleteCourse(row.id)">
+                    <svg-icon icon-class="delete" /> 删除
+                  </el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
             </template>
@@ -88,7 +94,7 @@
 
 <script>
 import { PageQueryCourseList } from '@/api/table';
-import { ReleaseCourse } from '@/api/course';
+import { ReleaseCourse, DeleteCourse } from '@/api/course';
 
 export default {
   data() {
@@ -143,13 +149,19 @@ export default {
       });
     },
     edit(id) {
-      this.$router.push(`/create_course_step_table/course_info?id=${id}&isTemplate=true`);
+      this.$router.push(`/create_course_step_table/course_info?id=${id}&is_template=true`);
     },
     releaseCourse(course_id, is_release) {
       ReleaseCourse({ course_id, is_release }).then(() => {
         this.queryCourseList();
         this.$message.success(`${is_release ? '' : '取消'}发布课程成功`);
       });
+    },
+    deleteCourse(id) {
+      DeleteCourse({ id }).then(() => {
+        this.queryCourseList();
+        this.$message.success('删除课程成功');
+      });
     }
   }
 };

+ 16 - 1
src/views/main/curricula_list/teacher.vue

@@ -67,6 +67,9 @@
                   <el-dropdown-item v-else @click.native="releaseCourse(row.id, false)">
                     <svg-icon icon-class="undo" /> 取消发布
                   </el-dropdown-item>
+                  <el-dropdown-item @click.native="deleteCourse(row.id)">
+                    <svg-icon icon-class="delete" /> 删除
+                  </el-dropdown-item>
                   <el-dropdown-item @click.native="studentList(row.id)">
                     <svg-icon icon-class="students" /> 学生列表
                   </el-dropdown-item>
@@ -96,7 +99,7 @@
 import { updateWordPack } from '@/utils/i18n';
 import { PageQueryMyCourseList } from '@/api/table';
 import { GetFinishStatusList_Course } from '@/api/select';
-import { ReleaseCourse } from '@/api/course';
+import { ReleaseCourse, DeleteCourse } from '@/api/course';
 
 export default {
   data() {
@@ -173,6 +176,18 @@ export default {
         this.queryMyCourseList();
         this.$message.success(`${is_release ? '' : '取消'}发布课程成功`);
       });
+    },
+    deleteCourse(id) {
+      this.$confirm('您确定要删除该课程吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        DeleteCourse({ id }).then(() => {
+          this.$message.success('删除课程成功');
+          this.queryMyCourseList();
+        });
+      });
     }
   }
 };

+ 29 - 2
src/views/teacher/create_course/index.vue

@@ -3,7 +3,7 @@
     <div class="create-course-title">创建课程</div>
     <div class="create-course-container">
       <div class="create template">
-        <div class="click">
+        <div class="click" @click="selectTemplate">
           <div class="plus"></div>
         </div>
         <div class="name">模板库</div>
@@ -15,12 +15,39 @@
         <div class="name">新建</div>
       </div>
     </div>
+
+    <!-- 选择模板 -->
+    <select-template
+      :dialog-visible="dialogVisible"
+      @dialogClose="dialogClose"
+      @confirmTemplate="confirmTemplate"
+    />
   </div>
 </template>
 
 <script>
+import SelectTemplate from '@/components/select/SelectTemplate.vue';
 export default {
-  name: 'CreateCourse'
+  components: { SelectTemplate },
+  data() {
+    return {
+      dialogVisible: false
+    };
+  },
+  methods: {
+    selectTemplate() {
+      this.dialogVisible = true;
+    },
+    dialogClose() {
+      this.dialogVisible = false;
+    },
+    confirmTemplate(id) {
+      this.dialogVisible = false;
+      this.$router.push(
+        `/create_course_step_table/course_info?is_use_template=true&template_id=${id}`
+      );
+    }
+  }
 };
 </script>
 

+ 53 - 30
src/views/teacher/create_course/step_table/CourseInfo.vue

@@ -50,7 +50,8 @@
           </el-select>
         </el-form-item>
 
-        <el-form-item label="授课教师" class="teacher-tag">
+        <el-form-item v-if="!is_template" label="授课教师" class="teacher-tag">
+          <el-button class="teacher" icon="el-icon-plus" circle @click="selectTeacher" />
           <el-tag
             v-for="(item, i) in user_list"
             :key="item.id"
@@ -60,7 +61,6 @@
           >
             {{ item.real_name }}
           </el-tag>
-          <el-button class="teacher" icon="el-icon-plus" circle @click="selectTeacher" />
         </el-form-item>
 
         <el-form-item label="课程周期">
@@ -104,6 +104,8 @@
         </el-form-item>
       </el-form>
     </div>
+
+    <!-- 选择教师 -->
     <select-teacher
       :dialog-visible="dialogVisible"
       :org-id="form.org_id"
@@ -126,8 +128,13 @@ export default {
   name: 'CourseInfo',
   components: { StepBar, SelectTeacher },
   data() {
+    let query = this.$route.query;
+
     return {
-      id: this.$route.query.id,
+      id: query.id,
+      is_template: 'is_template' in query ? query.is_template : false,
+      is_use_template: 'is_use_template' in query ? query.is_use_template : false,
+      template_id: 'template_id' in query ? query.template_id : '',
       form: {
         imageUrl: '',
         picture_id: '',
@@ -157,7 +164,43 @@ export default {
       this.orgList = org_list;
     });
     if (this.id) {
-      GetCourseInfo_ContainCSItem({ id: this.id }).then(
+      this.getCourseInfo_ContainCSItem(this.id);
+    }
+    if (this.is_use_template) {
+      this.getCourseInfo_ContainCSItem(this.template_id);
+    }
+  },
+  methods: {
+    nextStep() {
+      this.$refs.form.validate(valid => {
+        if (valid) {
+          if (this.id) {
+            this.form.id = this.id;
+            UpdateCourse(this.form).then(() => {
+              this.$message.success('修改课程成功!');
+              this.$router.push({
+                path: `/create_course_step_table/select_book/${this.id}?is_template=${this.is_template}`
+              });
+            });
+          } else {
+            this.form.is_template = this.is_template;
+            this.form.is_use_template = this.is_use_template;
+            this.form.template_id = this.template_id;
+
+            CreateCourse(this.form).then(res => {
+              this.$message.success('创建课程成功!');
+              this.$router.push({
+                path: `/create_course_step_table/select_book/${res.id}?is_template=${this.is_template}`
+              });
+            });
+          }
+        } else {
+          return false;
+        }
+      });
+    },
+    getCourseInfo_ContainCSItem(id) {
+      GetCourseInfo_ContainCSItem({ id }).then(
         ({
           name,
           org_id,
@@ -187,34 +230,14 @@ export default {
           this.form.price = price;
           this.form.is_enable_KHPJ = is_enable_KHPJ === 'true';
           this.form.is_enable_XYZP = is_enable_XYZP === 'true';
-          teacher_list.forEach(item => {
-            this.form.teacher_id_list.push(item.teacher_id);
-            this.user_list.push({ id: item.teacher_id, real_name: item.teacher_name });
-          });
-        }
-      );
-    }
-  },
-  methods: {
-    nextStep() {
-      this.$refs.form.validate(valid => {
-        if (valid) {
-          if (this.id) {
-            this.form.id = this.id;
-            UpdateCourse(this.form).then(() => {
-              this.$message.success('修改课程成功!');
-              this.$router.push({ path: `/create_course_step_table/select_book/${this.id}` });
-            });
-          } else {
-            CreateCourse(this.form).then(res => {
-              this.$message.success('创建课程成功!');
-              this.$router.push({ path: `/create_course_step_table/select_book/${res.id}` });
+          if (!this.is_template) {
+            teacher_list.forEach(item => {
+              this.form.teacher_id_list.push(item.teacher_id);
+              this.user_list.push({ id: item.teacher_id, real_name: item.teacher_name });
             });
           }
-        } else {
-          return false;
         }
-      });
+      );
     },
     beforeUpload(file) {
       let isImage = /^image/.test(file.type);
@@ -296,7 +319,7 @@ export default {
       }
 
       .teacher-tag .el-tag {
-        margin-right: 16px;
+        margin-left: 16px;
       }
 
       .teacher {

+ 36 - 5
src/views/teacher/create_course/step_table/CreateTask.vue

@@ -12,7 +12,7 @@
     <!-- 按钮 -->
     <div class="task-button">
       <el-button class="prev-step" @click="preStep"><i class="el-icon-back" />选择教材</el-button>
-      <el-button><router-link to="/create_course">关闭</router-link></el-button>
+      <el-button @click="$router.push(closeLink)">关闭</el-button>
     </div>
     <!-- 任务课节 -->
     <div class="task-item">
@@ -95,6 +95,12 @@
                               >
                                 <span>编辑</span><svg-icon icon-class="edit" />
                               </el-dropdown-item>
+                              <el-dropdown-item
+                                class="dropdown-menu"
+                                :command="{ id: item.id, type: 'delete', time_type: 0 }"
+                              >
+                                <span>删除</span><svg-icon icon-class="delete" />
+                              </el-dropdown-item>
                             </el-dropdown-menu>
                           </el-dropdown>
                         </div>
@@ -161,6 +167,12 @@
                               >
                                 <span>编辑</span><svg-icon icon-class="edit" />
                               </el-dropdown-item>
+                              <el-dropdown-item
+                                class="dropdown-menu"
+                                :command="{ id: item.id, type: 'delete', time_type: 1 }"
+                              >
+                                <span>删除</span><svg-icon icon-class="delete" />
+                              </el-dropdown-item>
                             </el-dropdown-menu>
                           </el-dropdown>
                         </div>
@@ -232,6 +244,12 @@
                               >
                                 <span>编辑</span><svg-icon icon-class="edit" />
                               </el-dropdown-item>
+                              <el-dropdown-item
+                                class="dropdown-menu"
+                                :command="{ id: item.id, type: 'delete', time_type: 2 }"
+                              >
+                                <span>删除</span><svg-icon icon-class="delete" />
+                              </el-dropdown-item>
                             </el-dropdown-menu>
                           </el-dropdown>
                         </div>
@@ -323,7 +341,8 @@ import {
   GetCSItemInfoBox,
   DeleteCSItem,
   AddLearningMaterialToCSItem,
-  DeleteLearningMaterialFromCSItem
+  DeleteLearningMaterialFromCSItem,
+  DeleteTask
 } from '@/api/course';
 
 export default {
@@ -333,9 +352,13 @@ export default {
     AddItem
   },
   data() {
+    let is_template = 'is_template' in this.$route.query ? this.$route.query.is_template : false;
+
     return {
       id: this.$route.params.id,
+      is_template,
       name: '',
+      closeLink: JSON.parse(is_template) ? '/main?tab=TemplateList' : '/create_course',
       picture_url: '',
       begin_date: '',
       end_date: '',
@@ -355,7 +378,7 @@ export default {
     };
   },
   computed: {
-    taskLength: function () {
+    taskLength() {
       return (
         this.itemInfoBox.pre_task_list.length +
         this.itemInfoBox.mid_task_list.length +
@@ -364,7 +387,7 @@ export default {
     }
   },
   watch: {
-    curItemID: function () {
+    curItemID() {
       this.getCSItemInfoBox();
     }
   },
@@ -388,7 +411,9 @@ export default {
     },
 
     preStep() {
-      this.$router.push({ path: `/create_course_step_table/select_book/${this.id}` });
+      this.$router.push({
+        path: `/create_course_step_table/select_book/${this.id}?is_template=${this.is_template}`
+      });
     },
 
     // 课节处理
@@ -495,6 +520,12 @@ export default {
           }
         });
       }
+      if (type === 'delete') {
+        DeleteTask({ id }).then(() => {
+          this.$message.success('删除任务成功');
+          this.getCSItemInfoBox();
+        });
+      }
     }
   }
 };

+ 7 - 2
src/views/teacher/create_course/step_table/SelectBook.vue

@@ -69,6 +69,7 @@ export default {
   data() {
     return {
       id: this.$route.params.id,
+      is_template: 'is_template' in this.$route.query ? this.$route.query.is_template : false,
       search: '',
       page_capacity: 14,
       cur_page: 1,
@@ -119,10 +120,14 @@ export default {
       }
     },
     prevCourseInfo() {
-      this.$router.push(`/create_course_step_table/course_info?id=${this.id}`);
+      this.$router.push(
+        `/create_course_step_table/course_info?id=${this.id}&is_template=${this.is_template}`
+      );
     },
     nextStep() {
-      this.$router.push({ path: `/create_course_step_table/create_task/${this.id}` });
+      this.$router.push({
+        path: `/create_course_step_table/create_task/${this.id}?is_template=${this.is_template}`
+      });
     }
   }
 };