|
@@ -14,13 +14,13 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="批(可选)" v-if="usebatch">
|
|
|
- <el-select clearable v-model="form.batchid">
|
|
|
- <el-option v-for="(i, index) in batchList" :key="index" :label="`第${i.batch}批`" :value="i._id"></el-option>
|
|
|
+ <el-select clearable v-model="form.batchid" :multiple="mult">
|
|
|
+ <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="班(可选)" v-if="useclass">
|
|
|
- <el-select clearable v-model="form.classid" @change="selectClass">
|
|
|
- <el-option v-for="(c, index) in classList" :key="index" :label="`${c.name.includes('班') ? c.name : `${c.name}班`}`" :value="c._id"></el-option>
|
|
|
+ <el-select clearable v-model="form.classid" :multiple="mult" @change="selectClass">
|
|
|
+ <el-option v-for="(c, index) in classList" :key="index" :label="c.name" :value="c._id"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="人(可选)" v-if="usestudent">
|
|
@@ -89,31 +89,59 @@ export default {
|
|
|
// 找到批次列表,查询班级列表
|
|
|
async selectTerm(termids = []) {
|
|
|
let termid;
|
|
|
+ // 只要选了期,就重置后面的选项
|
|
|
+ this.$set(this.form, `classid`, undefined);
|
|
|
+ this.$set(this.form, `batchid`, undefined);
|
|
|
+ // 多选单选分开处理
|
|
|
if (this.mult) {
|
|
|
- if (termids.length != 1) {
|
|
|
- this.$set(this.form, `classid`, undefined);
|
|
|
- this.$set(this.form, `batchid`, undefined);
|
|
|
- return;
|
|
|
- }
|
|
|
- termid = _.head(termids);
|
|
|
- } else termid = termids;
|
|
|
- const r = this.termList.find(f => f._id === termid);
|
|
|
- if (!r) return;
|
|
|
- const { batchnum } = r;
|
|
|
- this.$set(this, `batchList`, batchnum);
|
|
|
- const stures = await this.getClass({ termid });
|
|
|
- if (this.$checkRes(stures)) {
|
|
|
- let duplicate = _.cloneDeep(stures.data);
|
|
|
- duplicate = duplicate.map(i => {
|
|
|
- if (parseInt(i.name)) {
|
|
|
- i.order = parseInt(i.name);
|
|
|
- } else {
|
|
|
- // i.order = i.name;
|
|
|
+ if (termids.length >= 1) {
|
|
|
+ // 再将选择的期下的批次提取出来,将名字改成带期数的.以便区分
|
|
|
+ const batchList = [];
|
|
|
+ const classList = [];
|
|
|
+ for (const tid of termids) {
|
|
|
+ // 找期下的批次
|
|
|
+ const r = this.termList.find(f => f._id === tid);
|
|
|
+ if (!r) continue;
|
|
|
+ const { batchnum = [], term } = r;
|
|
|
+ for (const i of batchnum) {
|
|
|
+ // 处理批次选项
|
|
|
+ i.name = `第${term}期-第${i.batch}批`;
|
|
|
+ batchList.push(i);
|
|
|
+ // 处理班级选项
|
|
|
+ const cRes = await this.getClass({ termid: tid, batchid: i._id });
|
|
|
+ if (this.$checkRes(cRes)) {
|
|
|
+ const cl = cRes.data;
|
|
|
+ for (const c of cl) {
|
|
|
+ c.name = `第${c.term}期-第${c.batch}批-${c.name}班`;
|
|
|
+ }
|
|
|
+ classList.push(...cl);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ // 批次列表
|
|
|
+ this.$set(this, `batchList`, batchList);
|
|
|
+ // 班级列表
|
|
|
+ this.$set(this, `classList`, classList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ termid = termids;
|
|
|
+ // 正常找期下的批次,班级
|
|
|
+ const r = this.termList.find(f => f._id === termid);
|
|
|
+ if (!r) return;
|
|
|
+ const { batchnum } = r;
|
|
|
+ const nbn = batchnum.map(i => {
|
|
|
+ i.name = `第${r.term}期-第${i.batch}批`;
|
|
|
return i;
|
|
|
});
|
|
|
- duplicate = _.orderBy(duplicate, ['order'], ['asc']);
|
|
|
- this.$set(this, `classList`, duplicate);
|
|
|
+ this.$set(this, `batchList`, nbn);
|
|
|
+ const stures = await this.getClass({ termid });
|
|
|
+ if (this.$checkRes(stures)) {
|
|
|
+ const cl = stures.data;
|
|
|
+ for (const c of cl) {
|
|
|
+ c.name = `第${c.term}期-第${c.batch}批-${c.name}班`;
|
|
|
+ }
|
|
|
+ this.$set(this, `classList`, cl);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
async selectClass(classid) {
|