فهرست منبع

feat: 制定组队规则

yhd12345 4 سال پیش
والد
کامیت
42bb6f68c1
5فایلهای تغییر یافته به همراه215 افزوده شده و 2 حذف شده
  1. 40 0
      src/api/group.js
  2. 4 0
      src/api/index.js
  3. 45 0
      src/api/project.js
  4. 106 2
      src/views/CoursePage/CourseDetail.vue
  5. 20 0
      src/views/CoursePage/style/CourseDetail.css

+ 40 - 0
src/api/group.js

@@ -0,0 +1,40 @@
+import {axios} from "@/requests/axios.config";
+const prefix = "/group";
+
+function editGroupRule(data){
+    return axios.post(`${prefix}/rule`,data);
+}
+
+function createGroup(data){
+    return axios.post(`${prefix}`,data);
+}
+
+function addGroupMember(data){
+    return axios.post(`${prefix}/member/add`,data);
+}
+
+function findGroup(courseId){
+    return axios.get(`${prefix}`,{
+        params :{
+            courseId,
+        }
+    });
+}
+
+function findAllGroupsByCourse(courseId){
+    return axios.get(`${prefix}/all`,{
+        params :{
+            courseId,
+        }
+    });
+}
+
+const groupAPIs={
+    editGroupRule,
+    createGroup,
+    addGroupMember,
+    findGroup,
+    findAllGroupsByCourse
+};
+
+export default groupAPIs;

+ 4 - 0
src/api/index.js

@@ -5,6 +5,8 @@ import coderAPIs from "@/api/coder";
 import superAPIs from "@/api/super";
 import announcementAPIs from "@/api/announcement";
 import messageAPIs from "@/api/message";
+import groupAPIS from  "@/api/group";
+import  projectAPIs from "@/api/project";
 
 const api = {
   ...userAPIs,
@@ -14,6 +16,8 @@ const api = {
   ...superAPIs,
   ...announcementAPIs,
   ...messageAPIs,
+  ...groupAPIS,
+  ...projectAPIs,
 };
 
 export default api;

+ 45 - 0
src/api/project.js

@@ -0,0 +1,45 @@
+import {axios} from "@/requests/axios.config";
+const prefix = "/project";
+
+function findAllProjects(){
+    return axios.get(`${prefix}/findAll`);
+}
+
+function findCourseProjects(){
+    return axios.get(`${prefix}/findCourse`);
+}
+
+function findNonCourseProjects(){
+    return axios.get(`${prefix}/findNonCourse`);
+}
+
+function  findProjectById(id){
+    return axios.get(`${prefix}/findById`,{
+        params: {
+            id,
+        }
+    });
+}
+
+function  findProjectsByCourse(courseId){
+    return axios.get(`${prefix}/findByCourse`,{
+        params: {
+            courseId,
+        }
+    });
+}
+
+function createProject(data){
+    return axios.post(`${prefix}`,data);
+}
+
+const projectAPIs = {
+    findAllProjects,
+    findCourseProjects,
+    findNonCourseProjects,
+    findProjectById,
+    findProjectsByCourse,
+    createProject,
+};
+
+export default projectAPIs;

+ 106 - 2
src/views/CoursePage/CourseDetail.vue

@@ -48,7 +48,7 @@
           <el-radio-group v-model="tabName" size="large">
             <el-radio-button label="task" @click="switchTab('task')">任务</el-radio-button>
             <el-radio-button label="notice" @click="switchTab('notice')">通知</el-radio-button>
-<!--            <el-radio-button label="courseware" @click="switchTab('courseware')">课件</el-radio-button>-->
+            <el-radio-button label="project" @click="switchTab('project')">项目</el-radio-button>
             <el-radio-button label="comment" @click="switchTab('comment')">评论</el-radio-button>
           </el-radio-group>
           <div v-if="isCreator">
@@ -101,6 +101,38 @@
                 </el-button>
               </template>
             </el-popover>
+
+            <el-popover v-if="tabName==='project'"
+                        v-model:visible="projectPopover"
+                        :width="160"
+                        placement="bottom">
+              <el-row class="sel-project-type">
+                <div class="project-type-txt">
+                  <el-link href="javascript:void(0);" type="success" @click="setRule">
+                    开放组队
+                  </el-link>
+                </div>
+              </el-row>
+              <el-row class="sel-project-type">
+                <div class="project-type-txt">
+                  <el-link href="javascript:void(0);" type="warning">
+                    修改组队信息
+                  </el-link>
+                </div>
+              </el-row>
+              <el-row class="sel-project-type">
+                <div class="project-type-txt">
+                  <el-link href="javascript:void(0);" type="danger">
+                    查看队伍信息
+                  </el-link>
+                </div>
+              </el-row>
+              <template #reference>
+                <el-button plain type="primary" @click="projectPopover = true">组队
+                </el-button>
+              </template>
+            </el-popover>
+
             <el-upload v-if="tabName==='courseware'" :http-request="handleFileUploading"
                        :on-success="handleFileUploadSuccess"
                        :show-file-list="false" action="">
@@ -272,6 +304,22 @@
         <el-button plain type="danger" @click="beforeFormClose">我再想想</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog v-model="ruleFormDialog" :before-close="beforeFormClose" :title="ruleForm.dialogTitle">
+      <el-form ref="ruleFormRef" :model="ruleForm" :rules="ruleFormRule" label-position="right" label-width="150px">
+        <el-form-item label="小组最大人数" prop="maxSize">
+          <el-input v-model="ruleForm.maxSize"></el-input>
+        </el-form-item>
+        <el-form-item label="组名最大长度" prop="maxNameLen">
+          <el-input v-model="ruleForm.maxNameLen"></el-input>
+        </el-form-item>
+      </el-form>
+      <div style="margin: auto;width: fit-content">
+        <el-button plain type="primary" @click="CreateRule">确认</el-button>
+        <el-button plain type="danger" @click="beforeRuleFormClose">我再想想</el-button>
+      </div>
+
+    </el-dialog>
   </div>
 </template>
 
@@ -280,7 +328,6 @@ import NoticeItem from "./components/NoticeItem";
 import FileEntry from "./components/FileEntry";
 import { ElMessageBox, ElMessage } from "element-plus";
 import variables from "@/utils/variables";
-import announcement from "@/api/announcement";
 
 export default {
   name: "CourseDetail",
@@ -302,6 +349,7 @@ export default {
       themeColor,
       tabName: "task",
       noticePopover: false,
+      projectPopover: false,
       //
       evalExamList: [],
       coderExamList: [],
@@ -324,6 +372,23 @@ export default {
       },
       announcementList: [],
       //
+      ruleFormDialog: false,
+      ruleForm: {
+        dialogTitle: "制定组队规则",
+        courseVO: null,
+        id: null,
+        maxSize: null,
+        maxNameLen: null,
+      },
+      ruleFormRule: {
+        maxSize: {
+          required: true, message: "请输入小组最大成员人数", trigger: "blur",
+        },
+        maxNameLen: {
+          required: true, message: "请输入组名最大长度", trigger: "blur",
+        }
+      },
+
       commentContent: "",
       commentTree: [],
 
@@ -390,6 +455,10 @@ export default {
     isCreator() {
       return Number(this.courseInfo.teacher.id) === Number(this.$store.state.user.id);
     },
+    isNotRule() {
+      return false;
+      //todo
+    },
     imgUrl() {
       return this.courseInfo.imageUrl === null ? this.noImgUrl : this.courseInfo.imageUrl;
     },
@@ -529,6 +598,10 @@ export default {
       this.announcementForm.type = type;
       this.announcementFormDialog = true;
     },
+    setRule(){
+      this.ruleFormDialog =true;
+    },
+
     beforeFormClose() {
       ElMessageBox.confirm("是否确认退出?退出后将不保存表格信息。", "提示", {
         confirmButtonText: "确认退出",
@@ -541,6 +614,35 @@ export default {
           this.$refs.announceFormRef.resetFields();
         });
     },
+
+    beforeRuleFormClose() {
+      ElMessageBox.confirm("是否确认退出?退出后将不保存组队规则信息。", "提示", {
+        confirmButtonText: "确认退出",
+        cancelButtonText: "我再想想",
+        type: "warning",
+        center: true,
+      })
+          .then(() => {
+            this.ruleFormDialog = false;
+            this.$refs.ruleFormRef.resetFields();
+          });
+    },
+
+    CreateRule(){
+      let RuleVO={
+        courseVO: {courseId: this.courseInfo.id},
+        maxSize: this.ruleForm.maxSize,
+        maxNameLen: this.ruleForm.maxNameLen,
+      };
+      console.log(RuleVO);
+      this.$apis.editGroupRule(RuleVO)
+          .then(res => {
+            this.ruleFormDialog=false;
+            this.$refs.ruleFormRef.resetFields;
+            ElMessage.success("创建规则成功");
+          });
+    },
+
     handlePublishAnnouncement() {
       const _this = this;
       if (this.announcementForm.content === "") {
@@ -728,6 +830,8 @@ export default {
         case "comment":
           this.commentTree = (await this.$apis.getCommentsByCourseId(this.$route.params.id)).data.data;
           break;
+        case "project":
+          //todo
       }
     },
     // comment相关

+ 20 - 0
src/views/CoursePage/style/CourseDetail.css

@@ -112,6 +112,26 @@
     justify-content: space-around;
 }
 
+.sel-project-type {
+    display: flex;
+    align-items: center;
+    height: 45px;
+    justify-content: space-around;
+}
+
+.project-type-icon {
+    border-radius: 24px;
+    border: 2px solid;
+    box-sizing: border-box;
+    padding: 4px 12px;
+    font-size: 14px;
+}
+
+.project-type-txt {
+    font-size: 14px;
+    cursor: pointer;
+}
+
 
 .notice-type-icon {
     border-radius: 24px;