|
@@ -15,6 +15,7 @@
|
|
|
</el-col> -->
|
|
|
</el-row>
|
|
|
<a-table
|
|
|
+ ref="planTabel"
|
|
|
:termList="termList"
|
|
|
:data="list"
|
|
|
@cellClick="cellClick"
|
|
@@ -132,6 +133,7 @@ const { mapActions: schPlan } = createNamespacedHelpers('schPlan');
|
|
|
// term-${termid}:${term}
|
|
|
// term_batch-${batchid}: ${termid} 关键变量,拿到它,就可以找到配套的其他所有变量
|
|
|
// arrange_id-${batchid}: ${_id}
|
|
|
+// remark-${batchid}: ${remark}
|
|
|
export default {
|
|
|
name: 'school-arrange',
|
|
|
props: {},
|
|
@@ -176,7 +178,6 @@ export default {
|
|
|
});
|
|
|
this.$set(this, `list`, school);
|
|
|
await this.getSchoolPlan();
|
|
|
- // await this.getTotal();
|
|
|
}
|
|
|
},
|
|
|
//自动安排提示确认
|
|
@@ -192,7 +193,8 @@ export default {
|
|
|
.catch(() => {});
|
|
|
},
|
|
|
//自动安排
|
|
|
- toArrange() {
|
|
|
+ async toArrange() {
|
|
|
+ let msg = this.$message({ message: '正在分配中,请稍后', duration: 0 });
|
|
|
this.toReset();
|
|
|
let school = this.list.filter(f => f.daterange);
|
|
|
//整理之后的学校列表
|
|
@@ -232,10 +234,14 @@ export default {
|
|
|
}
|
|
|
this.$set(this, `termList`, termList);
|
|
|
this.getCarTotal();
|
|
|
+ msg.close();
|
|
|
+ this.$message.success('分配完成');
|
|
|
},
|
|
|
//保存整体计划
|
|
|
async toSave() {
|
|
|
//修改学校上报计划,整理数据
|
|
|
+ //备注
|
|
|
+ let remarks = this.$refs.planTabel.remarks;
|
|
|
let duplicate = _.cloneDeep(this.list);
|
|
|
duplicate = duplicate.filter(f => Object.keys(f).find(key => key.includes('batch_total')));
|
|
|
let schPlan = duplicate.map((i, index) => {
|
|
@@ -252,18 +258,19 @@ export default {
|
|
|
let carnum = i[this.proAffix(batchid, 'car_total')] || 0;
|
|
|
//数据的原_id arrange_id-${batchid}
|
|
|
let _id = i[this.proAffix(batchid, 'arrange_id')];
|
|
|
+ //取出有备注的批次备注
|
|
|
+ let remark = remarks[batchid];
|
|
|
//去掉值为undefined的key和value
|
|
|
- arrange.push(_.pickBy({ _id, term, termid, batch, batchid, number, carnum }, _.identity));
|
|
|
+ arrange.push(_.pickBy({ _id, term, termid, batch, batchid, number, carnum, remark }, _.identity));
|
|
|
});
|
|
|
plan.arrange = arrange;
|
|
|
return plan;
|
|
|
// }
|
|
|
});
|
|
|
- console.log(schPlan);
|
|
|
- this.$set(this, `schPlan`, schPlan);
|
|
|
+ // this.$set(this, `schPlan`, schPlan);
|
|
|
schPlan = _.compact(schPlan);
|
|
|
- // const res = await this.setSchPlan(schPlan);
|
|
|
- // this.$checkRes(res, '保存成功', res.errmsg);
|
|
|
+ const res = await this.setSchPlan(schPlan);
|
|
|
+ this.$checkRes(res, '保存成功', res.errmsg);
|
|
|
},
|
|
|
cellClick(data) {
|
|
|
this.drawer = true;
|
|
@@ -378,15 +385,17 @@ export default {
|
|
|
i = this.changeRange(i);
|
|
|
if (arrange)
|
|
|
arrange.map(p => {
|
|
|
- let { termid, term, batchid, batch, number, carnum, _id } = p;
|
|
|
+ let { termid, term, batchid, batch, number, carnum, _id, remark } = p;
|
|
|
let obj = {};
|
|
|
obj[this.proAffix(batchid, 'term_batch')] = termid;
|
|
|
obj[this.proAffix(batchid, 'batch')] = batch;
|
|
|
- obj[this.proAffix(batchid, 'batch_total')] = number;
|
|
|
- obj[this.proAffix(batchid, 'car_total')] = carnum;
|
|
|
+ obj[this.proAffix(batchid, 'batch_total')] = parseInt(number);
|
|
|
+ obj[this.proAffix(batchid, 'car_total')] = parseInt(carnum);
|
|
|
obj[this.proAffix(termid, 'term')] = term;
|
|
|
obj[this.proAffix(batchid, 'arrange_id')] = _id;
|
|
|
+ obj[this.proAffix(batchid, 'remark')] = remark;
|
|
|
i = { ...i, ...obj };
|
|
|
+ i = _.pickBy(i, _.identity);
|
|
|
});
|
|
|
i.plan = plan;
|
|
|
}
|
|
@@ -394,10 +403,15 @@ export default {
|
|
|
});
|
|
|
this.$set(this, `list`, list);
|
|
|
//计算下期列表的情况
|
|
|
- this.computedTermList();
|
|
|
+ this.getTotal();
|
|
|
}
|
|
|
this.$set(this, `already`, true);
|
|
|
},
|
|
|
+ //回显计算
|
|
|
+ getTotal() {
|
|
|
+ this.computedTermList();
|
|
|
+ this.computedSchool();
|
|
|
+ },
|
|
|
//检查已分配的数据是否与现在的期对应
|
|
|
//TODO term=>arrange {termid,batchid都需要检测}
|
|
|
checkTerm(term) {
|
|
@@ -421,7 +435,6 @@ export default {
|
|
|
return i; //bpt:该批次总人数 ,remaining:剩余人数
|
|
|
});
|
|
|
this.$set(this, `termList`, res);
|
|
|
- this.already = true;
|
|
|
},
|
|
|
//整理计划=>和日历的 events 一样
|
|
|
resetEvents() {
|
|
@@ -582,8 +595,11 @@ export default {
|
|
|
let dl = _.cloneDeep(this.list);
|
|
|
let arr = dt.map(t => {
|
|
|
t.batchnum.map(b => {
|
|
|
- let { batchid, remaining, bpt } = b;
|
|
|
- let num = dl.reduce((prev, next) => prev + (next[this.proAffix(batchid, 'batch_total')] * 1 || 0), 0);
|
|
|
+ let { _id: batchid, remaining, bpt } = b;
|
|
|
+ let num = dl.reduce((prev, next) => {
|
|
|
+ let n = next[this.proAffix(batchid, 'batch_total')] * 1 || 0;
|
|
|
+ return prev + n;
|
|
|
+ }, 0);
|
|
|
let remainder = bpt - num;
|
|
|
b.remaining = remainder;
|
|
|
return b;
|
|
@@ -592,6 +608,22 @@ export default {
|
|
|
});
|
|
|
this.$set(this, `termList`, arr);
|
|
|
},
|
|
|
+ //根据当前情况重新计算学校剩余名额
|
|
|
+ computedSchool() {
|
|
|
+ let dl = _.cloneDeep(this.list);
|
|
|
+ dl = dl.map(i => {
|
|
|
+ let keys = Object.keys(i).filter(f => f.includes('batch_total'));
|
|
|
+ let { remaining } = i;
|
|
|
+ let n = keys.reduce((prev, next) => {
|
|
|
+ let num = i[next] || 0;
|
|
|
+ return prev + num;
|
|
|
+ }, 0);
|
|
|
+ i.remaining = remaining - n;
|
|
|
+ return i;
|
|
|
+ });
|
|
|
+ console.log(dl);
|
|
|
+ this.$set(this, `list`, dl);
|
|
|
+ },
|
|
|
},
|
|
|
filters: {
|
|
|
getProp(data, prop) {
|