Browse Source

修改 bug

master
王泽彦 8 months ago
parent
commit
f6002d7b57
  1. 40
      niucloud/app/api/controller/apiController/CustomerResources.php
  2. 12
      niucloud/app/api/controller/apiController/Personnel.php
  3. 1
      niucloud/app/api/controller/apiController/Test.php
  4. 3
      niucloud/app/api/route/route.php
  5. 185
      niucloud/app/job/schedule/HandleCourseSchedule.php
  6. 85
      niucloud/app/job/transfer/schedule/CourseScheduleJob.php
  7. 2
      niucloud/app/model/school/SchoolStudent.php
  8. 10
      niucloud/app/service/admin/campus_person_role/CampusPersonRoleService.php
  9. 92
      niucloud/app/service/admin/course_schedule/CourseScheduleService.php
  10. 28
      niucloud/app/service/api/apiService/CustomerResourcesService.php
  11. 69
      niucloud/app/service/api/apiService/PersonnelService.php
  12. 4
      uniapp/api/apiRoute.js
  13. 202
      uniapp/pages-market/clue/add_clues.vue
  14. 21
      uniapp/pages-market/clue/index.vue

40
niucloud/app/api/controller/apiController/CustomerResources.php

@ -24,6 +24,23 @@ use core\base\BaseApiService;
class CustomerResources extends BaseApiService
{
/**
* 转换gender枚举值
* school_customer_resources: male/female/other
* school_student: 1/2/0
*/
private function convertGender($gender)
{
switch ($gender) {
case 'male':
return 1;
case 'female':
return 2;
case 'other':
default:
return 0;
}
}
//获取全部客户资源
public function getAll(Request $request)
@ -61,7 +78,7 @@ class CustomerResources extends BaseApiService
$personnel = new Personnel();
$role_id = $personnel->alias("a")
->join(['school_campus_person_role' => 'b'], 'a.id = b.person_id', 'left')
->where(['a.id' => $request->param('consultant', '')])
->where(['a.id' => $request->param('staff_id', '')]) // 使用staff_id而不是consultant
->value('b.role_id');
$customer_resources_data = [
@ -69,8 +86,9 @@ class CustomerResources extends BaseApiService
"create_date" => $date,
"source_channel" => $param['source_channel'] ?? '',
"source" => $param['source'] ?? '',
"consultant" => $param['consultant'] ?? 0,
"consultant" => 0, // 设置为0而不是当前登录人
"name" => $param['name'] ?? '',
"age" => $param['age'] ?? '', // 添加年龄字段
"gender" => $param['gender'] ?? 'other',//性别
"phone_number" => $param['phone_number'] ?? '',
"demand" => $param['demand'] ?? '',
@ -109,7 +127,23 @@ class CustomerResources extends BaseApiService
return fail("手机号已存在");
}
$res = (new CustomerResourcesService())->addData($customer_resources_data, $six_speed_data);
// 准备school_student表数据
$student_data = [
"name" => $param['name'] ?? '',
"gender" => $this->convertGender($param['gender'] ?? 'other'), // 转换gender枚举值
"age" => floatval($param['age'] ?? 0), // 转换为decimal
"birthday" => $param['birthday'] ?? null, // 前端计算的生日
"campus_id" => $param['campus'] ?? 0,
"headimg" => '', // 默认空字符串
"trial_class_count" => 2, // 默认2
"status" => 1, // 状态设置为1
"created_person_id" => $request->param('staff_id', 0), // 当前登录人
];
// 获取当前登录人的staff_id
$staff_id = $request->param('staff_id', 0);
$res = (new CustomerResourcesService())->addData($customer_resources_data, $six_speed_data, $student_data, $staff_id, $role_id);
if (!$res['code']) {
return fail($res['msg']);
}

12
niucloud/app/api/controller/apiController/Personnel.php

@ -93,6 +93,18 @@ class Personnel extends BaseApiService
return success($res);
}
//获取销售部门员工列表(根据校区筛选)
public function getSalesPersonnelByCampus(Request $request){
//获取销售部门员工信息
$campus = $request->param('campus', '');//校区id
$res = (new PersonnelService())->getSalesPersonnelByCampus($campus);
if(!$res['code']){
return fail($res['msg']);
}
return success($res['data']);
}
//验证新旧密码是否正确
public function checkOldPwd(Request $request){
//获取员工信息

1
niucloud/app/api/controller/apiController/Test.php

@ -43,4 +43,5 @@ class Test extends BaseApiService
return success($res);
}
}

3
niucloud/app/api/route/route.php

@ -225,6 +225,8 @@ Route::group(function () {
//员工端-获取全部人员列表
Route::get('personnel/getPersonnelAll', 'apiController.Personnel/getPersonnelAll');
//员工端-获取销售部门员工列表(根据校区筛选)
Route::get('personnel/getSalesPersonnelByCampus', 'apiController.Personnel/getSalesPersonnelByCampus');
//员工端-获取教练数据列表
Route::get('personnel/getCoachList', 'apiController.Personnel/getCoachList');
@ -577,6 +579,7 @@ Route::group(function () {
Route::post('student/attendance/leave', 'student.AttendanceController/leave');
// 学员取消
Route::post('student/attendance/cancel', 'student.AttendanceController/cancel');
})->middleware(ApiChannel::class)
->middleware(ApiPersonnelCheckToken::class, true)
->middleware(ApiLog::class);

185
niucloud/app/job/schedule/HandleCourseSchedule.php

@ -51,42 +51,98 @@ class HandleCourseSchedule extends BaseJob
try {
Db::startTrans();
// 批量更新,避免循环操作
$yesterday = date('Y-m-d', strtotime('-1 day'));
$currentDate = date('Y-m-d');
$currentTime = date('H:i:s');
$currentDateTime = date('Y-m-d H:i:s');
// 先查询需要更新的记录数量
$totalCount = CourseSchedule::where('course_date', '<', date('Y-m-d'))
->where('status', '<>', 'completed') // 避免重复更新已完成的课程
->count();
// 先处理time_slot,解析并更新start_time和end_time字段
$this->updateTimeFields();
$completedCount = 0;
$upcomingCount = 0;
$ongoingCount = 0;
$pendingCount = 0;
// 1. 更新已完成课程:course_date < 当天的课程
$completedRows = CourseSchedule::where('course_date', '<', $currentDate)
->where('status', '<>', 'completed')
->update([
'status' => 'completed',
'updated_at' => time()
]);
$completedCount = $completedRows;
// 2. 处理今天的课程,需要根据时间段判断状态
$todaySchedules = CourseSchedule::where('course_date', '=', $currentDate)
->whereIn('status', ['pending', 'upcoming', 'ongoing'])
->select();
foreach ($todaySchedules as $schedule) {
$startTime = $schedule['start_time'];
$endTime = $schedule['end_time'];
if (empty($startTime) || empty($endTime)) {
// 如果没有解析出时间,尝试从time_slot解析
$timeData = $this->parseTimeSlot($schedule['time_slot']);
if ($timeData) {
$startTime = $timeData['start_time'];
$endTime = $timeData['end_time'];
// 更新数据库中的时间字段
CourseSchedule::where('id', $schedule['id'])->update([
'start_time' => $startTime,
'end_time' => $endTime
]);
} else {
continue; // 无法解析时间,跳过
}
}
if ($totalCount == 0) {
Log::write('没有需要更新状态的过期课程');
Db::commit();
return [
'status' => 'success',
'total_count' => 0,
'updated_count' => 0,
'message' => '没有需要更新状态的过期课程'
];
// 判断课程状态
$newStatus = $this->determineStatus($currentTime, $startTime, $endTime);
if ($newStatus !== $schedule['status']) {
CourseSchedule::where('id', $schedule['id'])->update([
'status' => $newStatus,
'updated_at' => time()
]);
switch ($newStatus) {
case 'upcoming':
$upcomingCount++;
break;
case 'ongoing':
$ongoingCount++;
break;
case 'completed':
$completedCount++;
break;
default:
$pendingCount++;
break;
}
}
}
// 批量更新过期课程状态
$affectedRows = CourseSchedule::where('course_date', '<', date('Y-m-d'))
->where('status', '<>', 'completed') // 避免重复更新
// 3. 重置未来日期的课程为pending状态
$futureRows = CourseSchedule::where('course_date', '>', $currentDate)
->where('status', '<>', 'pending')
->update([
'status' => 'completed',
'status' => 'pending',
'updated_at' => time()
]);
$pendingCount += $futureRows;
Log::write('批量更新了' . $affectedRows . '个过期课程状态为已完成,总共检查了' . $totalCount . '个课程');
Log::write("课程状态更新完成 - 已完成: {$completedCount}个, 即将开始: {$upcomingCount}个, 进行中: {$ongoingCount}个, 待安排: {$pendingCount}个");
Db::commit();
return [
'status' => 'success',
'total_count' => $totalCount,
'updated_count' => $affectedRows,
'message' => '成功更新' . $affectedRows . '个过期课程状态'
'completed_count' => $completedCount,
'upcoming_count' => $upcomingCount,
'ongoing_count' => $ongoingCount,
'pending_count' => $pendingCount
];
} catch (\Exception $e) {
@ -100,4 +156,87 @@ class HandleCourseSchedule extends BaseJob
];
}
}
/**
* 更新课程安排表的start_time和end_time字段
*/
private function updateTimeFields()
{
try {
// 查询所有没有start_time或end_time的记录
$schedules = CourseSchedule::where(function($query) {
$query->whereNull('start_time')
->whereOr('end_time', null)
->whereOr('start_time', '')
->whereOr('end_time', '');
})->select();
foreach ($schedules as $schedule) {
$timeData = $this->parseTimeSlot($schedule['time_slot']);
if ($timeData) {
CourseSchedule::where('id', $schedule['id'])->update([
'start_time' => $timeData['start_time'],
'end_time' => $timeData['end_time']
]);
}
}
} catch (\Exception $e) {
Log::write('更新时间字段失败:' . $e->getMessage());
}
}
/**
* 解析time_slot字符串,提取开始和结束时间
* @param string $timeSlot 格式如 "09:00-10:30"
* @return array|null
*/
private function parseTimeSlot($timeSlot)
{
if (empty($timeSlot)) {
return null;
}
// 支持多种格式:09:00-10:30, 09:00~10:30, 9:00-10:30
if (preg_match('/(\d{1,2}:\d{2})\s*[-~~]\s*(\d{1,2}:\d{2})/', $timeSlot, $matches)) {
return [
'start_time' => $matches[1],
'end_time' => $matches[2]
];
}
return null;
}
/**
* 根据当前时间和课程时间段判断课程状态
* @param string $currentTime 当前时间 H:i:s
* @param string $startTime 开始时间 H:i:s
* @param string $endTime 结束时间 H:i:s
* @return string
*/
private function determineStatus($currentTime, $startTime, $endTime)
{
$currentTimestamp = strtotime($currentTime);
$startTimestamp = strtotime($startTime);
$endTimestamp = strtotime($endTime);
// 如果当前时间在课程时间段内,状态为进行中
if ($currentTimestamp >= $startTimestamp && $currentTimestamp <= $endTimestamp) {
return 'ongoing';
}
// 如果课程已结束,状态为已完成
if ($currentTimestamp > $endTimestamp) {
return 'completed';
}
// 如果距离开始时间不足6小时,状态为即将开始
$timeDiff = $startTimestamp - $currentTimestamp;
if ($timeDiff <= 6 * 3600 && $timeDiff > 0) { // 6小时 = 6 * 60 * 60 秒
return 'upcoming';
}
// 其他情况为待安排
return 'pending';
}
}

85
niucloud/app/job/transfer/schedule/CourseScheduleJob.php

@ -206,12 +206,20 @@ class CourseScheduleJob extends BaseJob
$newSchedule->course_id = $schedule->course_id;
$newSchedule->auto_schedule = 1;
$newSchedule->created_by = 'system';
// 解析时间段并填充start_time和end_time
$timeData = $this->parseTimeSlot($schedule->time_slot);
$newSchedule->start_time = $timeData ? $timeData['start_time'] : null;
$newSchedule->end_time = $timeData ? $timeData['end_time'] : null;
// 根据课程日期确定初始状态
$newSchedule->status = $this->determineInitialStatus($courseDate, $timeData);
// 复制其他所有字段(除了id和主键相关字段)
$attributes = $schedule->toArray();
foreach ($attributes as $key => $value) {
// 跳过id和主键相关字段
if ($key !== 'id' && $key !== 'course_date' && $key !== 'auto_schedule') {
// 跳过id、主键相关字段和我们已经设置的字段
if (!in_array($key, ['id', 'course_date', 'auto_schedule', 'start_time', 'end_time', 'status', 'created_by'])) {
$newSchedule->$key = $value;
}
}
@ -220,4 +228,77 @@ class CourseScheduleJob extends BaseJob
return $newSchedule;
}
/**
* 解析time_slot字符串,提取开始和结束时间
* @param string $timeSlot 格式如 "09:00-10:30"
* @return array|null
*/
private function parseTimeSlot($timeSlot)
{
if (empty($timeSlot)) {
return null;
}
// 支持多种格式:09:00-10:30, 09:00~10:30, 9:00-10:30
if (preg_match('/(\d{1,2}:\d{2})\s*[-~~]\s*(\d{1,2}:\d{2})/', $timeSlot, $matches)) {
return [
'start_time' => $matches[1],
'end_time' => $matches[2]
];
}
return null;
}
/**
* 根据课程日期和时间段确定初始状态
* @param string $courseDate 课程日期
* @param array|null $timeData 时间数据
* @return string
*/
private function determineInitialStatus($courseDate, $timeData)
{
$currentDate = date('Y-m-d');
$currentTime = date('H:i:s');
// 如果是过去的日期,直接标记为已完成
if ($courseDate < $currentDate) {
return 'completed';
}
// 如果是未来的日期,标记为待安排
if ($courseDate > $currentDate) {
return 'pending';
}
// 如果是今天且有时间数据,根据时间判断状态
if ($courseDate === $currentDate && $timeData) {
$startTime = $timeData['start_time'];
$endTime = $timeData['end_time'];
$currentTimestamp = strtotime($currentTime);
$startTimestamp = strtotime($startTime);
$endTimestamp = strtotime($endTime);
// 如果当前时间在课程时间段内,状态为进行中
if ($currentTimestamp >= $startTimestamp && $currentTimestamp <= $endTimestamp) {
return 'ongoing';
}
// 如果课程已结束,状态为已完成
if ($currentTimestamp > $endTimestamp) {
return 'completed';
}
// 如果距离开始时间不足6小时,状态为即将开始
$timeDiff = $startTimestamp - $currentTimestamp;
if ($timeDiff <= 6 * 3600 && $timeDiff > 0) {
return 'upcoming';
}
}
// 其他情况默认为待安排
return 'pending';
}
}

2
niucloud/app/model/school/SchoolStudent.php

@ -9,7 +9,7 @@ use core\base\BaseModel;
*/
class SchoolStudent extends BaseModel
{
protected $name = 'student';
protected $table = 'school_student';
protected $pk = 'id';
/**

10
niucloud/app/service/admin/campus_person_role/CampusPersonRoleService.php

@ -19,6 +19,7 @@ use app\model\sys\SysRole;
use app\model\departments\Departments;
use core\base\BaseAdminService;
use think\facade\Db;
/**
@ -117,16 +118,15 @@ class CampusPersonRoleService extends BaseAdminService
{
$tasks = $data['tasks'];
unset($data['tasks']);
if($this->model->where([['id', '<>', $id]])->where(['person_id' => $data['person_id']])->find()){
return fail("重复操作");
}
// if($this->model->where([['id', '<>', $id]])->where(['person_id' => $data['person_id']])->find()){
// return fail("重复操作");
// }
if($tasks){
$personnel_summary = new PersonnelSummary();
$personnel_summary->where(['id' => $tasks['id']])->update(['task_num' => $tasks['task_num']]);
}
$db = app()->db;
$data['dept_id'] = $db->table('school_sys_role')->where('role_id', $data['role_id'])->value('dept_id');
$data['dept_id'] = Db::table('school_sys_role')->where('role_id', $data['role_id'])->value('dept_id');
$this->model->where([['id', '=', $id]])->update($data);
return success("操作成功");

92
niucloud/app/service/admin/course_schedule/CourseScheduleService.php

@ -73,16 +73,24 @@ class CourseScheduleService extends BaseAdminService
*/
public function add(array $data)
{
// 解析时间段,填充start_time和end_time字段
$timeData = $this->parseTimeSlot($data['time_slot']);
$create = [
'campus_id' => $data['campus_id'],
'venue_id' => $data['venue_id'],
'course_date' => $data['course_date'],
'time_slot' => $data['time_slot'],
'start_time' => $timeData ? $timeData['start_time'] : null,
'end_time' => $timeData ? $timeData['end_time'] : null,
'course_id' => $data['course_id'],
'coach_id' => $data['coach_id'],
'auto_schedule' => $data['auto_schedule'],
'available_capacity' => (new Venue())->where('id', $data['venue_id'])->value('capacity')
'available_capacity' => (new Venue())->where('id', $data['venue_id'])->value('capacity'),
'status' => $this->determineInitialStatus($data['course_date'], $timeData),
'created_by' => 'manual'
];
$status = $this->model->where([
['course_date', '=', $data['course_date']],
['time_slot', '=', $data['time_slot']],
@ -105,15 +113,22 @@ class CourseScheduleService extends BaseAdminService
*/
public function edit(int $id, array $data)
{
// 解析时间段,填充start_time和end_time字段
$timeData = $this->parseTimeSlot($data['time_slot']);
$create = [
'campus_id' => $data['campus_id'],
'venue_id' => $data['venue_id'],
'course_date' => $data['course_date'],
'time_slot' => $data['time_slot'],
'start_time' => $timeData ? $timeData['start_time'] : null,
'end_time' => $timeData ? $timeData['end_time'] : null,
'course_id' => $data['course_id'],
'coach_id' => $data['coach_id'],
'auto_schedule' => $data['auto_schedule']
'auto_schedule' => $data['auto_schedule'],
'status' => $this->determineInitialStatus($data['course_date'], $timeData)
];
$status = $this->model->where([
['course_date', '=', $data['course_date']],
['time_slot', '=', $data['time_slot']],
@ -323,4 +338,77 @@ class CourseScheduleService extends BaseAdminService
->where('id', $data)->findOrEmpty();
return $info->toArray();
}
/**
* 解析time_slot字符串,提取开始和结束时间
* @param string $timeSlot 格式如 "09:00-10:30"
* @return array|null
*/
private function parseTimeSlot($timeSlot)
{
if (empty($timeSlot)) {
return null;
}
// 支持多种格式:09:00-10:30, 09:00~10:30, 9:00-10:30
if (preg_match('/(\d{1,2}:\d{2})\s*[-~~]\s*(\d{1,2}:\d{2})/', $timeSlot, $matches)) {
return [
'start_time' => $matches[1],
'end_time' => $matches[2]
];
}
return null;
}
/**
* 根据课程日期和时间段确定初始状态
* @param string $courseDate 课程日期
* @param array|null $timeData 时间数据
* @return string
*/
private function determineInitialStatus($courseDate, $timeData)
{
$currentDate = date('Y-m-d');
$currentTime = date('H:i:s');
// 如果是过去的日期,直接标记为已完成
if ($courseDate < $currentDate) {
return 'completed';
}
// 如果是未来的日期,标记为待安排
if ($courseDate > $currentDate) {
return 'pending';
}
// 如果是今天且有时间数据,根据时间判断状态
if ($courseDate === $currentDate && $timeData) {
$startTime = $timeData['start_time'];
$endTime = $timeData['end_time'];
$currentTimestamp = strtotime($currentTime);
$startTimestamp = strtotime($startTime);
$endTimestamp = strtotime($endTime);
// 如果当前时间在课程时间段内,状态为进行中
if ($currentTimestamp >= $startTimestamp && $currentTimestamp <= $endTimestamp) {
return 'ongoing';
}
// 如果课程已结束,状态为已完成
if ($currentTimestamp > $endTimestamp) {
return 'completed';
}
// 如果距离开始时间不足6小时,状态为即将开始
$timeDiff = $startTimestamp - $currentTimestamp;
if ($timeDiff <= 6 * 3600 && $timeDiff > 0) {
return 'upcoming';
}
}
// 其他情况默认为待安排
return 'pending';
}
}

28
niucloud/app/service/api/apiService/CustomerResourcesService.php

@ -20,6 +20,7 @@ use app\model\personnel\Personnel;
use app\model\resource_sharing\ResourceSharing;
use app\model\six_speed\SixSpeed;
use app\model\six_speed_modification_log\SixSpeedModificationLog;
use app\model\school\SchoolStudent;
use core\base\BaseApiService;
use think\facade\Db;
use think\facade\Event;
@ -112,7 +113,7 @@ class CustomerResourcesService extends BaseApiService
}
//添加数据
public function addData(array $customer_resources_data, array $six_speed_data)
public function addData(array $customer_resources_data, array $six_speed_data, array $student_data = [], $staff_id = 0, $role_id = 0)
{
$date = date('Y-m-d H:i:s');
$customer_resources_data['updated_at'] = $date;
@ -136,23 +137,32 @@ class CustomerResourcesService extends BaseApiService
Db::rollback();
return $res;
}
// 资源共享表新增记录
$personnel = new Personnel();
$role_id = $personnel->alias("a")
->join(['school_campus_person_role' => 'b'], 'a.id = b.person_id', 'left')
->where(['a.id' => $customer_resources_data['consultant']])
->value('b.role_id');
// 资源共享表新增记录 - 使用传入的staff_id和role_id
$resourceSharing = new ResourceSharing();
$resourceSharing->insert([
'resource_id' => $resource_id,
'user_id' => $customer_resources_data['consultant'],
'role_id' => $role_id
'user_id' => $staff_id, // 使用传入的登录人staff_id
'role_id' => $role_id // 使用传入的登录人role_id
]);
// 转介绍奖励逻辑:当source=3且有referral_resource_id时发放奖励
if ($customer_resources_data['source'] == '3' && !empty($customer_resources_data['referral_resource_id'])) {
$this->grantReferralReward($customer_resources_data['referral_resource_id'], $resource_id);
}
// 添加school_student表记录
if (!empty($student_data)) {
$student_data['user_id'] = $resource_id; // 设置user_id为新添加的客户资源ID
$student_data['updated_at'] = $date;
$student_data['created_at'] = $date;
$studentAdd = SchoolStudent::create($student_data);
if (!$studentAdd) {
Db::rollback();
$res['msg'] = '添加学员记录失败';
return $res;
}
}
Db::commit();
$res = [
'code' => 1,

69
niucloud/app/service/api/apiService/PersonnelService.php

@ -821,4 +821,73 @@ class PersonnelService extends BaseApiService
}
}
/**
* 获取销售部门员工列表(根据校区筛选)
* @param string $campus
* @return array
*/
public function getSalesPersonnelByCampus($campus = '')
{
try {
$where = [];
// 查询销售部门(dept_id=3)下的所有角色ID
$salesRoleIds = SysRole::where('dept_id', 3)
->where('status', 1)
->column('role_id');
if (empty($salesRoleIds)) {
return [
'code' => 1,
'msg' => '暂无销售部门角色',
'data' => []
];
}
// 构建校区人员角色关系查询条件
$campusPersonWhere = [
['role_id', 'in', $salesRoleIds]
];
// 根据传入的校区进行筛选
if (!empty($campus)) {
$campusPersonWhere[] = ['campus_id', '=', $campus];
}
// 查询符合条件的销售人员ID
$salesPersonIds = CampusPersonRole::where($campusPersonWhere)
->column('person_id');
if (empty($salesPersonIds)) {
return [
'code' => 1,
'msg' => '暂无销售人员数据',
'data' => []
];
}
// 从personnel表中获取人员信息,包含姓名和电话
$salesPersonnel = $this->model
->whereIn('id', $salesPersonIds)
->where('deleted_at', 0) // 只获取未删除的人员
->field('id, name, phone')
->order('create_time DESC')
->select()
->toArray();
return [
'code' => 1,
'msg' => '获取成功',
'data' => $salesPersonnel
];
} catch (\Exception $e) {
return [
'code' => 0,
'msg' => '获取销售人员列表失败:' . $e->getMessage(),
'data' => []
];
}
}
}

4
uniapp/api/apiRoute.js

@ -258,6 +258,10 @@ export default {
async common_getPersonnelAll(data = {}) {
return await http.get('/personnel/getPersonnelAll', data)
},
//获取销售部门员工列表(根据校区筛选)
async getSalesPersonnelByCampus(data = {}) {
return await http.get('/personnel/getSalesPersonnelByCampus', data)
},
//公共端-获取教练数据列表
async common_getCoachList(data = {}) {
return await http.get('/personnel/getCoachList', data)

202
uniapp/pages-market/clue/add_clues.vue

@ -211,29 +211,26 @@
</view>
</fui-form-item>
<!--生日-->
<!--年龄-->
<fui-form-item
label="生日"
label="年龄"
labelSize='26'
prop="birthday"
prop="age"
background='#434544'
labelColor='#fff'
:bottomBorder='false'>
<view class="input-title" style="margin-right:14rpx;">
<view
@click="openBirthdayPicker"
style="color: #fff; cursor: pointer;">
{{ formData.birthday ? formData.birthday : '请选择生日' }}
</view>
<fui-date-picker
:show="picker_show_birthday"
type="3"
:minDate="minDate"
:maxDate="maxDate"
:value="getCurrentBirthdayValue()"
@change="changePickerBirthday"
@cancel="closeBirthdayPicker"
></fui-date-picker>
<fui-input
:borderBottom="false"
:padding="[0]"
placeholder="请输入年龄(如5.3)"
v-model="formData.age"
backgroundColor="#434544"
size="26"
color="#fff"
type="digit"
@blur="handleAgeBlur"
></fui-input>
</view>
</fui-form-item>
@ -279,7 +276,7 @@
<!--客户初步意向度-->
<fui-form-item
label="客户初步意向度"
labelWidth="240"
labelSize='26'
prop=""
background='#434544'
@ -370,6 +367,7 @@
<!--可选上课时间-->
<fui-form-item
label="可选上课时间"
labelWidth="240"
labelSize='26'
prop=""
background='#434544'
@ -389,6 +387,7 @@
<fui-form-item
label="承诺到访时间"
labelSize='26'
labelWidth="240"
prop=""
background='#434544'
labelColor='#fff'
@ -616,14 +615,14 @@ export default {
source:'',//
consultant:'',//
name:'',//
age:'',//
age:'',//()
gender:'male',//|male-, female-, other-
phone_number:'',//
demand:'',//
decision_maker:'',//
initial_intent:'',//: high-, medium-, low-
status:'pending',//: active-, inactive-, pending-
birthday:'',//
birthday:'',//()
//
purchasing_power:'',//
@ -709,10 +708,6 @@ export default {
data_picker_input_name:'',//input_name
date_picker_show:false,//
//
picker_show_birthday: false,
minDate: '1900-01-01', //
maxDate: new Date().toISOString().split('T')[0], //
@ -862,9 +857,11 @@ export default {
fillCount++
}
if (parsedData.age) {
const age = parseInt(parsedData.age)
if (!isNaN(age) && age > 0 && age < 150) {
this.formData.age = age
const age = parseFloat(parsedData.age)
if (!isNaN(age) && age >= 0) {
this.formData.age = age.toString()
//
this.handleAgeBlur()
fillCount++
}
}
@ -1256,6 +1253,89 @@ export default {
// -
handleAgeBlur() {
if (!this.formData.age) {
this.formData.birthday = ''
return
}
const age = parseFloat(this.formData.age)
// 0
if (isNaN(age) || age < 0) {
uni.showToast({
title: '年龄请输入大于等于0的数字',
icon: 'none'
})
this.formData.age = ''
this.formData.birthday = ''
return
}
// 2
const ageStr = this.formData.age.toString()
if (ageStr.includes('.') && ageStr.split('.')[1].length > 2) {
uni.showToast({
title: '年龄小数最多保留2位',
icon: 'none'
})
return
}
try {
//
const today = new Date()
const currentYear = today.getFullYear()
const currentMonth = today.getMonth() + 1 // getMonth()0-11
const currentDay = today.getDate()
//
const yearsOld = Math.floor(age)
const monthsOld = Math.round((age - yearsOld) * 12)
let birthYear = currentYear - yearsOld
let birthMonth = currentMonth + 3 // +3
let birthDay = currentDay
// 12
if (birthMonth > 12) {
birthYear += 1
birthMonth -= 12
}
//
if (monthsOld > 0) {
birthMonth -= monthsOld
if (birthMonth <= 0) {
birthYear -= 1
birthMonth += 12
}
}
// 230
const maxDaysInMonth = new Date(birthYear, birthMonth, 0).getDate()
if (birthDay > maxDaysInMonth) {
birthDay = maxDaysInMonth
}
//
const formattedMonth = String(birthMonth).padStart(2, '0')
const formattedDay = String(birthDay).padStart(2, '0')
this.formData.birthday = `${birthYear}-${formattedMonth}-${formattedDay}`
console.log(`年龄: ${age}岁, 计算出的生日: ${this.formData.birthday}`)
} catch (error) {
console.error('计算生日失败:', error)
uni.showToast({
title: '生日计算失败,请重新输入',
icon: 'none'
})
this.formData.birthday = ''
}
},
//
async handlePhoneBlur(){
if(!this.formData.phone_number){
@ -1574,74 +1654,6 @@ export default {
this.date_picker_show = false
},
//
openBirthdayPicker() {
console.log('打开生日选择器')
this.picker_show_birthday = true
},
//
closeBirthdayPicker() {
console.log('关闭生日选择器')
this.picker_show_birthday = false
},
//
getCurrentBirthdayValue() {
if (this.formData.birthday) {
return this.formData.birthday
}
// 30
const defaultDate = new Date()
defaultDate.setFullYear(defaultDate.getFullYear() - 30)
return this.formatDate(defaultDate)
},
//
changePickerBirthday(e) {
console.log('生日选择器返回数据:', e)
let val = ''
//
if (e.result) {
val = e.result
} else if (e.value) {
val = e.value
} else if (e.detail && e.detail.result) {
val = e.detail.result
} else if (e.detail && e.detail.value) {
val = e.detail.value
} else if (Array.isArray(e) && e.length >= 3) {
// [2023, 1, 15]
const year = e[0]
const month = String(e[1]).padStart(2, '0')
const day = String(e[2]).padStart(2, '0')
val = `${year}-${month}-${day}`
}
//
if (val && typeof val === 'string') {
//
if (/^\d+$/.test(val)) {
const date = new Date(parseInt(val))
val = this.formatDate(date)
}
//
else if (val.includes('T')) {
val = val.split('T')[0]
}
//
else if (val.includes(' ')) {
val = val.split(' ')[0]
}
//
val = this.normalizeDate(val)
}
console.log('最终设置的生日值:', val)
this.formData.birthday = val
this.closeBirthdayPicker()
},
// index|0=,1
async nextStep(index) {

21
uniapp/pages-market/clue/index.vue

@ -31,13 +31,16 @@
所属校区{{ v.customerResource.campus_name }}
</view>
<view class="card-con">
来源{{ v.customerResource.source }}
渠道{{ v.customerResource.source }}
</view>
<view class="card-con" v-if="v.customerResource.source_channel">
来源渠道{{ v.customerResource.source_channel }}
线上渠道{{ v.customerResource.source_channel }}
</view>
<view class="card-con" v-if="v.sixSpeed && v.sixSpeed.consultation_remark">
到访备注{{ v.sixSpeed.consultation_remark || '' }}
</view>
<view class="card-con" v-if="v.sixSpeed && v.sixSpeed.consultation_remark">
市场老师{{ v.sixSpeed.consultation_remark || '' }}
</view>
</view>
<view class="card-right">
@ -551,12 +554,10 @@
},
//
//
async getPersonnelAll(campus = '') {
let res = await apiRoute.common_getPersonnelAll({
personnel_id: this.userInfo.id, //id
account_type: 'market', //|teacher=,market=
campus: campus
let res = await apiRoute.getSalesPersonnelByCampus({
campus: campus //
})
if (res.code != 1) {
uni.showToast({
@ -568,13 +569,15 @@
let arr = []
res.data.forEach((v, k) => {
//
let displayText = `${v.name} ${v.phone}`
arr.push({
text: v.name,
text: displayText,
value: v.id,
})
})
this.select_options = arr
console.log('员工', this.select_options)
console.log('销售部门员工', this.select_options)
},
//-

Loading…
Cancel
Save