lrf402788946 vor 4 Jahren
Ursprung
Commit
8fb911937b
1 geänderte Dateien mit 79 neuen und 5 gelöschten Zeilen
  1. 79 5
      src/views/train-plan/remind.vue

+ 79 - 5
src/views/train-plan/remind.vue

@@ -1,22 +1,96 @@
 <template>
   <div id="remind">
-    <p>remind</p>
+    <detail-frame :title="pageTitle">
+      <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-col>
+      </el-row>
+      <data-table :fields="fields" :data="list" :opera="opera" @msg="toSendMsg" :usePage="false"></data-table>
+    </detail-frame>
   </div>
 </template>
 
 <script>
+import _ from 'lodash';
+import dataTable from '@frame/components/filter-page-table';
+import detailFrame from '@frame/layout/admin/detail-frame';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: classes } = createNamespacedHelpers('classes');
 export default {
   name: 'remind',
   props: {},
-  components: {},
+  components: { detailFrame, dataTable },
   data: function() {
-    return {};
+    return {
+      loading: false,
+      options: undefined,
+      list: [],
+      total: 0,
+      opera: [
+        {
+          label: '发送确认通知',
+          icon: 'el-icon-message-solid',
+          method: 'msg',
+        },
+      ],
+      fields: [
+        { label: '批次', prop: 'batch' },
+        { label: '班级', prop: 'name' },
+      ],
+    };
   },
   created() {},
-  methods: {},
+  methods: {
+    ...classes(['query']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let { termid } = this.options;
+      const res = await this.query({ skip, limit, ...info, termid });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    toSendMsg({ data }) {
+      this.sendMsg([data._id]);
+    },
+    toSelect(val) {
+      this.selected = val;
+    },
+    async sendMsg(data) {
+      let classids = [];
+      if (data) {
+        //单发
+        classids = data;
+      } else {
+        //表格的多选,全发
+        classids = this.list.map(i => i._id);
+      }
+      const resNotice = await this.sendNotice({ classids });
+      this.$checkRes(resNotice, '发送成功', '发送失败');
+    },
+  },
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.search();
+        } else {
+          let ntermid = _.get(val, 'termid');
+          let otermid = _.get(this.options, 'termid');
+          if (ntermid && !_.isEqual(ntermid, otermid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.search();
+          }
+        }
+      },
+    },
+  },
   computed: {
-    ...mapState(['user']),
+    ...mapState(['user', 'defaultOption']),
     pageTitle() {
       return `${this.$route.meta.title}`;
     },