|
@@ -77,14 +77,27 @@ export default {
|
|
|
created() {
|
|
|
this.search();
|
|
|
//TODO 正常来说:我是根据计划进来的,我需要查的不仅是计划的信息,还需要根据计划id和用户id查询出我曾经添加过的信息做回显及修改
|
|
|
+ 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: 'headerTeacherTest 99991' });
|
|
|
+ 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);
|
|
@@ -159,19 +172,18 @@ export default {
|
|
|
// 获取已选择的时间
|
|
|
let arr = JSON.parse(JSON.stringify(this.selected));
|
|
|
//TODO整理数据
|
|
|
- let { _id } = this.info;
|
|
|
+ let { _id, teaplanid } = this.info;
|
|
|
let object = { trainplanid: _id };
|
|
|
object.nobatchid = arr.map(i => i.id || i._id);
|
|
|
//TODO修改班主任id为登录用户的id
|
|
|
object.headteacherid = 'headerTeacherTest 99991';
|
|
|
- //TODO 此处需要根据什么条件来判断是修改还是添加
|
|
|
- let isNew = true;
|
|
|
let res;
|
|
|
let msg;
|
|
|
- if (isNew) {
|
|
|
+ if (!teaplanid) {
|
|
|
res = this.dirCreatPlan(object);
|
|
|
msg = `时间上报成功`;
|
|
|
} else {
|
|
|
+ object.id = teaplanid;
|
|
|
res = this.dirUpdatePlan(object);
|
|
|
msg = `时间修改成功`;
|
|
|
}
|