|
@@ -209,8 +209,7 @@ export default {
|
|
|
schremaining = 0; //学校剩余名额 = 0
|
|
|
sch[this.proAffix(classtype, 'remaining')] = schremaining;
|
|
|
sch = this.computedSchRemaining(sch);
|
|
|
- //这个地方需要检查下所有 类型的 remaining
|
|
|
- console.log(sch, b);
|
|
|
+ //让循环自然结束就好了
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
@@ -300,6 +299,7 @@ export default {
|
|
|
sch[this.proAffix(b.termid, 'term')] = b.term; //记录该期 term-${termid} = term
|
|
|
sch[this.proAffix(b._id, 'batch')] = b.batch; //记录该批次 batch-${batchid} = batch
|
|
|
sch[this.proAffix(b._id, 'batch_total')] = number; //学校哪一批次有多少人,表格上显示的
|
|
|
+ // sch[this.proAffix(b._id, 'batch_type')] = b.classtype; //学校哪一批次有多少人,表格上显示的
|
|
|
return sch;
|
|
|
},
|
|
|
//将学校上报的月份数组[String]=>[{start,end}]方法
|
|
@@ -378,9 +378,7 @@ export default {
|
|
|
if (this.$checkRes(res)) {
|
|
|
let duplicate = _.cloneDeep(res.data);
|
|
|
let list = this.list.map((i, index) => {
|
|
|
- // console.log(i);
|
|
|
let plan = duplicate.find(f => f.schid == i.code);
|
|
|
- // console.log(plan);
|
|
|
if (plan) {
|
|
|
let { arrange, daterange } = plan;
|
|
|
i.daterange = daterange;
|
|
@@ -459,12 +457,34 @@ export default {
|
|
|
getCarTotal() {
|
|
|
let carpnum = this.template.carpnum * 1 || 53;
|
|
|
let list = this.list.map(i => {
|
|
|
- let keys = Object.keys(i).filter(f => f.includes('batch_total'));
|
|
|
- keys.map(key => {
|
|
|
- let { value: batchid } = this.proAffix(key);
|
|
|
- let carnum = Math.ceil(i[key] / carpnum);
|
|
|
- i[this.proAffix(batchid, 'car_total')] = carnum;
|
|
|
- });
|
|
|
+ //先排除学校就不需要车的
|
|
|
+ if (i.hascar == '1') {
|
|
|
+ //过滤出所有已分配批次的人数的 key
|
|
|
+ let keys = Object.keys(i).filter(f => f.includes('batch_total'));
|
|
|
+ keys.map(key => {
|
|
|
+ //将key 拆开 词缀固定不需要, 获得value=>batchid
|
|
|
+ let { value: batchid } = this.proAffix(key);
|
|
|
+ // 从 termList 找到该批次,找到批次中的 classtype 然后去查询classTypeList,看看这个类型的班级需不要派车
|
|
|
+ let ct;
|
|
|
+ for (const term of this.termList) {
|
|
|
+ let r = term.batchnum.find(f => f._id == batchid);
|
|
|
+ if (r) {
|
|
|
+ ct = _.get(r, `classtype`);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ct) {
|
|
|
+ let r = this.classTypeList.find(f => f.code == ct);
|
|
|
+ if (r) {
|
|
|
+ let hascar = _.get(r, 'hascar');
|
|
|
+ if (hascar == '1') {
|
|
|
+ let carnum = Math.ceil(i[key] / carpnum);
|
|
|
+ i[this.proAffix(batchid, 'car_total')] = carnum;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return i;
|
|
|
});
|
|
|
this.$set(this, `list`, list);
|
|
@@ -478,31 +498,53 @@ export default {
|
|
|
let sr = _.get(this.form.sch, 'remaining');
|
|
|
let pr = _.get(this.form.info, 'remaining');
|
|
|
let remainder = cv - ov;
|
|
|
- // console.log(cv, ov, remainder, sr, pr);
|
|
|
this.$set(this.form.sch, `remaining`, sr - remainder);
|
|
|
this.$set(this.form.info, `remaining`, pr - remainder);
|
|
|
},
|
|
|
//计算抽屉最大值
|
|
|
dGetMax(data) {
|
|
|
if (!this.drawer) return 0;
|
|
|
- // console.log(data);
|
|
|
let { num = 0, info, sch } = data;
|
|
|
- let { remaining: pl, bpt, _id: batchid } = info; //批次限制,批次总限制,批次id
|
|
|
+ let { remaining: pl, bpt, _id: batchid, classtype } = info; //批次限制,批次总限制,批次id
|
|
|
let { remaining: sl, number: spt, code } = sch; ////学校限制
|
|
|
- // console.log(pl, sl);
|
|
|
let res = 0;
|
|
|
//如果学校没有名额了,那么数字框内的最大值就是当前的值
|
|
|
if (sl == 0) {
|
|
|
- console.log('学校名额没了');
|
|
|
+ console.warn('学校名额没了');
|
|
|
res = num;
|
|
|
}
|
|
|
- //根据这个表来看,2中算法
|
|
|
+ //根据这个表来看,2种算法
|
|
|
// 1) 纵向计算(按批次算) 批次总限制 - 这批次 除了这个学校外 所有学校分配的人数之和
|
|
|
// 2) 横向计算(按学校算) 学校总限制 - 这个学校 除了当前批次外 所有批次的分配的人数之和
|
|
|
//如果批次限制 大于 学校限制:那么最大值 = 横向计算结果
|
|
|
if (pl > sl) {
|
|
|
- let keys = Object.keys(sch).filter(f => f.includes('batch_total') && f != this.proAffix(batchid, 'batch_total'));
|
|
|
- let obj = _.pick(sch, keys);
|
|
|
+ //需要过滤出这个在符合当前批次的班级类型的所有学生的key=>所有批次列表
|
|
|
+ let keys = Object.keys(sch)
|
|
|
+ .filter(f => f.includes('batch_total-'))
|
|
|
+ .map(i => {
|
|
|
+ let { value } = this.proAffix(i);
|
|
|
+ return value;
|
|
|
+ });
|
|
|
+ // 接着过滤,过滤出classtype符合条件的批次
|
|
|
+ let r = keys.filter(f => {
|
|
|
+ if (batchid == f) return false;
|
|
|
+ let midr = false;
|
|
|
+ for (const term of this.termList) {
|
|
|
+ //找到该期
|
|
|
+ let batch = term.batchnum.find(bf => bf._id == f);
|
|
|
+ if (batch) {
|
|
|
+ //判断该期的类型与现在要编辑的期的类型是不是一致的
|
|
|
+ if (batch.classtype == classtype) {
|
|
|
+ midr = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return midr;
|
|
|
+ });
|
|
|
+ // 过滤后的批次都是和这次编辑相同班级类型的班级
|
|
|
+ r = r.map(i => this.proAffix(i, 'batch_total'));
|
|
|
+ let obj = _.pick(sch, r);
|
|
|
let ot = Object.values(obj).reduce((prev, next) => prev + next * 1, 0);
|
|
|
res = spt * 1 - ot || 0;
|
|
|
}
|