guhongwei 5 年之前
父节点
当前提交
ddaf6927e8
共有 3 个文件被更改,包括 99 次插入3 次删除
  1. 2 1
      src/store/index.js
  2. 61 0
      src/views/train-plan/parts/send-form.vue
  3. 36 2
      src/views/train-plan/remind.vue

+ 2 - 1
src/store/index.js

@@ -26,12 +26,12 @@ import trainBatch from '@frame/store/train-plan-year';
 import attendance from '@frame/store/attendance';
 import group from '@frame/store/group';
 import uploadtask from '@frame/store/uploadtask';
-
 import nation from '@frame/store/nation';
 import completion from '@frame/store/question-completion';
 import termquest from '@frame/store/termquest';
 import dirPlan from '@frame/store/dir-plan';
 import login from '@frame/store/login';
+import notice from '@frame/store/notice';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
 import * as dostate from '@frame/store/setting/state';
@@ -75,6 +75,7 @@ export default new Vuex.Store({
     attendance,
     group,
     uploadtask,
+    notice,
   },
   state: { ...ustate, ...dostate },
   mutations: { ...umutations, ...domutations },

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

@@ -0,0 +1,61 @@
+<template>
+  <div id="send-form">
+    <el-row>
+      <el-col :span="24">
+        <el-form :model="form">
+          <el-form-item>
+            <template slot="label">
+              通知内容
+            </template>
+            <el-input
+              type="textarea"
+              maxlength="200"
+              :autosize="{ minRows: 2, maxRows: 6 }"
+              show-word-limit
+              v-model="form.content"
+              placeholder="请输入通知内容"
+            ></el-input>
+          </el-form-item>
+          <el-col :span="24" style="text-align:center;">
+            <el-button @click="resetForm">取消</el-button>
+            <el-button type="primary" @click="submitForm">确定</el-button>
+          </el-col>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'send-form',
+  props: {
+    form: null,
+  },
+  components: {},
+  data: function() {
+    return {};
+  },
+  created() {},
+  methods: {
+    resetForm() {
+      this.$emit('resetForm');
+    },
+    submitForm() {
+      this.$emit('submitForm', { data: this.form });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 36 - 2
src/views/train-plan/remind.vue

@@ -8,6 +8,9 @@
       </el-row>
       <data-table :fields="fields" :data="list" :opera="opera" @msg="toSendMsg" :usePage="false"></data-table>
     </detail-frame>
+    <el-dialog title="通知内容" :visible.sync="dialogSend">
+      <send-form :form="form" @resetForm="resetForm" @submitForm="submitForm"></send-form>
+    </el-dialog>
   </div>
 </template>
 
@@ -15,12 +18,15 @@
 import _ from 'lodash';
 import dataTable from '@frame/components/filter-page-table';
 import detailFrame from '@frame/layout/admin/detail-frame';
+import sendForm from './parts/send-form';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: student } = createNamespacedHelpers('student');
+const { mapActions: notice } = createNamespacedHelpers('notice');
 export default {
   name: 'remind',
   props: {},
-  components: { detailFrame, dataTable },
+  components: { detailFrame, dataTable, sendForm },
   data: function() {
     return {
       loading: false,
@@ -38,11 +44,16 @@ export default {
         { label: '批次', prop: 'batch' },
         { label: '班级', prop: 'name' },
       ],
+      dialogSend: false,
+      form: {},
+      classid: '',
     };
   },
   created() {},
   methods: {
     ...classes(['query']),
+    ...student({ getStudentList: 'query' }),
+    ...notice({ noticeCreate: 'create' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let { termid } = this.options;
       const res = await this.query({ skip, limit, ...info, termid });
@@ -51,8 +62,31 @@ export default {
         this.$set(this, `total`, res.total);
       }
     },
+    // 通知打开
     toSendMsg({ data }) {
-      this.sendMsg([data._id]);
+      this.$set(this, `classid`, data.id);
+      this.dialogSend = true;
+    },
+    // 取消提交
+    resetForm() {
+      this.form = {};
+      this.dialogSend = false;
+    },
+    // 通知确定
+    async submitForm({ data }) {
+      let classid = this.classid;
+      let res = await this.getStudentList({ classid });
+      var notified = res.data.map(item => ({ notifiedid: item.id }));
+      data.noticeid = this.user.id;
+      data.notified = notified;
+      const arr = await this.noticeCreate(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '通知成功',
+          type: 'success',
+        });
+        this.resetForm();
+      }
     },
     toSelect(val) {
       this.selected = val;