Browse Source

添加合班

1
mo 4 năm trước cách đây
mục cha
commit
8c43a1496f

+ 140 - 96
src/views/teamDetail/componentCourse/addCompound.vue

@@ -2,156 +2,192 @@
   <div class="fixedBox">
     <el-card>
       <div class="boxWrap">
-        <p>临时合课列表<span style="color:red;"> {{compoundList.length}} </span></p>
-        <el-popover placement="top"
-                    v-model='isLook'
-                    trigger="click">
+        <p>
+          待处理课程列表<span style="color: red">
+            {{ compoundList.length }}
+          </span>
+        </p>
+        <el-popover placement="top" v-model="isLook" trigger="click">
           <div>
-            <p class="title">临时合课列表 <i class="el-icon-minus minus"
-                 @click="isLook=false"></i></p>
+            <p class="title">
+              待处理课程列表<i
+                class="el-icon-minus minus"
+                @click="isLook = false"
+              ></i>
+            </p>
 
             <el-divider></el-divider>
           </div>
-          <el-button type="text"
-                     style="float:right"
-                     @click="clearCom">清空列表</el-button>
+          <el-button type="text" style="float: right" @click="clearCom"
+            >清空列表</el-button
+          >
           <div>
-            <el-radio-group v-model="radio">
-              <el-table :data="dataList"
-                        height='300px'
-                        :header-cell-style="{background:'#EDEEF0',color:'#444'}">
-                <el-table-column align='center'
-                                 label="主课"
-                                 width="110">
+              <el-table
+                :data="dataList"
+                height="300px"
+                :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
+              >
+                <el-table-column align="center" label="课程编号" width="110">
                   <template slot-scope="scope">
-
-                    <el-radio :label="scope.row.id"></el-radio>
-
+                    <div>{{ scope.row.id }}</div>
                   </template>
                 </el-table-column>
-                <el-table-column align='center'
-                                 width="180px"
-                                 label="课程名称"
-                                 prop="name"></el-table-column>
-                <el-table-column align="center"
-                                 label="课程类型">
+                <el-table-column
+                  align="center"
+                  width="180px"
+                  label="课程名称"
+                  prop="name"
+                ></el-table-column>
+                <el-table-column align="center" label="课程类型">
                   <template slot-scope="scope">
-                    <div>{{ scope.row.type | coursesType}}</div>
+                    <div>{{ scope.row.type | coursesType }}</div>
                   </template>
                 </el-table-column>
-                <el-table-column align="center"
-                                 width="180px"
-                                 prop="teacherName"
-                                 label="指导老师">
+                <el-table-column
+                  align="center"
+                  width="180px"
+                  prop="teacherName"
+                  label="指导老师"
+                >
                   <template slot-scope="scope">
                     <div>
-                      {{scope.row.teacherName}}({{scope.row.actualTeacherId}})
+                      {{ scope.row.teacherName }}({{
+                        scope.row.actualTeacherId
+                      }})
                     </div>
                   </template>
                 </el-table-column>
-                <el-table-column align="center"
-                                 width="200px"
-                                 label="上课时间">
-                  <template slot-scope="scope">{{ scope.row.startClassTime ? scope.row.startClassTime.substr(0, 16) : '' }}-{{ scope.row.endClassTime ? scope.row.endClassTime.substr(11,5) : ''}}</template>
+                <el-table-column align="center" width="200px" label="上课时间">
+                  <template slot-scope="scope"
+                    >{{
+                      scope.row.startClassTime
+                        ? scope.row.startClassTime.substr(0, 16)
+                        : ""
+                    }}-{{
+                      scope.row.endClassTime
+                        ? scope.row.endClassTime.substr(11, 5)
+                        : ""
+                    }}</template
+                  >
+                </el-table-column>
+                <el-table-column align="center" width="100px" label="是否结算">
+                  <template slot-scope="scope">
+                    <div>
+                      {{ scope.row.isSettlement ? "是" : "否" }}
+                    </div>
+                  </template>
                 </el-table-column>
-                <el-table-column align="center"
-                                 label="操作">
+                <el-table-column align="center" label="操作">
                   <template slot-scope="scope">
-                    <el-button type="text"
-                               @click="cancleCom(scope.row)">取消</el-button>
+                    <el-button type="text" @click="cancleCom(scope.row)"
+                      >取消</el-button
+                    >
                   </template>
                 </el-table-column>
               </el-table>
-            </el-radio-group>
           </div>
-          <el-button type="primary"
-                     size="mini"
-                     style="float:right;margin-top:20px;"
-                     @click="submitClass">确定</el-button>
-          <i class="el-icon-copy-document"
-             slot="reference"></i>
-        </el-popover>
+          <div class="addBtnList">
+            <el-button
+              v-permission="'courseSchedule/batchDelete?page=teamCourseList'"
+              @click="removeCourse"
+              :disabled="!dataList.length > 0"
+              type="primary"
+              size="mini"
+              >批量删除</el-button
+            >
+            <el-button
+              type="primary"
+              @click="submitClass"
+              size="mini"
+              >课程合并</el-button
+            >
+          </div>
 
+          <i class="el-icon-copy-document" slot="reference"></i>
+        </el-popover>
       </div>
     </el-card>
-    <el-dialog :visible.sync="show"
-               title="临时合课信息"
-               append-to-body
-               width="800px">
-      <compoundClass :show="show"
-                     v-if="show"
-                     @closeReset='closeReset'
-                     :isDisabled='true'
-                     @getList='getList'
-                     :idList='idList'
-                     :id='radio' />
+    <el-dialog
+      :visible.sync="show"
+      title="临时合课信息"
+      append-to-body
+      width="800px"
+    >
+      <compoundClass
+        :show="show"
+        v-if="show"
+        @closeReset="closeReset"
+        :isDisabled="true"
+        @getList="getList"
+        :idList="idList"
+        :dataList='dataList'
+      />
     </el-dialog>
   </div>
 </template>
 <script>
-import compoundClass from './compoundClass'
+import compoundClass from "./compoundClass";
 export default {
-  props: ['compoundList'],
+  props: ["compoundList"],
   components: { compoundClass },
-  data () {
+  data() {
     return {
-      radio: '',
+      radio: "",
       dataList: this.compoundList,
       isLook: false,
       show: false,
-      idList:''
-    }
+      idList: "",
+    };
   },
   methods: {
-    cancleCom (row) {
-      this.$emit('cancleCompound', row)
+    cancleCom(row) {
+      this.$emit("cancleCompound", row);
     },
-    clearCom () {
-      this.$emit('clearCom')
+    clearCom() {
+      this.$emit("clearCom");
     },
-    submitClass () {
-      if (!this.radio) {
-        this.$message.error('请选择一节主课')
-        return
-      }
+    submitClass() {
+      // if (!this.radio) {
+      //   this.$message.error("请选择一节主课");
+      //   return;
+      // }
       // let arr = []
-      let idList = []
-      this.dataList.forEach(com => {
+      let idList = [];
+      this.dataList.forEach((com) => {
         // arr.push(com.type)
-            idList.push(com.id)
-      })
+        idList.push(com.id);
+      });
       // arr = [... new Set(arr)]
       // if (arr.length != 1) {
       //   this.$message.error('请选择相同的课程类型')
       //   return
       // }
       if (this.dataList.length <= 1) {
-        this.$message.error('请至少选择2节课程')
-        return
+        this.$message.error("请至少选择2节课程");
+        return;
       }
       // 做判断
-      this.idList = idList.join(',')
+      this.idList = idList.join(",");
       this.show = true;
-      this.isLook = false
-
+      this.isLook = false;
     },
-    getList () {
-
+    getList() {},
+    closeReset() {
+      this.clearCom();
+      this.show = false;
+      this.$emit("getList");
+    },
+    removeCourse() {
+      this.$emit("removeCourse");
     },
-    closeReset () {
-      this.clearCom()
-      this.show = false
-      this.$emit('getList')
-     }
   },
   watch: {
-    compoundList (val) {
-      console.log(val)
-      this.dataList = val
-
-    }
-  }
-}
+    compoundList(val) {
+      console.log(val);
+      this.dataList = val;
+    },
+  },
+};
 </script>
 <style lang="scss" scoped>
 .title {
@@ -186,4 +222,12 @@ export default {
   font-size: 20px;
   cursor: pointer;
 }
+.addBtnList {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: flex-end;
+  margin-top: 15px;
+  padding-bottom: 10px;
+}
 </style>

+ 34 - 4
src/views/teamDetail/componentCourse/compoundClass.vue

@@ -11,6 +11,27 @@
     >
       <el-row>
         <el-col :span="12">
+          <el-form-item label="主课" prop="id">
+            <el-select
+              v-model.trim="maskForm.id"
+              style="width: 220px !important"
+              @change="changeId"
+              clearable
+              filterable
+            >
+              <el-option
+                v-for="(item, index) in dataList"
+                :key="index"
+                :value="item.id"
+                :label="item.name"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="12">
           <el-form-item label="课程名称" prop="teacher">
             <el-input
               v-model.trim="maskForm.name"
@@ -77,7 +98,7 @@
                 :value="item.id"
                 :label="item.realName"
               >
-                   <span style="float: left">{{ item.realName }}</span>
+                <span style="float: left">{{ item.realName }}</span>
                 <span style="float: right; color: #8492a6; font-size: 13px">{{
                   String(item.id)
                 }}</span>
@@ -215,7 +236,7 @@ import { getTeachSchool } from "@/api/teacherManager";
 import cleanDeep from "clean-deep";
 import dayjs from "dayjs";
 export default {
-  props: ["show", "id", "isDisabled", "idList"],
+  props: ["show", "dataList", "isDisabled", "idList"],
   components: { viewStudentList },
   data() {
     return {
@@ -242,6 +263,9 @@ export default {
         endTime: [
           { required: true, message: "请选择上课结束时间", trigger: "blur" },
         ],
+        id:[
+           { required: true, message: "请选择一节主课", trigger: "blur" },
+        ]
       },
       teacherList: [],
       schoolList: [],
@@ -255,7 +279,7 @@ export default {
       }
     });
 
-    this.getDetail(this.id);
+    // this.getDetail(this.id);
   },
   methods: {
     submitResetClass() {
@@ -352,10 +376,16 @@ export default {
         this.maskForm.address = "";
       }
     },
+    changeId(val){
+      if(val){
+        this.getDetail(val)
+      }else{
+        this.$refs.maskForm.resetFields()
+      }
+    },
     getDetail(id) {
       getCourseScheduleDetail({ courseScheduleId: id }).then((res) => {
         if (res.code == 200) {
-          console.log(res.data.groupType);
           this.maskForm = {
             id: res.data.id,
             teacher: res.data.actualTeacherId,

+ 94 - 40
src/views/teamDetail/teamCourseList.vue

@@ -211,13 +211,6 @@
               type="primary"
               >导出课表</el-button
             >
-            <el-button
-              v-permission="'courseSchedule/batchDelete?page=teamCourseList'"
-              @click="removeCourse"
-              :disabled="!deleteList.length > 0"
-              type="primary"
-              >批量删除</el-button
-            >
           </el-col>
         </el-row>
       </save-form>
@@ -225,8 +218,10 @@
       <div class="tableWrap" style="margin-top: 20px">
         <el-table
           :data="tableList"
+          ref="tableList"
           :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
           @selection-change="handleSelectionChange"
+          row-key="id"
         >
           >
           <el-table-column
@@ -343,8 +338,10 @@
                 <el-button
                   type="text"
                   @click="common(scope.row)"
-                  v-if=" scope.row.newCourseId > 0 &&
-                  scope.row.newCourseId != scope.row.id"
+                  v-if="
+                    scope.row.newCourseId > 0 &&
+                    scope.row.newCourseId != scope.row.id
+                  "
                 >
                   被合并课
                 </el-button>
@@ -393,7 +390,7 @@
                   >调整</el-button
                 >
 
-                <el-button
+                <!-- <el-button
                   type="text"
                   @click="addCompound(scope.row)"
                   v-if="
@@ -417,7 +414,7 @@
                   "
                   @click="cancleCompound(scope.row)"
                   >取消合课</el-button
-                >
+                > -->
                 <el-button
                   type="text"
                   v-if="
@@ -627,10 +624,11 @@
       />
     </el-dialog>
     <addCompound
-      :compoundList="compoundList"
+      :compoundList="deleteList"
       v-if="permission('courseSchedule/courseMerge')"
       @clearCom="clearCom"
       @getList="getList"
+      @removeCourse="removeCourse"
       @cancleCompound="cancleCompound"
     />
   </div>
@@ -718,6 +716,7 @@ export default {
       compoundList: [],
       deleteList: [],
       isMainGo: false,
+      isDetele: false,
     };
   },
   components: {
@@ -766,8 +765,8 @@ export default {
       }
     }
     // 课程时间段异常,不需要时间搜索
-    if(query.searchType == 'COURSE_TIME_ERROR') {
-      this.searchForm.timer = []
+    if (query.searchType == "COURSE_TIME_ERROR") {
+      this.searchForm.timer = [];
     }
 
     if (query.organId) {
@@ -792,13 +791,21 @@ export default {
     },
     async removeCourse(row) {
       if (this.deleteList.length < 1 && !row) {
-        this.$message.error("请自少选择一个班级");
+        this.$message.error("请自少选择一节课");
         return;
       }
-
+      let flag = false;
       let arr = this.deleteList.map((course) => {
+        console.log(course.status, course.isSettlement);
+        if (course.isSettlement || course.status == "UNDERWAY") {
+          flag = true;
+        }
         return course.id;
       });
+      if (flag) {
+        this.$message.error("已结算或进行中的课程无法删除");
+        return;
+      }
       let courseScheduleIds = arr.join(",") || row.id;
       try {
         await this.$confirm("是否确认删除此数据?", "提示", {
@@ -931,6 +938,20 @@ export default {
         if (res.code == 200) {
           this.tableList = res.data.rows;
           this.rules.total = res.data.total;
+          let idList = this.deleteList.map((course) => {
+            return course.id;
+          });
+          this.isDetele = true;
+          this.$nextTick(() => {
+            this.tableList.forEach((course) => {
+              if (idList.indexOf(course.id) != -1) {
+                this.$refs.tableList.toggleRowSelection(course, true);
+              }
+            });
+              this.isDetele = false;
+          });
+
+          // let arr = this.$helpers.lodash.differenceWith( this.tableList, this.deleteList,'id')
         }
       });
     },
@@ -982,32 +1003,36 @@ export default {
         })
         .catch(() => {});
     },
-    addCompound(row) {
-      this.compoundList.push(row);
-      this.compoundList = [...new Set(this.compoundList)];
-    },
-    isAddCom(row) {
-      let flag = false;
-      this.compoundList.forEach((com) => {
-        if (com.id == row.id) {
-          flag = true;
-        }
-      });
-      return flag;
-    },
+    // addCompound(row) {
+    //   this.compoundList.push(row);
+    //   this.compoundList = [...new Set(this.compoundList)];
+    // },
+    // isAddCom(row) {
+    //   let flag = false;
+    //   this.compoundList.forEach((com) => {
+    //     if (com.id == row.id) {
+    //       flag = true;
+    //     }
+    //   });
+    //   return flag;
+    // },
     cancleCompound(row) {
-      let indexNum = null;
-      this.compoundList.forEach((com, index) => {
-        if (com.id == row.id) {
-          indexNum = index;
-        }
-      });
-      if (indexNum + "") {
-        this.compoundList.splice(indexNum, 1);
-      }
+      // let indexNum = null;
+      // this.deleteList.forEach((com, index) => {
+      //   if (com.id == row.id) {
+      //     indexNum = index;
+      //   }
+      // });
+      // if (indexNum + "") {
+      //   this.deleteList.splice(indexNum, 1);
+      // }
+      console.log(row);
+      this.$refs.tableList.toggleRowSelection(row);
     },
     clearCom() {
-      this.compoundList = [];
+      // this.deleteList = [];
+      // this.$set(this,'deleteList',[])
+      this.$refs.tableList.clearSelection();
     },
     resetCompound(row) {
       this.$confirm("您确定取消合并该课程?", "提示", {
@@ -1026,7 +1051,36 @@ export default {
         .catch(() => {});
     },
     handleSelectionChange(arr) {
-      this.deleteList = arr;
+      // this.deleteList = arr;
+      if (arr.length > 0) {
+        console.log("添加");
+
+        this.deleteList = this.deleteList.concat(arr);
+        this.deleteList = this.$helpers.lodash.uniqBy(this.deleteList, "id");
+      } else {
+        if (this.isDetele) return;
+        // 有2种 1是新页
+        // 2是点击反选
+        let idList = this.deleteList.map((course) => {
+          return course.id;
+        });
+        this.$nextTick(() => {
+          let tableIdList = [];
+          this.tableList.forEach((course) => {
+            tableIdList.push(course.id);
+            if (idList.indexOf(course.id) != -1) {
+              this.$refs.tableList.toggleRowSelection(course, false);
+              // 删除这个元素
+            }
+          });
+          this.deleteList = this.$helpers.lodash.remove(
+            this.deleteList,
+            function (item) {
+              return tableIdList.indexOf(item.id) == -1;
+            }
+          );
+        });
+      }
     },
   },
   filters: {