更新
This commit is contained in:
parent
c276b14086
commit
59139615e1
@ -127,10 +127,11 @@ export default {
|
|||||||
const selected = this.courseList.find(item => item.id === this.formData.courseId);
|
const selected = this.courseList.find(item => item.id === this.formData.courseId);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
this.formData.courseName = selected.name;
|
this.formData.courseName = selected.name;
|
||||||
this.formData.courseType = selected.courseType;
|
this.formData.courseType = selected.type;
|
||||||
} else {
|
} else {
|
||||||
this.formData.courseName = '';
|
this.formData.courseName = '';
|
||||||
}
|
}
|
||||||
|
console.log('当前课程', this.formData)
|
||||||
},
|
},
|
||||||
handleCoachChange() {
|
handleCoachChange() {
|
||||||
const selected = this.coachList.find(item => item.id === this.formData.coachUserId);
|
const selected = this.coachList.find(item => item.id === this.formData.coachUserId);
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
<el-table-column label="科目" prop="subjectStr" align="center" width=""></el-table-column>
|
<el-table-column label="科目" prop="subjectStr" align="center" width=""></el-table-column>
|
||||||
<el-table-column label="教练" align="center" width="">
|
<el-table-column label="教练" align="center" width="">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.coachId" placeholder="请选择" @change="handleChange(scope.row)">
|
<el-select v-model="scope.row.coachId" placeholder="请选择" :disabled="scope.row.disable"
|
||||||
|
@change="handleChange(scope.row)">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in scope.row.coachList"
|
v-for="item in scope.row.coachList"
|
||||||
:key="item.coachId"
|
:key="item.coachId"
|
||||||
@ -34,7 +35,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import * as SchoolCourseOrderApi from '@/views/drivingSchool/DriveSchoolPay/api';
|
import * as SchoolCourseOrderApi from '@/views/drivingSchool/DriveSchoolPay/api';
|
||||||
import {getCoachByCourseId} from "@/views/drivingSchool/schoolCoachCourse/api/achoolCoachCourse";
|
import {getCoachByCourseId} from "@/views/drivingSchool/schoolCoachCourse/api/achoolCoachCourse";
|
||||||
import {saveProcess} from "@/views/drivingSchool/process/api";
|
import {getAllByUserIdAndCourseId, saveProcess} from "@/views/drivingSchool/process/api";
|
||||||
|
import {nextTick} from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "AssignmentCoach",
|
name: "AssignmentCoach",
|
||||||
@ -48,6 +50,7 @@ export default {
|
|||||||
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
formLoading: false,
|
formLoading: false,
|
||||||
process: [],
|
process: [],
|
||||||
|
selectCoach: [],
|
||||||
// 表单校验
|
// 表单校验
|
||||||
formRules: {},
|
formRules: {},
|
||||||
orderId: '',
|
orderId: '',
|
||||||
@ -58,6 +61,7 @@ export default {
|
|||||||
async open(data) {
|
async open(data) {
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
this.orderId = data.id
|
this.orderId = data.id
|
||||||
|
await this.getAllByUserIdAndCourseId(data.userId, data.courseId)
|
||||||
this.getData(data)
|
this.getData(data)
|
||||||
this.reset();
|
this.reset();
|
||||||
},
|
},
|
||||||
@ -101,6 +105,8 @@ export default {
|
|||||||
for (let i = 1; i <= 4; i++) {
|
for (let i = 1; i <= 4; i++) {
|
||||||
//根据res中subject判断与当前i相同的教练
|
//根据res中subject判断与当前i相同的教练
|
||||||
const coachArr = res.data.filter(item => item.subject === i + '')
|
const coachArr = res.data.filter(item => item.subject === i + '')
|
||||||
|
|
||||||
|
|
||||||
const item = {
|
const item = {
|
||||||
subject: i,
|
subject: i,
|
||||||
subjectStr: subjectArr[i - 1],
|
subjectStr: subjectArr[i - 1],
|
||||||
@ -113,8 +119,10 @@ export default {
|
|||||||
userId: data.userId,
|
userId: data.userId,
|
||||||
userName: data.userName,
|
userName: data.userName,
|
||||||
userMobile: data.userPhone,
|
userMobile: data.userPhone,
|
||||||
status: 0
|
status: 0,
|
||||||
|
disable: false
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断data中的教练id是否在coachArr中,如果在设置默认教练
|
//判断data中的教练id是否在coachArr中,如果在设置默认教练
|
||||||
if (data.coachUserId) {
|
if (data.coachUserId) {
|
||||||
const selectedCoach = coachArr.find(item => item.coachId == data.coachUserId);
|
const selectedCoach = coachArr.find(item => item.coachId == data.coachUserId);
|
||||||
@ -126,9 +134,35 @@ export default {
|
|||||||
if (i === 1) {
|
if (i === 1) {
|
||||||
item.status = 1
|
item.status = 1
|
||||||
}
|
}
|
||||||
this.process.push(item)
|
|
||||||
|
//在this.selectCoach中是否i等于里面的subject
|
||||||
|
if (this.selectCoach.some(item => item.subject == i)) {
|
||||||
|
const selectedCoach = this.selectCoach.find(item => item.subject == i)
|
||||||
|
const selectedCoachId = selectedCoach.coachId + ''
|
||||||
|
const selectedCoachName = selectedCoach.coachName
|
||||||
|
// 设置默认值
|
||||||
|
item.coachId = selectedCoachId
|
||||||
|
item.coachName = selectedCoachName
|
||||||
|
item.disable = true
|
||||||
|
//判断coachArr中是否有当前的id
|
||||||
|
if (!coachArr.some(item => item.coachId == selectedCoachId)) {
|
||||||
|
// 设置disable为true
|
||||||
|
item.coachList.push(selectedCoach)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nextTick(() => {
|
||||||
|
this.$set(this.process, this.process.length, item)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async getAllByUserIdAndCourseId(userId, courseId) {
|
||||||
|
const params = {
|
||||||
|
userId: userId,
|
||||||
|
courseId: courseId
|
||||||
|
}
|
||||||
|
const res = await getAllByUserIdAndCourseId(params)
|
||||||
|
this.selectCoach = res.data
|
||||||
|
},
|
||||||
handleChange(row) {
|
handleChange(row) {
|
||||||
// 你可以在这里处理选择变化后的逻辑
|
// 你可以在这里处理选择变化后的逻辑
|
||||||
//找出该行的selectedCoachId对应的coachList中的name
|
//找出该行的selectedCoachId对应的coachList中的name
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)">修改</el-button>
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)">修改</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="openAssignmentCoach(scope.row)" v-if="scope.row.paymentStatus == 2 && scope.row.ifAssignmentCoach == 0">分配教练</el-button>
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="openAssignmentCoach(scope.row)" v-if="scope.row.paymentStatus == 2 && scope.row.ifAssignmentCoach == 0 && scope.row.ifEnd == false">分配教练</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-close" @click="openEndOrder(scope.row)" v-if="scope.row.paymentStatus == 2 && scope.row.ifEnd == false">终止</el-button>
|
<el-button size="mini" type="text" icon="el-icon-close" @click="openEndOrder(scope.row)" v-if="scope.row.paymentStatus == 2 && scope.row.ifEnd == false">终止</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-plus" @click="openAddForm(scope.row)" v-if="scope.row.paymentStatus == 2 && scope.row.ifEnd == true && scope.row.isCreated == false">快速创建订单</el-button>
|
<el-button size="mini" type="text" icon="el-icon-plus" @click="openAddForm(scope.row)" v-if="scope.row.paymentStatus == 2 && scope.row.ifEnd == true && scope.row.isCreated == false">快速创建订单</el-button>
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||||
@ -170,12 +170,10 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 分配教练*/
|
/** 分配教练*/
|
||||||
openAssignmentCoach(data) {
|
openAssignmentCoach(data) {
|
||||||
console.log('data',data)
|
|
||||||
this.$refs["assignmentCoachRef"].open(data);
|
this.$refs["assignmentCoachRef"].open(data);
|
||||||
},
|
},
|
||||||
/** 分配教练*/
|
/** 分配教练*/
|
||||||
openEndOrder(data) {
|
openEndOrder(data) {
|
||||||
console.log('data',data)
|
|
||||||
this.$refs["endOrderRef"].open(data);
|
this.$refs["endOrderRef"].open(data);
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
|
@ -51,3 +51,11 @@ export function saveProcess(data) {
|
|||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 根据用户id和课程id查询进度
|
||||||
|
export function getAllByUserIdAndCourseId(params) {
|
||||||
|
return request({
|
||||||
|
url: '/process/getAllByUserIdAndCourseId',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user