更新
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);
|
||||
if (selected) {
|
||||
this.formData.courseName = selected.name;
|
||||
this.formData.courseType = selected.courseType;
|
||||
this.formData.courseType = selected.type;
|
||||
} else {
|
||||
this.formData.courseName = '';
|
||||
}
|
||||
console.log('当前课程', this.formData)
|
||||
},
|
||||
handleCoachChange() {
|
||||
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="教练" align="center" width="">
|
||||
<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
|
||||
v-for="item in scope.row.coachList"
|
||||
:key="item.coachId"
|
||||
@ -34,7 +35,8 @@
|
||||
<script>
|
||||
import * as SchoolCourseOrderApi from '@/views/drivingSchool/DriveSchoolPay/api';
|
||||
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 {
|
||||
name: "AssignmentCoach",
|
||||
@ -48,6 +50,7 @@ export default {
|
||||
// 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
formLoading: false,
|
||||
process: [],
|
||||
selectCoach: [],
|
||||
// 表单校验
|
||||
formRules: {},
|
||||
orderId: '',
|
||||
@ -58,6 +61,7 @@ export default {
|
||||
async open(data) {
|
||||
this.dialogVisible = true;
|
||||
this.orderId = data.id
|
||||
await this.getAllByUserIdAndCourseId(data.userId, data.courseId)
|
||||
this.getData(data)
|
||||
this.reset();
|
||||
},
|
||||
@ -101,6 +105,8 @@ export default {
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
//根据res中subject判断与当前i相同的教练
|
||||
const coachArr = res.data.filter(item => item.subject === i + '')
|
||||
|
||||
|
||||
const item = {
|
||||
subject: i,
|
||||
subjectStr: subjectArr[i - 1],
|
||||
@ -113,8 +119,10 @@ export default {
|
||||
userId: data.userId,
|
||||
userName: data.userName,
|
||||
userMobile: data.userPhone,
|
||||
status: 0
|
||||
status: 0,
|
||||
disable: false
|
||||
}
|
||||
|
||||
//判断data中的教练id是否在coachArr中,如果在设置默认教练
|
||||
if (data.coachUserId) {
|
||||
const selectedCoach = coachArr.find(item => item.coachId == data.coachUserId);
|
||||
@ -126,8 +134,34 @@ export default {
|
||||
if (i === 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) {
|
||||
// 你可以在这里处理选择变化后的逻辑
|
||||
|
@ -73,7 +73,7 @@
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<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="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-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>
|
||||
@ -170,12 +170,10 @@ export default {
|
||||
},
|
||||
/** 分配教练*/
|
||||
openAssignmentCoach(data) {
|
||||
console.log('data',data)
|
||||
this.$refs["assignmentCoachRef"].open(data);
|
||||
},
|
||||
/** 分配教练*/
|
||||
openEndOrder(data) {
|
||||
console.log('data',data)
|
||||
this.$refs["endOrderRef"].open(data);
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
|
@ -51,3 +51,11 @@ export function saveProcess(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