lrf402788946 4 years ago
parent
commit
086f867d5c
2 changed files with 89 additions and 39 deletions
  1. 88 38
      src/views/train-plan/remind-detail.vue
  2. 1 1
      src/views/train-plan/term-lesson.vue

+ 88 - 38
src/views/train-plan/remind-detail.vue

@@ -1,16 +1,24 @@
 <template>
-  <div id="remind-detail">
-    <detail-frame :title="pageTitle" returns="/train/plan/remind">
-      <el-tabs v-model="activeName" type="card">
-        <el-tab-pane label="学生" name="first">
-          <data-table :fields="fields" :data="stuList" :opera="opera" :usePage="false"></data-table>
-        </el-tab-pane>
-        <el-tab-pane label="非学生" name="second">
-          <data-table :fields="fields" :data="nostuList" :opera="opera" :usePage="false"></data-table>
-        </el-tab-pane>
-      </el-tabs>
-      <!-- @msg="toSendMsg" @view="toView" -->
+  <div id="remind">
+    <detail-frame :title="pageTitle" v-if="view === 'list'" returns="/train/plan/remind">
+      <el-row type="flex" align="middle" justify="end" class="btn_bar">
+        <el-col :span="2">
+          <el-button type="primary" size="mini" @click="toSendMsg()">发送通知</el-button>
+        </el-col>
+      </el-row>
+      <data-table :fields="fields" :data="list" :opera="opera" @view="toView" :total="total" @query="search"></data-table>
     </detail-frame>
+    <detail-frame title="通知确认" v-if="view === 'result'" :returns="toReturns">
+      <el-row type="flex" align="middle" justify="end" class="btn_bar">
+        <el-col :span="3">
+          <el-button type="primary" size="mini" @click="toResend()">再次通知未确认人员</el-button>
+        </el-col>
+      </el-row>
+      <data-table :fields="resFields" :data="result.notified" :opera="[]" :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>
 
@@ -18,62 +26,104 @@
 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.vue';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: notice } = createNamespacedHelpers('notice');
 export default {
-  name: 'remind-detail',
+  name: 'remind',
   props: {},
-  components: { detailFrame, dataTable },
+  components: { detailFrame, dataTable, sendForm },
   data: function() {
     return {
-      // 学生
-      stuList: [],
-      // 非学生
-      nostuList: [],
+      view: 'list',
+      loading: false,
+      options: undefined,
+      list: [],
+      total: 0,
       opera: [
-        {
-          label: '发送确认通知',
-          icon: 'el-icon-message-solid',
-          method: 'msg',
-        },
         {
           label: '查看通知情况',
           icon: 'el-icon-view',
           method: 'view',
         },
       ],
-      fields: [
-        { label: '名称', prop: 'name' },
-        { label: '电话', prop: 'phone' },
-        { label: '邮箱', prop: 'email' },
+      fields: [{ label: '内容', prop: 'content' }],
+      dialogSend: false,
+      form: {
+        type: '0',
+      },
+      result: {},
+      resFields: [
+        { label: '通知人员', prop: 'username' },
+        { label: '状态', prop: 'status', format: i => (i == '0' ? '未确认' : '已确认') },
       ],
-      activeName: 'first',
     };
   },
   created() {
     this.search();
   },
   methods: {
-    ...notice({ getNoticeList: 'query', getClassInfo: 'classList' }),
-    async search() {
-      let t = await this.getNoticeList();
-      let res = await this.getClassInfo(this.id);
+    ...notice({ noticeCreate: 'create', getNotice: 'query', resend: 'resend' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let classid = this.classid;
+      if (!classid) return;
+      const res = await this.getNotice({ skip, limit, ...info, classid });
       if (this.$checkRes(res)) {
-        let studList = _.get(res.data, `students`, []);
-        let teaList = _.get(res.data, `teachers`, []);
-        this.$set(this, `stuList`, _.uniqBy(studList, '_id'));
-        this.$set(this, `nostuList`, _.uniqBy(teaList, '_id'));
-        // let arr = [...studList, ...teaList];
-        // this.$set(this, `list`, _.uniqBy(arr, '_id'));
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
       }
     },
+    // 通知打开
+    toSendMsg({ data } = {}) {
+      if (data) this.$set(this, `classid`, data.id);
+      this.dialogSend = true;
+    },
+    // 取消提交
+    resetForm() {
+      this.form = {};
+      this.dialogSend = false;
+    },
+    // 通知确定
+    async submitForm({ data }) {
+      let classid = this.classid;
+      if (classid) {
+        data.classid = classid;
+      }
+      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.search();
+        this.resetForm();
+      }
+    },
+    toView({ data }) {
+      this.$set(this, `result`, data);
+      this.view = 'result';
+    },
+    toReturns() {
+      this.view = 'list';
+    },
+    async toResend() {
+      const { _id } = this.result;
+      console.log(this.result);
+      const res = await this.resend({ id: _id });
+      if (res.errcode == '0') this.$message.success('再次通知成功');
+      else this.$message.error(res.errmsg || '通知失败');
+    },
   },
+  watch: {},
   computed: {
     ...mapState(['user', 'defaultOption']),
     pageTitle() {
       return `${this.$route.meta.title}`;
     },
-    id() {
+    classid() {
       return this.$route.query.id;
     },
   },

+ 1 - 1
src/views/train-plan/term-lesson.vue

@@ -401,7 +401,7 @@ export default {
     async getHeadTeacher(data) {
       let batchid;
       let { type } = data;
-      let { planid, termid } = this.options;
+      let { planid, termid } = this.defaultOption;
       let keys = Object.keys(data).filter(f => f.includes('classid'));
       if (keys.length <= 0) return;
       let cla = this.classList.find(f => f._id == data[keys[0]]);