|
@@ -7,6 +7,9 @@
|
|
<el-col :span="2">
|
|
<el-col :span="2">
|
|
<el-button type="primary" size="mini" @click="dialog = true">生成模板计划</el-button>
|
|
<el-button type="primary" size="mini" @click="dialog = true">生成模板计划</el-button>
|
|
</el-col>
|
|
</el-col>
|
|
|
|
+ <el-col :span="2">
|
|
|
|
+ <el-button type="primary" size="mini" @click="savePlan">保存计划</el-button>
|
|
|
|
+ </el-col>
|
|
</el-row>
|
|
</el-row>
|
|
<table-cal :events="events" :vacation="vacation" @cellClick="eventClick"></table-cal>
|
|
<table-cal :events="events" :vacation="vacation" @cellClick="eventClick"></table-cal>
|
|
</el-card>
|
|
</el-card>
|
|
@@ -19,6 +22,8 @@
|
|
:vacation="vacation"
|
|
:vacation="vacation"
|
|
:isNew="formIsNew"
|
|
:isNew="formIsNew"
|
|
:predefineColors="template.color"
|
|
:predefineColors="template.color"
|
|
|
|
+ :classTypeList="classTypeList"
|
|
|
|
+ :loading.sync="eventLoading"
|
|
@save="setEvent"
|
|
@save="setEvent"
|
|
@delete="toDelete"
|
|
@delete="toDelete"
|
|
></event>
|
|
></event>
|
|
@@ -33,7 +38,7 @@
|
|
<el-col :span="24">至少需要 {{ template.leastDay }} 天 <span>(无假期等任何影响安排的因素)</span></el-col>
|
|
<el-col :span="24">至少需要 {{ template.leastDay }} 天 <span>(无假期等任何影响安排的因素)</span></el-col>
|
|
<el-col :span="24">
|
|
<el-col :span="24">
|
|
<span>每期有 {{ template | getBatchNum }} 批</span>
|
|
<span>每期有 {{ template | getBatchNum }} 批</span>
|
|
- <span>每批需要 {{ template.day }} 天</span>
|
|
|
|
|
|
+ <span>;每批需要 {{ template.day }} 天</span>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24" v-for="(b, index) in template.batchnum" :key="index">
|
|
<el-col :span="24" v-for="(b, index) in template.batchnum" :key="index">
|
|
第{{ b.batch }}批:<el-col style="padding-left:20px" :span="24" v-for="(c, cindex) in b.classnum" :key="cindex"
|
|
第{{ b.batch }}批:<el-col style="padding-left:20px" :span="24" v-for="(c, cindex) in b.classnum" :key="cindex"
|
|
@@ -49,6 +54,11 @@
|
|
<el-input-number v-model="input.termnum"></el-input-number>
|
|
<el-input-number v-model="input.termnum"></el-input-number>
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <el-form-item label="请选择班级类型">
|
|
|
|
+ <el-select v-model="input.classType">
|
|
|
|
+ <el-option v-for="(i, index) in classTypeList" :key="index" :label="i.name" :value="i.code"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
<el-form-item label="请选择开始日期">
|
|
<el-form-item label="请选择开始日期">
|
|
<el-date-picker
|
|
<el-date-picker
|
|
:picker-options="pickerOptions"
|
|
:picker-options="pickerOptions"
|
|
@@ -101,6 +111,7 @@ const { mapActions } = createNamespacedHelpers('trainplan');
|
|
const { mapActions: trainTemplate } = createNamespacedHelpers('trainTemplate');
|
|
const { mapActions: trainTemplate } = createNamespacedHelpers('trainTemplate');
|
|
const { mapActions: schPlan } = createNamespacedHelpers('schPlan');
|
|
const { mapActions: schPlan } = createNamespacedHelpers('schPlan');
|
|
const { mapActions: util } = createNamespacedHelpers('util');
|
|
const { mapActions: util } = createNamespacedHelpers('util');
|
|
|
|
+const { mapActions: classtype } = createNamespacedHelpers('classtype');
|
|
export default {
|
|
export default {
|
|
name: 'arrange',
|
|
name: 'arrange',
|
|
props: {},
|
|
props: {},
|
|
@@ -119,153 +130,12 @@ export default {
|
|
year: '2020',
|
|
year: '2020',
|
|
},
|
|
},
|
|
form: {},
|
|
form: {},
|
|
- events: [
|
|
|
|
- {
|
|
|
|
- term: 1,
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-07',
|
|
|
|
- enddate: '2020-04-12',
|
|
|
|
- batch: '1',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#E60000',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-08',
|
|
|
|
- enddate: '2020-04-13',
|
|
|
|
- batch: '2',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#E60000',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-09',
|
|
|
|
- enddate: '2020-04-14',
|
|
|
|
- batch: '3',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- { class: '3', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#E60000',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 7,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- term: 2,
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-13',
|
|
|
|
- enddate: '2020-04-18',
|
|
|
|
- batch: '1',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#FF7300',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-14',
|
|
|
|
- enddate: '2020-04-19',
|
|
|
|
- batch: '2',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#FF7300',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-15',
|
|
|
|
- enddate: '2020-04-20',
|
|
|
|
- batch: '3',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- { class: '3', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#FF7300',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 7,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- term: 3,
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-19',
|
|
|
|
- enddate: '2020-04-24',
|
|
|
|
- batch: '1',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#996B1F',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-20',
|
|
|
|
- enddate: '2020-04-25',
|
|
|
|
- batch: '2',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#996B1F',
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-21',
|
|
|
|
- enddate: '2020-04-26',
|
|
|
|
- batch: '3',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- { class: '3', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#996B1F',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 7,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- term: 4,
|
|
|
|
- batchnum: [
|
|
|
|
- {
|
|
|
|
- startdate: '2020-04-25',
|
|
|
|
- enddate: '2020-04-30',
|
|
|
|
- batch: '1',
|
|
|
|
- class: [
|
|
|
|
- { class: '1', number: '56' },
|
|
|
|
- { class: '2', number: '56' },
|
|
|
|
- ],
|
|
|
|
- color: '#FFD700',
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- classnum: 2,
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
|
|
+ events: [],
|
|
vacation: undefined,
|
|
vacation: undefined,
|
|
dialog: false,
|
|
dialog: false,
|
|
- selfBtn: {
|
|
|
|
- term: {
|
|
|
|
- text: '生成模板计划',
|
|
|
|
- click: () => (that.dialog = true),
|
|
|
|
- position: 'left',
|
|
|
|
- },
|
|
|
|
- plan: {
|
|
|
|
- text: '保存培训计划',
|
|
|
|
- click: () => that.savePlan(),
|
|
|
|
- position: 'right',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
input: {
|
|
input: {
|
|
termnum: 1,
|
|
termnum: 1,
|
|
- start: '2020-04-01',
|
|
|
|
- end: '2020-10-31',
|
|
|
|
|
|
+ classType: '0',
|
|
},
|
|
},
|
|
pickerOptions: {
|
|
pickerOptions: {
|
|
disabledDate: time => that.checkDate(time),
|
|
disabledDate: time => that.checkDate(time),
|
|
@@ -275,19 +145,27 @@ export default {
|
|
drawer: false,
|
|
drawer: false,
|
|
formIsNew: true,
|
|
formIsNew: true,
|
|
options: {},
|
|
options: {},
|
|
|
|
+ classTypeList: [],
|
|
|
|
+ eventLoading: false,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- created() {},
|
|
|
|
|
|
+ async created() {
|
|
|
|
+ this.getOtherList();
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
...mapActions(['fetch', 'update']),
|
|
...mapActions(['fetch', 'update']),
|
|
...trainTemplate({ trainTemplate: 'query' }),
|
|
...trainTemplate({ trainTemplate: 'query' }),
|
|
...schPlan({ setSchPlan: 'schArrange' }),
|
|
...schPlan({ setSchPlan: 'schArrange' }),
|
|
...util({ modelFetch: 'fetch' }),
|
|
...util({ modelFetch: 'fetch' }),
|
|
|
|
+ ...classtype({ getClassType: 'query' }),
|
|
async search() {
|
|
async search() {
|
|
let planid = _.get(this.defaultOption, 'planid');
|
|
let planid = _.get(this.defaultOption, 'planid');
|
|
if (!planid) return;
|
|
if (!planid) return;
|
|
const res = await this.fetch(planid);
|
|
const res = await this.fetch(planid);
|
|
if (this.$checkRes(res)) {
|
|
if (this.$checkRes(res)) {
|
|
|
|
+ this.$set(this, `info`, res.data);
|
|
|
|
+ let data = _.cloneDeep(res.data);
|
|
|
|
+ this.$set(this, `events`, _.cloneDeep(data.termnum));
|
|
let fest = _.get(res.data, 'festivals', []);
|
|
let fest = _.get(res.data, 'festivals', []);
|
|
let vac = fest.map(i => {
|
|
let vac = fest.map(i => {
|
|
let object = {};
|
|
let object = {};
|
|
@@ -301,29 +179,6 @@ export default {
|
|
return object;
|
|
return object;
|
|
});
|
|
});
|
|
this.$set(this, `vacation`, vac);
|
|
this.$set(this, `vacation`, vac);
|
|
- 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, index) => {
|
|
|
|
- i.termid = item._id;
|
|
|
|
- i.term = item.term;
|
|
|
|
- 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;
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
- events = events.map((i, index) => {
|
|
|
|
- i.index = index;
|
|
|
|
- return i;
|
|
|
|
- });
|
|
|
|
- // this.$set(this, `events`, events);
|
|
|
|
}
|
|
}
|
|
this.searchTemplate();
|
|
this.searchTemplate();
|
|
},
|
|
},
|
|
@@ -334,27 +189,27 @@ export default {
|
|
this.$message('正在自动生成计划,请稍后...');
|
|
this.$message('正在自动生成计划,请稍后...');
|
|
this.dialog = false;
|
|
this.dialog = false;
|
|
let isOk = false;
|
|
let isOk = false;
|
|
- let { start, end, termnum } = this.input;
|
|
|
|
|
|
+ let { start, end, termnum, classType } = this.input;
|
|
let { batchnum, term, total } = this.template;
|
|
let { batchnum, term, total } = this.template;
|
|
let event = []; //处理成功事件的存储
|
|
let event = []; //处理成功事件的存储
|
|
let wtotal = 0,
|
|
let wtotal = 0,
|
|
wtermnum = 0;
|
|
wtermnum = 0;
|
|
- let { total: newTotal, termnum: newTerm, events } = this.toArrange(start, end, termnum, term, total);
|
|
|
|
|
|
+ let { total: newTotal, termnum: newTerm, events, isInRange } = this.toArrange(start, end, termnum, term, classType, total);
|
|
if (newTotal == 0) isOk = true;
|
|
if (newTotal == 0) isOk = true;
|
|
- else {
|
|
|
|
- wtotal = newTotal;
|
|
|
|
- wtermnum = newTerm;
|
|
|
|
- event = events;
|
|
|
|
- }
|
|
|
|
|
|
+ else if (!isInRange) isOk = true;
|
|
|
|
+ wtotal = newTotal;
|
|
|
|
+ wtermnum = newTerm;
|
|
|
|
+ event = events;
|
|
while (!isOk) {
|
|
while (!isOk) {
|
|
let nt = this.computedTerm(batchnum, wtotal);
|
|
let nt = this.computedTerm(batchnum, wtotal);
|
|
- let res = this.toArrange(start, end, wtermnum, nt, wtotal, event);
|
|
|
|
|
|
+ let res = this.toArrange(start, end, wtermnum, nt, classType, wtotal, event);
|
|
|
|
+ // console.log(res);
|
|
|
|
+ // isOk = true;
|
|
if (res.total == 0) isOk = true;
|
|
if (res.total == 0) isOk = true;
|
|
- else {
|
|
|
|
- wtotal = res.total;
|
|
|
|
- wtermnum = res.termnum;
|
|
|
|
- event = events;
|
|
|
|
- }
|
|
|
|
|
|
+ else if (!res.isInRange) isOk = true;
|
|
|
|
+ wtotal = res.total;
|
|
|
|
+ wtermnum = res.termnum;
|
|
|
|
+ event = events;
|
|
}
|
|
}
|
|
this.$set(this, `events`, event);
|
|
this.$set(this, `events`, event);
|
|
},
|
|
},
|
|
@@ -364,10 +219,12 @@ export default {
|
|
// termnum:手动输入开始的期数
|
|
// termnum:手动输入开始的期数
|
|
// total:剩余人数
|
|
// total:剩余人数
|
|
// events:已有安排,第一次不用传,再安排需要
|
|
// events:已有安排,第一次不用传,再安排需要
|
|
- toArrange(start, end, termnum, term, total, events = []) {
|
|
|
|
|
|
+ toArrange(start, end, termnum, term, classType, total, events = []) {
|
|
let { day, batchnum } = this.template;
|
|
let { day, batchnum } = this.template;
|
|
|
|
+ let iirr = true;
|
|
for (let i = 0; i < term; i++) {
|
|
for (let i = 0; i < term; i++) {
|
|
if (total == 0) break;
|
|
if (total == 0) break;
|
|
|
|
+ if (!iirr) break;
|
|
let bnum = [];
|
|
let bnum = [];
|
|
for (const b of batchnum) {
|
|
for (const b of batchnum) {
|
|
if (total == 0) break;
|
|
if (total == 0) break;
|
|
@@ -399,20 +256,24 @@ export default {
|
|
//判断在不在假期
|
|
//判断在不在假期
|
|
if (r) break;
|
|
if (r) break;
|
|
let isInRange = this.isInRange(startdate, enddate, start, end);
|
|
let isInRange = this.isInRange(startdate, enddate, start, end);
|
|
|
|
+ console.log(startdate, enddate, isInRange);
|
|
let classes = [];
|
|
let classes = [];
|
|
//判断不在手选的时间范围内
|
|
//判断不在手选的时间范围内
|
|
- if (!isInRange) break;
|
|
|
|
|
|
+ if (!isInRange) {
|
|
|
|
+ iirr = false;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
let bobj = { startdate, enddate, batch: b.batch };
|
|
let bobj = { startdate, enddate, batch: b.batch };
|
|
for (const c of b.classnum) {
|
|
for (const c of b.classnum) {
|
|
|
|
+ let { class: name, number } = c;
|
|
|
|
+ let type = classType;
|
|
if (total * 1 - c.number * 1 >= 0) {
|
|
if (total * 1 - c.number * 1 >= 0) {
|
|
- let nc = _.omit(_.cloneDeep(c), ['_id']);
|
|
|
|
total = total * 1 - c.number * 1;
|
|
total = total * 1 - c.number * 1;
|
|
- classes.push(nc);
|
|
|
|
|
|
+ classes.push({ name, number, type });
|
|
} else {
|
|
} else {
|
|
- let nc = _.omit(_.cloneDeep(c), ['_id']);
|
|
|
|
- nc.number = total;
|
|
|
|
|
|
+ number = total;
|
|
total = 0;
|
|
total = 0;
|
|
- classes.push(nc);
|
|
|
|
|
|
+ classes.push({ name, number, type });
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -429,7 +290,7 @@ export default {
|
|
events.push(obj);
|
|
events.push(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- let obj = { total, termnum, events };
|
|
|
|
|
|
+ let obj = { total, termnum, events, isInRange: iirr };
|
|
return obj;
|
|
return obj;
|
|
},
|
|
},
|
|
//默认事件排序
|
|
//默认事件排序
|
|
@@ -444,102 +305,81 @@ export default {
|
|
});
|
|
});
|
|
return _.flatten(arr);
|
|
return _.flatten(arr);
|
|
},
|
|
},
|
|
- //模板事件结束
|
|
|
|
- //将期数改为手动输入的
|
|
|
|
- nameTerm(events, start) {
|
|
|
|
- let duplicate = _.cloneDeep(events);
|
|
|
|
- duplicate = duplicate.map(i => {
|
|
|
|
- i.term = start * 1 + i.term - 1;
|
|
|
|
- i.title = `第${i.term}期第${i.batch}批次`;
|
|
|
|
- return i;
|
|
|
|
- });
|
|
|
|
- return duplicate;
|
|
|
|
- },
|
|
|
|
//手动操作事件开始
|
|
//手动操作事件开始
|
|
- setEvent({ data, isNew }) {
|
|
|
|
|
|
+ async setEvent({ data, isNew }) {
|
|
data = JSON.parse(JSON.stringify(data));
|
|
data = JSON.parse(JSON.stringify(data));
|
|
- if (data.type == 0) {
|
|
|
|
- data.title = `第${data.term}期第${data.batch}批次`;
|
|
|
|
|
|
+ if (isNew) {
|
|
|
|
+ let { term, ...info } = data;
|
|
|
|
+ //新添,找是不是在已知 期 中添加的信息
|
|
|
|
+ let res = this.events.find(f => f.term == term);
|
|
|
|
+ if (res) {
|
|
|
|
+ //找:是不是修改已知 批次 中信息
|
|
|
|
+ let termIndex = this.events.findIndex(f => f.term == term);
|
|
|
|
+ let batchIndex = res.batchnum.findIndex(f => f.batch == info.batch);
|
|
|
|
+ //是修改已知批次,就将信息放进去
|
|
|
|
+ if (batchIndex >= 0) this.$set(this.events[termIndex].batchnum, batchIndex, info);
|
|
|
|
+ else {
|
|
|
|
+ //新添批次,取出来=>复制=>赋回去,保证刷新视图
|
|
|
|
+ let duplicate = _.cloneDeep(this.events[termIndex].batchnum);
|
|
|
|
+ duplicate.push(info);
|
|
|
|
+ this.$set(this.events[termIndex], `batchnum`, duplicate);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //需要处理该数据为期[批次[班级的形式]]
|
|
|
|
+ let { term, batch, name: cl, ...info } = data;
|
|
|
|
+ let ta = { term, classnum: cl.length };
|
|
|
|
+ let tb = { batch, ...info, name: cl };
|
|
|
|
+ ta.batchnum = [tb];
|
|
|
|
+ this.events.push(ta);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- let { name } = data;
|
|
|
|
- data = { ...data, title: name };
|
|
|
|
|
|
+ let { term, ...info } = data;
|
|
|
|
+ let res = this.events.find(f => f.term == term);
|
|
|
|
+ if (res) {
|
|
|
|
+ let termIndex = this.events.findIndex(f => f.term == term);
|
|
|
|
+ let batchIndex = res.batchnum.findIndex(f => f.batch == info.batch);
|
|
|
|
+ if (batchIndex >= 0) this.$set(this.events[termIndex].batchnum, batchIndex, info);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- this.$set(this.events, data.index, data);
|
|
|
|
this.toClose();
|
|
this.toClose();
|
|
},
|
|
},
|
|
-
|
|
|
|
- //列表编辑事件
|
|
|
|
- toEdit({ data, index }) {
|
|
|
|
- this.$set(this, `form`, JSON.parse(JSON.stringify(data)));
|
|
|
|
- this.formIsNew = false;
|
|
|
|
- this.drawer = true;
|
|
|
|
- },
|
|
|
|
- //列表删除事件
|
|
|
|
- toDelete({ data, index }) {
|
|
|
|
- this.$set(
|
|
|
|
- this,
|
|
|
|
- `events`,
|
|
|
|
- this.events.filter(f => f.index !== data.index)
|
|
|
|
- );
|
|
|
|
|
|
+ //列表删除事件,一定是删除批次,班级属于内部信息,期需要自己把批次都删了
|
|
|
|
+ toDelete(data) {
|
|
|
|
+ console.log(data);
|
|
|
|
+ let { term, batch } = data;
|
|
|
|
+ let res = this.events.find(f => f.term == term);
|
|
|
|
+ if (res) {
|
|
|
|
+ let termIndex = this.events.findIndex(f => f.term == term);
|
|
|
|
+ let batchIndex = res.batchnum.findIndex(f => f.batch == batch);
|
|
|
|
+ if (batchIndex >= 0) this.events[termIndex].batchnum.splice(batchIndex, 1);
|
|
|
|
+ }
|
|
this.toClose();
|
|
this.toClose();
|
|
},
|
|
},
|
|
//计划保存
|
|
//计划保存
|
|
savePlan() {
|
|
savePlan() {
|
|
let data = JSON.parse(JSON.stringify(this.info));
|
|
let data = JSON.parse(JSON.stringify(this.info));
|
|
let plan = JSON.parse(JSON.stringify(this.events));
|
|
let plan = JSON.parse(JSON.stringify(this.events));
|
|
- let termnum = [];
|
|
|
|
- termnum = _.uniqBy(
|
|
|
|
- plan.map(item => {
|
|
|
|
- let obj = { term: item.term };
|
|
|
|
- if (item.termid) obj._id = item.termid;
|
|
|
|
- return obj;
|
|
|
|
- }),
|
|
|
|
- 'term'
|
|
|
|
- ).map(i => {
|
|
|
|
- let object = _.cloneDeep(i);
|
|
|
|
- object.batchnum = plan
|
|
|
|
- .filter(fil => fil.term === i.term)
|
|
|
|
- .map(b => {
|
|
|
|
- b = _.pickBy(b, (val, key) => key !== 'term');
|
|
|
|
- b.startdate = JSON.parse(JSON.stringify(b.start));
|
|
|
|
- b.enddate = JSON.parse(JSON.stringify(b.end));
|
|
|
|
- b.name ? b.name : (b.name = JSON.parse(JSON.stringify(b.title)));
|
|
|
|
- delete b.start, delete b.end;
|
|
|
|
- if (_.startsWith(b.id, 'eve') || _.startsWith(b.id, 'vac')) delete b.id;
|
|
|
|
- return b;
|
|
|
|
- });
|
|
|
|
- object.classnum = object.batchnum.reduce((pre, cur) => {
|
|
|
|
- if (cur.type === '0') return pre + parseInt(cur.class);
|
|
|
|
- else return pre + 1;
|
|
|
|
- }, 0);
|
|
|
|
- return object;
|
|
|
|
- });
|
|
|
|
- data.termnum = termnum;
|
|
|
|
|
|
+ data.termnum = plan;
|
|
let res;
|
|
let res;
|
|
let msg;
|
|
let msg;
|
|
res = this.update(data);
|
|
res = this.update(data);
|
|
msg = `计划保存成功`;
|
|
msg = `计划保存成功`;
|
|
this.$checkRes(res, msg);
|
|
this.$checkRes(res, msg);
|
|
},
|
|
},
|
|
- //选择时间的事件
|
|
|
|
- selectDate(object) {
|
|
|
|
- let start = JSON.parse(JSON.stringify(object.startStr));
|
|
|
|
- let end = JSON.parse(JSON.stringify(object.endStr));
|
|
|
|
- this.$set(this.form, `start`, start);
|
|
|
|
- this.$set(this.form, `end`, end);
|
|
|
|
- this.$set(this.form, `index`, this.events.length);
|
|
|
|
- this.drawer = true;
|
|
|
|
- this.formIsNew = true;
|
|
|
|
- },
|
|
|
|
- //
|
|
|
|
|
|
+ //添加/修改事件
|
|
eventClick(event) {
|
|
eventClick(event) {
|
|
- if (event) this.formIsNew = false;
|
|
|
|
- let res = this.events.find(f => f.term == event.term);
|
|
|
|
- if (res) {
|
|
|
|
- let { term } = res;
|
|
|
|
- res = res.batchnum.find(f => f.batch == event.batch);
|
|
|
|
- let obj = { ...res, term };
|
|
|
|
- this.$set(this, `form`, obj);
|
|
|
|
|
|
+ if (_.isObject(event)) {
|
|
|
|
+ this.formIsNew = false;
|
|
|
|
+ let res = this.events.find(f => f.term == event.term);
|
|
|
|
+ if (res) {
|
|
|
|
+ let { term } = res;
|
|
|
|
+ res = res.batchnum.find(f => f.batch == event.batch);
|
|
|
|
+ let obj = { ...res, term };
|
|
|
|
+ this.$set(this, `form`, obj);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //新添只允许添加一个批次,一个批次一个批次添加
|
|
|
|
+ this.$set(this, `form`, { startdate: event, class: [] });
|
|
}
|
|
}
|
|
this.drawer = true;
|
|
this.drawer = true;
|
|
// this.formIsNew = false;
|
|
// this.formIsNew = false;
|
|
@@ -595,12 +435,6 @@ export default {
|
|
let res = moment(date).isBetween(`${year}-01-01`, `${year}-12-31`, null, '[]');
|
|
let res = moment(date).isBetween(`${year}-01-01`, `${year}-12-31`, null, '[]');
|
|
return !res;
|
|
return !res;
|
|
},
|
|
},
|
|
- async toSave(schPlan) {
|
|
|
|
- const res = await this.setSchPlan(schPlan);
|
|
|
|
- if (this.$checkRes(res)) {
|
|
|
|
- this.savePlan();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
dayPlus(date, num) {
|
|
dayPlus(date, num) {
|
|
return moment(date)
|
|
return moment(date)
|
|
.add(num, 'days')
|
|
.add(num, 'days')
|
|
@@ -640,9 +474,11 @@ export default {
|
|
isInRange(start, end, rs, re) {
|
|
isInRange(start, end, rs, re) {
|
|
let sr = moment(start).isBetween(rs, re, null, '[]');
|
|
let sr = moment(start).isBetween(rs, re, null, '[]');
|
|
let er = moment(end).isBetween(rs, re, null, '[]');
|
|
let er = moment(end).isBetween(rs, re, null, '[]');
|
|
- let rsr = moment(rs).isBetween(start, end, null, '[]');
|
|
|
|
- let rer = moment(re).isBetween(start, end, null, '[]');
|
|
|
|
- return sr || er || rsr || rer;
|
|
|
|
|
|
+ return sr && er;
|
|
|
|
+ },
|
|
|
|
+ async getOtherList() {
|
|
|
|
+ const res = await this.getClassType();
|
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `classTypeList`, res.data);
|
|
},
|
|
},
|
|
},
|
|
},
|
|
filters: {
|
|
filters: {
|
|
@@ -664,6 +500,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
deep: true,
|
|
deep: true,
|
|
|
|
+ immediate: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|