Browse Source

修改 bug

master
王泽彦 8 months ago
parent
commit
d3fc1502b8
  1. 4
      admin/src/app/views/course_schedule/components/course-schedule-edit.vue
  2. 75
      niucloud/app/service/api/apiService/OrderTableService.php
  3. 335
      uniapp/components/schedule/ScheduleDetail.vue
  4. 40
      uniapp/pages-coach/coach/schedule/schedule_table.vue

4
admin/src/app/views/course_schedule/components/course-schedule-edit.vue

@ -113,8 +113,8 @@
<el-form-item :label="t('autoSchedule')" prop="auto_schedule"> <el-form-item :label="t('autoSchedule')" prop="auto_schedule">
<el-radio-group v-model="formData.auto_schedule"> <el-radio-group v-model="formData.auto_schedule">
<el-radio :label="1">{{ t('yes') }}</el-radio> <el-radio label="1">{{ t('yes') }}</el-radio>
<el-radio :label="0">{{ t('no') }}</el-radio> <el-radio label="0">{{ t('no') }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>

75
niucloud/app/service/api/apiService/OrderTableService.php

@ -387,6 +387,9 @@ class OrderTableService extends BaseApiService
$result = Db::table('school_contract_sign')->insert($insertData); $result = Db::table('school_contract_sign')->insert($insertData);
if ($result) { if ($result) {
// 创建签署记录成功后,为甲乙双方生成数据源配置记录
$this->createDocumentDataSourceConfig($course['contract_id'], $orderData);
\think\facade\Log::info('合同签署记录创建成功', [ \think\facade\Log::info('合同签署记录创建成功', [
'student_id' => $student_id, 'student_id' => $student_id,
'contract_id' => $course['contract_id'], 'contract_id' => $course['contract_id'],
@ -405,6 +408,78 @@ class OrderTableService extends BaseApiService
} }
} }
/**
* 为甲乙双方创建文档数据源配置记录
* @param int $contract_id 合同ID
* @param array $orderData 订单数据
* @return bool
*/
private function createDocumentDataSourceConfig($contract_id, $orderData)
{
try {
// 获取合同模板的占位符配置
$contract = Db::table('school_contract')->where('id', $contract_id)->find();
if (!$contract || empty($contract['placeholder_config'])) {
\think\facade\Log::warning('合同模板无占位符配置', ['contract_id' => $contract_id]);
return false;
}
$placeholder_config = json_decode($contract['placeholder_config'], true);
if (!is_array($placeholder_config)) {
\think\facade\Log::warning('占位符配置格式错误', ['contract_id' => $contract_id]);
return false;
}
$insert_data = [];
$now = date('Y-m-d H:i:s');
// 为每个占位符配置创建数据源记录
foreach ($placeholder_config as $config) {
$data_source_record = [
'contract_id' => $contract_id,
'placeholder' => $config['placeholder'] ?? '',
'data_type' => $config['data_type'] ?? 'user_input',
'system_function' => $config['system_function'] ?? '',
'table_name' => $config['table_name'] ?? '',
'field_name' => $config['field_name'] ?? '',
'field_type' => $config['field_type'] ?? 'text',
'is_required' => $config['is_required'] ?? 0,
'default_value' => $config['default_value'] ?? '',
'sign_party' => $config['sign_party'] ?? '',
'validation_rule' => $config['validation_rule'] ?? '',
'created_at' => $now,
'updated_at' => $now
];
$insert_data[] = $data_source_record;
}
if (!empty($insert_data)) {
$result = Db::table('school_document_data_source_config')->insertAll($insert_data);
if ($result) {
\think\facade\Log::info('文档数据源配置创建成功', [
'contract_id' => $contract_id,
'order_id' => $orderData['id'],
'records_count' => count($insert_data)
]);
}
return $result ? true : false;
}
return true;
} catch (\Exception $e) {
\think\facade\Log::error('创建文档数据源配置异常', [
'contract_id' => $contract_id,
'order_data' => $orderData,
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString()
]);
return false;
}
}
/** /**
* 支付成功后创建支付记录 * 支付成功后创建支付记录
* @param array $orderData 订单数据 * @param array $orderData 订单数据

335
uniapp/components/schedule/ScheduleDetail.vue

@ -329,7 +329,7 @@
} }
}, },
// // 使API - admin
async fetchScheduleDetail() { async fetchScheduleDetail() {
if (!this.scheduleId) { if (!this.scheduleId) {
this.error = true; this.error = true;
@ -342,8 +342,8 @@
this.scheduleInfo = null; this.scheduleInfo = null;
try { try {
// API // APIadmin
const res = await api.getCourseScheduleInfo({ const res = await api.getCourseArrangementDetail({
schedule_id: this.scheduleId schedule_id: this.scheduleId
}); });
@ -351,57 +351,114 @@
// //
const data = res.data; const data = res.data;
// 使APIdata // 使APIadmin
this.scheduleInfo = { if (data.schedule_info) {
// // schedule_infoformal_studentswaiting_students
id: data.id, const allStudents = [...(data.formal_students || []), ...(data.waiting_students || [])];
course_name: data.course_name || '未命名课程',
course_date: data.course_date, this.scheduleInfo = {
time_slot: data.time_slot, // schedule_info
venue_name: data.venue_name || '未分配', id: data.schedule_info.id,
campus_name: data.campus_name || '', course_name: data.schedule_info.course_name || '未命名课程',
// course_date: data.schedule_info.course_date,
coach_name: data.coach_name || '未分配', time_slot: data.schedule_info.time_slot,
coach_avatar: data.coach_avatar || '', venue_name: data.schedule_info.venue_name || '未分配',
// campus_name: data.schedule_info.campus_name || '',
status: data.status, //
status_text: data.status_text || '待定', coach_name: data.schedule_info.coach_name || '未分配',
// coach_avatar: data.schedule_info.coach_avatar || '',
class_info: data.class_info || null, //
// status: data.schedule_info.status,
time_info: data.time_info || null, status_text: data.schedule_info.status_text || '待定',
// //
course_duration: data.time_info?.duration || data.course_duration || 60, class_info: data.schedule_info.class_info || null,
// //
students: (data.students || []).map(student => ({ time_info: data.schedule_info.time_info || null,
...student, //
status_text: this.getStatusText(student.status || 0), course_duration: data.schedule_info.time_info?.duration || data.schedule_info.course_duration || 60,
// //
course_progress: student.course_progress || { students: allStudents.map(student => ({
total: student.totalHours || 0, ...student,
used: student.usedHours || 0, status_text: this.getStatusText(student.status || 0),
remaining: student.remainingHours || 0, //
percentage: student.totalHours > 0 ? Math.round((student.usedHours / student.totalHours) * 100) : 0 course_progress: student.course_progress || {
}, total: student.totalHours || 0,
// used: student.usedHours || 0,
needsRenewal: student.needsRenewal || false, remaining: student.remainingHours || 0,
isTrialStudent: student.isTrialStudent || false, percentage: student.totalHours > 0 ? Math.round((student.usedHours / student.totalHours) * 100) : 0
// },
courseStatus: student.courseStatus || (student.person_type === 'student' ? '正式课' : '体验课'), //
courseType: student.schedule_type === 2 ? 'fixed' : 'temporary', needsRenewal: student.needsRenewal || false,
// isTrialStudent: student.isTrialStudent || student.person_type !== 'student',
age: student.age || 0, //
// courseStatus: student.courseStatus || (student.person_type === 'student' ? '正式课' : '体验课'),
trialClassCount: student.trialClassCount || 0, courseType: student.schedule_type === 2 ? 'waiting' : 'formal',
// //
remainingHours: student.remainingHours || 0, age: student.age || 0,
expiryDate: student.expiryDate || '' //
})), trialClassCount: student.trialClassCount || 0,
// //
available_capacity: data.available_capacity || 0, remainingHours: student.remainingHours || student.course_progress?.remaining || 0,
enrolled_count: data.enrolled_count || 0, expiryDate: student.expiryDate || ''
remaining_capacity: data.remaining_capacity || 0 })),
}; //
available_capacity: data.available_capacity || 0,
enrolled_count: allStudents.length,
remaining_capacity: data.remaining_capacity || 0
};
} else {
//
this.scheduleInfo = {
//
id: data.id,
course_name: data.course_name || '未命名课程',
course_date: data.course_date,
time_slot: data.time_slot,
venue_name: data.venue_name || '未分配',
campus_name: data.campus_name || '',
//
coach_name: data.coach_name || '未分配',
coach_avatar: data.coach_avatar || '',
//
status: data.status,
status_text: data.status_text || '待定',
//
class_info: data.class_info || null,
//
time_info: data.time_info || null,
//
course_duration: data.time_info?.duration || data.course_duration || 60,
//
students: (data.students || []).map(student => ({
...student,
status_text: this.getStatusText(student.status || 0),
//
course_progress: student.course_progress || {
total: student.totalHours || 0,
used: student.usedHours || 0,
remaining: student.remainingHours || 0,
percentage: student.totalHours > 0 ? Math.round((student.usedHours / student.totalHours) * 100) : 0
},
//
needsRenewal: student.needsRenewal || false,
isTrialStudent: student.isTrialStudent || false,
//
courseStatus: student.courseStatus || (student.person_type === 'student' ? '正式课' : '体验课'),
courseType: student.schedule_type === 2 ? 'waiting' : 'formal',
//
age: student.age || 0,
//
trialClassCount: student.trialClassCount || 0,
//
remainingHours: student.remainingHours || 0,
expiryDate: student.expiryDate || ''
})),
//
available_capacity: data.available_capacity || 0,
enrolled_count: data.enrolled_count || 0,
remaining_capacity: data.remaining_capacity || 0
};
}
console.log('课程安排详情加载成功:', this.scheduleInfo); console.log('课程安排详情加载成功:', this.scheduleInfo);
} else { } else {
@ -483,51 +540,66 @@
this.upgradeStudentIndex = -1; this.upgradeStudentIndex = -1;
}, },
// // 使API - admin
async convertWaitingToFormal(student, index) { async convertWaitingToFormal(student, index) {
try { try {
uni.showLoading({ uni.showLoading({
title: '升级中...' title: '升级中...'
}); });
// class_arrangement_detail // 使APIadmin
const upgradeData = { const upgradeData = {
resources_id: student.resources_id || student.resource_id,
schedule_id: this.scheduleId, schedule_id: this.scheduleId,
student_id: student.student_id || student.id, person_id: student.person_id || student.id,
from_schedule_type: 2, // person_type: student.person_type || 'customer_resource',
to_schedule_type: 1, // from_type: 2, //
position: this.formalStudents.length + 1, // to_type: 1 //
course_type: student.course_type === 3 ? 1 : student.course_type //
}; };
// // ID
const response = await api.upgradeStudentSchedule(upgradeData); if (student.person_type === 'student') {
upgradeData.student_id = student.student_id || student.id;
} else {
upgradeData.resources_id = student.resources_id || student.resource_id || student.id;
}
if (response.code === 1) { console.log('升级学员数据:', upgradeData);
//
student.course_type = 1; // //
student.courseStatus = '正式课'; const response = await api.upgradeStudentInArrangement(upgradeData);
student.courseType = 'temporary'; //
if (response.code === 1) {
// //
await this.fetchScheduleDetail(); await this.fetchScheduleDetail();
uni.showToast({ uni.showToast({
title: '升级成功', title: `学员 ${student.name} 升级成功!已移至正式位`,
icon: 'success' icon: 'success',
duration: 3000
}); });
} else { } else {
uni.showToast({ uni.showToast({
title: response.msg || '升级失败', title: response.msg || '升级失败',
icon: 'none' icon: 'none',
duration: 3000
}); });
} }
} catch (error) { } catch (error) {
console.error('升级等待位学员失败:', error); console.error('升级等待位学员失败:', error);
let errorMessage = '升级失败,请重试';
if (error.message) {
if (error.message.includes('timeout')) {
errorMessage = '升级超时,请重试';
} else if (error.message.includes('Network')) {
errorMessage = '网络异常,请检查网络连接';
}
}
uni.showToast({ uni.showToast({
title: '升级失败,请重试', title: errorMessage,
icon: 'none' icon: 'none',
duration: 3000
}); });
} finally { } finally {
uni.hideLoading(); uni.hideLoading();
@ -541,13 +613,13 @@
this.selectedStudentIndex = -1; this.selectedStudentIndex = -1;
}, },
// // 使API - admin
async handleAttendanceAction(action) { async handleAttendanceAction(action) {
if (!this.selectedStudent) return; if (!this.selectedStudent) return;
const actionMap = { const actionMap = {
'sign_in': { status: 1, text: '已签到', apiMethod: 'studentCheckin' }, 'sign_in': { status: 1, text: '已签到' },
'leave': { status: 2, text: '请假', apiMethod: 'studentLeave' } 'leave': { status: 2, text: '请假' }
}; };
if (actionMap[action]) { if (actionMap[action]) {
@ -556,39 +628,31 @@
title: '处理中...' title: '处理中...'
}); });
// API // 使APIadmin
const apiData = { const updateData = {
schedule_id: this.scheduleId, schedule_id: this.scheduleId,
person_id: this.selectedStudent.person_id || this.selectedStudent.id, person_id: this.selectedStudent.person_id || this.selectedStudent.id,
person_type: this.selectedStudent.person_type || 'student',
status: actionMap[action].status,
reason: `移动端${actionMap[action].text}操作`
}; };
// ID // ID
if (this.selectedStudent.student_id && this.selectedStudent.student_id > 0) { if (this.selectedStudent.person_type === 'student') {
// updateData.student_id = this.selectedStudent.student_id || this.selectedStudent.id;
apiData.student_id = this.selectedStudent.student_id;
} else if (this.selectedStudent.resources_id && this.selectedStudent.resources_id > 0) {
//
apiData.resources_id = this.selectedStudent.resources_id;
} else { } else {
// 使id updateData.resources_id = this.selectedStudent.resources_id || this.selectedStudent.resource_id || this.selectedStudent.id;
if (this.selectedStudent.person_type === 'student') {
apiData.student_id = this.selectedStudent.id;
} else {
apiData.resources_id = this.selectedStudent.id;
}
} }
// //
console.log('签到API调用参数:', apiData);
console.log('selectedStudent:', this.selectedStudent);
//
if (action === 'leave') { if (action === 'leave') {
apiData.remark = ''; updateData.reason = '移动端请假操作';
} }
// API console.log('更新学员状态数据:', updateData);
const response = await api[actionMap[action].apiMethod](apiData);
//
const response = await api.updateStudentStatusInArrangement(updateData);
if (response.code === 1) { if (response.code === 1) {
// API // API
@ -611,21 +675,34 @@
}); });
uni.showToast({ uni.showToast({
title: `${this.selectedStudent.name} ${actionMap[action].text}`, title: `${this.selectedStudent.name} ${actionMap[action].text}成功`,
icon: 'success' icon: 'success',
duration: 3000
}); });
} else { } else {
// API // API
uni.showToast({ uni.showToast({
title: response.msg || `${actionMap[action].text}失败`, title: response.msg || `${actionMap[action].text}失败`,
icon: 'none' icon: 'none',
duration: 3000
}); });
} }
} catch (error) { } catch (error) {
console.error(`${action} API调用失败:`, error); console.error(`${action} API调用失败:`, error);
let errorMessage = `${actionMap[action].text}失败,请重试`;
if (error.message) {
if (error.message.includes('timeout')) {
errorMessage = `${actionMap[action].text}超时,请重试`;
} else if (error.message.includes('Network')) {
errorMessage = '网络异常,请检查网络连接';
}
}
uni.showToast({ uni.showToast({
title: `${actionMap[action].text}失败,请重试`, title: errorMessage,
icon: 'none' icon: 'none',
duration: 3000
}); });
} finally { } finally {
uni.hideLoading(); uni.hideLoading();
@ -654,25 +731,37 @@
return statusTextMap[status] || '未知状态'; return statusTextMap[status] || '未知状态';
}, },
// //
handleArrangeStudent() { handleArrangeStudent() {
// try {
const url = `/pages-market/clue/class_arrangement_detail?schedule_id=${this.scheduleId}`; //
console.log('跳转到学员管理页面:', url); const url = `/pages-market/clue/class_arrangement_detail?schedule_id=${this.scheduleId}`;
uni.navigateTo({ console.log('跳转到学员管理页面:', url);
url: url,
success: () => { uni.navigateTo({
// url: url,
this.closePopup(); success: () => {
}, console.log('成功跳转到学员管理页面');
fail: (error) => { //
console.error('跳转到学员管理页面失败:', error); this.closePopup();
uni.showToast({ },
title: '跳转失败,请重试', fail: (error) => {
icon: 'none' console.error('跳转到学员管理页面失败:', error);
}); uni.showToast({
} title: '跳转失败,请重试',
}); icon: 'none',
duration: 3000
});
}
});
} catch (error) {
console.error('处理安排学员按钮失败:', error);
uni.showToast({
title: '操作失败,请重试',
icon: 'none',
duration: 3000
});
}
}, },
} }
} }

40
uniapp/pages-coach/coach/schedule/schedule_table.vue

@ -1441,6 +1441,14 @@ export default {
// 使API // 使API
async viewScheduleDetail(scheduleId) { async viewScheduleDetail(scheduleId) {
try { try {
if (!scheduleId) {
uni.showToast({
title: '课程ID不能为空',
icon: 'none'
});
return;
}
// //
this.selectedScheduleId = scheduleId; this.selectedScheduleId = scheduleId;
this.showScheduleDetail = true; this.showScheduleDetail = true;
@ -1451,12 +1459,40 @@ export default {
// APIScheduleDetailfetchScheduleDetail // APIScheduleDetailfetchScheduleDetail
// ScheduleDetailapi.getCourseArrangementDetail()admin // ScheduleDetailapi.getCourseArrangementDetail()admin
// 使 // 使
// API
try {
const testResponse = await api.getCourseArrangementDetail({
schedule_id: scheduleId
});
if (testResponse.code !== 1) {
console.warn('API预检查警告:', testResponse.msg);
}
} catch (preCheckError) {
console.warn('API预检查失败,将在ScheduleDetail组件中处理:', preCheckError);
}
} catch (error) { } catch (error) {
console.error('获取课程安排详情失败:', error); console.error('获取课程安排详情失败:', error);
let errorMessage = '获取课程详情失败';
if (error.message) {
if (error.message.includes('timeout')) {
errorMessage = '请求超时,请重试';
} else if (error.message.includes('Network')) {
errorMessage = '网络连接失败';
}
}
uni.showToast({ uni.showToast({
title: '获取课程详情失败', title: errorMessage,
icon: 'none' icon: 'none',
duration: 3000
}); });
// 使ScheduleDetail
this.selectedScheduleId = scheduleId;
this.showScheduleDetail = true;
} }
}, },

Loading…
Cancel
Save