lrf402788946 4 anni fa
parent
commit
62295e2408

+ 1 - 1
src/router/index.js

@@ -37,7 +37,7 @@ const routes = [
         path: '/train/plan/remind',
         name: 'remind_index',
         meta: { title: '班级列表', act: '通知' },
-        component: () => import('@/views/classes/classes.vue'),
+        component: () => import('@/views/classes/remind.vue'),
       },
       {
         path: '/student/index',

+ 2 - 0
src/store/index.js

@@ -24,6 +24,7 @@ import util from '@frame/store/util';
 import attendance from '@frame/store/attendance';
 import leave from '@frame/store/leave';
 import setting from '@frame/store/setting';
+import notice from '@frame/store/notice';
 import trainBatch from '@frame/store/train-plan-year';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
@@ -58,6 +59,7 @@ export default new Vuex.Store({
     setting,
     trainBatch,
     questionanswer,
+    notice,
   },
   state: { ...ustate, ...dostate },
   mutations: { ...umutations, ...domutations },

+ 72 - 0
src/views/classes/parts/send-form.vue

@@ -0,0 +1,72 @@
+<template>
+  <div id="send-form">
+    <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">
+              通知内容
+            </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>

+ 149 - 0
src/views/classes/remind.vue

@@ -0,0 +1,149 @@
+<template>
+  <div id="remind">
+    <detail-frame :title="pageTitle" v-if="view === 'list'">
+      <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>
+
+<script>
+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',
+  props: {},
+  components: { detailFrame, dataTable, sendForm },
+  data: function() {
+    return {
+      view: 'list',
+      loading: false,
+      options: undefined,
+      list: [],
+      total: 0,
+      opera: [
+        {
+          label: '查看通知情况',
+          icon: 'el-icon-view',
+          method: 'view',
+        },
+      ],
+      fields: [{ label: '内容', prop: 'content' }],
+      dialogSend: false,
+      form: {
+        type: '0',
+      },
+      result: {},
+      resFields: [
+        { label: '通知人员', prop: 'username' },
+        { label: '状态', prop: 'status', format: i => (i == '0' ? '未确认' : '已确认') },
+      ],
+    };
+  },
+  created() {},
+  methods: {
+    ...notice({ noticeCreate: 'create', getNotice: 'query', resend: 'resend' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let { classid } = this.options;
+      if (!classid) return;
+      const res = await this.getNotice({ skip, limit, ...info, classid });
+      if (this.$checkRes(res)) {
+        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.defaultOption;
+      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: {
+    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', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>