wuhongyuq 5 anni fa
parent
commit
399329d019
2 ha cambiato i file con 28 aggiunte e 16 eliminazioni
  1. 3 8
      src/layout/user/punchBtn.vue
  2. 25 8
      src/views/user/checkWork.vue

+ 3 - 8
src/layout/user/punchBtn.vue

@@ -18,13 +18,8 @@
           <h2>当前打卡时间</h2>
           <el-col :span="24" class="round">
             <p>打卡</p>
-            <p>{{ form.attend.date }}</p>
-            <p>{{ form.attend.time }}</p>
-            <!-- <ul>
-              <li></li>
-              <li></li>
-              <li></li>
-            </ul> -->
+            <p>{{ dates.date }}</p>
+            <p>{{ dates.time }}</p>
           </el-col>
         </el-col>
         <div style="margin: 16px;">
@@ -43,7 +38,7 @@ export default {
   props: {
     show: null,
     form: null,
-    attend: null,
+    dates: null,
   },
   components: {},
   data: () => ({}),

+ 25 - 8
src/views/user/checkWork.vue

@@ -9,7 +9,7 @@
         <el-col :span="24" class="main">
           <el-col :span="24" class="leaveBtn">
             <!-- <van-button round type="info" icon="smile" @click="onClickRight()">考勤打卡</van-button> -->
-            <punchBtn :show="show" :form="form" @openClick="openClick" @onSubmit="onSubmit"></punchBtn>
+            <punchBtn :show="show" :form="form" :dates="dates" @openClick="openClick" @onSubmit="onSubmit"></punchBtn>
           </el-col>
           <el-col :span="24" class="leaveList">
             <checkList :checkWorkList="checkWorkList"></checkList>
@@ -62,6 +62,7 @@ export default {
     form: {
       attend: [],
     },
+    dates: {},
     title: '',
     isleftarrow: '',
     transitionName: 'fade',
@@ -70,6 +71,7 @@ export default {
   created() {
     this.searchInfo();
     this.getDate();
+    // this.search();
   },
   computed: {},
   mounted() {
@@ -83,7 +85,12 @@ export default {
     },
   },
   methods: {
-    ...mapAttendance(['fetch', 'create']),
+    ...mapAttendance(['fetch', 'create', 'query']),
+    // async search() {
+    //   const res = await this.query();
+    //   console.log(res);
+    //   this.$set(this, `checkWorkList`, res.data);
+    // },
     searchInfo() {
       let site = JSON.parse(sessionStorage.getItem('site'));
       this.$set(this.form, `batchid`, site.batchid);
@@ -93,10 +100,15 @@ export default {
       this.show = true;
     },
     async onSubmit(form) {
+      let site = JSON.parse(sessionStorage.getItem('site'));
+      console.log(site);
       this.form.termid = '123456';
+      this.form.batchid = site.batchid;
+      this.form.ckassid = site.ckassid;
+      this.form.studentid = site.studentid;
       let data = this.form;
-      console.log(this.form.attend);
-      // let res = await this.create(data);
+      console.log(this.form.batchid);
+      let res = await this.create(data);
       this.show = false;
     },
     getDate() {
@@ -104,15 +116,20 @@ export default {
         var adate = new Date();
         let year = adate.getFullYear();
         let mouth = adate.getMonth() + 1;
-        let date = adate.getDate();
-        let newsdate = year + '-' + mouth + '-' + date;
+        let day = adate.getDate();
+        let newsdate = year + '年' + mouth + '月' + day + '日';
         this.value = adate.getHours() + ':' + adate.getMinutes() + adate.getSeconds();
         let str = adate.getHours() > 9 ? adate.getHours() : '0' + adate.getHours();
         let tt = adate.getMinutes() > 9 ? adate.getMinutes() : '0' + adate.getMinutes();
         let ss = adate.getSeconds() > 9 ? adate.getSeconds() : '0' + adate.getSeconds();
         let tim = str + ':' + tt + ':' + ss;
-        this.$set(this.form.attend, `time`, tim);
-        this.$set(this.form.attend, `date`, newsdate);
+        let time = tim;
+        let date = newsdate;
+        let attend = [{ time, date }];
+        for (const val of attend) {
+          this.$set(this, `dates`, val);
+        }
+        this.$set(this.form, `attend`, attend);
       }, 1000);
     },
   },