|
@@ -1,11 +1,11 @@
|
|
|
<template>
|
|
|
<div id="remind">
|
|
|
<detail-frame :title="pageTitle">
|
|
|
- <!-- <el-row type="flex" align="middle" justify="end" class="btn_bar">
|
|
|
+ <el-row type="flex" align="middle" justify="end" class="btn_bar">
|
|
|
<el-col :span="2">
|
|
|
- <el-button type="primary" size="mini" @click="sendMsg()">发送本期通知</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="toSendMsg()">发送本期通知</el-button>
|
|
|
</el-col>
|
|
|
- </el-row> -->
|
|
|
+ </el-row>
|
|
|
<data-table :fields="fields" :data="list" :opera="opera" @msg="toSendMsg" @view="toView" :usePage="false"></data-table>
|
|
|
</detail-frame>
|
|
|
<el-dialog title="通知内容" :visible.sync="dialogSend">
|
|
@@ -70,8 +70,9 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 通知打开
|
|
|
- toSendMsg({ data }) {
|
|
|
- this.$set(this, `classid`, data.id);
|
|
|
+ toSendMsg({ data } = {}) {
|
|
|
+ console.log(data);
|
|
|
+ if (data) this.$set(this, `classid`, data.id);
|
|
|
this.dialogSend = true;
|
|
|
},
|
|
|
// 取消提交
|
|
@@ -82,22 +83,34 @@ export default {
|
|
|
// 通知确定
|
|
|
async submitForm({ data }) {
|
|
|
let classid = this.classid;
|
|
|
- let r = await this.classNameList(classid);
|
|
|
- let elseList = [];
|
|
|
- let res = await this.getStudentList({ classid });
|
|
|
- var notified = res.data.map(item => ({ notifiedid: item.id }));
|
|
|
- let rl = await this.modelFetch({ model: 'lesson', classid });
|
|
|
- if (_.get(rl, `data`)) {
|
|
|
- let { lessons } = _.get(rl, `data`);
|
|
|
- elseList = _.uniq(_.compact(lessons.map(i => i.teaid)));
|
|
|
+ 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;
|
|
|
+ };
|
|
|
+ //如果classid为空,就说明是本期发送,应该把每个班的人都拽出来发送
|
|
|
+ if (classid) {
|
|
|
+ let r = await this.classNameList(classid);
|
|
|
+ if (!r.errcode != 0) return;
|
|
|
+ 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;
|
|
|
}
|
|
|
- if (_.get(data, 'headteacherid')) elseList.push(_.get(data, 'headteacherid'));
|
|
|
- if (_.get(data, 'lyteacherid')) elseList.push(_.get(data, 'lyteacherid'));
|
|
|
- elseList = elseList.map(i => ({ notifiedid: i }));
|
|
|
- data.noticeid = this.user.id;
|
|
|
- data.notified = [...notified, ...elseList];
|
|
|
+ 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(res)) {
|
|
|
+ if (this.$checkRes(arr)) {
|
|
|
this.$message({
|
|
|
message: '通知成功',
|
|
|
type: 'success',
|