|
@@ -1,245 +0,0 @@
|
|
|
-<template>
|
|
|
- <div id="detail">
|
|
|
- <detail-frame :title="mainTitle" returns="/plan/index">
|
|
|
- <el-row :gutter="10" type="flex">
|
|
|
- <el-col :span="12">
|
|
|
- <el-card header="全年计划信息">
|
|
|
- <el-form :model="info" label-width="60px" size="small" @submit.native.prevent>
|
|
|
- <el-form-item label="年份">
|
|
|
- {{ info.year }}
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="标题" prop="title">
|
|
|
- {{ info.title }}
|
|
|
- </el-form-item>
|
|
|
- <!-- <el-form-item label="备注" prop="remark">
|
|
|
- <el-input v-model="info.remark" type="textarea" :autosize="{ minRows: 3, maxRows: 5 }"></el-input>
|
|
|
- </el-form-item> -->
|
|
|
-
|
|
|
- <el-collapse v-model="collapse" accordion>
|
|
|
- <el-collapse-item title="无法带班时间列表" name="1">
|
|
|
- <data-table :fields="fields" :data="selected" :opera="opera" @delete="toDelete" :height="heights"></data-table>
|
|
|
- </el-collapse-item>
|
|
|
- </el-collapse>
|
|
|
- <el-form-item>
|
|
|
- <el-row type="flex" align="middle" justify="space-around" style="margin-top:20px">
|
|
|
- <el-col :span="6">
|
|
|
- <el-button type="primary" @click="savePlan">上报时间</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </el-card>
|
|
|
- </el-col>
|
|
|
- <el-col :span="16" :style="`width:${widths}px`">
|
|
|
- <el-card ref="card">
|
|
|
- <calendar :useDraft="false" @eventClick="eventClick" :events="events"></calendar>
|
|
|
- </el-card>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </detail-frame>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<script>
|
|
|
-import detailFrame from '@frame/layout/admin/detail-frame';
|
|
|
-import calendar from '@frame/components/calendar';
|
|
|
-import dataTable from '@frame/components/data-table';
|
|
|
-import _ from 'lodash';
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions } = createNamespacedHelpers('trainplan');
|
|
|
-const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan');
|
|
|
-export default {
|
|
|
- metaInfo: { title: '计划详情' },
|
|
|
- name: 'detail',
|
|
|
- props: {},
|
|
|
- components: { detailFrame, calendar, dataTable },
|
|
|
- data: () => ({
|
|
|
- info: {},
|
|
|
- form: {},
|
|
|
- events: [],
|
|
|
- collapse: '1',
|
|
|
- fields: [
|
|
|
- { label: '名称', prop: 'name' },
|
|
|
- { label: '期数', prop: 'term' },
|
|
|
- { label: '班级类型', prop: 'type', format: item => (item === '0' ? '正常班级' : '特殊班级') },
|
|
|
- ],
|
|
|
- opera: [
|
|
|
- {
|
|
|
- label: '删除',
|
|
|
- icon: 'el-icon-delete',
|
|
|
- method: 'delete',
|
|
|
- confirm: true,
|
|
|
- },
|
|
|
- ],
|
|
|
- heights: 250,
|
|
|
- selected: [],
|
|
|
- }),
|
|
|
- created() {
|
|
|
- this.search();
|
|
|
- this.searchDir();
|
|
|
- },
|
|
|
- mounted() {},
|
|
|
- methods: {
|
|
|
- ...mapActions(['fetch', 'create', 'update']),
|
|
|
- ...dirPlan({
|
|
|
- dirQuery: 'query',
|
|
|
- dirCreatPlan: 'create',
|
|
|
- dirUpdatePlan: 'update',
|
|
|
- }),
|
|
|
- async searchDir() {
|
|
|
- let res = await this.dirQuery({ trainplanid: this.info.id, headteacherid: this.user.userid });
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- let data = JSON.parse(JSON.stringify(res.data));
|
|
|
- if (res.data.length > 0) {
|
|
|
- this.$set(this.info, `teaplanid`, data[0]._id);
|
|
|
- let nobatch = this.events.filter(f => _.find(_.flatten(data.map(i => i.nobatchid)), m => m === f.id));
|
|
|
- this.$set(this, `selected`, nobatch);
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- //查询计划
|
|
|
- async search() {
|
|
|
- const res = await this.fetch(this.id);
|
|
|
- if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
- let midArr = JSON.parse(JSON.stringify(res.data));
|
|
|
- let events = [];
|
|
|
- events = _.flatten(
|
|
|
- midArr.termnum.map(item => {
|
|
|
- item.batchnum.map(i => {
|
|
|
- i.term = item.term;
|
|
|
- i.termid = item._id; //需要使用期id
|
|
|
- i.id = i._id;
|
|
|
- i.start = JSON.parse(JSON.stringify(i.startdate));
|
|
|
- i.end = JSON.parse(JSON.stringify(i.enddate));
|
|
|
- i.title = JSON.parse(JSON.stringify(i.name));
|
|
|
- delete i.startdate, delete i.enddate;
|
|
|
- return i;
|
|
|
- });
|
|
|
- return item.batchnum;
|
|
|
- })
|
|
|
- );
|
|
|
- let vac = midArr.festivals.map(i => {
|
|
|
- let object = {};
|
|
|
- object.id = i._id;
|
|
|
- object.start = i.begindate;
|
|
|
- object.end = i.finishdate;
|
|
|
- object.rendering = 'background';
|
|
|
- object.color = 'red';
|
|
|
- object.editable = false;
|
|
|
- return object;
|
|
|
- });
|
|
|
- this.$set(this, `events`, events.concat(vac));
|
|
|
- },
|
|
|
- //日历事件点击事件
|
|
|
- eventClick({ event }) {
|
|
|
- let arr = this.events.filter(fil => fil.id == event.id);
|
|
|
- let object = {};
|
|
|
- if (arr.length > 0) {
|
|
|
- object = arr[0];
|
|
|
- if (_.has(object, 'editable')) {
|
|
|
- this.$message.warning(`不能选择假期`);
|
|
|
- return false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- console.warn(`无对应id事件`);
|
|
|
- return;
|
|
|
- }
|
|
|
- let { id } = object;
|
|
|
- //查重,查批数id是否存在,存在重复提示;不存在添加
|
|
|
- let data = object;
|
|
|
- let re = () => {
|
|
|
- this.$notify({
|
|
|
- title: '重复添加该批',
|
|
|
- });
|
|
|
- };
|
|
|
- let push = data => {
|
|
|
- this.selected.push(data);
|
|
|
- this.$notify({
|
|
|
- title: '已添加',
|
|
|
- });
|
|
|
- };
|
|
|
- let res = _.find(this.selected, i => i.id === id);
|
|
|
- if (!res) push(object);
|
|
|
- else re();
|
|
|
- },
|
|
|
- //列表删除事件
|
|
|
- toDelete({ data, index }) {
|
|
|
- this.selected.splice(index, 1);
|
|
|
- },
|
|
|
- //保存计划事件
|
|
|
- savePlan() {
|
|
|
- // 获取已选择的时间
|
|
|
- let arr = JSON.parse(JSON.stringify(this.selected));
|
|
|
- //整理数据
|
|
|
- let { _id, teaplanid } = this.info;
|
|
|
- let object = { trainplanid: _id };
|
|
|
- object.nobatchid = arr.map(i => i.id || i._id);
|
|
|
- //修改班主任id为登录用户的id
|
|
|
- object.headteacherid = this.user.userid;
|
|
|
- let res;
|
|
|
- let msg;
|
|
|
- if (!teaplanid) {
|
|
|
- res = this.dirCreatPlan(object);
|
|
|
- msg = `时间上报成功`;
|
|
|
- } else {
|
|
|
- object.id = teaplanid;
|
|
|
- res = this.dirUpdatePlan(object);
|
|
|
- msg = `时间修改成功`;
|
|
|
- }
|
|
|
- if (this.$checkRes(res, msg)) this.$router.push({ path: '/plan/index' });
|
|
|
- },
|
|
|
- setHeight() {
|
|
|
- let heights = this.$refs.card.$el.clientHeight * 0.63;
|
|
|
- this.$set(this, `heights`, heights);
|
|
|
- },
|
|
|
- inEvents(start, end, selectStart, selectEnd) {
|
|
|
- //选中的开始时间和结束时间任意一个时间在事件的范围内,则视为无法上课
|
|
|
- //前提:开始时间,结束时间都是不能带班的;逐个事件判断,无需考虑当前事件之外的事件
|
|
|
- //case1: 开始时间<事件开始时间;但是: 1,事件开始时间<=结束时间; 2,事件开始时间<=结束时间<=事件结束时间; 3,事件结束时间<结束时间 => 不能带班
|
|
|
- //case2: 事件开始时间<=开始时间<=事件结束时间 => 不能带班
|
|
|
- let s = new Date(start).getTime(), //事件的开始时间
|
|
|
- e = new Date(end).getTime(), //事件的结束时间
|
|
|
- ss = new Date(selectStart).getTime(), //选取的开始时间
|
|
|
- se = new Date(selectEnd).setDate(new Date(selectEnd).getDate() - 1); //选取的结束时间
|
|
|
- //-1:天是因为我认为教师画到哪天,其实之后那一天就没事了.不过组件 就返回选择结束的下一天,所以才出现-1天的问题
|
|
|
- let res = s <= ss && ss <= e;
|
|
|
- if (res) return true;
|
|
|
- //case2
|
|
|
- else if (ss < s) {
|
|
|
- // 开始时间<事件开始时间
|
|
|
- let res2 = s <= se;
|
|
|
- //case1
|
|
|
- if (res2) return true;
|
|
|
- else return false;
|
|
|
- } else return false;
|
|
|
- },
|
|
|
- },
|
|
|
- computed: {
|
|
|
- ...mapState(['user']),
|
|
|
- widths() {
|
|
|
- let width = (document.body.clientWidth - 200) * 0.5;
|
|
|
- return width > 400 ? width : 400;
|
|
|
- },
|
|
|
- id() {
|
|
|
- return this.$route.query.id;
|
|
|
- },
|
|
|
- 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>
|
|
|
-/deep/.el-divider--horizontal {
|
|
|
- margin: 5px 0;
|
|
|
-}
|
|
|
-</style>
|