guhongwei 4 jaren geleden
bovenliggende
commit
57525a295c
2 gewijzigde bestanden met toevoegingen van 23 en 35 verwijderingen
  1. 11 0
      src/views/train-plan/parts/send-form.vue
  2. 12 35
      src/views/train-plan/remind.vue

+ 11 - 0
src/views/train-plan/parts/send-form.vue

@@ -3,6 +3,17 @@
     <el-row>
       <el-col :span="24">
         <el-form :model="form">
+          <el-form-item>
+            <template slot="label">
+              通知人
+            </template>
+            <el-radio-group v-model="form.type">
+              <el-radio label="0">所有人</el-radio>
+              <el-radio label="1">学生</el-radio>
+              <el-radio label="2">教师</el-radio>
+              <el-radio label="3">班主任</el-radio>
+            </el-radio-group>
+          </el-form-item>
           <el-form-item>
             <template slot="label">
               通知内容

+ 12 - 35
src/views/train-plan/remind.vue

@@ -51,7 +51,9 @@ export default {
         { label: '班级', prop: 'name' },
       ],
       dialogSend: false,
-      form: {},
+      form: {
+        type: '0',
+      },
       classid: '',
     };
   },
@@ -82,45 +84,20 @@ export default {
     // 通知确定
     async submitForm({ data }) {
       let classid = this.classid;
-      let dealData = data => {
-        let { students, teachers } = data;
-        students = students.map(item => ({ notifiedid: item.id }));
-        teachers = teachers.map(item => ({ notifiedid: item.id }));
-        let arr = [...students, ...teachers];
-        return arr;
-      };
-      console.log(dealData);
-      //如果classid为空,就说明是本期发送,应该把每个班的人都拽出来发送
       if (classid) {
-        let r = await this.classNameList(classid);
-        if (r.errcode != 0) return;
-        console.log('不为空');
-        data.notified = dealData(r.data);
-      } else {
-        let classids = this.list.map(i => i._id);
-        let rarr = [];
-        for (const classid of classids) {
-          let r = await this.classNameList(classid);
-          if (r.errcode != 0) continue;
-          let arr = dealData(r.data);
-          rarr = [...rarr, ...arr];
-        }
-        data.notified = rarr;
-        console.log(rarr);
+        data.classid = classid;
       }
-      console.log(data);
       data.noticeid = this.user.userid;
       let { planyearid, planid, termid } = this.defaultOption;
       data = { ...data, planyearid, planid, termid };
-
-      // const arr = await this.noticeCreate(data);
-      // if (this.$checkRes(arr)) {
-      //   this.$message({
-      //     message: '通知成功',
-      //     type: 'success',
-      //   });
-      //   this.resetForm();
-      // }
+      const arr = await this.noticeCreate(data);
+      if (this.$checkRes(arr)) {
+        this.$message({
+          message: '通知成功',
+          type: 'success',
+        });
+        this.resetForm();
+      }
     },
     toSelect(val) {
       this.selected = val;