|
@@ -4,8 +4,8 @@
|
|
|
<el-row :gutter="10" type="flex">
|
|
|
<el-col :span="12">
|
|
|
<el-card header="全年计划信息">
|
|
|
- <el-form :model="info" :rules="rules" label-width="60px" size="small" @submit.native.prevent>
|
|
|
- <el-form-item label="年份">
|
|
|
+ <el-form :model="info" :rules="rules" :isNew="isNew" label-width="60px" size="small" @submit.native.prevent>
|
|
|
+ <el-form-item label="年份" required>
|
|
|
{{ info.year }}
|
|
|
</el-form-item>
|
|
|
<el-form-item label="标题" prop="title" required>
|
|
@@ -77,6 +77,7 @@ import calendar from '@frame/components/calendar';
|
|
|
import dataTable from '@frame/components/data-table';
|
|
|
import _ from 'lodash';
|
|
|
import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: mapClass } = createNamespacedHelpers('trainplan');
|
|
|
export default {
|
|
|
metaInfo: { title: '计划详情' },
|
|
|
name: 'detail',
|
|
@@ -129,87 +130,21 @@ export default {
|
|
|
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: 'p1580869422724',
|
|
|
- },
|
|
|
- ],
|
|
|
+ batchnum: [],
|
|
|
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: 'p1580869422726',
|
|
|
- },
|
|
|
- {
|
|
|
- start: '2020-01-01',
|
|
|
- end: '2020-01-09',
|
|
|
- type: '1',
|
|
|
- number: '56',
|
|
|
- color: '#409EFF',
|
|
|
- name: '第二期特殊2班',
|
|
|
- title: '第二期特殊2班',
|
|
|
- id: 'p1580869422725',
|
|
|
- },
|
|
|
- ],
|
|
|
+ batchnum: [],
|
|
|
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',
|
|
|
- },
|
|
|
- ],
|
|
|
+ batchnum: [],
|
|
|
classnum: 1,
|
|
|
},
|
|
|
],
|
|
|
- title: 'test',
|
|
|
+ title: '',
|
|
|
year: 2020,
|
|
|
},
|
|
|
}),
|
|
@@ -218,12 +153,15 @@ export default {
|
|
|
},
|
|
|
mounted() {},
|
|
|
methods: {
|
|
|
+ ...mapClass(['fetch', 'create', 'update']),
|
|
|
// ...mapClass(['fetch', 'create', 'update']),
|
|
|
//查询计划
|
|
|
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);
|
|
|
+
|
|
|
+ this.loading = false;
|
|
|
let events = [];
|
|
|
events = _.flatten(
|
|
|
this.axiosData.termnum.map(item => {
|
|
@@ -234,8 +172,11 @@ export default {
|
|
|
return item.batchnum;
|
|
|
})
|
|
|
);
|
|
|
+ console.log(events);
|
|
|
let { termnum, year, title } = this.axiosData;
|
|
|
+
|
|
|
this.$set(this, `events`, events);
|
|
|
+
|
|
|
this.$set(this, `info`, { title, year });
|
|
|
},
|
|
|
//拖拽选择事件
|
|
@@ -264,10 +205,13 @@ export default {
|
|
|
this.events.splice(index, 1);
|
|
|
},
|
|
|
//保存计划事件
|
|
|
- savePlan() {
|
|
|
+ savePlan({ isNew }) {
|
|
|
//全年计划内容
|
|
|
+
|
|
|
let data = JSON.parse(JSON.stringify(this.info));
|
|
|
- data.year = this.year;
|
|
|
+
|
|
|
+ data.year = this.info.year;
|
|
|
+ console.log(data.year);
|
|
|
let termnum = [];
|
|
|
//1,获取所有期数
|
|
|
//2,按期数将events内数据分组
|
|
@@ -281,7 +225,18 @@ export default {
|
|
|
return object;
|
|
|
});
|
|
|
data.termnum = termnum;
|
|
|
- //TODO 连接接口
|
|
|
+ let res;
|
|
|
+ let msg;
|
|
|
+ console.log(this.isNew);
|
|
|
+ if (this.isNew) {
|
|
|
+ res = this.create(data);
|
|
|
+ console.log(data);
|
|
|
+ msg = `${this.keyWord}添加成功`;
|
|
|
+ } else {
|
|
|
+ res = this.update(data);
|
|
|
+ msg = `${this.keyWord}修改成功`;
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, msg)) this.$router.push({ path: '/plan/index' });
|
|
|
},
|
|
|
//保存表单函数
|
|
|
saveForm() {
|
|
@@ -356,7 +311,7 @@ export default {
|
|
|
return this.$route.query.id;
|
|
|
},
|
|
|
isNew() {
|
|
|
- return this.$route.query.id ? true : false; //false : true;
|
|
|
+ return this.$route.query.id ? false : true; //false : true;
|
|
|
},
|
|
|
mainTitle() {
|
|
|
let meta = this.$route.meta;
|