|
@@ -1,130 +1,187 @@
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
title="班级调整"
|
|
|
- :visible.sync="adjustShow"
|
|
|
+ :visible.sync="show"
|
|
|
:close-on-click-modal="false"
|
|
|
- width="50%"
|
|
|
+ width="70%"
|
|
|
>
|
|
|
<el-form ref="form" :model="form" label-width="50px" label-position="right">
|
|
|
<el-row justify="center">
|
|
|
- <el-row >
|
|
|
- <el-col class="flex-center" :span="12" >
|
|
|
- <el-form-item :label="from" >
|
|
|
- <el-select v-model="from" placeholder="请选择">
|
|
|
- <el-option
|
|
|
- v-for="item in classList"
|
|
|
- :key="item.classId"
|
|
|
- :label="item.className"
|
|
|
- :disabled="getDisable(item.classId)"
|
|
|
- :value="item.classId"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
+ <el-row>
|
|
|
+ <el-col class="flex-center-column" :span="12">
|
|
|
+ <el-form-item>
|
|
|
+ <mx-select @change="getStudents('from',$event)" :span="12" :list="display" v-model="from" placeholder="请选择" item-label="className" item-value="classId"
|
|
|
+ ></mx-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="from">
|
|
|
+ <class-table :list="studentsTableLeft" @confirm="studentSelected($event,'from')"></class-table>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col class="flex-center" :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="to" placeholder="请选择" item-label="className" item-value="classId"
|
|
|
+ ></mx-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item :label="to">
|
|
|
- <el-select v-model="to" placeholder="请选择">
|
|
|
- <el-option
|
|
|
- v-for="item in classList"
|
|
|
- :key="item.classId"
|
|
|
- :label="item.className"
|
|
|
- :disabled="getDisable(item.classId)"
|
|
|
- :value="item.classId"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
+ <class-table :list="studentsTableRight" @confirm="studentSelected($event,'to')" ></class-table>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
-
|
|
|
- <el-col :span="24" class="flex-center" style="margin-top: 20px">
|
|
|
+<!-- <el-col>-->
|
|
|
+<!-- <el-alert-->
|
|
|
+<!-- title="不可关闭的 alert"-->
|
|
|
+<!-- type="success"-->
|
|
|
+<!-- :closable="false">-->
|
|
|
+<!-- </el-alert>-->
|
|
|
+<!-- </el-col>-->
|
|
|
+ <el-col :span="24" class="flex-center" v-if="this.from && this.to" style="margin-top: 20px">
|
|
|
<el-transfer
|
|
|
- :button-texts="['到左边', '到右边']"
|
|
|
- v-model="value"
|
|
|
- :titles="[from, to]"
|
|
|
- :data="list"
|
|
|
+ v-model="tranRight"
|
|
|
+ :titles="[from ? from : '未选择', to ? to : '未选择']"
|
|
|
+ :data="tranLeft"
|
|
|
@change="transferChange"
|
|
|
>
|
|
|
</el-transfer>
|
|
|
</el-col>
|
|
|
- <el-row :gutter="10">
|
|
|
- <el-col :span="12">
|
|
|
- <span></span>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">10</el-col>
|
|
|
- </el-row>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="adjustShow = false">取 消</el-button>
|
|
|
- <el-button type="primary" @click="adjustShow = false">确 定</el-button>
|
|
|
+ <el-button @click="show = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="show = false">确 定</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { getDispatchResult } from '@/api/webApi/elective/dispatch'
|
|
|
+import MxSelect from '@/components/mx-select/mx-select'
|
|
|
+import ClassTable from './class-table'
|
|
|
|
|
|
export default {
|
|
|
name: 'class-adjust',
|
|
|
+ components: {
|
|
|
+ MxSelect,
|
|
|
+ ClassTable
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- value: [],
|
|
|
- list: [],
|
|
|
+ studentListOne: [],
|
|
|
form: {},
|
|
|
+ studentsTableLeft: [],
|
|
|
+ studentsTableRight: [],
|
|
|
from: '',
|
|
|
to: '',
|
|
|
classList: [{
|
|
|
classId: '201',
|
|
|
className: '201班'
|
|
|
- },{
|
|
|
+ }, {
|
|
|
classId: '202',
|
|
|
className: '202班'
|
|
|
- },{
|
|
|
+ }, {
|
|
|
classId: '203',
|
|
|
className: '203班'
|
|
|
}],
|
|
|
- adjustShow: false
|
|
|
+ selectedLeft: [],
|
|
|
+ selectedRight: [],
|
|
|
+ show: false,
|
|
|
+ tranRight: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.list = this.getList()
|
|
|
- this.value = this.list.filter(item => {
|
|
|
- if (item.key > 30) {
|
|
|
- return item
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ tranLeft() {
|
|
|
+ const selected = this.selectedRight.concat(this.selectedLeft)
|
|
|
+ return selected.map(item => {
|
|
|
+ return {
|
|
|
+ key: item.studentId,
|
|
|
+ label: item.studentName,
|
|
|
}
|
|
|
- }).map(item => item.key)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ display() {
|
|
|
+ return this.classList.map(item => {
|
|
|
+ return {
|
|
|
+ classId: item.classId,
|
|
|
+ className: item.className,
|
|
|
+ disabled: this.getDisable(item.classId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- computed: {},
|
|
|
methods: {
|
|
|
+ studentSelected(list,type) {
|
|
|
+ // 1 添加至母框
|
|
|
+ if(type== 'from'){
|
|
|
+ this.selectedLeft = list
|
|
|
+ }
|
|
|
+ if(type== 'to'){
|
|
|
+ this.selectedRight = list
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getStudents(type,classId) {
|
|
|
+ console.log(classId)
|
|
|
+ if(type == 'from') {
|
|
|
+ // 左边table
|
|
|
+ const res = await getDispatchResult()
|
|
|
+ const index = res.data.findIndex(item=>(item.classId == classId))
|
|
|
+ index != -1 ? this.studentsTableLeft = res.data[index].students.map(
|
|
|
+ item => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ className: res.data[index].classId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ :
|
|
|
+ this.studentsTableLeft = []
|
|
|
+
|
|
|
+ }
|
|
|
+ if(type == 'to') {
|
|
|
+ // 右边table
|
|
|
+ const res = await getDispatchResult()
|
|
|
+ const index = res.data.findIndex(item=>(item.classId == classId))
|
|
|
+ index != -1 ? this.studentsTableRight = res.data[index].students.map(
|
|
|
+ item => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ className: res.data[index].classId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ :
|
|
|
+ this.studentsTableRight = []
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
// 判断是否有这个元素
|
|
|
getDisable(itemId) {
|
|
|
- return this.from == itemId || this.to == itemId
|
|
|
+ return this.from == itemId || this.to == itemId
|
|
|
},
|
|
|
- getList(){
|
|
|
- const data = [];
|
|
|
- for (let i = 1; i <= 40; i++) {
|
|
|
- data.push({
|
|
|
- key: i,
|
|
|
- label: `学生${i}`,
|
|
|
- });
|
|
|
- }
|
|
|
- return data;
|
|
|
- },
|
|
|
- transferChange(currentVal,direction,array) {
|
|
|
- console.log('当前值',currentVal)
|
|
|
- console.log('方向',direction)
|
|
|
- console.log('array',array)
|
|
|
+ transferChange(currentVal, direction, array) {
|
|
|
+ if(!this.from || !this.to) {
|
|
|
+ console.log(111111111)
|
|
|
+ this.$message.warning('需要选择两个班级')
|
|
|
+ return
|
|
|
+ }
|
|
|
},
|
|
|
open() {
|
|
|
- this.adjustShow = true
|
|
|
- },
|
|
|
+ this.show = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
+.flex-center-column {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
.flex-center{
|
|
|
- display: flex;justify-content: center;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ justify-content: center;
|
|
|
}
|
|
|
</style>
|