|
@@ -1,7 +1,18 @@
|
|
|
<template>
|
|
|
<div id="index">
|
|
|
<list-frame :title="mainTitle" @query="search" :needFilter="false" :needAdd="false" :needPag="false">
|
|
|
- <data-table :fields="fields" :data="list" :opera="opera" @apply="toApply"></data-table>
|
|
|
+ <el-alert type="success" effect="dark" :title="`您申请的科目为:${getTeaSubject()}`" center :closable="false"></el-alert>
|
|
|
+ <data-table :fields="fields" :data="list" :opera="opera" @apply="toApply">
|
|
|
+ <template #custom="{item, row}">
|
|
|
+ <template v-if="item.prop === 'time'">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" v-for="(i, index) in row[item.prop]" :key="`${index}`">
|
|
|
+ {{ i }}
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-table>
|
|
|
</list-frame>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -13,73 +24,84 @@ import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions } = createNamespacedHelpers('trainplan');
|
|
|
const { mapActions: teaplan } = createNamespacedHelpers('teaplan');
|
|
|
const { mapActions: teacher } = createNamespacedHelpers('teacher');
|
|
|
+const { mapActions: subject } = createNamespacedHelpers('subject');
|
|
|
|
|
|
export default {
|
|
|
metaInfo: { title: '计划一览' },
|
|
|
name: 'index',
|
|
|
props: {},
|
|
|
components: { listFrame, dataTable },
|
|
|
- data: () => ({
|
|
|
- opera: [
|
|
|
- {
|
|
|
- label: '申请授课',
|
|
|
- icon: 'el-icon-document',
|
|
|
- method: 'apply',
|
|
|
- display: i => !i.is_apply,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '已上报本期',
|
|
|
- display: i => i.is_apply,
|
|
|
- },
|
|
|
- ],
|
|
|
- fields: [
|
|
|
- { label: '期', prop: 'term' },
|
|
|
- { label: '开始日期', prop: 'start' },
|
|
|
- { label: '结束日期', prop: 'end' },
|
|
|
- ],
|
|
|
- list: [],
|
|
|
- needConfirm: true,
|
|
|
- }),
|
|
|
- created() {
|
|
|
+ data: function() {
|
|
|
+ var _this = this;
|
|
|
+ return {
|
|
|
+ teacher: {},
|
|
|
+ opera: [
|
|
|
+ {
|
|
|
+ label: '申请授课',
|
|
|
+ icon: 'el-icon-document',
|
|
|
+ method: 'apply',
|
|
|
+ display: i => !_this.applyList.find(f => f.termid == i.termid && f.date == i.day),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '已上报本期',
|
|
|
+ display: i => _this.applyList.find(f => f.termid == i.termid && f.date == i.day),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ fields: [
|
|
|
+ { label: '期', prop: 'term' },
|
|
|
+ { label: '科目', prop: 'subname' },
|
|
|
+ { label: '日期', prop: 'day' },
|
|
|
+ { label: '时间', prop: 'time', custom: true },
|
|
|
+ ],
|
|
|
+ list: [],
|
|
|
+ subjectList: [],
|
|
|
+ applyList: [],
|
|
|
+ needConfirm: true,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ this.getSubject();
|
|
|
+ await this.getTeacherInfo();
|
|
|
this.search();
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...subject({ getSubjectList: 'query' }),
|
|
|
...teacher({ getTeacher: 'fetch' }),
|
|
|
...mapActions(['query', 'delete', 'fetch']),
|
|
|
...teaplan({ apply: 'create', applyFetch: 'query' }),
|
|
|
+ async getTeacherInfo() {
|
|
|
+ const res = await this.getTeacher(this.user.userid);
|
|
|
+ if (res.errcode == '0') this.$set(this, `teacher`, res.data);
|
|
|
+ else this.$message.error(res.errmsg || '未找到教师信息');
|
|
|
+ },
|
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
let { planid } = this.defaultOption;
|
|
|
let res = await this.fetch(planid);
|
|
|
if (this.$checkRes(res)) {
|
|
|
let { termnum } = res.data;
|
|
|
- termnum = termnum.map(i => {
|
|
|
- let { batchnum } = i;
|
|
|
- let sb = _.head(_.orderBy(batchnum, ['startdate'], ['asc']));
|
|
|
- if (sb) i.start = sb.startdate;
|
|
|
- let eb = _.head(_.orderBy(batchnum, ['enddate'], ['desc']));
|
|
|
- if (eb) i.end = eb.enddate;
|
|
|
- return i;
|
|
|
- });
|
|
|
- this.$set(this, `list`, termnum);
|
|
|
+ let arr = [];
|
|
|
+ arr = termnum
|
|
|
+ .map(t => {
|
|
|
+ let { term, _id: termid } = t;
|
|
|
+ let obj = { term, termid };
|
|
|
+ let lessons = t.batchnum.map(b => b.lessons.map(l => ({ ...l, ...obj })));
|
|
|
+ return lessons.flat();
|
|
|
+ })
|
|
|
+ .flat();
|
|
|
+ arr = arr.filter(f => f.subid === this.teacher.subid);
|
|
|
+ this.$set(this, `list`, arr);
|
|
|
this.searchApply();
|
|
|
}
|
|
|
},
|
|
|
async searchApply() {
|
|
|
const res = await this.applyFetch({ teacherid: this.user.userid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- let dl = _.cloneDeep(res.data);
|
|
|
- let dtl = _.cloneDeep(this.list);
|
|
|
- dtl = dtl.map(i => {
|
|
|
- let r = dl.find(f => f.termid == i._id);
|
|
|
- if (r) i.is_apply = true;
|
|
|
- return i;
|
|
|
- });
|
|
|
- this.$set(this, `list`, dtl);
|
|
|
+ this.$set(this, 'applyList', res.data);
|
|
|
}
|
|
|
},
|
|
|
async toApply({ data }) {
|
|
|
if (this.needConfirm) {
|
|
|
- this.$confirm('申请上课后,您将不能删除该数据,若出现误报等问题,请与中心人员沟通', '提示', {
|
|
|
+ this.$confirm('申请上课后,您将不能撤销申请,若出现误报等问题,请与中心人员沟通,中心人员需要进行调整', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning',
|
|
@@ -90,14 +112,20 @@ export default {
|
|
|
} else this.teaApply(data);
|
|
|
},
|
|
|
async teaApply(data) {
|
|
|
- let { _id: termid } = data;
|
|
|
+ let { termid, day: date } = data;
|
|
|
let { userid: teacherid } = this.user;
|
|
|
- const teacherInfo = await this.getTeacher(teacherid);
|
|
|
- if (teacherInfo) {
|
|
|
- const { subid } = teacherInfo.data;
|
|
|
- const res = await this.apply({ termid, subid, teacherid });
|
|
|
- if (this.$checkRes(res, '申请成功', res.errmsg || '申请失败')) this.search();
|
|
|
- } else this.$message.error('未找到教师信息');
|
|
|
+ const { subid } = this.teacher;
|
|
|
+ const res = await this.apply({ termid, subid, teacherid, date });
|
|
|
+ if (this.$checkRes(res, '申请成功', res.errmsg || '申请失败')) this.search();
|
|
|
+ },
|
|
|
+ async getSubject() {
|
|
|
+ const res = await this.getSubjectList();
|
|
|
+ if (res.errcode == '0') this.$set(this, `subjectList`, res.data);
|
|
|
+ },
|
|
|
+ getTeaSubject() {
|
|
|
+ const { subid } = this.teacher;
|
|
|
+ const res = this.subjectList.find(f => f._id == subid);
|
|
|
+ if (res) return res.name;
|
|
|
},
|
|
|
},
|
|
|
computed: {
|