Bladeren bron

添加了 创建课节页面

dusenyao 4 jaren geleden
bovenliggende
commit
6253feedd5

+ 1 - 1
src/api/app.js

@@ -56,7 +56,7 @@ export function fileUpload(SecurityLevel, file) {
 
   return request({
     method: 'post',
-    url: 'GCLSFileServer/WebFileUpload',
+    url: '/GCLSFileServer/WebFileUpload',
     params,
     headers: {
       'Content-Type': 'multipart/form-data'

+ 40 - 1
src/api/course.js

@@ -35,7 +35,7 @@ export function GetCourseInfo_ContainCSItem(Parameter) {
   );
   return request({
     method: 'post',
-    url: process.env.VUE_APP_FileServer,
+    url: process.env.VUE_APP_LearnWebSI,
     params
   });
 }
@@ -65,3 +65,42 @@ export function RemoveBookFromCourse(Parameter) {
     params
   });
 }
+
+/**
+ * @description 添加课节到课程
+ * @param {Object} Parameter course_id 课程ID begin_time 开始时间 end_time 截止时间 name 课节名称
+ */
+export function AddCSItemToCourse(Parameter) {
+  let params = getRequestParameter('teaching-cs_item_manager-AddCSItemToCourse', Parameter);
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params
+  });
+}
+
+/**
+ * @description 得到课节详情(信息集合)
+ * @param {Object} Parameter id 课次id
+ */
+export function GetCSItemInfoBox(Parameter) {
+  let params = getRequestParameter('teaching-cs_item_manager-GetCSItemInfoBox', Parameter);
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params
+  });
+}
+
+/**
+ * @description 删除课节
+ * @param {Object} Parameter id 课次ID
+ */
+export function DeleteCSItem(Parameter) {
+  let params = getRequestParameter('teaching-cs_item_manager-DeleteCSItem', Parameter);
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params
+  });
+}

+ 14 - 2
src/components/StepBar.vue

@@ -3,9 +3,12 @@
     <div class="step-container">
       <div v-for="(item, i) in stepList" :key="i">
         <div :class="['step-container-wrapper', { active: i === stepNumber }]">
-          <span class="step-number">{{ i + 1 }}</span>
+          <span
+            :class="['step-number', { completed: i < stepNumber }]"
+            v-text="i < stepNumber ? '√' : i + 1"
+          ></span>
           <span class="step-name">{{ stepName(i) }}</span>
-          <span v-if="i < 2" class="step-line" />
+          <span v-if="i < 2" :class="['step-line', { completed: i < stepNumber }]" />
         </div>
         <div :class="['step-container-name', { active: i === stepNumber }]">{{ item.name }}</div>
       </div>
@@ -80,6 +83,11 @@ export default {
         border: 1px solid #808080;
         padding: 9px 14px;
         border-radius: 50%;
+
+        &.completed {
+          border-color: $basicColor;
+          color: $basicColor;
+        }
       }
 
       & .step-name {
@@ -93,6 +101,10 @@ export default {
         width: 240px;
         height: 1px;
         background-color: #d9d9d9;
+
+        &.completed {
+          background-color: $basicColor;
+        }
       }
 
       &.active {

+ 6 - 0
src/icons/svg/create-white.svg

@@ -0,0 +1,6 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M9.5 5V3.5C9.5 2.94771 9.9477 2.5 10.5 2.5H20.5C21.0523 2.5 21.5 2.94771 21.5 3.5V14.5C21.5 15.0523 21.0523 15.5 20.5 15.5H18.5" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M13.5 9H3.5C2.94772 9 2.5 9.44772 2.5 10V20C2.5 20.5523 2.94772 21 3.5 21H13.5C14.0523 21 14.5 20.5523 14.5 20V10C14.5 9.44772 14.0523 9 13.5 9Z" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M8.5 12.5V17.5" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M6 15H11" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

+ 7 - 0
src/icons/svg/delete.svg

@@ -0,0 +1,7 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M16 0H0V16H16V0Z" fill="white" fill-opacity="0.01"/>
+<path d="M5 4.00033L5.4 1.66699H10.6L11 4.00033" stroke="#2C2C2C" stroke-linejoin="round"/>
+<path d="M2 4H14" stroke="#2C2C2C" stroke-linecap="round"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12.3327 4L11.666 14.3333H4.33268L3.66602 4H12.3327Z" stroke="#2C2C2C" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M6.33398 11.667H9.66732" stroke="#2C2C2C" stroke-linecap="round"/>
+</svg>

+ 8 - 0
src/icons/svg/preserve.svg

@@ -0,0 +1,8 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M24 0H0V24H24V0Z" fill="white" fill-opacity="0.01"/>
+<path d="M3 4.5C3 3.67158 3.67158 3 4.5 3H17.1407L21 6.60325V19.5C21 20.3285 20.3285 21 19.5 21H4.5C3.67158 21 3 20.3285 3 19.5V4.5Z" stroke="white" stroke-width="1.5" stroke-linejoin="round"/>
+<path d="M12.0042 3L12 6.6923C12 6.86225 11.7761 7 11.5 7H7.5C7.22385 7 7 6.86225 7 6.6923V3H12.0042Z" stroke="white" stroke-width="1.5" stroke-linejoin="round"/>
+<path d="M4.5 3H17.1407" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M7 13H17" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M7 17H12.0042" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>

+ 11 - 0
src/icons/svg/upload.svg

@@ -0,0 +1,11 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M24 0H0V24H24V0Z" fill="white" fill-opacity="0.01"/>
+<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
+<path d="M24 0H0V24H24V0Z" fill="#333333"/>
+</mask>
+<g mask="url(#mask0)">
+<path d="M3 12.0042V21H21V12" stroke="#333333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M16.5 7.5L12 3L7.5 7.5" stroke="#333333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M11.9961 16V3" stroke="#333333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
+</g>
+</svg>

+ 4 - 0
src/router/index.js

@@ -76,6 +76,10 @@ const routes = [
         path: '/create_course_step_table/select_book/:id',
         name: 'SelectBook',
         component: () => import('@/views/teacher/create_course/step_table/SelectBook')
+      },
+      {
+        path: '/create_course_step_table/create_task/:id',
+        component: () => import('@/views/teacher/create_course/step_table/CreateTask')
       }
     ]
   },

+ 3 - 3
src/views/login/index.vue

@@ -5,7 +5,7 @@
       :model="loginForm"
       :rules="loginRules"
       class="login-form"
-      auto-complete="on"
+      autocomplete="on"
       label-position="left"
     >
       <div class="title-container">
@@ -18,7 +18,7 @@
           v-model="loginForm.user_name"
           type="text"
           name="user_name"
-          auto-complete="on"
+          autocomplete="on"
           :placeholder="$t('username')"
         />
       </el-form-item>
@@ -30,7 +30,7 @@
           type="password"
           name="password"
           :placeholder="$t('password')"
-          auto-complete="on"
+          autocomplete="on"
           @keyup.enter.native="handleLogin"
         />
       </el-form-item>

+ 326 - 4
src/views/teacher/create_course/step_table/CreateTask.vue

@@ -1,12 +1,117 @@
 <template>
   <div class="task">
     <step-bar :step-number="2" />
+    <div class="task-course-info">
+      <div class="cover"><img :src="picture_url" alt="封面" /></div>
+      <div class="info">
+        <div class="name">{{ name }}</div>
+        <div class="date">{{ begin_date }}<span>-</span>{{ end_date }}</div>
+      </div>
+    </div>
+    <div class="task-button">
+      <el-button class="prev-step" @click="preStep"><i class="el-icon-back" />选择教材</el-button>
+      <el-button class="preserve" type="primary"><svg-icon icon-class="preserve" />保存</el-button>
+      <el-button>关闭</el-button>
+    </div>
+    <div class="task-item">
+      <div class="task-item-list">
+        <template v-if="cs_item_list.length > 0">
+          <div
+            v-for="item in cs_item_list"
+            :key="item.id"
+            :class="['task-item-list-title', { selected: item.id === curItemID }]"
+            @click="curItemID = item.id"
+          >
+            <span>{{ item.name }}</span>
+            <el-dropdown placement="bottom" trigger="click" @command="deleteCSItem">
+              <i class="el-icon-more"></i>
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item class="delete-menu" :command="item.id">
+                  <span>删除</span><svg-icon icon-class="delete" />
+                </el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </div>
+        </template>
+        <div v-else class="task-item-list-title">新课节</div>
+        <el-button class="create-item selected" type="primary" @click="dialogVisible = true">
+          <svg-icon icon-class="create-white" /> 创建新课节
+        </el-button>
+      </div>
+      <div class="task-item-container">
+        <div class="item-info">
+          <div class="title">课节信息</div>
+          <div class="item-info-name">
+            <div>课节名称</div>
+            <el-input />
+          </div>
+          <div class="item-info-date">
+            <div>时间</div>
+            <el-date-picker
+              type="daterange"
+              range-separator="~"
+              value-format="yyyy-MM-dd"
+              unlink-panels
+            />
+          </div>
+        </div>
+        <div class="item-task">
+          <div class="title">课节任务</div>
+        </div>
+        <div class="learning-materials">
+          <div class="title">学习资料</div>
+          <div>
+            <el-button><svg-icon icon-class="upload" /> 上传文件</el-button>
+          </div>
+        </div>
+      </div>
+    </div>
+
+    <!--添加课节信息框-->
+    <el-dialog
+      :visible.sync="dialogVisible"
+      title="课节信息"
+      width="490px"
+      top="25vh"
+      :close-on-click-modal="false"
+      :show-close="false"
+    >
+      <el-form
+        ref="itemForm"
+        :model="itemForm"
+        :rules="itemRules"
+        label-width="90px"
+        label-position="left"
+      >
+        <el-form-item label="课节名称" prop="name">
+          <el-input v-model="itemForm.name" class="item-name" />
+        </el-form-item>
+        <el-form-item label="课节周期" prop="date">
+          <el-date-picker
+            v-model="itemForm.date"
+            type="daterange"
+            range-separator="~"
+            value-format="yyyy-MM-dd"
+            unlink-panels
+          />
+        </el-form-item>
+        <el-form-item>
+          <el-button class="cancel" @click="dialogVisible = false">取消</el-button>
+          <el-button type="primary" @click="addCSItem">确定</el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import StepBar from '@/components/StepBar';
-import { GetCourseInfo_ContainCSItem } from '@/api/course';
+import {
+  GetCourseInfo_ContainCSItem,
+  AddCSItemToCourse,
+  GetCSItemInfoBox,
+  DeleteCSItem
+} from '@/api/course';
 
 export default {
   name: 'CreateTask',
@@ -15,13 +120,77 @@ export default {
   },
   data() {
     return {
-      id: this.$route.params.id
+      id: this.$route.params.id,
+      name: '',
+      picture_url: '',
+      begin_date: '',
+      end_date: '',
+      cs_item_list: [],
+      curItemID: '',
+      dialogVisible: false,
+      itemForm: {
+        name: '',
+        date: []
+      },
+      itemRules: {
+        name: { required: true, message: '课节名称不能为空', trigger: 'blur' },
+        date: { required: true, message: '课节周期不能为空', trigger: 'blur' }
+      },
+      itemInfoBox: {
+        name: ''
+      }
     };
   },
-  created() {},
+  watch: {
+    curItemID: function () {
+      console.log(2);
+    }
+  },
+  created() {
+    this.getCourseInfo();
+  },
   methods: {
     getCourseInfo() {
-      GetCourseInfo_ContainCSItem().then(response => {});
+      GetCourseInfo_ContainCSItem({ id: this.id }).then(
+        ({ name, picture_url, begin_date, end_date, cs_item_list }) => {
+          this.name = name;
+          this.picture_url = picture_url;
+          this.begin_date = begin_date;
+          this.end_date = end_date;
+          this.cs_item_list = cs_item_list;
+          this.curItemID = cs_item_list[cs_item_list.length - 1].id;
+        }
+      );
+    },
+    preStep() {
+      this.$router.push({ path: `/create_course_step_table/select_book/${this.id}` });
+    },
+    addCSItem() {
+      let data = {
+        course_id: this.id,
+        name: this.itemForm.name,
+        begin_time: this.itemForm.date[0],
+        end_time: this.itemForm.date[1]
+      };
+      AddCSItemToCourse(data).then(() => {
+        this.dialogVisible = false;
+        this.getCourseInfo();
+      });
+    },
+    getCSItemInfoBox() {
+      GetCSItemInfoBox({ id: this.curItemID }).then(res => {});
+    },
+    deleteCSItem(id) {
+      this.$confirm('您确定要删除该课节吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        DeleteCSItem({ id }).then(() => {
+          this.$message.success('删除课节成功!');
+          this.getCourseInfo();
+        });
+      });
     }
   }
 };
@@ -32,5 +201,158 @@ export default {
 
 .task {
   @include container;
+
+  margin-top: $step-h;
+
+  // 上部的课程信息
+  &-course-info {
+    display: flex;
+    width: 100%;
+    height: 120px;
+    background-color: #fff;
+    border-radius: 8px;
+
+    .cover {
+      width: 192px;
+      height: 100%;
+      border-right: 1px solid #e5e5e5;
+
+      img {
+        width: 100%;
+        height: 100%;
+      }
+    }
+
+    .info {
+      padding: 26px 32px;
+
+      .name {
+        font-size: 24px;
+      }
+
+      .date {
+        color: #6b6b6b;
+        font-size: 14px;
+        margin-top: 16px;
+
+        span {
+          margin: 0 24px;
+        }
+      }
+    }
+  }
+
+  // 中间的按钮
+  &-button {
+    margin: 16px 0;
+    display: flex;
+    justify-content: flex-end;
+
+    .el-button + .el-button {
+      margin-left: 16px;
+    }
+
+    .prev-step .el-icon-back {
+      margin-right: 12px;
+    }
+
+    .preserve .svg-icon {
+      margin-right: 8px;
+    }
+  }
+
+  // 下部的课节
+  &-item {
+    display: flex;
+    border-radius: 8px;
+    height: calc(100vh - #{$header-h} - #{$step-h} - 240px);
+
+    &-list {
+      flex: 3;
+      height: 100%;
+      background-color: #eee;
+
+      &-title {
+        display: flex;
+        justify-content: space-between;
+        padding: 16px 24px;
+        height: 56px;
+        line-height: 24px;
+        background-color: #eee;
+        cursor: pointer;
+
+        &.selected {
+          background-color: #fff;
+        }
+      }
+
+      .create-item {
+        margin: 24px;
+        font-size: 16px;
+        padding: 11px 20px;
+        width: calc(100% - 48px);
+      }
+    }
+
+    &-container {
+      flex: 7;
+      background-color: #fff;
+      box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.15);
+
+      .learning-materials {
+        padding: 24px 32px;
+
+        .title {
+          font-size: 20px;
+          margin-bottom: 24px;
+        }
+      }
+
+      .item-info {
+        @extend .learning-materials;
+
+        border-bottom: 1px solid #d9d9d9;
+
+        &-name,
+        &-date {
+          display: flex;
+          margin-top: 16px;
+
+          > :first-child {
+            width: 110px;
+            min-width: 120px;
+            line-height: 40px;
+          }
+
+          .el-input {
+            width: 600px;
+          }
+        }
+      }
+
+      .item-task {
+        @extend .learning-materials;
+
+        border-bottom: 1px solid #d9d9d9;
+      }
+    }
+  }
+
+  .el-dialog {
+    .item-name {
+      width: 350px;
+    }
+  }
+}
+
+.el-dropdown-menu {
+  padding: 1px;
+
+  .delete-menu {
+    width: 128px;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+  }
 }
 </style>

+ 4 - 1
src/views/teacher/create_course/step_table/SelectBook.vue

@@ -43,7 +43,7 @@
             />
             <div>
               <el-button class="prev-step"><i class="el-icon-back" />课程信息</el-button>
-              <el-button type="primary" class="next-step">
+              <el-button type="primary" class="next-step" @click="nextStep">
                 下一步<i class="el-icon-right" />
               </el-button>
             </div>
@@ -125,6 +125,9 @@ export default {
           }
         });
       }
+    },
+    nextStep() {
+      this.$router.push({ path: `/create_course_step_table/create_task/${this.id}` });
     }
   }
 };