guhongwei 4 年之前
父节点
当前提交
4e59eaaa1d

+ 21 - 5
src/router/index.js

@@ -81,23 +81,39 @@ const routes = [
       {
       {
         path: '/teaching/index',
         path: '/teaching/index',
         name: 'teaching_index',
         name: 'teaching_index',
-        meta: { title: '在线授课管理' },
+        meta: { title: '直播讲课' },
         component: () => import('@/views/teaching/index.vue'),
         component: () => import('@/views/teaching/index.vue'),
       },
       },
       {
       {
         path: '/teaching/detail',
         path: '/teaching/detail',
         name: 'teaching_detail',
         name: 'teaching_detail',
-        meta: { title: '在线授课信息', sub: '管理' },
+        meta: { title: '直播讲课信息', sub: '管理' },
         component: () => import('@/views/teaching/detail.vue'),
         component: () => import('@/views/teaching/detail.vue'),
       },
       },
       {
       {
         path: '/teaching/live',
         path: '/teaching/live',
         name: 'teaching_live',
         name: 'teaching_live',
-        meta: { title: '在线直播', sub: '管理' },
+        meta: { title: '直播讲课', sub: '管理' },
         component: () => import('@/views/teaching/live.vue'),
         component: () => import('@/views/teaching/live.vue'),
       },
       },
-      // 在线直播
-      ,
+      {
+        path: '/teaching/afterClass',
+        name: 'teaching_afterClass',
+        meta: { title: '课后答疑', sub: '管理' },
+        component: () => import('@/views/teaching/afterClass.vue'),
+      },
+      {
+        path: '/teaching/afterClassDetail',
+        name: 'teaching_afterClassDetail',
+        meta: { title: '课后答疑', sub: '管理' },
+        component: () => import('@/views/teaching/afterClassDetail.vue'),
+      },
+      {
+        path: '/teaching/afterClassList',
+        name: 'teaching_afterClassList',
+        meta: { title: '答疑列表', sub: '管理' },
+        component: () => import('@/views/teaching/afterClassList.vue'),
+      },
     ],
     ],
   },
   },
   {
   {

+ 6 - 0
src/store/index.js

@@ -18,6 +18,9 @@ import uploadtask from '@frame/store/uploadtask';
 import task from '@frame/store/task';
 import task from '@frame/store/task';
 import teaplan from '@frame/store/tea-plan';
 import teaplan from '@frame/store/tea-plan';
 import liveroom from '@frame/store/liveroom';
 import liveroom from '@frame/store/liveroom';
+import answerapply from '@frame/store/answerapply';
+import chatroom from '@frame/store/chatroom';
+import answerchat from '@frame/store/answerchat';
 import * as ustate from '@frame/store/user/state';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
 import * as umutations from '@frame/store/user/mutations';
 import * as dostate from '@frame/store/setting/state';
 import * as dostate from '@frame/store/setting/state';
@@ -47,5 +50,8 @@ export default new Vuex.Store({
     task,
     task,
     teaplan,
     teaplan,
     liveroom,
     liveroom,
+    answerapply,
+    chatroom,
+    answerchat,
   },
   },
 });
 });

+ 110 - 0
src/views/teaching/afterClass.vue

@@ -0,0 +1,110 @@
+<template>
+  <div id="afterClass">
+    <list-frame :title="mainTitle" @query="search" :total="total" :needFilter="false" @add="$router.push({ path: '/teaching/afterClassDetail' })">
+      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete" :toFormat="toFormat"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: subject } = createNamespacedHelpers('subject');
+const { mapActions: answerapply } = createNamespacedHelpers('answerapply');
+export default {
+  metaInfo: { title: '课后答疑' },
+  name: 'afterClass',
+  props: {},
+  components: {
+    listFrame,
+    dataTable,
+  },
+  data: function() {
+    return {
+      opera: [
+        {
+          label: '编辑',
+          icon: 'el-icon-edit',
+          method: 'edit',
+          display: item => {
+            return item.status === '0' ? true : false;
+          },
+        },
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '科目名称', prop: 'subid', format: true },
+        { label: '状态', prop: 'status', format: i => (i === '0' ? '待审核' : i === '1' ? '审核通过' : '审核拒绝') },
+      ],
+      list: [],
+      total: 0,
+      // 查询科目
+      subjectList: [],
+    };
+  },
+  created() {
+    this.getOtherList();
+    this.search();
+  },
+  methods: {
+    ...subject({ getSubjectList: 'query' }),
+    ...answerapply(['query', 'delete']),
+    // 查询科目
+    async getOtherList() {
+      let res = await this.getSubjectList();
+      if (this.$checkRes(res)) {
+        this.$set(this, `subjectList`, res.data);
+      }
+    },
+    // 查询列表
+    async search({ skip, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, teacherid: this.user.userid, ...info });
+      if (this.$checkRes(res)) this.$set(this, `list`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: '/teaching/afterClassDetail', query: { id: data.id } });
+    },
+    // 删除
+    async toDelete({ data }) {
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '刪除信息成功',
+          type: 'success',
+        });
+        this.search();
+      }
+    },
+    // 过滤科目名称
+    toFormat({ model, value }) {
+      if (model == 'subid') {
+        const res = this.subjectList.find(f => f.id == value);
+        if (res) return res.name;
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      return `${main}${sub}`;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 145 - 0
src/views/teaching/afterClassDetail.vue

@@ -0,0 +1,145 @@
+<template>
+  <div id="afterClassDetail">
+    <detail-frame :title="mainTitle" returns="/teaching/afterClass">
+      <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
+        <template #options="{item}">
+          <template v-if="item.model === 'subid'">
+            <el-option v-for="(i, index) in subjectList" :key="index" :label="i.name" :value="i.id"></el-option>
+          </template>
+        </template>
+        <template #custom="{item}">
+          <template v-if="item.model == 'date'">
+            <el-date-picker v-model="dateArray" type="date" placeholder="请选择" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate">
+            </el-date-picker>
+            <el-col :span="24">
+              答疑时间:<span v-for="item in dateList" :key="item"
+                >{{ item }}<el-button type="text" size="mini" @click="deleteDate(item)">删除</el-button>;</span
+              >
+            </el-col>
+          </template>
+        </template>
+      </data-form>
+    </detail-frame>
+  </div>
+</template>
+
+<script>
+import detailFrame from '@frame/layout/admin/detail-frame';
+import dataForm from '@frame/components/form';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: subject } = createNamespacedHelpers('subject');
+const { mapActions: answerapply } = createNamespacedHelpers('answerapply');
+export default {
+  metaInfo: { title: '课后答疑' },
+  name: 'afterClassDetail',
+  props: {},
+  components: {
+    detailFrame,
+    dataForm,
+  },
+  data: function() {
+    return {
+      info: {},
+      fields: [
+        { label: '科目', required: true, model: 'subid', type: 'select' },
+        { label: '时间', required: false, model: 'date', custom: true },
+      ],
+      rules: {
+        subid: [{ required: true, message: '请选择科目名称' }],
+      },
+      // 科目列表
+      subjectList: [],
+      // 选择时间
+      dateArray: '',
+      // 时间列表
+      dateList: [],
+    };
+  },
+  created() {
+    this.getOtherList();
+    if (this.id) {
+      this.search();
+    }
+  },
+  methods: {
+    ...subject({ getSubjectList: 'query' }),
+    ...answerapply(['fetch', 'create', 'update']),
+    // 查詢詳情
+    async search() {
+      let res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `dateList`, res.data.date);
+        this.$set(this, `info`, res.data);
+      }
+    },
+    // 查询科目
+    async getOtherList() {
+      let res = await this.getSubjectList();
+      if (this.$checkRes(res)) {
+        this.$set(this, `subjectList`, res.data);
+      }
+    },
+    // 添加
+    async handleSave({ isNew, data }) {
+      let res;
+      let msg;
+      if (isNew) {
+        data.teacherid = this.user.userid;
+        data.teacher = this.user.name;
+        data.date = this.dateList;
+        console.log(data);
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
+      } else {
+        res = await this.update(data);
+        msg = `${this.keyWord}修改成功`;
+      }
+      if (this.$checkRes(res, msg)) this.$router.push({ path: '/teaching/afterClass' });
+    },
+    // 选择时间
+    changeDate(value) {
+      if (value == null || value == '') {
+        return;
+      } else {
+        this.dateList.push(value);
+      }
+      this.dateArray = '';
+    },
+    // 删除时间
+    deleteDate(index) {
+      this.dateList.splice(index, 1);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+    isNew() {
+      return this.$route.query.id ? false : true;
+    },
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      return `${main}${sub}`;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  watch: {
+    isNew: {
+      immediate: true,
+      handler(val) {
+        if (val) this.loading = false;
+        else this.search();
+      },
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 70 - 0
src/views/teaching/afterClassList.vue

@@ -0,0 +1,70 @@
+<template>
+  <div id="afterClassList">
+    <list-frame :title="mainTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
+      <data-table :fields="fields" :data="list" :opera="opera" @delete="toDelete"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: answerchat } = createNamespacedHelpers('answerchat');
+
+export default {
+  metaInfo: { title: '答疑列表' },
+  name: 'afterClassList',
+  props: {},
+  components: {
+    listFrame,
+    dataTable,
+  },
+  data: function() {
+    return {
+      opera: [
+        {
+          label: '删除',
+          icon: 'el-icon-delete',
+          method: 'delete',
+        },
+      ],
+      fields: [
+        { label: '房间号', prop: 'number' },
+        { label: '学生', prop: 'student' },
+      ],
+      list: [],
+      total: 0,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...answerchat(['query', 'delete']),
+    // 查询列表
+    async search({ skip, limit = 10, ...info } = {}) {
+      const res = await this.query({ skip, limit, teacherid: this.user.userid, ...info });
+      if (this.$checkRes(res)) this.$set(this, `list`, res.data);
+      this.$set(this, `total`, res.total);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    ...mapState(['user']),
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      return `${main}${sub}`;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>