Browse Source

班主任预点名增加全选功能

houxq 1 year ago
parent
commit
7bfbd9030f
1 changed files with 30 additions and 9 deletions
  1. 30 9
      src/pages/stxkbzr/index.vue

+ 30 - 9
src/pages/stxkbzr/index.vue

@@ -1,6 +1,6 @@
 <template>
 <template>
   <div class="content">
   <div class="content">
-    <van-nav-bar title="本班学生选课" @click="changeTitle" v-show="!isShowbar" left-arrow @click-left="onClickLeft" />
+    <van-nav-bar title="本班学生选课"  v-show="!isShowbar" left-arrow @click-left="onClickLeft" />
     <div class="week">
     <div class="week">
       <ul class="weekday">
       <ul class="weekday">
         <li @click="changeWeek(week,index)"  :class="[state.week == week.name ? 'dayblue' : '']" v-for="(week, index) in classWeek" :key="week">
         <li @click="changeWeek(week,index)"  :class="[state.week == week.name ? 'dayblue' : '']" v-for="(week, index) in classWeek" :key="week">
@@ -57,12 +57,15 @@
     <div class="sign-up" v-if="toSignUp">
     <div class="sign-up" v-if="toSignUp">
       <van-icon @click="close" name="cross" size="0.4*13.3vw" />
       <van-icon @click="close" name="cross" size="0.4*13.3vw" />
       <h3>预点名</h3>
       <h3>预点名</h3>
+     <div class="flex justify-between"> 
       <p>
       <p>
         今日本班学生到校:
         今日本班学生到校:
         <span style="color: #003eee">{{ xsxx.m1 }}</span>/{{ xsxx.m2 }}
         <span style="color: #003eee">{{ xsxx.m1 }}</span>/{{ xsxx.m2 }}
       </p>
       </p>
+      <p  style="margin-right:20px" @click="selectAllStudent()">全选</p>
+      </div>
       <div class="students">
       <div class="students">
-        <span @click="selectStudent(item, index,'0')" :class="initClass(item)" v-for="(item, index) in ydmStu" :key="item">{{ item.realname}} {{item.kk_name}} </span>
+        <span @click="selectStudent(item, index,'0')" :class="initClass(item)" v-for="(item, index) in ydmStu" :key="item" >{{ item.realname}} {{item.kk_name}} </span>
       </div>
       </div>
       <div class="submit"  >
       <div class="submit"  >
         <button :class="absentStu.length == 0 ||state.showIndex!=index ?' disabled':'blueBtn'" @click="submitDM('0')">
         <button :class="absentStu.length == 0 ||state.showIndex!=index ?' disabled':'blueBtn'" @click="submitDM('0')">
@@ -165,6 +168,7 @@ export default {
       weekname: "",
       weekname: "",
       index: "",
       index: "",
       cm_id: "",
       cm_id: "",
+      isAllCheck: false,
     };
     };
   },
   },
   methods: {
   methods: {
@@ -211,7 +215,6 @@ export default {
     changeWeek(week, index) {
     changeWeek(week, index) {
       this.state.week = week.name;
       this.state.week = week.name;
       this.state.showIndex = index;
       this.state.showIndex = index;
-      console.log(this.state.showIndex, 33);
       this.courseNum = week.course.length;
       this.courseNum = week.course.length;
       this.xsxx.m1 = week.dmxx.xsqd;
       this.xsxx.m1 = week.dmxx.xsqd;
       this.xsxx.m2 = week.dmxx.xszs;
       this.xsxx.m2 = week.dmxx.xszs;
@@ -232,7 +235,6 @@ export default {
       var day = new Date().getDay();
       var day = new Date().getDay();
       var weeks = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
       var weeks = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
       this.index = this.classWeek.findIndex((item) => item.name == weeks[day]);
       this.index = this.classWeek.findIndex((item) => item.name == weeks[day]);
-      console.log(this.classWeek[this.index], this.index, 678);
       this.changeWeek(this.classWeek[this.index], this.index);
       this.changeWeek(this.classWeek[this.index], this.index);
       // this.state.week = weeks[day];
       // this.state.week = weeks[day];
       // this.state.showIndex = weeks.indexOf(this.state.week);
       // this.state.showIndex = weeks.indexOf(this.state.week);
@@ -246,25 +248,45 @@ export default {
           kccq_cqycxsxm: stu.realname,
           kccq_cqycxsxm: stu.realname,
           kccq_cqycxsbh: stu.uid,
           kccq_cqycxsbh: stu.uid,
         });
         });
-        console.log(stu.isCheck, 456);
       } else {
       } else {
         let i = this.absentStu.findIndex(
         let i = this.absentStu.findIndex(
           (item) => stu.uid == item.kccq_cqycxsbh
           (item) => stu.uid == item.kccq_cqycxsbh
         );
         );
         this.absentStu.splice(i, 1);
         this.absentStu.splice(i, 1);
-        console.log(stu.isCheck, 567);
       }
       }
       if (this.state.showIndex != this.index) {
       if (this.state.showIndex != this.index) {
         showToast("只有当天才能点名呦~");
         showToast("只有当天才能点名呦~");
       }
       }
     },
     },
+    //全选
+    selectAllStudent() {
+      if (this.state.showIndex != this.index) {
+        showToast("只有当天才能点名呦~");
+      }
+      this.isAllCheck = !this.isAllCheck;
+      if (this.isAllCheck) {
+        this.ydmStu.map((item) => {
+          item.isCheck = true;
+          this.absentStu.push({
+            kccq_cqycxsxm: item.realname,
+            kccq_cqycxsbh: item.uid,
+          });
+        });
+      } else {
+        this.ydmStu.map((item) => {
+          item.isCheck = false;
+          this.absentStu = [];
+        });
+      }
+    },
+
     initClass(data) {
     initClass(data) {
       let className = "";
       let className = "";
       if (data.statue == 0) {
       if (data.statue == 0) {
         className = "blueBg";
         className = "blueBg";
       } else if (data.statue == "1") {
       } else if (data.statue == "1") {
         className = "orangeBg";
         className = "orangeBg";
-      } else if (data.statue == 2) {
+      } else if (data.statue == "2") {
         className = "redBg";
         className = "redBg";
       }
       }
       if (data.isCheck) {
       if (data.isCheck) {
@@ -297,7 +319,7 @@ export default {
         });
         });
         this.$forceUpdate();
         this.$forceUpdate();
         this.absentStu = [];
         this.absentStu = [];
-        //   this.isCheck=
+        this.isAllCheck = false;
       });
       });
     },
     },
     close() {
     close() {
@@ -572,7 +594,6 @@ export default {
 }
 }
 .sign-up {
 .sign-up {
   p {
   p {
-    width: 95%;
     height: 0.37 * 13.3vw;
     height: 0.37 * 13.3vw;
     font-size: 0.28 * 13.3vw;
     font-size: 0.28 * 13.3vw;
     font-family: AdobeHeitiStd-Regular;
     font-family: AdobeHeitiStd-Regular;