|
@@ -6,38 +6,34 @@
|
|
width="70%"
|
|
width="70%"
|
|
>
|
|
>
|
|
<el-form ref="form" :model="form" label-width="50px" label-position="right">
|
|
<el-form ref="form" :model="form" label-width="50px" label-position="right">
|
|
- <el-row justify="center">
|
|
|
|
|
|
+ <el-row>
|
|
<el-row>
|
|
<el-row>
|
|
- <el-col class="flex-center-column" :span="12">
|
|
|
|
|
|
+
|
|
|
|
+ <el-col class="flex-center-column" :span="12">
|
|
<el-form-item>
|
|
<el-form-item>
|
|
- <mx-select @change="getStudents('from',$event)" :span="12" :list="display" v-model="fromClassId" placeholder="请选择" item-label="className" item-value="classId"
|
|
|
|
|
|
+ <mx-select @change="getStudents('from',$event)" :span="12" :list="display" v-model="fromClassId"
|
|
|
|
+ placeholder="请选择" item-label="className" item-value="classId"
|
|
></mx-select>
|
|
></mx-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item >
|
|
|
|
|
|
+ <el-form-item>
|
|
<class-table :list="studentsTableLeft" @confirm="studentSelected($event,'from')"></class-table>
|
|
<class-table :list="studentsTableLeft" @confirm="studentSelected($event,'from')"></class-table>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col class="flex-center-column" :span="12">
|
|
<el-col class="flex-center-column" :span="12">
|
|
- <el-form-item >
|
|
|
|
- <mx-select @change="getStudents('to',$event)" :span="12" :list="display" v-model="toClassId" placeholder="请选择" item-label="className" item-value="classId"
|
|
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <mx-select @change="getStudents('to',$event)" :span="12" :list="display" v-model="toClassId"
|
|
|
|
+ placeholder="请选择" item-label="className" item-value="classId"
|
|
></mx-select>
|
|
></mx-select>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
- <el-form-item >
|
|
|
|
- <class-table :list="studentsTableRight" @confirm="studentSelected($event,'to')" ></class-table>
|
|
|
|
|
|
+ <el-form-item>
|
|
|
|
+ <class-table :list="studentsTableRight" @confirm="studentSelected($event,'to')"></class-table>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
-<!-- <el-col>-->
|
|
|
|
-<!-- <el-alert-->
|
|
|
|
-<!-- title="不可关闭的 alert"-->
|
|
|
|
-<!-- type="success"-->
|
|
|
|
-<!-- :closable="false">-->
|
|
|
|
-<!-- </el-alert>-->
|
|
|
|
-<!-- </el-col>-->
|
|
|
|
<el-col :span="24" class="flex-center" v-if="fromClassId && toClassId" style="margin-top: 20px">
|
|
<el-col :span="24" class="flex-center" v-if="fromClassId && toClassId" style="margin-top: 20px">
|
|
<el-transfer
|
|
<el-transfer
|
|
v-model="tranRight"
|
|
v-model="tranRight"
|
|
- :titles="[fromClassId ? getClassName(fromClassId) : '未选择', toClassId ? getClassName(toClassId) : '未选择']"
|
|
|
|
|
|
+ :titles="[fromClassId ? `${getClassName(fromClassId)}(添加)` : '未选择', toClassId ? `${getClassName(toClassId)}(添加)`: '未选择']"
|
|
:data="parentFrame"
|
|
:data="parentFrame"
|
|
@change="transferChange"
|
|
@change="transferChange"
|
|
>
|
|
>
|
|
@@ -53,7 +49,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { classesResult, getDispatchResult } from '@/api/webApi/elective/dispatch'
|
|
|
|
|
|
+import { classesResult, resultDispatch } from '@/api/webApi/elective/dispatch'
|
|
import MxClassTreeTranslateMixin from '@/components/Cache/modules/mx-classTree-translate-mixin.js'
|
|
import MxClassTreeTranslateMixin from '@/components/Cache/modules/mx-classTree-translate-mixin.js'
|
|
import MxSelect from '@/components/mx-select/mx-select'
|
|
import MxSelect from '@/components/mx-select/mx-select'
|
|
import ClassTable from './class-table'
|
|
import ClassTable from './class-table'
|
|
@@ -64,10 +60,10 @@ export default {
|
|
MxSelect,
|
|
MxSelect,
|
|
ClassTable
|
|
ClassTable
|
|
},
|
|
},
|
|
|
|
+ inject: ['refreshData'],
|
|
mixins: [MxClassTreeTranslateMixin],
|
|
mixins: [MxClassTreeTranslateMixin],
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- studentListOne: [],
|
|
|
|
form: {},
|
|
form: {},
|
|
studentsTableLeft: [],
|
|
studentsTableLeft: [],
|
|
studentsTableRight: [],
|
|
studentsTableRight: [],
|
|
@@ -75,7 +71,6 @@ export default {
|
|
toClassId: '',
|
|
toClassId: '',
|
|
group: '',
|
|
group: '',
|
|
settings: [],
|
|
settings: [],
|
|
- classList: [],
|
|
|
|
selectedLeft: [],
|
|
selectedLeft: [],
|
|
selectedRight: [],
|
|
selectedRight: [],
|
|
show: false,
|
|
show: false,
|
|
@@ -90,8 +85,7 @@ export default {
|
|
return selected.map(item => {
|
|
return selected.map(item => {
|
|
return {
|
|
return {
|
|
key: item.studentId,
|
|
key: item.studentId,
|
|
- label: item.studentName,
|
|
|
|
- classId: item.classId
|
|
|
|
|
|
+ label: item.name,
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -110,7 +104,7 @@ export default {
|
|
// 获取左tran实际的数据
|
|
// 获取左tran实际的数据
|
|
// 母框去重右框
|
|
// 母框去重右框
|
|
return this.parentFrame.filter(item => {
|
|
return this.parentFrame.filter(item => {
|
|
- if(this.tranRight.findIndex(r => r == item.key ) == -1) {
|
|
|
|
|
|
+ if (this.tranRight.findIndex(r => r == item.key) == -1) {
|
|
return item
|
|
return item
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -119,71 +113,104 @@ export default {
|
|
// 获取左tran实际的数据
|
|
// 获取左tran实际的数据
|
|
// 母框去重右框
|
|
// 母框去重右框
|
|
return this.parentFrame.filter(item => {
|
|
return this.parentFrame.filter(item => {
|
|
- if(this.tranRight.findIndex(r => r == item.key ) != -1 )return item
|
|
|
|
|
|
+ if (this.tranRight.findIndex(r => r == item.key) != -1) return item
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ saveResultDispatch(clazzId,students) {
|
|
|
|
+ // 分派转移
|
|
|
|
+ resultDispatch({
|
|
|
|
+ roundId: this.group.roundId,
|
|
|
|
+ students: students,
|
|
|
|
+ toClazzId: clazzId
|
|
|
|
+ }).then(res => {
|
|
|
|
+ console.log(res)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
confirm() {
|
|
confirm() {
|
|
- // 左tran 是包含 右边的 (只是不显示右tran的数据)要先去重
|
|
|
|
- // 左tran 去掉跟左table重复的数据就是 右tran 需要调换的
|
|
|
|
- // 同理右tran 去掉跟右table重复的数据就是 左tran 需要调换的
|
|
|
|
- // 1.去重
|
|
|
|
|
|
+ if( !this.fromClassId || !this.toClassId) {
|
|
|
|
+ this.$message.warning('请先选择需要调整的两个班级')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 左tran 是包含 右边的 (只是不显示右tran的数据)要先去重
|
|
|
|
+ // 左tran 去掉跟左table重复的数据就是 右tran 需要调换的
|
|
|
|
+ // 同理右tran 去掉跟右table重复的数据就是 左tran 需要调换的
|
|
|
|
+ // 1.去重
|
|
// 左tran实际勾选去除左边table
|
|
// 左tran实际勾选去除左边table
|
|
const left = this.getTranLeft().filter(item => {
|
|
const left = this.getTranLeft().filter(item => {
|
|
return this.studentsTableLeft.findIndex(s => s.studentId == item.key) == -1
|
|
return this.studentsTableLeft.findIndex(s => s.studentId == item.key) == -1
|
|
- })
|
|
|
|
|
|
+ }).map(item => item.key)
|
|
// 右tran实际勾选去除右边table
|
|
// 右tran实际勾选去除右边table
|
|
const right = this.getTranRight().filter(item => {
|
|
const right = this.getTranRight().filter(item => {
|
|
return this.studentsTableRight.findIndex(s => s.studentId == item.key) == -1
|
|
return this.studentsTableRight.findIndex(s => s.studentId == item.key) == -1
|
|
- })
|
|
|
|
|
|
+ }).map(item => item.key)
|
|
console.log(left) // 左边的学生放入左边表格
|
|
console.log(left) // 左边的学生放入左边表格
|
|
- console.log(right)// 右边的学生放入右边边表格
|
|
|
|
- // 2.分别调用调换接口
|
|
|
|
|
|
+ if( !left.length && !right.length) {
|
|
|
|
+ this.$message.warning('调整人数不可为0')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 2.分别调用调换接口
|
|
|
|
+ if (left.length) this.saveResultDispatch(this.fromClassId,left)
|
|
|
|
+ console.log(left)// 左边的学生放入左边表格
|
|
|
|
+ console.log(right)// 右边的学生放入右边表格
|
|
|
|
+ if (right.length) this.saveResultDispatch(this.toClassId,right)
|
|
|
|
+ this.$nextTick(()=> {
|
|
|
|
+ this.show = false
|
|
|
|
+ // 注销数据
|
|
|
|
+ Object.assign(this.$data,this.$options.data());
|
|
|
|
+ this.refreshData()
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // 2.分别调用调换接口
|
|
|
|
|
|
},
|
|
},
|
|
- studentSelected(list,type) {
|
|
|
|
|
|
+ studentSelected(list, type) {
|
|
// 1 添加至母框
|
|
// 1 添加至母框
|
|
- if(type== 'from'){
|
|
|
|
- this.selectedLeft = list
|
|
|
|
- }
|
|
|
|
- if(type== 'to'){
|
|
|
|
- this.selectedRight = list
|
|
|
|
- }
|
|
|
|
|
|
+ if (type == 'from') this.selectedLeft = list
|
|
|
|
+ if (type == 'to') this.selectedRight = list
|
|
|
|
+
|
|
},
|
|
},
|
|
- getStudents(type,classId) {
|
|
|
|
|
|
+ getStudents(type, classId) {
|
|
console.log(type)
|
|
console.log(type)
|
|
console.log(classId)
|
|
console.log(classId)
|
|
classesResult({
|
|
classesResult({
|
|
- group: this.group.groupId,
|
|
|
|
|
|
+ groupId: this.group.groupId,
|
|
roundId: this.group.roundId,
|
|
roundId: this.group.roundId,
|
|
classId: classId
|
|
classId: classId
|
|
}).then(res => {
|
|
}).then(res => {
|
|
- console.log(res)
|
|
|
|
- })
|
|
|
|
- getDispatchResult().then(res => {
|
|
|
|
- console.log(res)
|
|
|
|
- if( type =='from') this.studentsTableLeft = res.data[0].students.map(item => {
|
|
|
|
- item.classId = classId
|
|
|
|
- item.className = this.getClassName(classId)
|
|
|
|
- return item
|
|
|
|
- })
|
|
|
|
- if( type =='to') this.studentsTableRight = res.data[1].students.map(item => {
|
|
|
|
- item.classId = classId
|
|
|
|
- item.className = this.getClassName(classId)
|
|
|
|
- return item
|
|
|
|
- })
|
|
|
|
|
|
+ if( type == 'from') {
|
|
|
|
+ if(!res.hasOwnProperty('data')){
|
|
|
|
+ this.studentsTableLeft = []
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.studentsTableLeft = res.data.students.map(item => {
|
|
|
|
+ item.classId = classId
|
|
|
|
+ item.className = this.getClassName(classId)
|
|
|
|
+ return item
|
|
|
|
+ })
|
|
|
|
+ }else if( type == 'to') {
|
|
|
|
+ if(!res.hasOwnProperty('data')){
|
|
|
|
+ this.studentsTableRight = []
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.studentsTableRight = res.data.students.map(item => {
|
|
|
|
+ item.classId = classId
|
|
|
|
+ item.className = this.getClassName(classId)
|
|
|
|
+ return item
|
|
|
|
+ })
|
|
|
|
+ }
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 判断是否有这个元素
|
|
// 判断是否有这个元素
|
|
getDisable(itemId) {
|
|
getDisable(itemId) {
|
|
- return this.fromClassId == itemId || this.toClassId == itemId
|
|
|
|
|
|
+ return this.fromClassId == itemId || this.toClassId == itemId
|
|
},
|
|
},
|
|
transferChange(currentVal, direction, array) {
|
|
transferChange(currentVal, direction, array) {
|
|
- if(!this.fromClassId || !this.toClassId) {
|
|
|
|
|
|
+ if (!this.fromClassId || !this.toClassId) {
|
|
this.$message.warning('需要选择两个班级')
|
|
this.$message.warning('需要选择两个班级')
|
|
return
|
|
return
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- open(row ,settings) {
|
|
|
|
|
|
+ open(row, settings) {
|
|
console.log(row)
|
|
console.log(row)
|
|
console.log(settings)
|
|
console.log(settings)
|
|
this.group = row
|
|
this.group = row
|
|
@@ -200,7 +227,8 @@ export default {
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
justify-content: center;
|
|
}
|
|
}
|
|
-.flex-center{
|
|
|
|
|
|
+
|
|
|
|
+.flex-center {
|
|
display: flex;
|
|
display: flex;
|
|
flex-direction: row;
|
|
flex-direction: row;
|
|
justify-content: center;
|
|
justify-content: center;
|