|
@@ -31,8 +31,8 @@
|
|
</el-card>
|
|
</el-card>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="16" :style="`width:${widths}px`">
|
|
<el-col :span="16" :style="`width:${widths}px`">
|
|
- <el-card ref="card">
|
|
|
|
- <calendar :useDraft="false" @eventClick="eventClick" :events="events"></calendar>
|
|
|
|
|
|
+ <el-card ref="card" v-if="info.year">
|
|
|
|
+ <calendar :year="info.year" :useDraft="false" @eventClick="eventClick" :events="events"></calendar>
|
|
</el-card>
|
|
</el-card>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
@@ -45,7 +45,8 @@ import detailFrame from '@frame/layout/admin/detail-frame';
|
|
import calendar from '@frame/components/calendar';
|
|
import calendar from '@frame/components/calendar';
|
|
import dataTable from '@frame/components/data-table';
|
|
import dataTable from '@frame/components/data-table';
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
-import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
|
|
+import { createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions } = createNamespacedHelpers('trainplan');
|
|
export default {
|
|
export default {
|
|
metaInfo: { title: '计划详情' },
|
|
metaInfo: { title: '计划详情' },
|
|
name: 'detail',
|
|
name: 'detail',
|
|
@@ -58,13 +59,14 @@ export default {
|
|
batchnum: [],
|
|
batchnum: [],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
-
|
|
|
|
form: {},
|
|
form: {},
|
|
events: [],
|
|
events: [],
|
|
collapse: '1',
|
|
collapse: '1',
|
|
fields: [
|
|
fields: [
|
|
- { label: '期数', prop: 'term' },
|
|
|
|
|
|
+ // { label: '期数', prop: 'termnum' },
|
|
|
|
+ { label: '名称', prop: 'name' },
|
|
{ label: '班级类型', prop: 'type', format: item => (item === '0' ? '正常班级' : '特殊班级') },
|
|
{ label: '班级类型', prop: 'type', format: item => (item === '0' ? '正常班级' : '特殊班级') },
|
|
|
|
+ { label: '总人数', prop: 'number', format: item => `${item}人` },
|
|
],
|
|
],
|
|
opera: [
|
|
opera: [
|
|
{
|
|
{
|
|
@@ -76,132 +78,61 @@ export default {
|
|
],
|
|
],
|
|
heights: 250,
|
|
heights: 250,
|
|
selected: [],
|
|
selected: [],
|
|
- axiosData: {
|
|
|
|
- termnum: [
|
|
|
|
- {
|
|
|
|
- term: '1',
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- start: '2020-01-01',
|
|
|
|
- end: '2020-01-09',
|
|
|
|
- type: '0',
|
|
|
|
- number: '56',
|
|
|
|
- color: '#0BEB95',
|
|
|
|
- batch: '1',
|
|
|
|
- class: '1',
|
|
|
|
- title: '第1期第1批次',
|
|
|
|
- id: 'p1580869239498',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- start: '2020-01-01',
|
|
|
|
- end: '2020-01-09',
|
|
|
|
- type: '1',
|
|
|
|
- number: '56',
|
|
|
|
- color: '#409EFF',
|
|
|
|
- name: '第一期特殊1班',
|
|
|
|
- title: '第一期特殊1班',
|
|
|
|
- id: 'p1580869422722',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 2,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- term: '2',
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- start: '2020-01-01',
|
|
|
|
- end: '2020-01-09',
|
|
|
|
- type: '0',
|
|
|
|
- number: '56',
|
|
|
|
- color: '#0BEB95',
|
|
|
|
- batch: '1',
|
|
|
|
- class: '1',
|
|
|
|
- title: '第2期第1批次',
|
|
|
|
- id: 'p1580869239490',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- start: '2020-01-01',
|
|
|
|
- end: '2020-01-09',
|
|
|
|
- type: '1',
|
|
|
|
- number: '56',
|
|
|
|
- color: '#409EFF',
|
|
|
|
- name: '第二期特殊1班',
|
|
|
|
- title: '第二期特殊1班',
|
|
|
|
- id: 'p1580869422723',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- start: '2020-01-01',
|
|
|
|
- end: '2020-01-09',
|
|
|
|
- type: '1',
|
|
|
|
- number: '56',
|
|
|
|
- color: '#409EFF',
|
|
|
|
- name: '第二期特殊2班',
|
|
|
|
- title: '第二期特殊2班',
|
|
|
|
- id: 'p1580869422726',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 3,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- term: '3',
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- start: '2020-01-01',
|
|
|
|
- end: '2020-01-09',
|
|
|
|
- type: '0',
|
|
|
|
- number: '56',
|
|
|
|
- color: '#ff4444',
|
|
|
|
- batch: '1',
|
|
|
|
- class: '1',
|
|
|
|
- title: '第3期第1批次',
|
|
|
|
- id: 'p1580869239499',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 1,
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- title: 'test',
|
|
|
|
- year: 2020,
|
|
|
|
- },
|
|
|
|
}),
|
|
}),
|
|
- created() {
|
|
|
|
- if (this.isNew) this.$set(this.info, `year`, new Date().getFullYear());
|
|
|
|
- },
|
|
|
|
|
|
+ created() {},
|
|
mounted() {},
|
|
mounted() {},
|
|
methods: {
|
|
methods: {
|
|
- // ...mapClass(['fetch', 'create', 'update']),
|
|
|
|
|
|
+ ...mapActions(['fetch', 'create', 'update']),
|
|
//查询计划
|
|
//查询计划
|
|
async search() {
|
|
async search() {
|
|
- // const res = await this.fetch(this.id);
|
|
|
|
- // if (this.$checkRes(res)) this.$set(this, `info`, res.data);
|
|
|
|
- // this.loading = false;
|
|
|
|
|
|
+ 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 = [];
|
|
let events = [];
|
|
events = _.flatten(
|
|
events = _.flatten(
|
|
- this.axiosData.termnum.map(item => {
|
|
|
|
|
|
+ midArr.termnum.map(item => {
|
|
item.batchnum.map(i => {
|
|
item.batchnum.map(i => {
|
|
i.term = item.term;
|
|
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, delete i.name;
|
|
return i;
|
|
return i;
|
|
});
|
|
});
|
|
return item.batchnum;
|
|
return item.batchnum;
|
|
})
|
|
})
|
|
);
|
|
);
|
|
- let { termnum, year, title } = this.axiosData;
|
|
|
|
|
|
+ //这个events不完整,真正的events还需要将假期的数据整合至一起
|
|
|
|
+ // 不需要知道哪些是安排的计划.没有计划简表,计划简表=>上报时间表
|
|
|
|
+ //TODO,服务端修改后,整理假期事件并整合
|
|
|
|
+ console.log(events);
|
|
|
|
+ // 假期中添加一个字段 editable:false,只有假期有这个字段
|
|
this.$set(this, `events`, events);
|
|
this.$set(this, `events`, events);
|
|
- this.$set(this, `info`, { title, year });
|
|
|
|
},
|
|
},
|
|
//日历事件点击事件
|
|
//日历事件点击事件
|
|
eventClick({ event }) {
|
|
eventClick({ event }) {
|
|
let arr = this.events.filter(fil => fil.id == event.id);
|
|
let arr = this.events.filter(fil => fil.id == event.id);
|
|
let object = {};
|
|
let object = {};
|
|
- if (arr.length > 0) object = arr[0];
|
|
|
|
- else {
|
|
|
|
|
|
+ let nextArr = [];
|
|
|
|
+ if (arr.length > 0) {
|
|
|
|
+ //有这个事件
|
|
|
|
+ object = arr[0];
|
|
|
|
+ //再判断这个类型是普通,还是特殊;如果是普通类型:则需要将这一期的所有普通类型都查出来;特殊类型直接object
|
|
|
|
+ if (object.type === '0') nextArr = this.events.filter(f => f.termid === object.termid && f.type === '0');
|
|
|
|
+ if (!_.get(object, 'editable', true)) {
|
|
|
|
+ this.$message.warning('不能上报假期的时间');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
console.warn(`无对应id事件`);
|
|
console.warn(`无对应id事件`);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- let { term, type, name, termid, number } = object;
|
|
|
|
|
|
+
|
|
|
|
+ let { type, termid, id } = object;
|
|
//查重,先查期数一致,再查类型
|
|
//查重,先查期数一致,再查类型
|
|
//期数没有,则加入;期数有,则看类型,如果是普通班级,则不加入;如果是特殊班级,则查该期是否有特殊班级的id,没有就加入
|
|
//期数没有,则加入;期数有,则看类型,如果是普通班级,则不加入;如果是特殊班级,则查该期是否有特殊班级的id,没有就加入
|
|
- let data = object;
|
|
|
|
let re = () => {
|
|
let re = () => {
|
|
this.$notify({
|
|
this.$notify({
|
|
title: '重复添加该期',
|
|
title: '重复添加该期',
|
|
@@ -213,20 +144,22 @@ export default {
|
|
title: '已添加',
|
|
title: '已添加',
|
|
});
|
|
});
|
|
};
|
|
};
|
|
- if (_.findIndex(this.selected, i => i.term === term) >= 0) {
|
|
|
|
- //重复加入
|
|
|
|
|
|
+ // 需要判断期id和期类型
|
|
|
|
+ let isSelected = this.selected.filter(i => i.termid === termid && i.type == type);
|
|
|
|
+ if (isSelected.length > 0) {
|
|
|
|
+ //普通班=>重复加入
|
|
if (type === '0') re();
|
|
if (type === '0') re();
|
|
else {
|
|
else {
|
|
- // TODO此处需要根据实际有没有id可以区分开每期特殊班和特殊班,目前用name来区分
|
|
|
|
- let res = _.findIndex(this.selected, i => {
|
|
|
|
- if (i.name) return i.name === name;
|
|
|
|
- else return false;
|
|
|
|
- });
|
|
|
|
|
|
+ // 特殊班=>使用id(batchid,批的id)判断
|
|
|
|
+ let res = this.selected.filter(f => f.id === id);
|
|
//特殊班重复加入
|
|
//特殊班重复加入
|
|
- if (res > 0) re();
|
|
|
|
- else push(data); //加入
|
|
|
|
|
|
+ if (res.length > 0) re();
|
|
|
|
+ else push(this.setSchoolDate(object)); //加入
|
|
}
|
|
}
|
|
- } else push(data);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ if (type === '0') push(this.setSchoolDate(nextArr));
|
|
|
|
+ else push(this.setSchoolDate(object)); //加入
|
|
|
|
+ }
|
|
},
|
|
},
|
|
//列表删除事件
|
|
//列表删除事件
|
|
toDelete({ data, index }) {
|
|
toDelete({ data, index }) {
|
|
@@ -239,7 +172,8 @@ export default {
|
|
//TODO整理数据
|
|
//TODO整理数据
|
|
let data = { ...this.info };
|
|
let data = { ...this.info };
|
|
arr = arr.map(i => {
|
|
arr = arr.map(i => {
|
|
- return { termnum: i.termnum, termid: i.id, number: '未计算,使用实际数据计算' };
|
|
|
|
|
|
+ console.log(i);
|
|
|
|
+ return { termnum: i.termnum, termid: i.termid, number: '未计算,使用实际数据计算' };
|
|
});
|
|
});
|
|
data.term = arr;
|
|
data.term = arr;
|
|
//最后加入schoolId
|
|
//最后加入schoolId
|
|
@@ -249,13 +183,36 @@ export default {
|
|
let heights = this.$refs.card.$el.clientHeight * 0.63;
|
|
let heights = this.$refs.card.$el.clientHeight * 0.63;
|
|
this.$set(this, `heights`, heights);
|
|
this.$set(this, `heights`, heights);
|
|
},
|
|
},
|
|
|
|
+ //添加上报时间
|
|
|
|
+ setSchoolDate(object) {
|
|
|
|
+ let data = JSON.parse(JSON.stringify(object));
|
|
|
|
+ //整合出的数据需要有 期数 termnum;期id termid; 人数 number
|
|
|
|
+ //因为点击普通类型,就会将这一期的所有普通类型添加进去,所以需要用data数组去计算筛选出来的所有事件的人数,期数和期id随意提取一个就好
|
|
|
|
+ //特殊类型就是data是object
|
|
|
|
+ //所以直接判断,如果_.isArray(data) => 是普通类型的,按普通类型处理;反之为特殊类型,按特殊类型处理
|
|
|
|
+ let res = {};
|
|
|
|
+ if (_.isArray(data)) {
|
|
|
|
+ res.number = data.reduce((pre, cur) => pre + parseInt(cur.class) * parseInt(cur.number), 0);
|
|
|
|
+ res.termnum = JSON.parse(JSON.stringify(data[0].term));
|
|
|
|
+ res.termid = JSON.parse(JSON.stringify(data[0].termid));
|
|
|
|
+ res.type = JSON.parse(JSON.stringify(data[0].type));
|
|
|
|
+ res.name = `第${res.termnum}期`;
|
|
|
|
+ } else {
|
|
|
|
+ res.number = JSON.parse(JSON.stringify(data.number));
|
|
|
|
+ res.termnum = JSON.parse(JSON.stringify(data.term));
|
|
|
|
+ res.termid = JSON.parse(JSON.stringify(data.termid));
|
|
|
|
+ res.type = JSON.parse(JSON.stringify(data.type));
|
|
|
|
+ res.name = JSON.parse(JSON.stringify(data.title));
|
|
|
|
+ res.id = JSON.parse(JSON.stringify(data._id));
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
isNew: {
|
|
isNew: {
|
|
immediate: true,
|
|
immediate: true,
|
|
handler(val) {
|
|
handler(val) {
|
|
- if (val) this.loading = false;
|
|
|
|
- else this.search();
|
|
|
|
|
|
+ if (!val) this.search();
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -268,7 +225,7 @@ export default {
|
|
return this.$route.query.id;
|
|
return this.$route.query.id;
|
|
},
|
|
},
|
|
isNew() {
|
|
isNew() {
|
|
- return this.$route.query.id ? true : false; //false : true;
|
|
|
|
|
|
+ return this.$route.query.id ? false : true;
|
|
},
|
|
},
|
|
mainTitle() {
|
|
mainTitle() {
|
|
let meta = this.$route.meta;
|
|
let meta = this.$route.meta;
|